Browse Source

Add loop in the CLI for freezing UTXOs

Prior to this commit the wallet-tool (un)freeze tool would only
allow a single freeze or unfreeze per run. So a user intending
to (un)freeze several UTXOs would have to run the script several
times which would be slow due to the need to sync the wallet
many times.

See also the discussion in: http://gnusha.org/joinmarket/2020-01-09.log
master
chris-belcher 6 years ago
parent
commit
66823aacd1
No known key found for this signature in database
GPG Key ID: EF734EA677F31129
  1. 34
      jmclient/jmclient/wallet_utils.py

34
jmclient/jmclient/wallet_utils.py

@ -980,6 +980,7 @@ def display_utxos_for_disable_choice_default(utxos_enabled, utxos_disabled):
start += 1 start += 1
yield txid, idx yield txid, idx
jmprint("List of UTXOs:")
ulist = list(output_utxos(utxos_disabled, 'FROZEN')) ulist = list(output_utxos(utxos_disabled, 'FROZEN'))
disabled_max = len(ulist) - 1 disabled_max = len(ulist) - 1
ulist.extend(output_utxos(utxos_enabled, 'NOT FROZEN', start=len(ulist))) ulist.extend(output_utxos(utxos_enabled, 'NOT FROZEN', start=len(ulist)))
@ -1032,22 +1033,23 @@ def wallet_freezeutxo(wallet, md, display_callback=None, info_callback=None):
if md is None: if md is None:
info_callback("Specify the mixdepth with the -m flag", "error") info_callback("Specify the mixdepth with the -m flag", "error")
return "Failed" return "Failed"
utxos_enabled, utxos_disabled = get_utxos_enabled_disabled(wallet, md) while True:
if utxos_disabled == {} and utxos_enabled == {}: utxos_enabled, utxos_disabled = get_utxos_enabled_disabled(wallet, md)
info_callback("The mixdepth: " + str(md) + \ if utxos_disabled == {} and utxos_enabled == {}:
" contains no utxos to freeze/unfreeze.", "error") info_callback("The mixdepth: " + str(md) + \
return "Failed" " contains no utxos to freeze/unfreeze.", "error")
display_ret = display_callback(utxos_enabled, utxos_disabled) return "Failed"
if display_ret is None: display_ret = display_callback(utxos_enabled, utxos_disabled)
return "OK" if display_ret is None:
(txid, index), disable = display_ret break
wallet.disable_utxo(txid, index, disable) (txid, index), disable = display_ret
if disable: wallet.disable_utxo(txid, index, disable)
info_callback("Utxo: {} is now frozen and unavailable for spending." if disable:
.format(fmt_utxo((txid, index)))) info_callback("Utxo: {} is now frozen and unavailable for spending."
else: .format(fmt_utxo((txid, index))))
info_callback("Utxo: {} is now unfrozen and available for spending." else:
.format(fmt_utxo((txid, index)))) info_callback("Utxo: {} is now unfrozen and available for spending."
.format(fmt_utxo((txid, index))))
return "Done" return "Done"
def get_wallet_type(): def get_wallet_type():

Loading…
Cancel
Save