3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 23:32:16 +00:00

Make Transaction.addInput(TransactionOutput) return the created input. Use it to make a minor simplification.

This commit is contained in:
Mike Hearn 2013-06-11 12:24:14 +02:00
parent 6077d32c4a
commit b865e6a510
2 changed files with 7 additions and 5 deletions

View File

@ -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 * signInputs() must be called to finalize the transaction and finish the inputs off. Otherwise it won't be
* accepted by the network. * accepted by the network.
*/ */
public void addInput(TransactionOutput from) { public TransactionInput addInput(TransactionOutput from) {
addInput(new TransactionInput(params, this, from)); final TransactionInput input = new TransactionInput(params, this, from);
addInput(input);
return input;
} }
/** /**

View File

@ -3171,9 +3171,9 @@ public class Wallet implements Serializable, BlockChainListener {
} }
for (TransactionOutput output : selection.gathered) { for (TransactionOutput output : selection.gathered) {
req.tx.addInput(output); TransactionInput input = req.tx.addInput(output);
// If the scriptBytes don't default to none, our size calculations will be thrown off // 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); checkState(input.getScriptBytes().length == 0);
try { try {
if (output.getScriptPubKey().isSentToAddress()) { if (output.getScriptPubKey().isSentToAddress()) {
// Send-to-address spends usually take maximum pubkey.length (as it may be compressed or not) + 75 bytes // Send-to-address spends usually take maximum pubkey.length (as it may be compressed or not) + 75 bytes