Skip to content

Instantly share code, notes, and snippets.

@jooray
Created April 13, 2023 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jooray/825c5f088280960d4e5f94a46bee83b5 to your computer and use it in GitHub Desktop.
Save jooray/825c5f088280960d4e5f94a46bee83b5 to your computer and use it in GitHub Desktop.
A way to search for monero transactions with particular inputs in ring groups
const monerojs = require('monero-javascript');
const cliProgress = require('cli-progress');
async function scanForInputs() {
// parameters
const rpc = await monerojs.connectToDaemonRpc('http://localhost:18081');
const min_height = 2853173;
// get indices using node command line interface:
// const monerojs = require('monero-javascript');
// const rpc = await monerojs.connectToDaemonRpc('http://localhost:18081');
// tx = await rpc.getTx('TX hash here')
// tx.getOutputs()[0].getIndex()
// put the indices here:
const ring_member_indices = [ 70900000, 70911111 ]
// go!
let height = await rpc.getHeight();
const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
bar.start(height-min_height, 0);
for (block_i=min_height; block_i <= height; block_i++) {
const block = await rpc.getBlockByHeight(block_i)
for (const tx_hash of block.getTxHashes()) {
rpc.getTx(tx_hash).then( (tx) => {
for (const input of tx.getInputs()) {
let absIndex = 0
for (const relIndex of input.getRingOutputIndices()) {
absIndex = absIndex + relIndex
for (const ringMemberIndex of ring_member_indices) {
if (absIndex === ringMemberIndex) {
console.log('')
console.log(`Transaction ${tx_hash} contains ring member ${ringMemberIndex}`);
console.log('')
}
}
}
}
})
}
bar.update(block_i-min_height)
}
bar.stop()
}
scanForInputs();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment