Last active
April 25, 2021 04:32
-
-
Save WietseWind/4a3320a28686303522620f14d732c6be to your computer and use it in GitHub Desktop.
Fetch all Trust Lines for an XRPL account
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 Client = require('rippled-ws-client') | |
const main = async () => { | |
const client = await new Client('wss://xrplcluster.com') | |
let fetchMore = true | |
let marker = undefined | |
const lines = [] | |
while (fetchMore) { | |
const data = await client.send({ | |
command: 'account_lines', | |
account: 'rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr', | |
marker | |
}) | |
const lineCount = data?.lines?.length || 0 | |
marker = data?.marker | |
fetchMore = lineCount > 0 && marker | |
console.log('Fetched # TrustLines:', lineCount, marker) | |
if (lineCount > 0) { | |
lines.push(...data.lines) | |
} | |
} | |
console.log('Got a total # TrustLines:', lines.length) | |
client.close() | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment