Skip to content

Commit

Permalink
Output more helpful error message on bad mpk format
Browse files Browse the repository at this point in the history
This has tripped up every people on github. The only place to get
the correct master public key is from Electrum itself.
  • Loading branch information
chris-belcher committed Jun 15, 2018
1 parent 2a0d918 commit 0b5d3c7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions electrumpersonalserver/deterministicwallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ def rewind_one(self, change):
class SingleSigWallet(DeterministicWallet):
def __init__(self, mpk):
super(SingleSigWallet, self).__init__()
self.branches = (btc.bip32_ckd(mpk, 0), btc.bip32_ckd(mpk, 1))
try:
self.branches = (btc.bip32_ckd(mpk, 0), btc.bip32_ckd(mpk, 1))
except Exception:
raise ValueError("Bad master public key format. Get it from " +
"Electrum menu `Wallet` -> `Information`")
#m/change/i

def pubkey_to_scriptpubkey(self, pubkey):
Expand Down Expand Up @@ -163,8 +167,12 @@ class MultisigWallet(DeterministicWallet):
def __init__(self, m, mpk_list):
super(MultisigWallet, self).__init__()
self.m = m
self.pubkey_branches = [(btc.bip32_ckd(mpk, 0), btc.bip32_ckd(mpk, 1))
for mpk in mpk_list]
try:
self.pubkey_branches = [(btc.bip32_ckd(mpk, 0), btc.bip32_ckd(mpk,
1)) for mpk in mpk_list]
except Exception:
raise ValueError("Bad master public key format. Get it from " +
"Electrum menu `Wallet` -> `Information`")
#derivation path for pubkeys is m/change/index

def redeem_script_to_scriptpubkey(self, redeem_script):
Expand Down

0 comments on commit 0b5d3c7

Please sign in to comment.