diff --git a/core/src/main/java/com/google/bitcoin/core/Transaction.java b/core/src/main/java/com/google/bitcoin/core/Transaction.java index d7ef7e9a..9f8653e8 100644 --- a/core/src/main/java/com/google/bitcoin/core/Transaction.java +++ b/core/src/main/java/com/google/bitcoin/core/Transaction.java @@ -665,8 +665,10 @@ public class Transaction extends ChildMessage implements Serializable { * signInputs() must be called to finalize the transaction and finish the inputs off. Otherwise it won't be * accepted by the network. */ - public void addInput(TransactionOutput from) { - addInput(new TransactionInput(params, this, from)); + public TransactionInput addInput(TransactionOutput from) { + final TransactionInput input = new TransactionInput(params, this, from); + addInput(input); + return input; } /** diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index d7bf4fe0..77b5de7d 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -3171,9 +3171,9 @@ public class Wallet implements Serializable, BlockChainListener { } for (TransactionOutput output : selection.gathered) { - req.tx.addInput(output); - // If the scriptBytes don't default to none, our size calculations will be thrown off - checkState(req.tx.getInput(req.tx.getInputs().size()-1).getScriptBytes().length == 0); + TransactionInput input = req.tx.addInput(output); + // If the scriptBytes don't default to none, our size calculations will be thrown off. + checkState(input.getScriptBytes().length == 0); try { if (output.getScriptPubKey().isSentToAddress()) { // Send-to-address spends usually take maximum pubkey.length (as it may be compressed or not) + 75 bytes