commit 0b5d3c7909a8111a6484a881add0f6eae42c1765
parent 2a0d918ac4ac19037846935893807491c77da15d
Author: chris-belcher <chris-belcher@users.noreply.github.com>
Date: Fri, 15 Jun 2018 02:20:52 +0100
Output more helpful error message on bad mpk format
This has tripped up every people on github. The only place to get
the correct master public key is from Electrum itself.
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/electrumpersonalserver/deterministicwallet.py b/electrumpersonalserver/deterministicwallet.py
@@ -105,7 +105,11 @@ class DeterministicWallet(object):
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):
@@ -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):