Skip to content

Instantly share code, notes, and snippets.

@0xB10C
Last active January 5, 2018 20:33
Show Gist options
  • Save 0xB10C/bd2fe15cd863471253273c6bea87ea1b to your computer and use it in GitHub Desktop.
Save 0xB10C/bd2fe15cd863471253273c6bea87ea1b to your computer and use it in GitHub Desktop.
generates a list of mempool transactions with more than one 1000sat output
#!/usr/bin/env python
# requires https://github.com/petertodd/python-bitcoinlib
# just retry if a TypeError occurs on nodes without tx indexing (e.g. pruned nodes)
import bitcoin
import bitcoin.rpc
rpc = bitcoin.rpc.RawProxy()
rawmempool = rpc.getrawmempool(False);
print("tx in mempool: " + str(len(rawmempool)))
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
for chunk in chunks(rawmempool, 2000): # creates chunks of 2000 txids
commands = [ {"method": "getrawtransaction", "params": [txid,True]} for txid in chunk]
results = rpc._batch(commands)
for tx in results:
onekSatOuts = 0
for vout in tx['result']['vout']:
value = float(vout["value"])
if value == 0.00001000:
onekSatOuts += 1
if onekSatOuts > 1:
print("1kSat x" + str(onekSatOuts) + " - " + tx['result']['txid']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment