Extract methods for creating and parsing payment requests, payment messages and payment acks, as well as Ack data class. Expose more payment request data from PaymentSession. Add unit tests for roundtripping all messages.

This commit is contained in:
Andreas Schildbach
2014-05-03 17:24:16 +02:00
committed by Mike Hearn
parent bd49cd4027
commit cdfec498a4
5 changed files with 365 additions and 52 deletions

View File

@@ -23,6 +23,7 @@ import com.google.bitcoin.net.discovery.DnsDiscovery;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.params.RegTestParams;
import com.google.bitcoin.params.TestNet3Params;
import com.google.bitcoin.protocols.payments.PaymentProtocol;
import com.google.bitcoin.protocols.payments.PaymentProtocolException;
import com.google.bitcoin.protocols.payments.PaymentSession;
import com.google.bitcoin.store.*;
@@ -557,14 +558,14 @@ public class WalletTool {
}
setup();
// No refund address specified, no user-specified memo field.
ListenableFuture<PaymentSession.Ack> future = session.sendPayment(ImmutableList.of(req.tx), null, null);
ListenableFuture<PaymentProtocol.Ack> future = session.sendPayment(ImmutableList.of(req.tx), null, null);
if (future == null) {
// No payment_url for submission so, broadcast and wait.
peers.startAsync();
peers.awaitRunning();
peers.broadcastTransaction(req.tx).get();
} else {
PaymentSession.Ack ack = future.get();
PaymentProtocol.Ack ack = future.get();
wallet.commitTx(req.tx);
System.out.println("Memo from server: " + ack.getMemo());
}