Skip to content

Instantly share code, notes, and snippets.

@mbaneshi
Forked from WietseWind/sample.js
Created January 31, 2022 18:19
Show Gist options
  • Save mbaneshi/6e1853f6694420a92b4ba46d8dc6062d to your computer and use it in GitHub Desktop.
Save mbaneshi/6e1853f6694420a92b4ba46d8dc6062d to your computer and use it in GitHub Desktop.
Fetching all issuer trustlines (node, websocket)
const { XrplClient } = require('xrpl-client')
const account = 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B' // The issuer, Bitstamp USD
const currency = 'USD'
const client = new XrplClient()
const main = async () => {
await client.ready()
const { account_data } = await client.send({ command: 'account_info', account })
let marker = ''
const l = []
while (typeof marker === 'string') {
const lines = await client.send({ command: 'account_lines', account, marker: marker === '' ? undefined : marker })
marker = lines?.marker === marker ? null : lines?.marker
console.log(`Got ${lines.lines.length} results`)
lines.lines.forEach(t => {
if (t.currency === currency) {
l.push(t.account)
}
})
}
console.log('# Trust Lines:', l.length)
client.close()
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment