Skip to content

Instantly share code, notes, and snippets.

@rusq
Last active October 14, 2016 21:32
Show Gist options
  • Save rusq/c50cd788b662715c4a28fe465b2f952e to your computer and use it in GitHub Desktop.
Save rusq/c50cd788b662715c4a28fe465b2f952e to your computer and use it in GitHub Desktop.
Get electrum bitcoin wallet history as a dict
import subprocess
import sys
def get_history():
"""
Get electrum history without requiring it as a module
Returns:
(dict) - current electrum wallet history
"""
history = None
try:
history = eval(subprocess.check_output(['electrum', 'history']))
except OSError:
sys.stderr.write("ERROR: Install electrum with: pip install electrum")
except:
sys.stderr.write("Something bad happened: %s" % sys.exc_info()[1])
return history
if __name__ == '__main__':
history = get_history()
if history is not None:
for tx in history:
print("%s;%+.8f" % (tx["date"], tx["value"]))
else:
print("I HAVE NOTHING FOR YOU")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment