Author

Topic: How to send lots of transactions quickly from a single address (Read 1136 times)

newbie
Activity: 26
Merit: 0
What happens when the user deposits another $10 to the deposit address?
Then it would start another chain of $0.20 outputs again... or at least that's under the assumptions I am making on what you are trying to do from your explanation.

I don't think I get what you're trying to do.

The reason I don't want to do that is because I don't want to have to keep track of those chains. I'm thinking about how the code is going to look like... I'd rather not have to mess with storing anything. I know that sounds lame, but one of the things I like about bitcoin is that everything is in the blockchain. I like to design my code so that there is the least amount of moving parts as possible.

The way I have it now, all I have to do is call blockr.io and they tell me exactly what I need.

At any rate, bitpay insight has a noCache option which I think I'll give a try
sr. member
Activity: 475
Merit: 252
Does bitcore.js have any transaction decoding capabilities? I don't see it on their docs page.

https://github.com/bitpay/bitcore/blob/master/lib/transaction/transaction.js#L280
This will let you create a Transaction object from a raw tx 0-9a-fA-F string.

https://github.com/bitpay/bitcore/blob/master/lib/transaction/transaction.js#L43
Then just inspect the Transaction.outputs to look for the information about the transaction.
sr. member
Activity: 475
Merit: 252
What happens when the user deposits another $10 to the deposit address?
Then it would start another chain of $0.20 outputs again... or at least that's under the assumptions I am making on what you are trying to do from your explanation.

I don't think I get what you're trying to do.
newbie
Activity: 26
Merit: 0
Code:
{"status":"success","data":{"address":"1CMHexnK9gMT9RznMB75ZCAfpny8oPDcNW","unspent": {"tx":"a9563808cfd21ab9334269b58dbdab253c22b773ad6058667df8c63564980b4d","amount":"0.00273151","n":1,"confirmations":1,"script":"76a9147c7f9af7dc42b8b5277039a2cc8eb710b51f17b788ac"}]},"code":200,"message":""}
So this is what you get back from blockr.


Here's the raw transaction it is referring to:

01000000017920fe9ef3a69ed78e2909f62c4eca9eb453ecc17b2703e648ef9dbb4353cfa501000 0006b483045022100cfa77f826a2845bdad66c99aef4e318678bbfb2e829c8b9cff3b611db4e209 b3022071c42415cc39b997f7d48855f3da11d49b7c435e1d09ed2a98d37346c3fd38f3012103db6 362bd31a3c590c38aa7583de5b565ab527ce8b4648245ccf7ffbb0e1f955affffffff027d5d0000 000000001976a914f077c10e90ba49739f28c483e76c49ce9facfa2588acff2a0400000000001976a9147c7f9af7dc42b8b5277039a2cc8eb710b51f17b788ac00000000


"tx" can be found by double sha256 hashing the raw transaction and reversing the byte order (to little endian)
"amount" can be found in the bold area. 1. convert to big endian 2. convert from hex to decimal 3. multiply by 100,000,000
ff2a040000000000 -> 0000000000042aff -> 273151 -> 0.00273151
"n" can be found by counting which output it is order-wise, first output is 0, etc.
"script" can be found directly after the amount in the bold+italic part (Skipping the scriptlen byte)


So what I suggest is just generating a transaction, grabbing the unspent info from the first transaction and using it to generate the second transaction etc. and unleash the chain of transactions, maybe pushing them 10-15 seconds apart (to give each one time to propagate. Also remember you must push them in order, otherwise they will get rejected for referring to a non-existent output.)
I'll still have to call a blockchain service to get other unspent outputs (see previous post), but I may have to end up doing this. I'm in javascript, so parsing out all that stuff might be hard. Does bitcore.js have any transaction decoding capabilities? I don't see it on their docs page.
newbie
Activity: 26
Merit: 0
Ah I see. The problem is that blockr.io is not returning the most recent picture of my address's unspent outputs. For the record, I'm getting unpent outputs directly from this api endpoint:

http://btc.blockr.io/api/v1/address/unspent/1CMHexnK9gMT9RznMB75ZCAfpny8oPDcNW

I guess I need to find another unspent outputs provider?

No, if you're going to send them instantly anyways, grab the unspent from your change on the way out before you push the raw transaction.

Do you know how to parse a raw transaction?
That will work, only assuming that there is only ever going to be one unspent output 'chain'. What happens when the user deposits another $10 to the deposit address? I'm still going to need to call a blockchain service to get a list of all unspent outputs.

The problem here is that sometimes (right after a transaction) blockr.io is returning an unspent output that has just been recently spent. Just now I did a test, and it took about 60 seconds for the unspent output to switch over to the new one. So basically I'm limited by one transaction every minute. Once I find a blockchain service that updates faster, theres not much I can do.
sr. member
Activity: 475
Merit: 252
Code:
{"status":"success","data":{"address":"1CMHexnK9gMT9RznMB75ZCAfpny8oPDcNW","unspent": {"tx":"a9563808cfd21ab9334269b58dbdab253c22b773ad6058667df8c63564980b4d","amount":"0.00273151","n":1,"confirmations":1,"script":"76a9147c7f9af7dc42b8b5277039a2cc8eb710b51f17b788ac"}]},"code":200,"message":""}
So this is what you get back from blockr.


Here's the raw transaction it is referring to:

01000000017920fe9ef3a69ed78e2909f62c4eca9eb453ecc17b2703e648ef9dbb4353cfa501000 0006b483045022100cfa77f826a2845bdad66c99aef4e318678bbfb2e829c8b9cff3b611db4e209 b3022071c42415cc39b997f7d48855f3da11d49b7c435e1d09ed2a98d37346c3fd38f3012103db6 362bd31a3c590c38aa7583de5b565ab527ce8b4648245ccf7ffbb0e1f955affffffff027d5d0000 000000001976a914f077c10e90ba49739f28c483e76c49ce9facfa2588acff2a0400000000001976a9147c7f9af7dc42b8b5277039a2cc8eb710b51f17b788ac00000000


"tx" can be found by double sha256 hashing the raw transaction and reversing the byte order (to little endian)
"amount" can be found in the bold area. 1. convert to big endian 2. convert from hex to decimal 3. multiply by 100,000,000
ff2a040000000000 -> 0000000000042aff -> 273151 -> 0.00273151
"n" can be found by counting which output it is order-wise, first output is 0, etc.
"script" can be found directly after the amount in the bold+italic part (Skipping the scriptlen byte)


So what I suggest is just generating a transaction, grabbing the unspent info from the first transaction and using it to generate the second transaction etc. and unleash the chain of transactions, maybe pushing them 10-15 seconds apart (to give each one time to propagate. Also remember you must push them in order, otherwise they will get rejected for referring to a non-existent output.)
sr. member
Activity: 475
Merit: 252
Ah I see. The problem is that blockr.io is not returning the most recent picture of my address's unspent outputs. For the record, I'm getting unpent outputs directly from this api endpoint:

http://btc.blockr.io/api/v1/address/unspent/1CMHexnK9gMT9RznMB75ZCAfpny8oPDcNW

I guess I need to find another unspent outputs provider?

No, if you're going to send them instantly anyways, grab the unspent from your change on the way out before you push the raw transaction.

Do you know how to parse a raw transaction?
newbie
Activity: 26
Merit: 0
Ah I see. The problem is that blockr.io is not returning the most recent picture of my address's unspent outputs. For the record, I'm getting unpent outputs directly from this api endpoint:

http://btc.blockr.io/api/v1/address/unspent/1CMHexnK9gMT9RznMB75ZCAfpny8oPDcNW

I guess I need to find another unspent outputs provider?
legendary
Activity: 1176
Merit: 1011
That may be true if you're using the bitcoind daemon directly, but I'm using pushtx (blockr.io and blockchain.info), and they won't allow unconfirmed outputs. Maybe if I found a pushtx provider service that doesn't kick out unconfirmed outputs?

As an example, try to use pushtx to push this transaction

https://blockchain.info/pushtx

Quote
0100000001d6e9983e878ece6c2fdccd8b94f688bc8c85392e6de86e1fa0b4d476087012bb01000 0006b483045022100ff97666c564f7ec3bfc5a297f0e983f63093faac24f3d359f9e68f7c661383 b00220366b8cf072a668c0c8f37e721b93e5e8efef618fe70cc3dcc69479e6c2d9917c012103db6 362bd31a3c590c38aa7583de5b565ab527ce8b4648245ccf7ffbb0e1f955affffffff02455d0000 000000001976a91411cb3813c57c5a8c4715ded20b05ddd354e8867e88acd4ae040000000000197 6a9147c7f9af7dc42b8b5277039a2cc8eb710b51f17b788ac00000000


The error returned is:

Quote
An outpoint is already spent in [75068748]
Your output was not unconfirmed, it was already spent in another transaction.

Most PushTX APIs accept unconfirmed inputs just fine. But obviously they (like pretty much any node) don't take txs that spend outputs that are already spent in an existing tx.
sr. member
Activity: 475
Merit: 252
The error returned is:

Quote
An outpoint is already spent in [75068748]
This is because the wallet you are using (or code, idk) is referring to the old output.

What you tried to do:
Code:
Output A -> Output B and Change C....... then...... Output A -> Output D and Change E

What you need to do:
Code:
Output A -> Output B and Change C....... then...... Output C -> Output D and Change E
(Where C is the Change from the first transaction you pushed)

You need to code your wallet to refer to a transaction output that isn't confirmed yet... most libraries manage outputs for addresses well only when they are confirmed.
newbie
Activity: 26
Merit: 0
That may be true if you're using the bitcoind daemon directly, but I'm using pushtx (blockr.io and blockchain.info), and they won't allow unconfirmed outputs. Maybe if I found a pushtx provider service that doesn't kick out unconfirmed outputs?

As an example, try to use pushtx to push this transaction

https://blockchain.info/pushtx

Quote
0100000001d6e9983e878ece6c2fdccd8b94f688bc8c85392e6de86e1fa0b4d476087012bb01000 0006b483045022100ff97666c564f7ec3bfc5a297f0e983f63093faac24f3d359f9e68f7c661383 b00220366b8cf072a668c0c8f37e721b93e5e8efef618fe70cc3dcc69479e6c2d9917c012103db6 362bd31a3c590c38aa7583de5b565ab527ce8b4648245ccf7ffbb0e1f955affffffff02455d0000 000000001976a91411cb3813c57c5a8c4715ded20b05ddd354e8867e88acd4ae040000000000197 6a9147c7f9af7dc42b8b5277039a2cc8eb710b51f17b788ac00000000


The error returned is:

Quote
An outpoint is already spent in [75068748]

(I still don't know what that number means)

When I try to push to blockr.io it gives me a similar error about the transaction being invalid. When the unspent output becomes more confirmed, it works.

https://blockchain.info/unspent?active=1CMHexnK9gMT9RznMB75ZCAfpny8oPDcNW&format=html

here is the unspent outputs (as you can see it only has 5 conforms at this time)
legendary
Activity: 1176
Merit: 1011
Provided that your tip transactions have enough fee (doesn't need to be high, just not zero or ridiculously low, 0.00001 BTC should suffice) you can send subsequent tip transactions using the previous output, without waiting for confirmations.

E.g. you have $10 on a particular address. You send a $0.20 tip, and your address now has a new unspent (but still unconfirmed) output if $9.80. You can immediately create a new transaction for a $0.30 tip from that $9.80, thus leaving $9.50 on your address. And so on.

However, if getting timely confirmations is of your concern, then yes, splitting an amount into multiple smaller outputs would allow you to send multiple, independent tip transactions immediately.

Pro tip: instead of just splitting the $10 into hundred $0.10 outputs and using multiple of those, use "binary optimization". Create outputs of $0.10, $0.20, $0.40, $0.80, $1.60 etc. Now you can create any multiple of $0.10 with a minimum of inputs, thus lowering the tx size. Or in this particular case, you could probably just set up a bunch of common values in between as well, i.e. having $0.25, $0.30, $0.50 etc outputs ready to spend.
newbie
Activity: 26
Merit: 0
I'm building a mictotipping platform. The way it works is a chrome extension that works like a wallet sends out transactions to the "tipee".

The problem I'm running into is that when you have an address with a single funding transaction, you're limited to one transaction per block or one transaction every 10 minutes, since you can't use an unconfirmed output in a transaction. You always have to wait until the previous transaction confirms before it can be used in another transaction.

Is there some way to have it so that one wallet can send, say, 25 transactions per minute?

I have no idea if what I just wrote made any sense.

One solution I came up with is to "chop up" any unspent outputs so that you always have a set of confirmed outputs when making a transaction.

So it goes like this:

1. Generate deposit address
2. User sends $10 bucks to deposit address
3. After that transaction confirms, split up the single $10 input into one hundred smaller outputs.
4. Once the chopping transaction confirms, the address will have a ton of unspent outputs and will never be "vapor locked".
5. User sends $0.05 transaction, using one (or multiple) of the chopped outputs
6. 20 seconds later he sends another transaction, using some more of the chopped outputs
7. 20 seconds later... etc. etc.

Does this problem have a name? Has anyone ran into this problem before?

You can see the code here: https://github.com/priestc/Autotip (still in beta)
Jump to: