Skip to content

Instantly share code, notes, and snippets.

@wilsonianb
Last active April 18, 2017 23:05
Show Gist options
  • Save wilsonianb/1ac6b544c979e7c8b64b587e3769f3e1 to your computer and use it in GitHub Desktop.
Save wilsonianb/1ac6b544c979e7c8b64b587e3769f3e1 to your computer and use it in GitHub Desktop.
Sign and submit EscrowCancel Ripple transaction
// $ npm install ripple-lib
// $ RIPPLE_SECRET=sECRET RIPPLE_ADDRESS=rADDRESS SEQUENCE=4 RIPPLE_SERVER="ws://s.altnet.rippletest.net:51233" node escrow-cancel.js
// SEQUENCE is the sequence number of the corresponding EscrowCreate transaction
// For main network, use RIPPLE_SERVER="wss://s1.ripple.com:443"
var ripple = require('ripple-lib')
const ADDRESS = process.env['RIPPLE_ADDRESS']
const SECRET = process.env['RIPPLE_SECRET']
const SEQUENCE = process.env['SEQUENCE']
const IP = process.env['RIPPLE_SERVER']
const api = new ripple.RippleAPI({server: IP});
api.connect().then(() => {
return api.prepareEscrowCancellation(ADDRESS, {
owner: ADDRESS,
escrowSequence: parseInt(SEQUENCE)
}).then(prepared => {
console.log(prepared)
const signedTransaction = api.sign(prepared.txJSON, SECRET).signedTransaction;
return api.submit(signedTransaction);
})
.then(result => {
console.log(result)
process.exit(0);
})
}).catch(error => {
console.log(error)
process.exit(1);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment