support for old public key addresses

This commit is contained in:
Lex Berezhny 2020-09-21 15:27:47 -04:00
parent 4e6bdb64a8
commit 62a3022a3d

View file

@ -273,11 +273,17 @@ class Output(InputOutput):
@property @property
def pubkey_hash(self): def pubkey_hash(self):
return self.script.values['pubkey_hash'] pubkey_hash = self.script.values.get('pubkey_hash')
if pubkey_hash:
return pubkey_hash
return hash160(self.script.values['pubkey'])
@property @property
def has_address(self): def has_address(self):
return 'pubkey_hash' in self.script.values return (
'pubkey_hash' in self.script.values or
'pubkey' in self.script.values
)
def get_address(self, ledger): def get_address(self, ledger):
return ledger.hash160_to_address(self.pubkey_hash) return ledger.hash160_to_address(self.pubkey_hash)