Created
October 27, 2020 11:04
-
-
Save WietseWind/52714ccc0e4692c08ac94149a191a5f6 to your computer and use it in GitHub Desktop.
Cobo Vault encode/decode full XRPL tx QR signing (terminal)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {decodeUR} = require('@cvbb/bc-ur') | |
const {decode} = require('ripple-binary-codec') | |
const {verifySignature} = require('verify-xrpl-signature') | |
const str = 'UR:BYTES/TPHPYQQ5WVSSYC8SDSZEP3RSULNL480RM859KXP9UXGEDKYF8HVYGV0KA9Y3WWDVW3RRQ3QZYQAR3HWPCEW6T9ZWGAU0FDSW5U9PSL4G8NE98YZA4TFUMUJUMU34VQ3QZZA5WYPH54WWNQK295W7GYYVV4AD0P5D6XTWENTCFZC8KKGVW2CQS2A5YK' | |
const data = decodeUR([str]).toUpperCase() | |
console.log(data) | |
console.log(decode(data)) | |
console.log(verifySignature(data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {encodeUR} = require('@cvbb/bc-ur') | |
const qrcode = require('qrcode-terminal') | |
// const tx = { | |
// TransactionType: 'Payment', | |
// Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn', | |
// Destination: 'ra5nK24KXen9AHvsdFTKHSANinZseWnPcX', | |
// Amount: { | |
// currency: 'USD', | |
// value: '1', | |
// issuer: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn' | |
// }, | |
// Fee: '12', | |
// Flags: 2147483648, | |
// Sequence: 2 | |
const tx = { | |
TransactionType: "TrustSet", | |
AuthorizeXUMM: true | |
} | |
const txJson = JSON.stringify(tx) | |
console.log('TXJson Length', txJson.length) | |
const dataHex = Buffer.from(txJson, 'utf-8').toString('hex') | |
const dataFragmets = encodeUR(dataHex, 500 /* fragmentCapacity */) | |
dataFragmets.forEach(d => { | |
console.log(d) | |
qrcode.generate(d, {small: true}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment