const fetch = require('node-fetch')
const {decode} = require('ripple-binary-codec')
const {encodeNodePublic} = require('ripple-address-codec')
const base64ToDecoded = base64 => decode(Buffer.from(base64, 'base64').toString('hex'))
const pubkeyToNode = pubhex => encodeNodePublic(Buffer.from(pubhex, 'hex'))
const main = async () => {
const f = await fetch('http://vl.ripple.com/')
const {manifest, blob} = await f.json()
const {validators} = JSON.parse(Buffer.from(blob, 'base64').toString('utf-8'))
return validators.map(v => {
const manifest = base64ToDecoded(v.manifest)
return {
validation_public_key: v.validation_public_key,
decodedManifestPubKeys: {
PublicKey: pubkeyToNode(manifest.PublicKey),
SigningPubKey: pubkeyToNode(manifest.SigningPubKey)
},
manifest
}
})
}
console.log(await main())