sending to a large number of output addresses

24 views
Skip to first unread message

Wei Hsu

unread,
Oct 14, 2016, 4:52:44 PM10/14/16
to bitcoinj
Given a large number of output addresses, what's the best way to send a payment to each one? Assuming the wallet balance is sufficient.

If I send the payments one by one in quick succession, I might get an InsufficientMoneyException if some of the funds are tied up in change.

I've also tried combining it all into one transaction, but that could result in a transaction that exceeds the maximum transaction size if a lot of inputs are required, or a lot of output addresses are specified.

I'd appreciate any ideas on how to approach this- thanks in advance!

Jarl Fransson

unread,
Oct 17, 2016, 6:26:11 AM10/17/16
to bitcoinj
I think it is bad to send them one by one. Also, in total that will require more resources and cost more in fees. You should probably find a reasonable limit for the number of outputs and create a few larger transactions if your number of addresses exceed that limit.

Wei

unread,
Oct 17, 2016, 6:47:12 AM10/17/16
to bitcoinj
True, sending one by one will cost more in fees. More importantly for me, it will take a lot more time to send them one by one.

Limiting the number of outputs might still result in a transaction that exceeds the maximum size, since we don't know how many inputs the transaction needs. That makes it difficult to partition the recipient addresses ahead of time. For my application, it would be helpful to create all the transactions first and then broadcast them in a separate step - wondering if that's possible to do with BitcoinJ in this case.

--
You received this message because you are subscribed to a topic in the Google Groups "bitcoinj" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bitcoinj/e_hiH9Dqhs0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bitcoinj+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jarl Fransson

unread,
Oct 17, 2016, 9:52:44 AM10/17/16
to bitcoinj
Den måndag 17 oktober 2016 kl. 12:47:12 UTC+2 skrev Wei Hsu:
True, sending one by one will cost more in fees. More importantly for me, it will take a lot more time to send them one by one.

Limiting the number of outputs might still result in a transaction that exceeds the maximum size, since we don't know how many inputs the transaction needs. That makes it difficult to partition the recipient addresses ahead of time. For my application, it would be helpful to create all the transactions first and then broadcast them in a separate step - wondering if that's possible to do with BitcoinJ in this case.

Yes, you can control inputs with not too much work. You could use Wallet.calculateAllSpendCandidates and analyze your spendable outputs, decide on a set and add up an amount that's max for your tx, then write your CoinSelector to select exatly those as inputs you added up to the amount with.
Reply all
Reply to author
Forward
0 new messages