How to send money to set of recipients using bitcoinj

3

I am creating a wallet app using the bitcoinj library. I have a use-case where I need to send bitcoins to multiple recipients in one transaction. Currently, I am creating multiple send requests for each address but only first send request is successful and rest of the requests failed and give me following error:

Exception in thread "AWT-EventQueue-0" org.bitcoinj.core.Wallet$DustySendRequested
   at org.bitcoinj.core.Wallet.completeTx(Wallet.java:3646)
   at org.bitcoinj.core.Wallet.sendCoinsOffline(Wallet.java:3471)
   at org.bitcoinj.core.Wallet.sendCoins(Wallet.java:3536)
   at org.bitcoinj.core.Wallet.sendCoins(Wallet.java:3506)....

Please help me to sort this out. I would be very thankful.

rashidmdk

Posted 2016-06-11T18:34:37.127

Reputation: 31

Answers

1

Try this. You can add several outputs to a transaction

 SendRequest req;
 Transaction transaction = null;

transaction = new Transaction(this.activity.getNetWorkParameters());
        transaction.addOutput(coin1,address1);
        transaction.addOutput(coin2,address2);
        req = SendRequest.forTx(transaction);

jgm

Posted 2016-06-11T18:34:37.127

Reputation: 748