electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 4019102264e932b2aa762014544d7e34afe0f42e
parent c71648bfec107e50ed3e9827e6322f2281f34a4b
Author: ecdsa <ecdsa@github>
Date:   Mon,  4 Mar 2013 07:43:01 +0100

rename sequence, fix bip32

Diffstat:
Mlib/bitcoin.py | 14+++++++++-----
Mlib/wallet.py | 6+++---
2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/bitcoin.py b/lib/bitcoin.py @@ -412,7 +412,7 @@ def CKD_prime(K, c, n): -class DeterministicSequence: +class ElectrumSequence: """ Privatekey(type,n) = Master_private_key + H(n|S|type) """ def __init__(self, master_public_key, mpk2 = None): @@ -517,11 +517,15 @@ class BIP32Sequence: @classmethod def mpk_from_seed(klass, seed): master_secret, master_chain, master_public_key, master_public_key_compressed = bip32_init(seed) - return master_public_key, master_chain + return master_public_key.encode('hex'), master_chain.encode('hex') - def get_pubkey(self, sequence): - K = self.master_public_key - chain = self.mchain + def get_pubkey(self, sequence, use_mpk2=False): + if not use_mpl2: + K = self.master_public_key.decode('hex') + chain = self.master_chain.decode('hex') + else: + K = self.master_public_key_2.decode('hex') + chain = self.master_chain_2.decode('hex') for i in sequence: K, K_compressed, chain = CKD_prime(K, chain, i) return K_compressed diff --git a/lib/wallet.py b/lib/wallet.py @@ -94,7 +94,7 @@ class Wallet: self.accounts = config.get('accounts', {}) # this should not include public keys self.sequences = {} - self.sequences[0] = DeterministicSequence(self.config.get('master_public_key')) + self.sequences[0] = ElectrumSequence(self.config.get('master_public_key')) if self.accounts.get(0) is None: self.accounts[0] = { 0:[], 1:[], 'name':'Main account' } @@ -162,9 +162,9 @@ class Wallet: self.config.set_key('seed', self.seed, True) self.config.set_key('seed_version', self.seed_version, True) - mpk = DeterministicSequence.mpk_from_seed(self.seed) + mpk = ElectrumSequence.mpk_from_seed(self.seed) self.config.set_key('master_public_key', mpk, True) - self.sequences[0] = DeterministicSequence(mpk) + self.sequences[0] = ElectrumSequence(mpk) self.accounts[0] = { 0:[], 1:[], 'name':'Main account' } self.config.set_key('accounts', self.accounts, True)