XRP Tx gt 20.000 XRP

node v8.17.0
version: 3.0.0
endpointsharetweet
const websocket = require('websocket') const RippledWsClient = require('rippled-ws-client') // Set these values and then check the magic at the bottom of this script const minAmount = 20000 // Min amount in XRP const account = 'rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh' const fetchData = function (connection, lastSeenLedgerAndTx) { return new Promise((resolve, reject) => { let hasSeenOverlappingTx = typeof lastSeenLedgerAndTx === 'undefined' let txs = [] let command = { command: 'account_tx', account: account, ledger_index_max: (typeof lastSeenLedgerAndTx !== 'undefined' ? lastSeenLedgerAndTx.Ledger : -1) } connection.send(command).then((r) => { let lastSeen = null r.transactions.forEach((i) => { if (i.tx.TransactionType === 'Payment' && parseInt(i.tx.Amount) >= minAmount * 1000 * 1000) { if (hasSeenOverlappingTx) { txs.push({ Amount: parseInt(i.tx.Amount) / 1000 / 1000, From: i.tx.Account, To: i.tx.Destination, Ledger: i.tx.inLedger, Hash: i.tx.hash }) lastSeen = { Ledger: i.tx.inLedger, Hash: i.tx.hash } } } if (!hasSeenOverlappingTx && i.tx.hash === lastSeenLedgerAndTx.Hash) { hasSeenOverlappingTx = true } }) resolve({ // let nextSeq = r.marker.seq txs: txs, next () { return fetchData(connection, lastSeen) } }) }) }) } new RippledWsClient('wss://s2.ripple.com').then(function (connection) { fetchData(connection).then((data) => { console.log(data.txs) // data.txs = array with transactions, // data.next = promise with the next set of results data.next().then((moreData) => { console.log(moreData.txs) }) }) }).catch(function (error) { // Oops! })
Loading…

no comments

    sign in to comment