def get_xpub(self, bip32_path, xtype, creating=False): address_n = parse_path(bip32_path) with self.run_flow(creating_wallet=creating): node = trezorlib.btc.get_public_node(self.client, address_n).node return serialize_xpub(xtype, node.chain_code, node.public_key, node.depth, self.i4b(node.fingerprint), self.i4b(node.child_num))
def get_xpub(self, bip32_path, xtype): self.checkDevice() # bip32_path is of the form 44'/0'/1' # S-L-O-W - we don't handle the fingerprint directly, so compute # it manually from the previous node # This only happens once so it's bearable #self.get_client() # prompt for the PIN before displaying the dialog if necessary #self.handler.show_message("Computing master public key") splitPath = bip32_path.split('/') if splitPath[0] == 'm': splitPath = splitPath[1:] bip32_path = bip32_path[2:] fingerprint = 0 if len(splitPath) > 1: prevPath = "/".join(splitPath[0:len(splitPath) - 1]) nodeData = self.dongleObject.getWalletPublicKey(prevPath) publicKey = compress_public_key(nodeData['publicKey']) # h = hashlib.new('ripemd160') h.update(hashlib.sha256(publicKey).digest()) fingerprint = unpack(">I", h.digest()[0:4])[0] nodeData = self.dongleObject.getWalletPublicKey(bip32_path) publicKey = compress_public_key(nodeData['publicKey']) depth = len(splitPath) lastChild = splitPath[len(splitPath) - 1].split('\'') childnum = int(lastChild[0]) if len( lastChild) == 1 else 0x80000000 | int(lastChild[0]) xpub = bitcoin.serialize_xpub(xtype, nodeData['chainCode'], publicKey, depth, self.i4b(fingerprint), self.i4b(childnum)) return xpub
def get_xpub(self, bip32_path, xtype): address_n = self.expand_path(bip32_path) creating = False node = self.get_public_node(address_n, creating).node return serialize_xpub(xtype, node.chain_code, node.public_key, node.depth, self.i4b(node.fingerprint), self.i4b(node.child_num))
def get_xpub(self, bip32_path): address_n = self.expand_path(bip32_path) creating = False #self.next_account_number() == 0 node = self.get_public_node(address_n, creating).node return serialize_xpub(0, node.chain_code, node.public_key, node.depth, self.i4b(node.fingerprint), self.i4b(node.child_num))
def get_xpub(self, bip32_path, xtype): assert xtype in SatochipPlugin.SUPPORTED_XTYPES try: # needs PIN self.cc.card_verify_PIN() # bip32_path is of the form 44'/0'/1' self.print_error("[get_xpub(): bip32_path = ", bip32_path)#debugSatochip (depth, bytepath)= bip32path2bytes(bip32_path) (childkey, childchaincode)= self.cc.card_bip32_get_extendedkey(bytepath) if depth == 0: #masterkey fingerprint= bytes([0,0,0,0]) child_number= bytes([0,0,0,0]) else: #get parent info (parentkey, parentchaincode)= self.cc.card_bip32_get_extendedkey(bytepath[0:-4]) fingerprint= hash_160(parentkey.get_public_key_bytes(compressed=True))[0:4] child_number= bytepath[-4:] #xpub= serialize_xpub('standard', childchaincode, childkey.get_public_key_bytes(compressed=True), depth, fingerprint, child_number) xpub= serialize_xpub(xtype, childchaincode, childkey.get_public_key_bytes(compressed=True), depth, fingerprint, child_number) self.print_error("SatochipClient: get_xpub(): xpub=", xpub)#debugSatochip return xpub # return BIP32Node(xtype=xtype, # eckey=childkey, # chaincode=childchaincode, # depth=depth, # fingerprint=fingerprint, # child_number=child_number).to_xpub() except Exception as e: self.print_error(repr(e)) return None
def get_xpub(self, bip32_path, xtype): assert xtype in SatochipPlugin.SUPPORTED_XTYPES try: hex_authentikey = self.handler.win.wallet.storage.get( 'authentikey') self.print_error( "get_xpub(): self.handler.win.wallet.storage.authentikey:", hex_authentikey) #debugSatochip if hex_authentikey is not None: self.cc.parser.authentikey_from_storage = ECPubkey( bytes.fromhex(hex_authentikey)) except Exception as e: #attributeError? self.print_error( "get_xpub(): exception when getting authentikey from self.handler.win.wallet.storage:", str(e)) #debugSatochip try: # needs PIN self.cc.card_verify_PIN() # bip32_path is of the form 44'/0'/1' self.print_error("[get_xpub(): bip32_path = ", bip32_path) #debugSatochip (depth, bytepath) = bip32path2bytes(bip32_path) (childkey, childchaincode) = self.cc.card_bip32_get_extendedkey(bytepath) if depth == 0: #masterkey fingerprint = bytes([0, 0, 0, 0]) child_number = bytes([0, 0, 0, 0]) else: #get parent info (parentkey, parentchaincode) = self.cc.card_bip32_get_extendedkey( bytepath[0:-4]) fingerprint = hash_160( parentkey.get_public_key_bytes(compressed=True))[0:4] child_number = bytepath[-4:] #xpub= serialize_xpub('standard', childchaincode, childkey.get_public_key_bytes(compressed=True), depth, fingerprint, child_number) xpub = serialize_xpub( xtype, childchaincode, childkey.get_public_key_bytes(compressed=True), depth, fingerprint, child_number) self.print_error("SatochipClient: get_xpub(): xpub=", xpub) #debugSatochip return xpub # return BIP32Node(xtype=xtype, # eckey=childkey, # chaincode=childchaincode, # depth=depth, # fingerprint=fingerprint, # child_number=child_number).to_xpub() except Exception as e: self.print_error(repr(e)) return None
def get_xpub(self, bip32_path, xtype): assert xtype in SatochipPlugin.SUPPORTED_XTYPES try: hex_authentikey = self.handler.win.wallet.storage.get( 'authentikey') print_error( "[satochip] SatochipClient: get_xpub(): self.handler.win.wallet.storage.authentikey:" + str(hex_authentikey)) #debugSatochip if hex_authentikey is not None: self.parser.authentikey_from_storage = ECPubkey( bytes.fromhex(hex_authentikey)) except Exception as e: #attributeError? print_error( "[satochip] SatochipClient: get_xpub(): exception when getting authentikey from self.handler.win.wallet.storage:" + str(e)) #debugSatochip # bip32_path is of the form 44'/0'/1' print_error("[satochip] SatochipClient: get_xpub(): bip32_path=" + bip32_path) #debugSatochip (depth, bytepath) = bip32path2bytes(bip32_path) (childkey, childchaincode) = self.cc.card_bip32_get_extendedkey(bytepath) #print_error("[satochip] SatochipClient: get_xpub(): depth="+str(depth))#debugSatochip if depth == 0: #masterkey fingerprint = bytes([0, 0, 0, 0]) child_number = bytes([0, 0, 0, 0]) else: #get parent info #print_error("[satochip] SatochipClient: get_xpub(): get xpub for parent")#debugSatochip (parentkey, parentchaincode) = self.cc.card_bip32_get_extendedkey( bytepath[0:-4]) fingerprint = hash_160( parentkey.get_public_key_bytes(compressed=True))[0:4] child_number = bytepath[-4:] #xpub= serialize_xpub('standard', childchaincode, childkey.get_public_key_bytes(compressed=True), depth, fingerprint, child_number) xpub = serialize_xpub(xtype, childchaincode, childkey.get_public_key_bytes(compressed=True), depth, fingerprint, child_number) print_error("[satochip] SatochipClient: get_xpub(): xpub=" + str(xpub)) #debugSatochip return xpub