From 979480e4cdafdc7571834e0503a67c5e991b2e8b Mon Sep 17 00:00:00 2001 From: undeath Date: Sun, 25 Nov 2018 23:56:16 +0100 Subject: [PATCH] fix possible crash on tx with odd scripts --- jmclient/jmclient/blockchaininterface.py | 6 +++++- jmclient/jmclient/commitment_utils.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jmclient/jmclient/blockchaininterface.py b/jmclient/jmclient/blockchaininterface.py index e3232db..23b52f1 100644 --- a/jmclient/jmclient/blockchaininterface.py +++ b/jmclient/jmclient/blockchaininterface.py @@ -837,9 +837,13 @@ class BitcoinCoreInterface(BlockchainInterface): if ret is None: result.append(None) else: + if ret['scriptPubKey'].get('addresses'): + address = ret['scriptPubKey']['addresses'][0] + else: + address = None result_dict = {'value': int(Decimal(str(ret['value'])) * Decimal('1e8')), - 'address': ret['scriptPubKey']['addresses'][0], + 'address': address, 'script': ret['scriptPubKey']['hex']} if includeconf: result_dict['confirms'] = int(ret['confirmations']) diff --git a/jmclient/jmclient/commitment_utils.py b/jmclient/jmclient/commitment_utils.py index 588049b..722eabb 100644 --- a/jmclient/jmclient/commitment_utils.py +++ b/jmclient/jmclient/commitment_utils.py @@ -56,7 +56,7 @@ def validate_utxo_data(utxo_datas, retrieve=False, segwit=False): return False if res[0]['address'] != addr: print("privkey corresponds to the wrong address for utxo: " + str(u)) - print("blockchain returned address: " + res[0]['address']) + print("blockchain returned address: {}".format(res[0]['address'])) print("your privkey gave this address: " + addr) return False if retrieve: