electrum-personal-server

Maximally lightweight electrum server for a single user
git clone https://git.parazyd.org/electrum-personal-server
Log | Files | Refs | README

commit 2a0d918ac4ac19037846935893807491c77da15d
parent 5f7c503bde0393269ac6863f93ace1882336db76
Author: chris-belcher <chris-belcher@users.noreply.github.com>
Date:   Thu, 14 Jun 2018 02:51:49 +0100

Tolerate listtransactions having no address field

Transaction monitor keeps track of the last known wallet transaction from
listtransactions, it is a tuple of (txid, address). But some transactions
dont have an address field. This seemed to cause the crash in issue #31

Diffstat:
Melectrumpersonalserver/transactionmonitor.py | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/electrumpersonalserver/transactionmonitor.py b/electrumpersonalserver/transactionmonitor.py @@ -165,7 +165,8 @@ class TransactionMonitor(object): if len(ret) > 0: #txid doesnt uniquely identify transactions from listtransactions #but the tuple (txid, address) does - self.last_known_wallet_txid = (ret[-1]["txid"], ret[-1]["address"]) + self.last_known_wallet_txid = (ret[-1]["txid"], + ret[-1].get("address", None)) else: self.last_known_wallet_txid = None self.debug("last_known_wallet_txid = " + str( @@ -386,7 +387,8 @@ class TransactionMonitor(object): recent_tx_index = len(ret) #=0 means no new txes break else: - txid_list = [(tx["txid"], tx["address"]) for tx in ret] + txid_list = [(tx["txid"], tx.get("address", None)) + for tx in ret] recent_tx_index = next((i for i, (txid, addr) in enumerate(txid_list) if txid == self.last_known_wallet_txid[0] and @@ -400,7 +402,8 @@ class TransactionMonitor(object): self.debug("recent tx index = " + str(recent_tx_index) + " ret = " + str([(t["txid"], t["address"]) for t in ret])) if len(ret) > 0: - self.last_known_wallet_txid = (ret[0]["txid"], ret[0]["address"]) + self.last_known_wallet_txid = (ret[0]["txid"], + ret[0].get("address", None)) self.debug("last_known_wallet_txid = " + str( self.last_known_wallet_txid)) assert(recent_tx_index != -1)