diff --git a/jmclient/jmclient/output.py b/jmclient/jmclient/output.py index 6f76361..e76a790 100644 --- a/jmclient/jmclient/output.py +++ b/jmclient/jmclient/output.py @@ -55,8 +55,9 @@ def generate_podle_error_string(priv_utxo_pairs, to, ts, wallet_service, cjamoun errmsg += ("Utxos only in item 3 are not big enough for this " "coinjoin transaction, set by the value " "of taker_utxo_amtpercent.\n") - errmsg += ("If you cannot source a utxo from your wallet according " + errmsg += ("If you cannot source a utxo from your spending mixdepth according " "to these rules, use the tool add-utxo.py to source a " + "utxo from another mixdepth or a " "utxo external to your joinmarket wallet. Read the help " "with 'python add-utxo.py --help'\n\n") errmsg += ("***\nFor reference, here are the utxos in your wallet:\n") diff --git a/jmclient/jmclient/taker.py b/jmclient/jmclient/taker.py index fab90c8..b7c4a0f 100644 --- a/jmclient/jmclient/taker.py +++ b/jmclient/jmclient/taker.py @@ -742,7 +742,6 @@ class Taker(object): return priv_utxo_pairs, too_old, too_small commit_type_byte = "P" - podle_data = None tries = jm_single().config.getint("POLICY", "taker_utxo_retries") age = jm_single().config.getint("POLICY", "taker_utxo_age") #Minor rounding errors don't matter here @@ -751,24 +750,11 @@ class Taker(object): "taker_utxo_amtpercent") / 100.0) priv_utxo_pairs, to, ts = priv_utxo_pairs_from_utxos(self.input_utxos, age, amt) - #Note that we ignore the "too old" and "too small" lists in the first - #pass through, because the same utxos appear in the whole-wallet check. #For podle data format see: podle.PoDLE.reveal() #In first round try, don't use external commitments podle_data = generate_podle(priv_utxo_pairs, tries) if not podle_data: - #We defer to a second round to try *all* utxos in wallet; - #this is because it's much cleaner to use the utxos involved - #in the transaction, about to be consumed, rather than use - #random utxos that will persist after. At this step we also - #allow use of external utxos in the json file. - if any(self.wallet_service.get_utxos_by_mixdepth().values()): - utxos = {} - for mdutxo in self.wallet_service.get_utxos_by_mixdepth().values(): - utxos.update(mdutxo) - priv_utxo_pairs, to, ts = priv_utxo_pairs_from_utxos( - utxos, age, amt) #Pre-filter the set of external commitments that work for this #transaction according to its size and age. dummy, extdict = get_podle_commitments() @@ -777,7 +763,18 @@ class Taker(object): list(extdict.keys()), age, amt) else: ext_valid = None - podle_data = generate_podle(priv_utxo_pairs, tries, ext_valid) + #We defer to a second round to try *all* utxos in spending mixdepth; + #this is because it's much cleaner to use the utxos involved + #in the transaction, about to be consumed, rather than use + #random utxos that will persist after. At this step we also + #allow use of external utxos in the json file. + mixdepth_utxos = self.wallet_service.get_utxos_by_mixdepth()[self.mixdepth] + if len(self.input_utxos) == len(mixdepth_utxos): + # Already tried the whole mixdepth + podle_data = generate_podle([], tries, ext_valid) + else: + priv_utxo_pairs, to, ts = priv_utxo_pairs_from_utxos(mixdepth_utxos, age, amt) + podle_data = generate_podle(priv_utxo_pairs, tries, ext_valid) if podle_data: jlog.debug("Generated PoDLE: " + repr(podle_data)) return (commit_type_byte + bintohex(podle_data.commitment), diff --git a/jmclient/test/test_taker.py b/jmclient/test/test_taker.py index edfd65e..9464515 100644 --- a/jmclient/test/test_taker.py +++ b/jmclient/test/test_taker.py @@ -176,6 +176,7 @@ def test_make_commitment(setup_taker, failquery, external): taker = get_taker([(mixdepth, amount, 3, "mnsquzxrHXpFsZeL42qwbKdCP2y1esN3qw", NO_ROUNDING)]) taker.cjamount = amount taker.input_utxos = convert_utxos(t_utxos_by_mixdepth[0]) + taker.mixdepth = mixdepth if failquery: jm_single().bc_interface.setQUSFail(True) taker.make_commitment()