/** * Creates an output that pays to the given pubkey directly (no address) with the given value, adds it to this * transaction, and returns the new output. */ public TransactionOutput addOutput(Coin value, ECKey pubkey) { return addOutput(new TransactionOutput(params, this, value, pubkey)); }
/** * Creates an output that pays to the given pubkey directly (no address) with the given value, adds it to this * transaction, and returns the new output. */ public TransactionOutput addOutput(Coin value, ECKey pubkey) { return addOutput(new TransactionOutput(params, this, value, pubkey)); }
/** * Creates an output that pays to the given pubkey directly (no address) with the given value, adds it to this * transaction, and returns the new output. */ public TransactionOutput addOutput(Coin value, ECKey pubkey) { return addOutput(new TransactionOutput(params, this, value, pubkey)); }
/** * Creates an output based on the given address and value, adds it to this transaction, and returns the new output. */ public TransactionOutput addOutput(Coin value, Address address) { return addOutput(new TransactionOutput(params, this, value, address)); }
public void addAllOutputs(List<TransactionOutput> outputs) { checkArgument(outputs.size() == numberOfOutputs, "Number of outputs don't match"); if (trimmedOutputs != null) { trimmedOutputs = null; } long index = 0; for (TransactionOutput output : outputs) { super.addOutput(new TrimmedOutput(output, index++, this)); } }
/** * Creates an output that pays to the given script. The address and key forms are specialisations of this method, * you won't normally need to use it unless you're doing unusual things. */ public TransactionOutput addOutput(Coin value, Script script) { return addOutput(new TransactionOutput(params, this, value, script.getProgram())); }
/** * Creates an output that pays to the given script. The address and key forms are specialisations of this method, * you won't normally need to use it unless you're doing unusual things. */ public TransactionOutput addOutput(Coin value, Script script) { return addOutput(new TransactionOutput(params, this, value, script.getProgram())); }
/** * Creates an output that pays to the given script. The address and key forms are specialisations of this method, * you won't normally need to use it unless you're doing unusual things. */ public TransactionOutput addOutput(Coin value, Script script) { return addOutput(new TransactionOutput(params, this, value, script.getProgram())); }
public static SendRequest emptyWallet(Address destination) { SendRequest req = new SendRequest(); final NetworkParameters parameters = destination.getParameters(); checkNotNull(parameters, "Address is for an unknown network"); req.tx = new Transaction(parameters); req.tx.addOutput(Coin.ZERO, destination); req.emptyWallet = true; return req; }
public static SendRequest toCLTVPaymentChannel(NetworkParameters params, BigInteger time, ECKey from, ECKey to, Coin value) { SendRequest req = new SendRequest(); Script output = ScriptBuilder.createCLTVPaymentChannelOutput(time, from, to); req.tx = new Transaction(params); req.tx.addOutput(value, output); return req; }
public static SendRequest toCLTVPaymentChannel(NetworkParameters params, BigInteger time, ECKey from, ECKey to, Coin value) { SendRequest req = new SendRequest(); Script output = ScriptBuilder.createCLTVPaymentChannelOutput(time, from, to); req.tx = new Transaction(params); req.tx.addOutput(value, output); return req; }
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); }
public static BitSendRequest emptyWallet(BitAddress destination) { checkNotNull(destination.getType(), "Address is for an unknown network"); checkTypeCompatibility(destination.getType()); BitSendRequest req = new BitSendRequest(destination.getType()); Transaction tx = new Transaction(req.type); tx.addOutput(Coin.ZERO, destination); req.tx = new BitTransaction(tx); req.emptyWallet = true; return req; }
/** * Returns a {@link SendRequest} suitable for broadcasting to the network. */ public SendRequest getSendRequest() { Transaction tx = new Transaction(params); for (Protos.Output output : paymentDetails.getOutputsList()) tx.addOutput(new TransactionOutput(params, tx, Coin.valueOf(output.getAmount()), output.getScript().toByteArray())); return SendRequest.forTx(tx).fromPaymentDetails(paymentDetails); }
public void fillAnchorTransactionWithoutSignatures (WalletHelper walletHelper) { long totalAmount = channelStatus.amountServer + channelStatus.amountClient; if (anchorTx == null) { Script anchorScriptServer = getAnchorScriptOutput(); Script anchorScriptServerP2SH = ScriptBuilder.createP2SHOutputScript(anchorScriptServer); anchorTx = new Transaction(Constants.getNetwork()); anchorTx.addOutput(Coin.valueOf(totalAmount), anchorScriptServerP2SH); } anchorTx = walletHelper.addInputs(anchorTx, channelStatus.amountServer, channelStatus.feePerByte); anchorTxHash = anchorTx.getHash(); }
@Test public void opReturnOneOutputWithValueTest() throws Exception { // Tests basic send of transaction with one output that destroys coins and has an OP_RETURN. receiveATransaction(wallet, myAddress); Transaction tx = new Transaction(PARAMS); Coin messagePrice = CENT; Script script = ScriptBuilder.createOpReturnScript("hello world!".getBytes()); tx.addOutput(messagePrice, script); SendRequest request = SendRequest.forTx(tx); wallet.completeTx(request); }
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); }
@Test public void serializeTransactionsBtc() throws Exception, Bip44KeyLookAheadExceededException { WalletPocketHD account = new WalletPocketHD(rootKey, BTC, null, null); Transaction tx = new Transaction(BTC); tx.addOutput(BTC.oneCoin().toCoin(), account.getReceiveAddress()); account.addNewTransactionIfNeeded(tx); testWalletSerializationForCoin(account); }
@Test public void serializeTransactionsNbt() throws Exception, Bip44KeyLookAheadExceededException { WalletPocketHD account = new WalletPocketHD(rootKey, NBT, null, null); Transaction tx = new Transaction(NBT); tx.addOutput(NBT.oneCoin().toCoin(), account.getReceiveAddress()); account.addNewTransactionIfNeeded(tx); testWalletSerializationForCoin(account); }