From 34f8600996fad01fc9e6f8591259f0f17d4345fe Mon Sep 17 00:00:00 2001 From: undeath Date: Sat, 14 Jul 2018 19:44:23 +0200 Subject: [PATCH] fix wallet syncing --- jmclient/jmclient/wallet_utils.py | 4 ++-- jmclient/jmclient/yieldgenerator.py | 4 +++- scripts/add-utxo.py | 3 ++- scripts/jmtainter.py | 3 ++- scripts/sendpayment.py | 3 ++- scripts/tumbler.py | 3 ++- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/jmclient/jmclient/wallet_utils.py b/jmclient/jmclient/wallet_utils.py index e7bc12a..7b4319e 100644 --- a/jmclient/jmclient/wallet_utils.py +++ b/jmclient/jmclient/wallet_utils.py @@ -985,8 +985,8 @@ def wallet_tool_main(wallet_root_path): # unconfirmed balance is included in the wallet display by default if 'listunspent_args' not in jm_single().config.options('POLICY'): jm_single().config.set('POLICY','listunspent_args', '[0]') - sync_wallet(wallet, fast=options.fastsync) - wallet.save() + while not jm_single().bc_interface.wallet_synced: + sync_wallet(wallet, fast=options.fastsync) #Now the wallet/data is prepared, execute the script according to the method if method == "display": return wallet_display(wallet, options.gaplimit, options.showprivkey) diff --git a/jmclient/jmclient/yieldgenerator.py b/jmclient/jmclient/yieldgenerator.py index 1ec25df..07641a4 100644 --- a/jmclient/jmclient/yieldgenerator.py +++ b/jmclient/jmclient/yieldgenerator.py @@ -240,7 +240,9 @@ def ygmain(ygclass, txfee=1000, cjfee_a=200, cjfee_r=0.002, ordertype='swreloffe if jm_single().config.get("BLOCKCHAIN", "blockchain_source") == "electrum-server": jm_single().bc_interface.synctype = "with-script" - sync_wallet(wallet, fast=options.fastsync) + + while not jm_single().bc_interface.wallet_synced: + sync_wallet(wallet, fast=options.fastsync) maker = ygclass(wallet, [options.txfee, cjfee_a, cjfee_r, options.ordertype, options.minsize]) diff --git a/scripts/add-utxo.py b/scripts/add-utxo.py index 1a1c29a..e8254de 100644 --- a/scripts/add-utxo.py +++ b/scripts/add-utxo.py @@ -176,7 +176,8 @@ def main(): if options.loadwallet: wallet_path = get_wallet_path(options.loadwallet, None) wallet = open_wallet(wallet_path, gap_limit=options.gaplimit) - sync_wallet(wallet, fast=options.fastsync) + while not jm_single().bc_interface.wallet_synced: + sync_wallet(wallet, fast=options.fastsync) for md, utxos in wallet.get_utxos_by_mixdepth_().items(): for (txid, index), utxo in utxos.items(): diff --git a/scripts/jmtainter.py b/scripts/jmtainter.py index 24f216c..253121d 100644 --- a/scripts/jmtainter.py +++ b/scripts/jmtainter.py @@ -84,7 +84,8 @@ def cli_get_wallet(wallet_name, sync=True): "blockchain_source") == "electrum-server": jm_single().bc_interface.synctype = "with-script" if sync: - sync_wallet(wallet, fast=options.fastsync) + while not jm_single().bc_interface.wallet_synced: + sync_wallet(wallet, fast=options.fastsync) return wallet #======Electrum specific utils========================= diff --git a/scripts/sendpayment.py b/scripts/sendpayment.py index ff6598e..ed033fd 100644 --- a/scripts/sendpayment.py +++ b/scripts/sendpayment.py @@ -134,7 +134,8 @@ def main(): "blockchain_source") == "electrum-server" and options.makercount != 0: jm_single().bc_interface.synctype = "with-script" #wallet sync will now only occur on reactor start if we're joining. - sync_wallet(wallet, fast=options.fastsync) + while not jm_single().bc_interface.wallet_synced: + sync_wallet(wallet, fast=options.fastsync) if options.makercount == 0: direct_send(wallet, amount, mixdepth, destaddr, options.answeryes) return diff --git a/scripts/tumbler.py b/scripts/tumbler.py index e843c6a..5d05b3c 100644 --- a/scripts/tumbler.py +++ b/scripts/tumbler.py @@ -38,7 +38,8 @@ def main(): if jm_single().config.get("BLOCKCHAIN", "blockchain_source") == "electrum-server": jm_single().bc_interface.synctype = "with-script" - sync_wallet(wallet, fast=options['fastsync']) + while not jm_single().bc_interface.wallet_synced: + sync_wallet(wallet, fast=options['fastsync']) #Parse options and generate schedule #Output information to log files