From c189649777301185a29f18e2c0148ea66e1f1b28 Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Wed, 17 Oct 2018 00:00:43 -0700 Subject: [PATCH 1/2] Send a Conditionally-Held Escrow: update example Hex should be uppercase; see https://github.com/ripple/ripple-lib/issues/953 --- .../send-a-conditionally-held-escrow.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/content/tutorials/use-complex-payment-types/use-escrows/send-a-conditionally-held-escrow.md b/content/tutorials/use-complex-payment-types/use-escrows/send-a-conditionally-held-escrow.md index 7424745436..c05c619a2b 100644 --- a/content/tutorials/use-complex-payment-types/use-escrows/send-a-conditionally-held-escrow.md +++ b/content/tutorials/use-complex-payment-types/use-escrows/send-a-conditionally-held-escrow.md @@ -10,14 +10,20 @@ XRP Ledger escrows require PREIMAGE-SHA-256 [Crypto-Conditions](https://tools.ie Example JavaScript code for a random fulfillment and condition: ```js -cc = require('five-bells-condition'); +const cc = require('five-bells-condition') +const crypto = require('crypto') -const fulfillment_bytes = crypto.randomBytes(32); -const myFulfillment = new cc.PreimageSha256(); -myFulfillment.setPreimage(fulfillment_bytes); -console.log(myFulfillment.serializeBinary().toString('hex')); +const preimageData = crypto.randomBytes(32) +const myFulfillment = new cc.PreimageSha256() +myFulfillment.setPreimage(preimageData) + +const condition = myFulfillment.getConditionBinary().toString('hex').toUpperCase(); +console.log('Condition:', condition) // (Random hexadecimal, 72 chars in length) -console.log(myFulfillment.getConditionBinary().toString('hex')); + +// keep secret until you want to finish executing the held payment: +const fulfillment = myFulfillment.serializeBinary().toString('hex').toUpperCase(); +console.log('Fulfillment:', fulfillment) // (Random hexadecimal, 78 chars in length) ``` From 27be0da73b985605ecfbd29272e3da0c01f745db Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Wed, 17 Oct 2018 00:01:47 -0700 Subject: [PATCH 2/2] Remove semicolons from js --- .../use-escrows/send-a-conditionally-held-escrow.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/tutorials/use-complex-payment-types/use-escrows/send-a-conditionally-held-escrow.md b/content/tutorials/use-complex-payment-types/use-escrows/send-a-conditionally-held-escrow.md index c05c619a2b..8a69fc6f80 100644 --- a/content/tutorials/use-complex-payment-types/use-escrows/send-a-conditionally-held-escrow.md +++ b/content/tutorials/use-complex-payment-types/use-escrows/send-a-conditionally-held-escrow.md @@ -17,12 +17,12 @@ const preimageData = crypto.randomBytes(32) const myFulfillment = new cc.PreimageSha256() myFulfillment.setPreimage(preimageData) -const condition = myFulfillment.getConditionBinary().toString('hex').toUpperCase(); +const condition = myFulfillment.getConditionBinary().toString('hex').toUpperCase() console.log('Condition:', condition) // (Random hexadecimal, 72 chars in length) // keep secret until you want to finish executing the held payment: -const fulfillment = myFulfillment.serializeBinary().toString('hex').toUpperCase(); +const fulfillment = myFulfillment.serializeBinary().toString('hex').toUpperCase() console.log('Fulfillment:', fulfillment) // (Random hexadecimal, 78 chars in length) ``` @@ -41,9 +41,9 @@ Example for setting a `CancelAfter` time of 24 hours in the future: _JavaScript_ ```js -const rippleOffset = 946684800; -const CancelAfter = Math.floor(Date.now() / 1000) + (24*60*60) - rippleOffset; -console.log(CancelAfter); +const rippleOffset = 946684800 +const CancelAfter = Math.floor(Date.now() / 1000) + (24*60*60) - rippleOffset +console.log(CancelAfter) // Example: 556927412 ```