Skip to content

Commit 98676f9

Browse files
committed
Handle listunspent records w/o address fields
1 parent 051ec4e commit 98676f9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bitcoin/rpc.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,13 @@ def listunspent(self, minconf=0, maxconf=9999999, addrs=None):
594594
del unspent['txid']
595595
del unspent['vout']
596596

597-
unspent['address'] = CBitcoinAddress(unspent['address'])
597+
# address isn't always available as Bitcoin Core allows scripts w/o
598+
# an address type to be imported into the wallet, e.g. non-p2sh
599+
# segwit
600+
try:
601+
unspent['address'] = CBitcoinAddress(unspent['address'])
602+
except KeyError:
603+
pass
598604
unspent['scriptPubKey'] = CScript(unhexlify(unspent['scriptPubKey']))
599605
unspent['amount'] = int(unspent['amount'] * COIN)
600606
r2.append(unspent)

0 commit comments

Comments
 (0)