Checks tutorials: 1st draft done

This commit is contained in:
mDuo13
2018-04-02 18:20:59 -07:00
parent aaf44e664c
commit 1832697701
38 changed files with 1382 additions and 88 deletions

View File

@@ -1,5 +1,7 @@
'use strict'
const RippleAPI = require('ripple-lib').RippleAPI
const decodeAddress = require('ripple-address-codec').decodeAddress;
const createHash = require('crypto').createHash;
// This example connects to a public Test Net server
const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'})
@@ -12,6 +14,16 @@ api.connect().then(() => {
}).then(response => {
console.log("Final transaction result:", response)
// Re-calculate checkID to work around issue ripple-lib#876
const checkIDhasher = createHash('sha512')
checkIDhasher.update(Buffer.from('0043', 'hex'))
checkIDhasher.update(new Buffer(decodeAddress(response.address)))
const seqBuf = Buffer.alloc(4)
seqBuf.writeUInt32BE(response.sequence, 0)
checkIDhasher.update(seqBuf)
const checkID = checkIDhasher.digest('hex').slice(0,64).toUpperCase()
console.log("Calculated checkID:", checkID)
// Disconnect and return
}).then(() => {
api.disconnect().then(() => {