From c189649777301185a29f18e2c0148ea66e1f1b28 Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Wed, 17 Oct 2018 00:00:43 -0700 Subject: [PATCH] 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) ```