Skip to content

Instantly share code, notes, and snippets.

@mDuo13
Created June 2, 2016 22:12
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 mDuo13/d60522735ab36d52de0d187edd0006fb to your computer and use it in GitHub Desktop.
Save mDuo13/d60522735ab36d52de0d187edd0006fb to your computer and use it in GitHub Desktop.
search for EnableAmendment (Python)
import txsplain
# You need to modify txsplain's lookup_ledger function for this code to work.
# The code as published doesn't have expand=True. (It's a trivial change though.)
#
# Also This script also doesn't do any error handling (e.g. if one side of your
# search goes beyond the current ledger, it'll just die)
def search_ledger(ledger_index, tx_type):
ledger = txsplain.lookup_ledger(ledger_index=ledger_index, expand=True)
for tx in ledger["transactions"]:
if tx["TransactionType"] == tx_type:
return tx["hash"]
return False
ledger_index_start = 21225285
offset = 1
while 1:
li = ledger_index_start + offset
print("Searching ledger", li)
tx_hash = search_ledger(li, "EnableAmendment")
if tx_hash:
print("Found in ledger %d: hash %s" % (li, tx_hash))
break
li = ledger_index_start - offset
print("Searching ledger", li)
tx_hash = search_ledger(li, "EnableAmendment")
if tx_hash:
print("Found in ledger %d: hash %s" % (li, tx_hash))
break
offset += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment