From 107ed7612edf40cd9e0cc803d4b6a0f136cc0ee6 Mon Sep 17 00:00:00 2001 From: David Fuelling Date: Wed, 5 Feb 2020 14:42:55 -0700 Subject: [PATCH] Df/update example readme (#431) * Fix STREAM README Signed-off-by: David Fuelling --- examples-parent/send-money/README.md | 28 ++++++++----------- .../interledger/stream/SendMoneyRequest.java | 13 +++++---- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/examples-parent/send-money/README.md b/examples-parent/send-money/README.md index 7fec1c67..bd454d3e 100644 --- a/examples-parent/send-money/README.md +++ b/examples-parent/send-money/README.md @@ -56,23 +56,9 @@ StreamConnectionDetails connectionDetails = We can create a link using the following code: ```java -String sharedSecret = "some random secret you generated"; -IlpOverHttpLinkSettings linkSettings = IlpOverHttpLinkSettings.builder() - .incomingLinkSettings(IncomingLinkSettings.builder() - .authType(IlpOverHttpLinkSettings.AuthType.SIMPLE) - .encryptedTokenSharedSecret(sharedSecret) - .build()) - .outgoingLinkSettings(OutgoingLinkSettings.builder() - .authType(IlpOverHttpLinkSettings.AuthType.SIMPLE) - .tokenSubject(SENDER_ACCOUNT_USERNAME) - .url(HttpUrl.parse(TESTNET_URI + "/ilp")) - .encryptedTokenSharedSecret(sharedSecret) - .build()) - .build(); - Link link = new IlpOverHttpLink( () -> SENDER_ADDRESS, - linkSettings, + HttpUrl.parse("https://example.com/accounts/peer/ilp"), newHttpClient(), new ObjectMapper(), InterledgerCodecContextFactory.oer(), @@ -86,8 +72,16 @@ SimpleStreamSender simpleStreamSender = new SimpleStreamSender(link); Now, we can send a payment for 1000 millidrops from our source account to our destination account using the shared secret. ```java -SendMoneyResult result = simpleStreamSender.sendMoney(SharedSecret.of(connectionDetails.sharedSecret().value()), - SENDER_ADDRESS, connectionDetails.destinationAddress(), UnsignedLong.valueOf(1000)).get(); + +SendMoneyRequest sendMoneyRequest = SendMoneyRequest.builder() + .sourceAddress(InterledgerAddress.of(SPSP_SENDER)) + .amount(UnsignedLong.valueOf(1000L)) + .denomination(Denomination.builder().assetScale((short) 9).assetCode(XRP).build()) + .destinationAddress(connectionDetails.destinationAddress()) + .sharedSecret(connectionDetails.sharedSecret()) + .build(); + +SendMoneyResult result = simpleStreamSender.sendMoney(sendMoneyRequest).get(); ``` Finally, we can verify the account balance of the receiver using the Rust admin client: diff --git a/stream-parent/stream-core/src/main/java/org/interledger/stream/SendMoneyRequest.java b/stream-parent/stream-core/src/main/java/org/interledger/stream/SendMoneyRequest.java index 5f6b75cd..7890be19 100644 --- a/stream-parent/stream-core/src/main/java/org/interledger/stream/SendMoneyRequest.java +++ b/stream-parent/stream-core/src/main/java/org/interledger/stream/SendMoneyRequest.java @@ -8,6 +8,7 @@ import java.time.Duration; import java.util.Optional; + import javax.annotation.Nullable; @Immutable @@ -18,7 +19,7 @@ static SendMoneyRequestBuilder builder() { } /** - * The shared secret, shared between only the sender and receiverd, required by IL-RFC-29 to encrypt stream frames so + * The shared secret, shared between only the sender and receiver, required by IL-RFC-29 to encrypt stream frames so * that only the sender and receiver can decrypt them. * * @return A {@link SharedSecret} known only to the sender and receiver, negotiated using some higher-level protocol @@ -48,10 +49,10 @@ static SendMoneyRequestBuilder builder() { UnsignedLong amount(); /** - * @deprecated ascertained via the type of payment tracker used for sending. - * Returns the {@link SenderAmountMode} for this payment tracker. - * * @return A {@link SenderAmountMode} that indicates the meaning of {@link #amount()}. + * + * @deprecated ascertained via the type of payment tracker used for sending. Returns the {@link SenderAmountMode} for + * this payment tracker. */ @Deprecated @Nullable @@ -84,9 +85,9 @@ static SendMoneyRequestBuilder builder() { PaymentTracker paymentTracker(); /** - * @deprecated no longer performs a check on compatible SenderAmountMode since payment tracker is the authority - * * @return this instance + * + * @deprecated no longer performs a check on compatible SenderAmountMode since payment tracker is the authority */ @Deprecated default SendMoneyRequest check() {