Ripple-lib valid addr. (promise)
const RippleAPI = require('ripple-lib').RippleAPI
const RippleAddressCodec = require('ripple-address-codec')
const api = new RippleAPI({ server: 'wss://s2.ripple.com:443' })
/**
* Note: isValidAddress will probably be exposed in a future ripple-lib release at api level.
*/
api.connect().then(() => {
return new Promise((resolve, reject) => {
if (RippleAddressCodec.isValidAddress("rBwdSqfFMBYUazUsv9pV1ZpHTG2nZcaNJv")) {
resolve(true)
} else {
reject(new Error('Invalid XRPL account'))
}
})
}).then(r => {
console.log('Valid?', r)
}).then(() => {
console.log('Disconnect')
api.disconnect()
})
.catch(e => console.log("Caught error", e))
no comments