From 904cb350b7efb16d3c778b8a89b090c4c8027467 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Thu, 14 Jul 2022 22:12:10 +0100 Subject: [PATCH] Don't start maker with only expired-timelock utxos Fixes #1314. Prior to this commit, an attempt to start a maker bot which only contained coins that were expired timelocked utxos (i.e. spendable), in the RPC would result in the maker service starting but failing to create offers. Instead, we want the maker service to not start as there are no coins actually available for it. --- jmclient/jmclient/wallet_rpc.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jmclient/jmclient/wallet_rpc.py b/jmclient/jmclient/wallet_rpc.py index a3f3afd..4add2bd 100644 --- a/jmclient/jmclient/wallet_rpc.py +++ b/jmclient/jmclient/wallet_rpc.py @@ -25,7 +25,7 @@ from jmclient import Taker, jm_single, \ NotEnoughFundsException, get_tumble_log, get_tumble_schedule, \ get_schedule, get_tumbler_parser, schedule_to_text, \ tumbler_filter_orders_callback, tumbler_taker_finished_update, \ - validate_address + validate_address, FidelityBondMixin from jmbase.support import get_log, utxostr_to_utxo jlog = get_log() @@ -702,6 +702,17 @@ class JMWalletDaemon(Service): # of the service (and therefore the startup) from # proceeding: raise NotEnoughCoinsForMaker() + # We must also not start if the only coins available are of + # the TL type *even* if the TL is expired. This check is done + # here early, as above, to avoid the maker service starting. + utxos = self.services["wallet"].get_all_utxos() + # remove any TL type: + utxos = [u for u in utxos.values() if not \ + FidelityBondMixin.is_timelocked_path(u["path"])] + # Note that only the following check is required since we + # already checked that balance is non-zero. + if len(utxos) == 0: + raise NotEnoughCoinsForMaker() self.services["maker"].addCleanup(cleanup) # order of addition of service setup functions matters;