/** * Removes all the outputs from this transaction. * Note that this also invalidates the length attribute */ public void clearOutputs() { unCache(); for (TransactionOutput output : outputs) { output.setParent(null); } outputs.clear(); // You wanted to reserialize, right? this.length = this.unsafeBitcoinSerialize().length; }
/** * Removes all the outputs from this transaction. * Note that this also invalidates the length attribute */ public void clearOutputs() { unCache(); for (TransactionOutput output : outputs) { output.setParent(null); } outputs.clear(); // You wanted to reserialize, right? this.length = this.unsafeBitcoinSerialize().length; }
/** * Removes all the inputs from this transaction. * Note that this also invalidates the length attribute */ public void clearInputs() { unCache(); for (TransactionInput input : inputs) { input.setParent(null); } inputs.clear(); // You wanted to reserialize, right? this.length = this.unsafeBitcoinSerialize().length; }
/** * Removes all the inputs from this transaction. * Note that this also invalidates the length attribute */ public void clearInputs() { unCache(); for (TransactionInput input : inputs) { input.setParent(null); } inputs.clear(); // You wanted to reserialize, right? this.length = this.unsafeBitcoinSerialize().length; }
/** * Removes all the outputs from this transaction. * Note that this also invalidates the length attribute */ public void clearOutputs() { unCache(); for (TransactionOutput output : outputs) { output.setParent(null); } outputs.clear(); // You wanted to reserialize, right? this.length = this.unsafeBitcoinSerialize().length; }
/** * Removes all the inputs from this transaction. * Note that this also invalidates the length attribute */ public void clearInputs() { unCache(); for (TransactionInput input : inputs) { input.setParent(null); } inputs.clear(); // You wanted to reserialize, right? this.length = this.unsafeBitcoinSerialize().length; }
/** * Removes all the outputs from this transaction. * Note that this also invalidates the length attribute */ public void clearOutputs() { unCache(); for (TransactionOutput output : outputs) { output.setParent(null); } outputs.clear(); // You wanted to reserialize, right? this.length = this.unsafeBitcoinSerialize().length; }
/** * Removes all the inputs from this transaction. * Note that this also invalidates the length attribute */ public void clearInputs() { unCache(); for (TransactionInput input : inputs) { input.setParent(null); } inputs.clear(); // You wanted to reserialize, right? this.length = this.unsafeBitcoinSerialize().length; }
/** * Returns the transaction hash as you see them in the block explorer. */ @Override public Sha256Hash getHash() { if (hash == null) { hash = Sha256Hash.wrapReversed(Sha256Hash.hashTwice(unsafeBitcoinSerialize())); } return hash; }
/** * Returns the transaction hash as you see them in the block explorer. */ @Override public Sha256Hash getHash() { if (hash == null) { hash = Sha256Hash.wrapReversed(Sha256Hash.hashTwice(unsafeBitcoinSerialize())); } return hash; }
@Override public void onSuccess(Transaction result) { // Send the successfully accepted transaction back to the client. final Protos.TwoWayChannelMessage.Builder msg = Protos.TwoWayChannelMessage.newBuilder(); msg.setType(Protos.TwoWayChannelMessage.MessageType.CLOSE); if (result != null) { // Result can be null on various error paths, like if we never actually opened // properly and so on. msg.getSettlementBuilder().setTx(ByteString.copyFrom(result.unsafeBitcoinSerialize())); log.info("Sending CLOSE back with broadcast settlement tx."); } else { log.info("Sending CLOSE back without broadcast settlement tx."); } conn.sendToClient(msg.build()); conn.destroyConnection(clientRequestedClose); }
@Override public void onSuccess(Transaction result) { // Send the successfully accepted transaction back to the client. final Protos.TwoWayChannelMessage.Builder msg = Protos.TwoWayChannelMessage.newBuilder(); msg.setType(Protos.TwoWayChannelMessage.MessageType.CLOSE); if (result != null) { // Result can be null on various error paths, like if we never actually opened // properly and so on. msg.getSettlementBuilder().setTx(ByteString.copyFrom(result.unsafeBitcoinSerialize())); log.info("Sending CLOSE back with broadcast settlement tx."); } else { log.info("Sending CLOSE back without broadcast settlement tx."); } conn.sendToClient(msg.build()); conn.destroyConnection(clientRequestedClose); }
@Override public void onSuccess(Transaction result) { // Send the successfully accepted transaction back to the client. final Protos.TwoWayChannelMessage.Builder msg = Protos.TwoWayChannelMessage.newBuilder(); msg.setType(Protos.TwoWayChannelMessage.MessageType.CLOSE); if (result != null) { // Result can be null on various error paths, like if we never actually opened // properly and so on. msg.getSettlementBuilder().setTx(ByteString.copyFrom(result.unsafeBitcoinSerialize())); log.info("Sending CLOSE back with broadcast settlement tx."); } else { log.info("Sending CLOSE back without broadcast settlement tx."); } conn.sendToClient(msg.build()); conn.destroyConnection(clientRequestedClose); }
/** * Create a payment message. This wraps up transaction data along with anything else useful for making a payment. * * @param transactions transactions to include with the payment message * @param refundOutputs list of outputs to refund coins to, or null * @param memo arbitrary, user readable memo, or null if none * @param merchantData arbitrary merchant data, or null if none * @return created payment message */ public static Protos.Payment createPaymentMessage(List<Transaction> transactions, @Nullable List<Protos.Output> refundOutputs, @Nullable String memo, @Nullable byte[] merchantData) { Protos.Payment.Builder builder = Protos.Payment.newBuilder(); for (Transaction transaction : transactions) { transaction.verify(); builder.addTransactions(ByteString.copyFrom(transaction.unsafeBitcoinSerialize())); } if (refundOutputs != null) { for (Protos.Output output : refundOutputs) builder.addRefundTo(output); } if (memo != null) builder.setMemo(memo); if (merchantData != null) builder.setMerchantData(ByteString.copyFrom(merchantData)); return builder.build(); }
/** * Create a payment message. This wraps up transaction data along with anything else useful for making a payment. * * @param transactions transactions to include with the payment message * @param refundOutputs list of outputs to refund coins to, or null * @param memo arbitrary, user readable memo, or null if none * @param merchantData arbitrary merchant data, or null if none * @return created payment message */ public static Protos.Payment createPaymentMessage(List<Transaction> transactions, @Nullable List<Protos.Output> refundOutputs, @Nullable String memo, @Nullable byte[] merchantData) { Protos.Payment.Builder builder = Protos.Payment.newBuilder(); for (Transaction transaction : transactions) { transaction.verify(); builder.addTransactions(ByteString.copyFrom(transaction.unsafeBitcoinSerialize())); } if (refundOutputs != null) { for (Protos.Output output : refundOutputs) builder.addRefundTo(output); } if (memo != null) builder.setMemo(memo); if (merchantData != null) builder.setMerchantData(ByteString.copyFrom(merchantData)); return builder.build(); }
@Override public void onSuccess(Transaction result) { // Send the successfully accepted transaction back to the client. final Protos.TwoWayChannelMessage.Builder msg = Protos.TwoWayChannelMessage.newBuilder(); msg.setType(Protos.TwoWayChannelMessage.MessageType.CLOSE); if (result != null) { // Result can be null on various error paths, like if we never actually opened // properly and so on. msg.getSettlementBuilder().setTx(ByteString.copyFrom(result.unsafeBitcoinSerialize())); log.info("Sending CLOSE back with broadcast settlement tx."); } else { log.info("Sending CLOSE back without broadcast settlement tx."); } conn.sendToClient(msg.build()); conn.destroyConnection(clientRequestedClose); }
/** Reduce the value of the first output of a transaction to pay the given feePerKb as appropriate for its size. */ private boolean adjustOutputDownwardsForFee(Transaction tx, CoinSelection coinSelection, Coin feePerKb, boolean ensureMinRequiredFee) { final int size = tx.unsafeBitcoinSerialize().length + estimateBytesForSigning(coinSelection); Coin fee = feePerKb.multiply(size).divide(1000); if (ensureMinRequiredFee && fee.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE; TransactionOutput output = tx.getOutput(0); output.setValue(output.getValue().subtract(fee)); return !output.isDust(); }
/** Reduce the value of the first output of a transaction to pay the given feePerKb as appropriate for its size. */ private boolean adjustOutputDownwardsForFee(Transaction tx, CoinSelection coinSelection, Coin feePerKb, boolean ensureMinRequiredFee) { final int size = tx.unsafeBitcoinSerialize().length + estimateBytesForSigning(coinSelection); Coin fee = feePerKb.multiply(size).divide(1000); if (ensureMinRequiredFee && fee.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE; TransactionOutput output = tx.getOutput(0); output.setValue(output.getValue().subtract(fee)); return !output.isDust(); }
/** Reduce the value of the first output of a transaction to pay the given feePerKb as appropriate for its size. */ private boolean adjustOutputDownwardsForFee(Transaction tx, CoinSelection coinSelection, Coin feePerKb, boolean ensureMinRequiredFee) { final int size = tx.unsafeBitcoinSerialize().length + estimateBytesForSigning(coinSelection); Coin fee = feePerKb.multiply(size).divide(1000); if (ensureMinRequiredFee && fee.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE; TransactionOutput output = tx.getOutput(0); output.setValue(output.getValue().subtract(fee)); return !output.isDust(); }
/** Reduce the value of the first output of a transaction to pay the given feePerKb as appropriate for its size. */ private boolean adjustOutputDownwardsForFee(Transaction tx, CoinSelection coinSelection, Coin feePerKb, boolean ensureMinRequiredFee, boolean useInstantSend) { final int size = tx.unsafeBitcoinSerialize().length + estimateBytesForSigning(coinSelection); Coin fee = feePerKb.multiply(size).divide(1000); if (ensureMinRequiredFee && fee.compareTo(params.isDIP0001ActiveAtTip() ? Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.div(10) : Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) fee = params.isDIP0001ActiveAtTip() ? Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.div(10) : Transaction.REFERENCE_DEFAULT_MIN_TX_FEE; if(useInstantSend) fee = TransactionLockRequest.MIN_FEE.multiply(tx.getInputs().size()); TransactionOutput output = tx.getOutput(0); output.setValue(output.getValue().subtract(fee)); return !output.isDust(); }