Skip to content

Commit

Permalink
quit scripts gracefully on walletservice rpc startup failure
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamISZ committed Oct 7, 2020
1 parent 5af2d49 commit 5604857
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jmclient/jmclient/wallet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,8 @@ def wallet_tool_main(wallet_root_path):
# this object is only to respect the layering,
# the service will not be started since this is a synchronous script:
wallet_service = WalletService(wallet)
if wallet_service.rpc_error:
sys.exit(EXIT_FAILURE)

if method not in noscan_methods and jm_single().bc_interface is not None:
# if nothing was configured, we override bitcoind's options so that
Expand Down
2 changes: 2 additions & 0 deletions scripts/add-utxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ def main():
wallet_path = get_wallet_path(options.loadwallet)
wallet = open_wallet(wallet_path, gap_limit=options.gaplimit)
wallet_service = WalletService(wallet)
if wallet_service.rpc_error:
sys.exit(EXIT_FAILURE)
while True:
if wallet_service.sync_wallet(fast=not options.recoversync):
break
Expand Down
2 changes: 2 additions & 0 deletions scripts/sendpayment.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def main():
wallet_password_stdin=options.wallet_password_stdin,
gap_limit=options.gaplimit)
wallet_service = WalletService(wallet)
if wallet_service.rpc_error:
sys.exit(EXIT_FAILURE)
# in this script, we need the wallet synced before
# logic processing for some paths, so do it now:
while not wallet_service.synced:
Expand Down
2 changes: 2 additions & 0 deletions scripts/tumbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def main():
wallet_path = get_wallet_path(wallet_name, None)
wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth, wallet_password_stdin=options_org.wallet_password_stdin)
wallet_service = WalletService(wallet)
if wallet_service.rpc_error:
sys.exit(EXIT_FAILURE)
# in this script, we need the wallet synced before
# logic processing for some paths, so do it now:
while not wallet_service.synced:
Expand Down

0 comments on commit 5604857

Please sign in to comment.