/** * Create a payment request. You may want to sign the request using {@link #signPaymentRequest}. Use * {@link Protos.PaymentRequest.Builder#build} to get the actual payment request. * * @param params network parameters * @param outputs list of outputs to request coins to * @param memo arbitrary, user readable memo, or null if none * @param paymentUrl URL to send payment message to, or null if none * @param merchantData arbitrary merchant data, or null if none * @return created payment request, in its builder form */ public static Protos.PaymentRequest.Builder createPaymentRequest(NetworkParameters params, List<Protos.Output> outputs, @Nullable String memo, @Nullable String paymentUrl, @Nullable byte[] merchantData) { final Protos.PaymentDetails.Builder paymentDetails = Protos.PaymentDetails.newBuilder(); paymentDetails.setNetwork(params.getPaymentProtocolId()); for (Protos.Output output : outputs) paymentDetails.addOutputs(output); if (memo != null) paymentDetails.setMemo(memo); if (paymentUrl != null) paymentDetails.setPaymentUrl(paymentUrl); if (merchantData != null) paymentDetails.setMerchantData(ByteString.copyFrom(merchantData)); paymentDetails.setTime(Utils.currentTimeSeconds()); final Protos.PaymentRequest.Builder paymentRequest = Protos.PaymentRequest.newBuilder(); paymentRequest.setSerializedPaymentDetails(paymentDetails.build().toByteString()); return paymentRequest; }
/** * Create a payment request. You may want to sign the request using {@link #signPaymentRequest}. Use * {@link Protos.PaymentRequest.Builder#build} to get the actual payment request. * * @param params network parameters * @param outputs list of outputs to request coins to * @param memo arbitrary, user readable memo, or null if none * @param paymentUrl URL to send payment message to, or null if none * @param merchantData arbitrary merchant data, or null if none * @return created payment request, in its builder form */ public static Protos.PaymentRequest.Builder createPaymentRequest(NetworkParameters params, List<Protos.Output> outputs, @Nullable String memo, @Nullable String paymentUrl, @Nullable byte[] merchantData) { final Protos.PaymentDetails.Builder paymentDetails = Protos.PaymentDetails.newBuilder(); paymentDetails.setNetwork(params.getPaymentProtocolId()); for (Protos.Output output : outputs) paymentDetails.addOutputs(output); if (memo != null) paymentDetails.setMemo(memo); if (paymentUrl != null) paymentDetails.setPaymentUrl(paymentUrl); if (merchantData != null) paymentDetails.setMerchantData(ByteString.copyFrom(merchantData)); paymentDetails.setTime(Utils.currentTimeSeconds()); final Protos.PaymentRequest.Builder paymentRequest = Protos.PaymentRequest.newBuilder(); paymentRequest.setSerializedPaymentDetails(paymentDetails.build().toByteString()); return paymentRequest; }
/** * Create a payment request. You may want to sign the request using {@link #signPaymentRequest}. Use * {@link org.bitcoin.protocols.payments.Protos.PaymentRequest.Builder#build} to get the actual payment request. * * @param params network parameters * @param outputs list of outputs to request coins to * @param memo arbitrary, user readable memo, or null if none * @param paymentUrl URL to send payment message to, or null if none * @param merchantData arbitrary merchant data, or null if none * @return created payment request, in its builder form */ public static Protos.PaymentRequest.Builder createPaymentRequest(NetworkParameters params, List<Protos.Output> outputs, @Nullable String memo, @Nullable String paymentUrl, @Nullable byte[] merchantData) { final Protos.PaymentDetails.Builder paymentDetails = Protos.PaymentDetails.newBuilder(); paymentDetails.setNetwork(params.getPaymentProtocolId()); for (Protos.Output output : outputs) paymentDetails.addOutputs(output); if (memo != null) paymentDetails.setMemo(memo); if (paymentUrl != null) paymentDetails.setPaymentUrl(paymentUrl); if (merchantData != null) paymentDetails.setMerchantData(ByteString.copyFrom(merchantData)); paymentDetails.setTime(Utils.currentTimeSeconds()); final Protos.PaymentRequest.Builder paymentRequest = Protos.PaymentRequest.newBuilder(); paymentRequest.setSerializedPaymentDetails(paymentDetails.build().toByteString()); return paymentRequest; }
/** * Create a payment request. You may want to sign the request using {@link #signPaymentRequest}. Use * {@link Protos.PaymentRequest.Builder#build} to get the actual payment request. * * @param params network parameters * @param outputs list of outputs to request coins to * @param memo arbitrary, user readable memo, or null if none * @param paymentUrl URL to send payment message to, or null if none * @param merchantData arbitrary merchant data, or null if none * @return created payment request, in its builder form */ public static Protos.PaymentRequest.Builder createPaymentRequest(NetworkParameters params, List<Protos.Output> outputs, @Nullable String memo, @Nullable String paymentUrl, @Nullable byte[] merchantData) { final Protos.PaymentDetails.Builder paymentDetails = Protos.PaymentDetails.newBuilder(); paymentDetails.setNetwork(params.getPaymentProtocolId()); for (Protos.Output output : outputs) paymentDetails.addOutputs(output); if (memo != null) paymentDetails.setMemo(memo); if (paymentUrl != null) paymentDetails.setPaymentUrl(paymentUrl); if (merchantData != null) paymentDetails.setMerchantData(ByteString.copyFrom(merchantData)); paymentDetails.setTime(Utils.currentTimeSeconds()); final Protos.PaymentRequest.Builder paymentRequest = Protos.PaymentRequest.newBuilder(); paymentRequest.setSerializedPaymentDetails(paymentDetails.build().toByteString()); return paymentRequest; }
/** * Create a payment request. You may want to sign the request using {@link #signPaymentRequest}. Use * {@link Protos.PaymentRequest.Builder#build} to get the actual payment request. * * @param params network parameters * @param outputs list of outputs to request coins to * @param memo arbitrary, user readable memo, or null if none * @param paymentUrl URL to send payment message to, or null if none * @param merchantData arbitrary merchant data, or null if none * @return created payment request, in its builder form */ public static Protos.PaymentRequest.Builder createPaymentRequest(NetworkParameters params, List<Protos.Output> outputs, @Nullable String memo, @Nullable String paymentUrl, @Nullable byte[] merchantData) { final Protos.PaymentDetails.Builder paymentDetails = Protos.PaymentDetails.newBuilder(); paymentDetails.setNetwork(params.getPaymentProtocolId()); for (Protos.Output output : outputs) paymentDetails.addOutputs(output); if (memo != null) paymentDetails.setMemo(memo); if (paymentUrl != null) paymentDetails.setPaymentUrl(paymentUrl); if (merchantData != null) paymentDetails.setMerchantData(ByteString.copyFrom(merchantData)); paymentDetails.setTime(Utils.currentTimeSeconds()); final Protos.PaymentRequest.Builder paymentRequest = Protos.PaymentRequest.newBuilder(); paymentRequest.setSerializedPaymentDetails(paymentDetails.build().toByteString()); return paymentRequest; }
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.PaymentRequest other) { if (other == org.bitcoin.protocols.payments.Protos.PaymentRequest.getDefaultInstance()) return this; if (other.hasPaymentDetailsVersion()) { setPaymentDetailsVersion(other.getPaymentDetailsVersion()); } if (other.hasPkiType()) { bitField0_ |= 0x00000002; pkiType_ = other.pkiType_; onChanged(); } if (other.hasPkiData()) { setPkiData(other.getPkiData()); } if (other.hasSerializedPaymentDetails()) { setSerializedPaymentDetails(other.getSerializedPaymentDetails()); } if (other.hasSignature()) { setSignature(other.getSignature()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.PaymentRequest other) { if (other == org.bitcoin.protocols.payments.Protos.PaymentRequest.getDefaultInstance()) return this; if (other.hasPaymentDetailsVersion()) { setPaymentDetailsVersion(other.getPaymentDetailsVersion()); } if (other.hasPkiType()) { bitField0_ |= 0x00000002; pkiType_ = other.pkiType_; onChanged(); } if (other.hasPkiData()) { setPkiData(other.getPkiData()); } if (other.hasSerializedPaymentDetails()) { setSerializedPaymentDetails(other.getSerializedPaymentDetails()); } if (other.hasSignature()) { setSignature(other.getSignature()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.PaymentRequest other) { if (other == org.bitcoin.protocols.payments.Protos.PaymentRequest.getDefaultInstance()) return this; if (other.hasPaymentDetailsVersion()) { setPaymentDetailsVersion(other.getPaymentDetailsVersion()); } if (other.hasPkiType()) { bitField0_ |= 0x00000002; pkiType_ = other.pkiType_; onChanged(); } if (other.hasPkiData()) { setPkiData(other.getPkiData()); } if (other.hasSerializedPaymentDetails()) { setSerializedPaymentDetails(other.getSerializedPaymentDetails()); } if (other.hasSignature()) { setSignature(other.getSignature()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
private Protos.PaymentRequest newExpiredPaymentRequest() { Protos.Output.Builder outputBuilder = Protos.Output.newBuilder() .setAmount(coin.value) .setScript(ByteString.copyFrom(outputToMe.getScriptBytes())); Protos.PaymentDetails paymentDetails = Protos.PaymentDetails.newBuilder() .setNetwork("test") .setTime(time - 10) .setExpires(time - 1) .setPaymentUrl(simplePaymentUrl) .addOutputs(outputBuilder) .setMemo(paymentRequestMemo) .setMerchantData(merchantData) .build(); return Protos.PaymentRequest.newBuilder() .setPaymentDetailsVersion(1) .setPkiType("none") .setSerializedPaymentDetails(paymentDetails.toByteString()) .build(); }
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.PaymentRequest other) { if (other == org.bitcoin.protocols.payments.Protos.PaymentRequest.getDefaultInstance()) return this; if (other.hasPaymentDetailsVersion()) { setPaymentDetailsVersion(other.getPaymentDetailsVersion()); } if (other.hasPkiType()) { bitField0_ |= 0x00000002; pkiType_ = other.pkiType_; onChanged(); } if (other.hasPkiData()) { setPkiData(other.getPkiData()); } if (other.hasSerializedPaymentDetails()) { setSerializedPaymentDetails(other.getSerializedPaymentDetails()); } if (other.hasSignature()) { setSignature(other.getSignature()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
private Protos.PaymentRequest newSimplePaymentRequest(String netID) { Protos.Output.Builder outputBuilder = Protos.Output.newBuilder() .setAmount(coin.value) .setScript(ByteString.copyFrom(outputToMe.getScriptBytes())); Protos.PaymentDetails paymentDetails = Protos.PaymentDetails.newBuilder() .setNetwork(netID) .setTime(time) .setPaymentUrl(simplePaymentUrl) .addOutputs(outputBuilder) .setMemo(paymentRequestMemo) .setMerchantData(merchantData) .build(); return Protos.PaymentRequest.newBuilder() .setPaymentDetailsVersion(1) .setPkiType("none") .setSerializedPaymentDetails(paymentDetails.toByteString()) .build(); }
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.PaymentRequest other) { if (other == org.bitcoin.protocols.payments.Protos.PaymentRequest.getDefaultInstance()) return this; if (other.hasPaymentDetailsVersion()) { setPaymentDetailsVersion(other.getPaymentDetailsVersion()); } if (other.hasPkiType()) { bitField0_ |= 0x00000002; pkiType_ = other.pkiType_; onChanged(); } if (other.hasPkiData()) { setPkiData(other.getPkiData()); } if (other.hasSerializedPaymentDetails()) { setSerializedPaymentDetails(other.getSerializedPaymentDetails()); } if (other.hasSignature()) { setSignature(other.getSignature()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
@Test public void testDefaults() throws Exception { Protos.Output.Builder outputBuilder = Protos.Output.newBuilder() .setScript(ByteString.copyFrom(outputToMe.getScriptBytes())); Protos.PaymentDetails paymentDetails = Protos.PaymentDetails.newBuilder() .setTime(time) .addOutputs(outputBuilder) .build(); Protos.PaymentRequest paymentRequest = Protos.PaymentRequest.newBuilder() .setSerializedPaymentDetails(paymentDetails.toByteString()) .build(); MockPaymentSession paymentSession = new MockPaymentSession(paymentRequest); assertEquals(Coin.ZERO, paymentSession.getValue()); assertNull(paymentSession.getPaymentUrl()); assertNull(paymentSession.getMemo()); }
private Protos.PaymentRequest minimalPaymentRequest() { Protos.PaymentDetails.Builder paymentDetails = Protos.PaymentDetails.newBuilder(); paymentDetails.setTime(System.currentTimeMillis()); Protos.PaymentRequest.Builder paymentRequest = Protos.PaymentRequest.newBuilder(); paymentRequest.setSerializedPaymentDetails(paymentDetails.build().toByteString()); return paymentRequest.build(); }