Last active
May 25, 2018 04:47
-
-
Save WietseWind/d35c66fb22a5071357d2832fec6a561f to your computer and use it in GitHub Desktop.
Check XRPL burn
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 websocket = require('websocket') | |
const RippleClient = require('rippled-ws-client') | |
const burnGtXrp = { | |
ledger: 5, | |
tx: 1 | |
} | |
new RippleClient('wss://rippled.xrptipbot.com').then(connection => { | |
let atLedgerIndex = 38862032 | |
let lastCoins = null | |
let fetchCount = 0 | |
const fetchNextLedger = () => { | |
fetchCount++ | |
connection.send({ | |
command: 'ledger', | |
ledger_index: atLedgerIndex | |
}).then(response => { | |
let coins = parseInt(response.ledger.totalCoins) / 1000000 | |
let diff = (lastCoins === null ? 0 : coins - lastCoins) | |
let diffGt = diff >= burnGtXrp.ledger ? '<FLAG>' : '' | |
console.log(`${response.ledger_index} ${response.ledger.close_time_human} ${coins.toFixed(6)} ${diff.toFixed(6)} ${diffGt}`) | |
if (diff >= 5) { | |
// Fetch the transactions responsible for the high burn rate | |
connection.send({ | |
command: 'ledger', | |
ledger_index: response.ledger_index + 1, | |
transactions: true, | |
expand: true | |
}).then(ledgerData => { | |
ledgerData.ledger.transactions.forEach(tx => { | |
let txFee = parseInt(tx.Fee) / 1000000 | |
if (txFee >= burnGtXrp.tx) { | |
console.log(`${tx.hash} burned: ${txFee.toFixed(6)} XRP (${tx.TransactionType})`) | |
// console.log(tx) | |
} | |
}) | |
}) | |
} | |
lastCoins = coins | |
atLedgerIndex = parseInt(response.ledger_index) - 1 | |
fetchNextLedger() | |
}) | |
} | |
fetchNextLedger() | |
}).catch(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment