Created
January 12, 2022 13:57
-
-
Save WietseWind/9b80e10edc5c3ef63a8d77eb162f5775 to your computer and use it in GitHub Desktop.
Fetching all issuer trustlines (node, websocket)
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 { 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