diff --git a/core/src/main/java/com/google/bitcoin/protocols/payments/PaymentSession.java b/core/src/main/java/com/google/bitcoin/protocols/payments/PaymentSession.java index 9414064fa..098aa3b2e 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/payments/PaymentSession.java +++ b/core/src/main/java/com/google/bitcoin/protocols/payments/PaymentSession.java @@ -1,5 +1,6 @@ /** * Copyright 2013 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,6 +73,7 @@ import java.util.concurrent.Callable; * tx itself later if needed.
* * @author Kevin Greene + * @author Andreas Schildbach * @see BIP 0070 */ public class PaymentSession { @@ -597,8 +599,6 @@ public class PaymentSession { try { if (request == null) throw new PaymentRequestException("request cannot be null"); - if (!request.hasPaymentDetailsVersion()) - throw new PaymentRequestException.InvalidVersion("No version"); if (request.getPaymentDetailsVersion() != 1) throw new PaymentRequestException.InvalidVersion("Version 1 required. Received version " + request.getPaymentDetailsVersion()); paymentRequest = request; diff --git a/core/src/test/java/com/google/bitcoin/protocols/payments/PaymentSessionTest.java b/core/src/test/java/com/google/bitcoin/protocols/payments/PaymentSessionTest.java index de9458a02..6963e5a39 100644 --- a/core/src/test/java/com/google/bitcoin/protocols/payments/PaymentSessionTest.java +++ b/core/src/test/java/com/google/bitcoin/protocols/payments/PaymentSessionTest.java @@ -1,5 +1,6 @@ /** * Copyright 2013 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,6 +83,23 @@ public class PaymentSessionTest { assertTrue(refundScript.equals(payment.getRefundTo(0).getScript())); } + @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(BigInteger.ZERO, paymentSession.getValue()); + assertNull(paymentSession.getPaymentUrl()); + assertNull(paymentSession.getMemo()); + } + @Test public void testExpiredPaymentRequest() throws Exception { MockPaymentSession paymentSession = new MockPaymentSession(newExpiredPaymentRequest());