/** * 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(); }
/** * <code>required .payments.Payment payment = 1;</code> * * <pre> * Payment message that triggered this ACK * </pre> */ public Builder mergePayment(org.bitcoin.protocols.payments.Protos.Payment value) { if (paymentBuilder_ == null) { if (((bitField0_ & 0x00000001) == 0x00000001) && payment_ != org.bitcoin.protocols.payments.Protos.Payment.getDefaultInstance()) { payment_ = org.bitcoin.protocols.payments.Protos.Payment.newBuilder(payment_).mergeFrom(value).buildPartial(); } else { payment_ = value; } onChanged(); } else { paymentBuilder_.mergeFrom(value); } bitField0_ |= 0x00000001; return this; } /**
/** * <code>required .payments.Payment payment = 1;</code> * * <pre> * Payment message that triggered this ACK * </pre> */ public Builder mergePayment(org.bitcoin.protocols.payments.Protos.Payment value) { if (paymentBuilder_ == null) { if (((bitField0_ & 0x00000001) == 0x00000001) && payment_ != org.bitcoin.protocols.payments.Protos.Payment.getDefaultInstance()) { payment_ = org.bitcoin.protocols.payments.Protos.Payment.newBuilder(payment_).mergeFrom(value).buildPartial(); } else { payment_ = value; } onChanged(); } else { paymentBuilder_.mergeFrom(value); } bitField0_ |= 0x00000001; return this; } /**
public Builder toBuilder() { return newBuilder(this); }
public Builder toBuilder() { return newBuilder(this); }
public Builder toBuilder() { return newBuilder(this); }
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) {
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) {
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) {
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) {
public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) {
public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public static Builder newBuilder(org.bitcoin.protocols.payments.Protos.Payment prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
@Test public void testPaymentAck() throws Exception { // Create Payment paymentMessage = Protos.Payment.newBuilder().build(); PaymentACK paymentAck = PaymentProtocol.createPaymentAck(paymentMessage, MEMO); byte[] paymentAckBytes = paymentAck.toByteArray(); // Parse PaymentACK parsedPaymentAck = PaymentACK.parseFrom(paymentAckBytes); assertEquals(paymentMessage, parsedPaymentAck.getPayment()); assertEquals(MEMO, parsedPaymentAck.getMemo()); } }