Browse Source

Merge #488: Add loop in the CLI for freezing UTXOs

66823aa Add loop in the CLI for freezing UTXOs (chris-belcher)

Tree-SHA512: 0a75dfaa680c52aa8f14eb7ee810eae27870637cf637cd570bf930ee23f64c3f6a38426e4f6962d3cd6d3beb2c8438fd7b2e76c0c157ff1bfe5153a442e68cca
master
chris-belcher 6 years ago
parent
commit
bf3b38c40f
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

@ -981,6 +981,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)))
@ -1033,22 +1034,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