Browse Source

Fix bugs in electrum wallet sync:

Set wallet synced to True on code branch where wallet is empty, so sync completes.
Ensure wallet_synced is False at the start of new sync (otherwise Resync in Qt fails).
master
AdamISZ 8 years ago
parent
commit
b10cbe9c71
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 2
      jmclient/jmclient/electrum_data.py
  2. 13
      jmclient/jmclient/electruminterface.py
  3. 1
      scripts/joinmarket-qt.py

2
jmclient/jmclient/electrum_data.py

@ -247,7 +247,7 @@ def set_electrum_testnet():
DEFAULT_SERVERS = {
'testnetnode.arihanc.com': {'t':'51001', 's':'51002'},
'testnet1.bauerj.eu': {'t':'51001', 's':'51002'},
#'14.3.140.101': {'t':'51001', 's':'51002'},
#'14.3.140.101': {'t':'51001', 's':'51002'}, #non-responsive?
'testnet.hsmiths.com': {'t':'53011', 's':'53012'},
'electrum.akinbo.org': {'t':'51001', 's':'51002'},
'ELEX05.blackpole.online': {'t':'52011', 's':'52002'},}

13
jmclient/jmclient/electruminterface.py

@ -221,6 +221,8 @@ class ElectrumInterface(BlockchainInterface):
self.wallet = wallet
#wipe the temporary cache of address histories
self.temp_addr_history = {}
#mark as not currently synced
self.wallet_synced = False
if self.synctype == "sync-only":
reactor.run()
@ -250,6 +252,8 @@ class ElectrumInterface(BlockchainInterface):
log.debug("downloading wallet history from Electrum server ...")
for mixdepth in range(wallet.max_mix_depth):
for forchange in [0, 1]:
#start from a clean index
wallet.index[mixdepth][forchange] = 0
self.synchronize_batch(wallet, mixdepth, forchange, 0)
def synchronize_batch(self, wallet, mixdepth, forchange, start_index):
@ -264,14 +268,14 @@ class ElectrumInterface(BlockchainInterface):
#get_new_addr is OK here, as guaranteed to be sequential *on this branch*
a = wallet.get_new_addr(mixdepth, forchange)
d = self.get_from_electrum('blockchain.address.get_history', a)
d.addCallback(self.process_address_history, wallet,
mixdepth, forchange, i, a, start_index)
#makes sure entries in temporary address history are ready
#to be accessed.
if i not in self.temp_addr_history[mixdepth][forchange]:
self.temp_addr_history[mixdepth][forchange][i] = {'synced': False,
'addr': a,
'used': False}
'addr': a,
'used': False}
d.addCallback(self.process_address_history, wallet,
mixdepth, forchange, i, a, start_index)
def process_address_history(self, history, wallet, mixdepth, forchange, i,
addr, start_index):
@ -338,6 +342,7 @@ class ElectrumInterface(BlockchainInterface):
addrs.extend(branch_list)
if len(addrs) == 0:
log.debug('no tx used')
self.wallet_synced = True
if self.synctype == 'sync-only':
reactor.stop()
return

1
scripts/joinmarket-qt.py

@ -1513,7 +1513,6 @@ def get_wallet_printout(wallet):
mbalances: is a simple array of 5 mixdepth balances
xpubs: [[xpubext, xpubint], ...]
Bitcoin amounts returned are in btc, not satoshis
TODO add metadata such as xpubs
"""
walletview = wallet_display(wallet, jm_single().config.getint("GUI",
"gaplimit"), False, serialized=False)

Loading…
Cancel
Save