Skip to content

Instantly share code, notes, and snippets.

@chill117
Last active August 29, 2015 14:04
Show Gist options
  • Save chill117/07555de183683ea17343 to your computer and use it in GitHub Desktop.
Save chill117/07555de183683ea17343 to your computer and use it in GitHub Desktop.
Get an address by its index from the default wallet in Electrum.
#!/usr/bin/env python
# Place this file in the Electrum scripts directory. Then run from command line, like this: `~/.electrum/scripts/get_address_by_index.py <index>`.
import sys
from electrum import SimpleConfig, Wallet, WalletStorage
try:
index = int(sys.argv[1])
except Exception:
print 'Usage: ' + sys.argv[0] + ' <index>'
sys.exit(1)
config = SimpleConfig()
storage = WalletStorage(config)
wallet = Wallet(storage)
for i in wallet.accounts:
print wallet.accounts[i].get_address(0, index)
break
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment