Java Code Examples for org.bitcoin.protocols.payments.Protos#PaymentDetails

The following examples show how to use org.bitcoin.protocols.payments.Protos#PaymentDetails . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaymentSessionTest.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
@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());
}
 
Example 2
Source File: PaymentSessionTest.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: PaymentSessionTest.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example 4
Source File: PaymentSessionTest.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
@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());
}
 
Example 5
Source File: PaymentSessionTest.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example 6
Source File: PaymentSessionTest.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example 7
Source File: PaymentSessionTest.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
@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());
}
 
Example 8
Source File: PaymentSessionTest.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example 9
Source File: PaymentSessionTest.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example 10
Source File: PaymentSession.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the protobuf that describes the payment to be made.
 */
public Protos.PaymentDetails getPaymentDetails() {
    return paymentDetails;
}
 
Example 11
Source File: PaymentSession.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
/** Returns the protobuf that describes the payment to be made. */
public Protos.PaymentDetails getPaymentDetails() {
    return paymentDetails;
}
 
Example 12
Source File: PaymentSession.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
/** Returns the protobuf that describes the payment to be made. */
public Protos.PaymentDetails getPaymentDetails() {
    return paymentDetails;
}