Browse Source

update joinmarket-qt for electrum interface

master
AdamISZ 8 years ago
parent
commit
3939759537
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 16
      jmclient/jmclient/electruminterface.py
  2. 21
      scripts/joinmarket-qt.py

16
jmclient/jmclient/electruminterface.py

@ -36,7 +36,13 @@ class TxElectrumClientProtocol(LineReceiver):
def connectionMade(self):
log.debug('connection to Electrum succesful')
self.msg_id = 0
self.factory.bci.sync_addresses(self.factory.bci.wallet)
if self.factory.bci.wallet:
#Use connectionMade as a trigger to start wallet sync,
#if the reactor start happened after the call to wallet sync
#(in Qt, the reactor starts before wallet sync, so we make
#this call manually instead).
self.factory.bci.sync_addresses(self.factory.bci.wallet)
#these server calls must always be done to keep the connection open
self.start_ping()
self.call_server_method('blockchain.numblocks.subscribe')
@ -174,6 +180,7 @@ class ElectrumInterface(BlockchainInterface):
#Format: {"txid": (loop, unconfirmed true/false, confirmed true/false,
#spent true/false), ..}
self.tx_watcher_loops = {}
self.wallet = None
self.wallet_synced = False
def start_electrum_proto(self, electrum_server=None):
@ -205,7 +212,12 @@ class ElectrumInterface(BlockchainInterface):
#used to hold open server conn
self.electrum_conn.call_server_method('blockchain.numblocks.subscribe')
def sync_wallet(self, wallet, restart_cb=False):
def sync_wallet(self, wallet, fast=False, restart_cb=False):
"""This triggers the start of syncing, wiping temporary state
and starting the reactor for wallet-tool runs. The 'fast'
and 'restart_cb' parameters are ignored and included only
for compatibility; they are both only used by Core.
"""
self.wallet = wallet
#wipe the temporary cache of address histories
self.temp_addr_history = {}

21
scripts/joinmarket-qt.py

@ -1381,11 +1381,30 @@ class JMMainWindow(QMainWindow):
def syncWalletUpdate(self, fast, restart_cb=None):
if restart_cb:
fast=False
#Special syncing condition for Electrum
iselectrum = jm_single().config.get("BLOCKCHAIN",
"blockchain_source") == "electrum-server"
if iselectrum:
jm_single().bc_interface.synctype = "with-script"
jm_single().bc_interface.sync_wallet(self.wallet, fast=fast,
restart_cb=restart_cb)
self.updateWalletInfo()
if iselectrum:
#sync_wallet only initialises, we must manually call its entry
#point here (because we can't use connectionMade as a trigger)
jm_single().bc_interface.sync_addresses(self.wallet)
self.wait_for_sync_loop = task.LoopingCall(self.updateWalletInfo)
self.wait_for_sync_loop.start(0.2)
else:
self.updateWalletInfo()
def updateWalletInfo(self):
if jm_single().config.get("BLOCKCHAIN",
"blockchain_source") == "electrum-server":
if not jm_single().bc_interface.wallet_synced:
return
self.wait_for_sync_loop.stop()
t = self.centralWidget().widget(0)
if not self.wallet: #failure to sync in constructor means object is not created
newstmsg = "Unable to sync wallet - see error in console."

Loading…
Cancel
Save