add wallet.is_segwit
This commit is contained in:
parent
6f083a712d
commit
af54ba023b
|
@ -217,6 +217,8 @@ class Deterministic_KeyStore(Software_KeyStore):
|
|||
def get_passphrase(self, password):
|
||||
return pw_decode(self.passphrase, password) if self.passphrase else ''
|
||||
|
||||
def is_segwit(self):
|
||||
return False
|
||||
|
||||
|
||||
class Xpub:
|
||||
|
@ -333,6 +335,8 @@ class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
|
|||
pk = bip32_private_key(sequence, k, c)
|
||||
return pk
|
||||
|
||||
def is_segwit(self):
|
||||
return bool(deserialize_xpub(self.xpub)[0])
|
||||
|
||||
|
||||
class Old_KeyStore(Deterministic_KeyStore):
|
||||
|
|
|
@ -1516,7 +1516,7 @@ class Simple_Wallet(Abstract_Wallet):
|
|||
|
||||
def load_keystore(self):
|
||||
self.keystore = load_keystore(self.storage, 'keystore')
|
||||
self.xpub_type = deserialize_xpub(self.keystore.xpub)[0]
|
||||
self.is_segwit = self.keystore.is_segwit()
|
||||
|
||||
def get_pubkey(self, c, i):
|
||||
pubkey_list = self.change_pubkeys if c else self.receiving_pubkeys
|
||||
|
@ -1632,13 +1632,13 @@ class Standard_Wallet(Simple_Deterministic_Wallet):
|
|||
wallet_type = 'standard'
|
||||
|
||||
def pubkeys_to_redeem_script(self, pubkey):
|
||||
if self.xpub_type == 1:
|
||||
if self.is_segwit:
|
||||
return transaction.segwit_script(pubkey)
|
||||
|
||||
def pubkeys_to_address(self, pubkey):
|
||||
if self.xpub_type == 0:
|
||||
if not self.is_segwit:
|
||||
return bitcoin.public_key_to_p2pkh(pubkey.decode('hex'))
|
||||
elif self.xpub_type == 1 and bitcoin.TESTNET:
|
||||
elif bitcoin.TESTNET:
|
||||
redeem_script = self.pubkeys_to_redeem_script(pubkey)
|
||||
return bitcoin.hash160_to_p2sh(hash_160(redeem_script.decode('hex')))
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue