private static void resetTxInputs(Transaction tx, List<TransactionInput> originalInputs) { tx.clearInputs(); for (TransactionInput input : originalInputs) tx.addInput(input); } }
private void resetTxInputs(SendRequest req, List<TransactionInput> originalInputs) { req.tx.clearInputs(); for (TransactionInput input : originalInputs) req.tx.addInput(input); }
/** * Adds an input to this transaction that imports value from the given output. Note that this input is <i>not</i> * complete and after every input is added with {@link #addInput()} and every output is added with * {@link #addOutput()}, a {@link TransactionSigner} must be used to finalize the transaction and finish the inputs * off. Otherwise it won't be accepted by the network. * @return the newly created input. */ public TransactionInput addInput(TransactionOutput from) { return addInput(new TransactionInput(params, this, from)); }
/** * Adds an input to this transaction that imports value from the given output. Note that this input is <i>not</i> * complete and after every input is added with {@link #addInput()} and every output is added with * {@link #addOutput()}, a {@link TransactionSigner} must be used to finalize the transaction and finish the inputs * off. Otherwise it won't be accepted by the network. * @return the newly created input. */ public TransactionInput addInput(TransactionOutput from) { return addInput(new TransactionInput(params, this, from)); }
/** * Adds an input to this transaction that imports value from the given output. Note that this input is <i>not</i> * complete and after every input is added with {@link #addInput(TransactionInput)} and every output is added with * {@link #addOutput(TransactionOutput)}, a {@link TransactionSigner} must be used to finalize the transaction and * finish the inputs off. Otherwise it won't be accepted by the network. * @return the newly created input. */ public TransactionInput addInput(TransactionOutput from) { return addInput(new TransactionInput(params, this, from)); }
/** * Creates and adds an input to this transaction, with no checking that it's valid. * @return the newly created input. */ public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script) { return addInput( new TransactionInput( params, this, script.getProgram(), new TransactionOutPoint(params, outputIndex, spendTxHash))); }
/** * Creates and adds an input to this transaction, with no checking that it's valid. * @return the newly created input. */ public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script) { return addInput(new TransactionInput(params, this, script.getProgram(), new TransactionOutPoint(params, outputIndex, spendTxHash))); }
/** * Creates and adds an input to this transaction, with no checking that it's valid. * @return the newly created input. */ public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script) { return addInput(new TransactionInput(params, this, script.getProgram(), new TransactionOutPoint(params, outputIndex, spendTxHash))); }
private synchronized Transaction makeUnsignedChannelContract(Coin valueToMe) throws ValueOutOfRangeException { Transaction tx = new Transaction(wallet.getParams()); tx.addInput(getContractInternal().getOutput(0)); // Our output always comes first. // TODO: We should drop myKey in favor of output key + multisig key separation // (as its always obvious who the client is based on T2 output order) tx.addOutput(valueToMe, myKey.toAddress(wallet.getParams())); return tx; }
private synchronized Transaction makeUnsignedChannelContract(Coin valueToMe) throws ValueOutOfRangeException { Transaction tx = new Transaction(wallet.getParams()); tx.addInput(getContractInternal().getOutput(0)); // Our output always comes first. // TODO: We should drop myKey in favor of output key + multisig key separation // (as its always obvious who the client is based on T2 output order) tx.addOutput(valueToMe, myKey.toAddress(wallet.getParams())); return tx; }
private synchronized Transaction makeUnsignedChannelContract(Coin valueToMe) throws ValueOutOfRangeException { Transaction tx = new Transaction(wallet.getParams()); tx.addInput(getContractInternal().getOutput(0)); // Our output always comes first. // TODO: We should drop myKey in favor of output key + multisig key separation // (as its always obvious who the client is based on T2 output order) tx.addOutput(valueToMe, myKey.toAddress(wallet.getParams())); return tx; }
private synchronized Transaction makeUnsignedChannelContract(Coin valueToMe) throws ValueOutOfRangeException { Transaction tx = new Transaction(wallet.getParams()); tx.addInput(getContractInternal().getOutput(0)); // Our output always comes first. // TODO: We should drop myKey in favor of output key + multisig key separation // (as its always obvious who the client is based on T2 output order) tx.addOutput(valueToMe, myKey.toAddress(wallet.getParams())); return tx; }
public Transaction getClosingTransaction (ChannelStatus channelStatus, float feePerByte) { //For the sake of privacy (and simplicity) we use lexicographically ordering here, as defined in BIP69 Transaction transaction = new Transaction(Constants.getNetwork()); transaction.addInput(channel.anchorTxHash, 0, Tools.getDummyScript()); //TODO deduct the transaction fee correctly from both amounts //TODO would be better to have another address on file that we can use here.. long feePerParty = (Tools.getTransactionFees(2, 2, feePerByte) / 2); transaction.addOutput(Coin.valueOf(channelStatus.amountClient - feePerParty), channel.channelStatus.addressClient); transaction.addOutput(Coin.valueOf(channelStatus.amountServer - feePerParty), channel.channelStatus.addressServer); return Tools.applyBIP69(transaction); }
@Test(expected = VerificationException.CoinbaseScriptSizeOutOfRange.class) public void coinbaseScriptSigTooSmall() throws Exception { tx.clearInputs(); tx.addInput(Sha256Hash.ZERO_HASH, 0xFFFFFFFFL, new ScriptBuilder().build()); tx.verify(); }
@Test(expected = VerificationException.UnexpectedCoinbaseInput.class) public void coinbaseInputInNonCoinbaseTX() throws Exception { tx.addInput(Sha256Hash.ZERO_HASH, 0xFFFFFFFFL, new ScriptBuilder().data(new byte[10]).build()); tx.verify(); }
protected synchronized SendRequest makeUnsignedChannelContract(Coin valueToMe) { Transaction tx = new Transaction(wallet.getParams()); if (!getTotalValue().subtract(valueToMe).equals(Coin.ZERO)) { tx.addOutput(getTotalValue().subtract(valueToMe), getClientKey().toAddress(wallet.getParams())); } tx.addInput(contract.getOutput(0)); return SendRequest.forTx(tx); }
protected synchronized SendRequest makeUnsignedChannelContract(Coin valueToMe) { Transaction tx = new Transaction(wallet.getParams()); if (!getTotalValue().subtract(valueToMe).equals(Coin.ZERO)) { tx.addOutput(getTotalValue().subtract(valueToMe), getClientKey().toAddress(wallet.getParams())); } tx.addInput(contract.getOutput(0)); return SendRequest.forTx(tx); }
/** Create a fake transaction, without change. */ public static Transaction createFakeTxWithoutChange(final NetworkParameters params, final TransactionOutput output) { Transaction prevTx = FakeTxBuilder.createFakeTx(params, Coin.COIN, new ECKey().toAddress(params)); Transaction tx = new Transaction(params); tx.addOutput(output); tx.addInput(prevTx.getOutput(0)); return tx; }
protected synchronized SendRequest makeUnsignedChannelContract(Coin valueToMe) { Transaction tx = new Transaction(wallet.getParams()); if (!getTotalValue().subtract(valueToMe).equals(Coin.ZERO)) { tx.addOutput(getTotalValue().subtract(valueToMe), getClientKey().toAddress(wallet.getParams())); } tx.addInput(contract.getOutput(0)); return SendRequest.forTx(tx); }
@Test(expected = VerificationException.CoinbaseScriptSizeOutOfRange.class) public void coinbaseScriptSigTooLarge() throws Exception { tx.clearInputs(); TransactionInput input = tx.addInput(Sha256Hash.ZERO_HASH, 0xFFFFFFFFL, new ScriptBuilder().data(new byte[99]).build()); assertEquals(101, input.getScriptBytes().length); tx.verify(); }