Browse Source

hex encode the output of account.get_pubkey()

283
ThomasV 12 years ago
parent
commit
bc6e2e18f1
  1. 10
      lib/account.py
  2. 2
      lib/wallet.py

10
lib/account.py

@ -161,7 +161,7 @@ class BIP32_Account(Account):
def get_address(self, for_change, n): def get_address(self, for_change, n):
pubkey = self.get_pubkey(for_change, n) pubkey = self.get_pubkey(for_change, n)
address = public_key_to_bc_address( pubkey ) address = public_key_to_bc_address( pubkey.decode('hex') )
return address return address
def get_pubkey(self, for_change, n): def get_pubkey(self, for_change, n):
@ -169,7 +169,7 @@ class BIP32_Account(Account):
chain = self.c chain = self.c
for i in [for_change, n]: for i in [for_change, n]:
K, K_compressed, chain = CKD_prime(K, chain, i) K, K_compressed, chain = CKD_prime(K, chain, i)
return K_compressed return K_compressed.encode('hex')
def get_private_key(self, sequence, master_k): def get_private_key(self, sequence, master_k):
chain = self.c chain = self.c
@ -213,12 +213,12 @@ class BIP32_Account_2of2(BIP32_Account):
chain = self.c2 chain = self.c2
for i in [for_change, n]: for i in [for_change, n]:
K, K_compressed, chain = CKD_prime(K, chain, i) K, K_compressed, chain = CKD_prime(K, chain, i)
return K_compressed return K_compressed.encode('hex')
def get_address(self, for_change, n): def get_address(self, for_change, n):
pubkey1 = self.get_pubkey(for_change, n) pubkey1 = self.get_pubkey(for_change, n)
pubkey2 = self.get_pubkey2(for_change, n) pubkey2 = self.get_pubkey2(for_change, n)
address = Transaction.multisig_script([pubkey1.encode('hex'), pubkey2.encode('hex')], 2)["address"] address = Transaction.multisig_script([pubkey1, pubkey2], 2)["address"]
return address return address
def get_input_info(self, sequence): def get_input_info(self, sequence):
@ -227,6 +227,6 @@ class BIP32_Account_2of2(BIP32_Account):
pubkey2 = self.get_pubkey2(chain, i) pubkey2 = self.get_pubkey2(chain, i)
# fixme # fixme
pk_addr = None # public_key_to_bc_address( pubkey1 ) # we need to return that address to get the right private key pk_addr = None # public_key_to_bc_address( pubkey1 ) # we need to return that address to get the right private key
redeemScript = Transaction.multisig_script([pubkey1.encode('hex'), pubkey2.encode('hex')], 2)['redeemScript'] redeemScript = Transaction.multisig_script([pubkey1, pubkey2], 2)['redeemScript']
return pk_addr, redeemScript return pk_addr, redeemScript

2
lib/wallet.py

@ -294,7 +294,7 @@ class Wallet:
def get_public_key(self, address): def get_public_key(self, address):
account, sequence = self.get_address_index(address) account, sequence = self.get_address_index(address)
return self.accounts[account].get_pubkey( sequence ) return self.accounts[account].get_pubkey( *sequence )
def decode_seed(self, password): def decode_seed(self, password):

Loading…
Cancel
Save