Last active
October 14, 2016 21:32
-
-
Save rusq/c50cd788b662715c4a28fe465b2f952e to your computer and use it in GitHub Desktop.
Get electrum bitcoin wallet history as a dict
This file contains hidden or 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
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