From 8e5d47061f19638bb9e0dd26eaaaae6c8c172237 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 29 Oct 2019 10:21:10 -0400 Subject: [PATCH] check txo.has_address before calling txo.get_address() --- torba/torba/client/basedatabase.py | 2 +- torba/torba/client/basetransaction.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/torba/torba/client/basedatabase.py b/torba/torba/client/basedatabase.py index 14d4fea9e..fadbc6f9b 100644 --- a/torba/torba/client/basedatabase.py +++ b/torba/torba/client/basedatabase.py @@ -398,7 +398,7 @@ class BaseDatabase(SQLiteMixin): for txi in tx.inputs: if txi.txo_ref.txo is not None: txo = txi.txo_ref.txo - if txo.get_address(self.ledger) == address: + if txo.has_address and txo.get_address(self.ledger) == address: conn.execute(*self._insert_sql("txi", { 'txid': tx.id, 'txoid': txo.id, diff --git a/torba/torba/client/basetransaction.py b/torba/torba/client/basetransaction.py index 7669f6dc3..e54d5e509 100644 --- a/torba/torba/client/basetransaction.py +++ b/torba/torba/client/basetransaction.py @@ -226,6 +226,10 @@ class BaseOutput(InputOutput): def pubkey_hash(self): return self.script.values['pubkey_hash'] + @property + def has_address(self): + return 'pubkey_hash' in self.script.values + def get_address(self, ledger): return ledger.hash160_to_address(self.pubkey_hash)