From 733ac8f4dd00382ffa30f34a9240807c4615ee6e Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Sun, 8 Jan 2017 22:35:12 +0200 Subject: [PATCH] Bugfix in daemon to prevent duplicate JMTX messages Introduces an additional jm_state to avoid resending JMTX in case the response to checkUtxosAccepted takes too long. Fix bug in -Qt where blockr wallet sync is called with fast option. Make unconfirmed message more informative (more TODO here). Fix bug in blockr_data (from upstream). --- jmclient/jmclient/blockchaininterface.py | 6 +++--- jmclient/jmclient/taker.py | 2 +- jmdaemon/jmdaemon/daemon_protocol.py | 5 +++-- scripts/joinmarket-qt.py | 5 ++++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/jmclient/jmclient/blockchaininterface.py b/jmclient/jmclient/blockchaininterface.py index d7b8ba6..2bf17ef 100644 --- a/jmclient/jmclient/blockchaininterface.py +++ b/jmclient/jmclient/blockchaininterface.py @@ -240,8 +240,8 @@ class BlockrInterface(BlockchainInterface): #pragma: no cover def sync_unspent(self, wallet): # finds utxos in the wallet st = time.time() - # dont refresh unspent dict more often than 10 minutes - rate_limit_time = 10 * 60 + # dont refresh unspent dict more often than 1 minutes + rate_limit_time = 1 * 60 if st - self.last_sync_unspent < rate_limit_time: log.debug( 'blockr sync_unspent() happened too recently (%dsec), skipping' @@ -436,7 +436,7 @@ class BlockrInterface(BlockchainInterface): #pragma: no cover data = [] for ids in txids: blockr_url = 'https://' + self.blockr_domain + '.blockr.io/api/v1/tx/info/' - data = btc.make_request_blockr(blockr_url + ','.join(ids))['data'] + blockr_data = btc.make_request_blockr(blockr_url + ','.join(ids))['data'] if not isinstance(blockr_data, list): blockr_data = [blockr_data] data += blockr_data diff --git a/jmclient/jmclient/taker.py b/jmclient/jmclient/taker.py index 4571803..b390c5e 100644 --- a/jmclient/jmclient/taker.py +++ b/jmclient/jmclient/taker.py @@ -573,7 +573,7 @@ class Taker(object): return self.push() def unconfirm_callback(self, txd, txid): - jlog.debug("Unconfirmed callback in sendpayment, ignoring") + jlog.debug("Transaction seen on network, waiting for confirmation") def confirm_callback(self, txd, txid, confirmations): jlog.debug("Confirmed callback in taker, confs: " + str(confirmations)) diff --git a/jmdaemon/jmdaemon/daemon_protocol.py b/jmdaemon/jmdaemon/daemon_protocol.py index a97e907..6504fa4 100644 --- a/jmdaemon/jmdaemon/daemon_protocol.py +++ b/jmdaemon/jmdaemon/daemon_protocol.py @@ -223,6 +223,7 @@ class JMDaemonServerProtocol(amp.AMP, OrderbookWatch): #this can be called a second time on timeout, in which case we #do nothing return + self.jm_state = 3 d = self.callRemote(JMFillResponse, success=accepted, ioauth_data = json.dumps(self.ioauth_data)) @@ -249,11 +250,11 @@ class JMDaemonServerProtocol(amp.AMP, OrderbookWatch): #TODO create re-set function to start again else: #only update state if client accepted - self.jm_state = 3 + self.jm_state = 4 @JMMakeTx.responder def on_JM_MAKE_TX(self, nick_list, txhex): - if not self.jm_state == 3: + if not self.jm_state == 4: log.msg("Make tx was called in wrong state, rejecting") return {'accepted': False} nick_list = json.loads(nick_list) diff --git a/scripts/joinmarket-qt.py b/scripts/joinmarket-qt.py index 75484d7..6b854e6 100644 --- a/scripts/joinmarket-qt.py +++ b/scripts/joinmarket-qt.py @@ -493,7 +493,10 @@ class SpendTab(QWidget): log.debug('starting coinjoin ..') w.statusBar().showMessage("Syncing wallet ...") - jm_single().bc_interface.sync_wallet(w.wallet, fast=True) + if jm_single().config.get("BLOCKCHAIN", "blockchain_source") != "blockr": + jm_single().bc_interface.sync_wallet(w.wallet, fast=True) + else: + jm_single().bc_interface.sync_wallet(w.wallet) if not multiple: destaddr = str(self.widgets[0][1].text()) #convert from bitcoins (enforced by QDoubleValidator) to satoshis