Ripple Wallet Generator (raw)

node v8.17.0
version: 2.0.0
endpointsharetweet
const crypto = require('crypto') const rippleSecretCodec = require('ripple-secret-codec') const rippleKeypairs = require('ripple-keypairs') const ripple = require('ripple-lib').RippleAPI const rippleApi = new ripple() var passphrase = 'masterpassphrase' // Create a SHA512 hash from the `passphrase` var hash = crypto.createHash('sha512').update(passphrase).digest('hex').toUpperCase() // Get the first 32 chars var hexSeed = hash.substring(0,32) // Encode in base58 with Ripple-aphabet. Here's our secret console.log('hexSeed: ' + hexSeed) var secret = rippleSecretCodec.encodeHex(hexSeed).secret_b58 console.log('Secret: ' + secret) // Generate keypair with secret var keypair = rippleKeypairs.deriveKeypair(secret) // Retrieve the wallet address var address = rippleKeypairs.deriveAddress(keypair.publicKey) // Create object with secret & wallet address var wallet = { address: address, secret: secret } console.log('Passphrase: ' + passphrase) console.log('Address: ' + address) // Now sign a transaction... var tx = { TransactionType: 'Payment', Account: address, Fee : (0.000012 * 1000 * 1000) + '', Destination: 'rPEPPER7kfTD9w2To4CQk6UCfuHM9c6GDY', DestinationTag : 2, Amount: (1 * 1000 * 1000) + '', Sequence: 0 } var txJSON = JSON.stringify(tx) var txSign = rippleApi.sign(txJSON, secret) return txSign
Loading…

no comments

    sign in to comment