def derive_pubkeys(self, for_change, n): xpub = self.xpub_change if for_change else self.xpub_receive if xpub is None: xpub = bip32_public_derivation(self.xpub, "", "/%d" % for_change) if for_change: self.xpub_change = xpub else: self.xpub_receive = xpub _, _, _, c, cK = deserialize_xkey(xpub) cK, c = CKD_pub(cK, c, n) result = cK.encode('hex') return result
def get_private_key(self, sequence, wallet, password): out = [] xpubs = self.get_master_pubkeys() roots = [k for k, v in wallet.master_public_keys.iteritems() if v in xpubs] for root in roots: xpriv = wallet.get_master_private_key(root, password) if not xpriv: continue _, _, _, c, k = deserialize_xkey(xpriv) pk = bip32_private_key(sequence, k, c) out.append(pk) return out
def derive_pubkey_from_xpub(cls, xpub, for_change, n): _, _, _, c, cK = deserialize_xkey(xpub) for i in [for_change, n]: cK, c = CKD_pub(cK, c, i) return cK.encode('hex')