Browse Source

Additional method changemixdepth in wallet-tool

This commit adds a method 'changemixdepth' to the list
of methods that can be invoked with the wallet-tool.py script.
It is a noscan method, so doesn't require sync, and uses the
value of the -m option as the new *number* of mixdepths, and
updates the wallet's storage for future runs.
Users are advised not to reduce this number, but increasing it
should always be fine.
Running tumbler with insufficient mixdepths quits with warning.
master
AdamISZ 7 years ago
parent
commit
98bcc86446
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 2
      jmclient/jmclient/wallet.py
  2. 15
      jmclient/jmclient/wallet_utils.py
  3. 8
      scripts/tumbler.py

2
jmclient/jmclient/wallet.py

@ -1074,6 +1074,8 @@ class BIP32Wallet(BaseWallet):
for md, data in self._storage.data[self._STORAGE_INDEX_CACHE].items(): for md, data in self._storage.data[self._STORAGE_INDEX_CACHE].items():
md = int(md) md = int(md)
if md > self.max_mixdepth:
continue
md_map = self._index_cache[md] md_map = self._index_cache[md]
for t, k in data.items(): for t, k in data.items():
md_map[int(t)] = k md_map[int(t)] = k

15
jmclient/jmclient/wallet_utils.py

@ -31,7 +31,10 @@ def get_wallettool_parser():
'(importprivkey) Adds privkeys to this wallet, privkeys are spaces or commas separated.\n' '(importprivkey) Adds privkeys to this wallet, privkeys are spaces or commas separated.\n'
'(dumpprivkey) Export a single private key, specify an hd wallet path\n' '(dumpprivkey) Export a single private key, specify an hd wallet path\n'
'(signmessage) Sign a message with the private key from an address in \n' '(signmessage) Sign a message with the private key from an address in \n'
'the wallet. Use with -H and specify an HD wallet path for the address.') 'the wallet. Use with -H and specify an HD wallet path for the address.\n'
'(changemixdepth) Use with -m to change the *maximum* number of mixdepths\n'
'in the wallet; you are advised to only increase, not decrease this \n'
'number from the current value (initially 5).')
parser = OptionParser(usage='usage: %prog [options] [wallet file] [method]', parser = OptionParser(usage='usage: %prog [options] [wallet file] [method]',
description=description) description=description)
parser.add_option('-p', parser.add_option('-p',
@ -851,6 +854,11 @@ def get_wallet_cls(wtype=None):
return cls return cls
def change_wallet_mixdepth(wallet, max_mixdepth):
wallet.max_mixdepth = max_mixdepth
wallet.save()
return "Maximum mixdepth successfully updated."
def create_wallet(path, password, max_mixdepth, wallet_cls=None, **kwargs): def create_wallet(path, password, max_mixdepth, wallet_cls=None, **kwargs):
storage = Storage(path, password, create=True) storage = Storage(path, password, create=True)
wallet_cls = wallet_cls or get_wallet_cls() wallet_cls = wallet_cls or get_wallet_cls()
@ -977,7 +985,8 @@ def wallet_tool_main(wallet_root_path):
methods = ['display', 'displayall', 'summary', 'showseed', 'importprivkey', methods = ['display', 'displayall', 'summary', 'showseed', 'importprivkey',
'history', 'showutxos'] 'history', 'showutxos']
methods.extend(noseed_methods) methods.extend(noseed_methods)
noscan_methods = ['showseed', 'importprivkey', 'dumpprivkey', 'signmessage'] noscan_methods = ['showseed', 'importprivkey', 'dumpprivkey',
'signmessage', 'changemixdepth']
readonly_methods = ['display', 'displayall', 'summary', 'showseed', readonly_methods = ['display', 'displayall', 'summary', 'showseed',
'history', 'showutxos', 'dumpprivkey', 'signmessage'] 'history', 'showutxos', 'dumpprivkey', 'signmessage']
@ -1044,6 +1053,8 @@ def wallet_tool_main(wallet_root_path):
return "Key import completed." return "Key import completed."
elif method == "signmessage": elif method == "signmessage":
return wallet_signmessage(wallet, options.hd_path, args[2]) return wallet_signmessage(wallet, options.hd_path, args[2])
elif method == 'changemixdepth':
return change_wallet_mixdepth(wallet, options.mixdepth-1)
#Testing (can port to test modules, TODO) #Testing (can port to test modules, TODO)

8
scripts/tumbler.py

@ -34,7 +34,13 @@ def main():
max_mix_depth = options['mixdepthsrc'] + options['mixdepthcount'] max_mix_depth = options['mixdepthsrc'] + options['mixdepthcount']
wallet_path = get_wallet_path(wallet_name, None) wallet_path = get_wallet_path(wallet_name, None)
wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth) wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth)
if wallet.max_mixdepth < max_mix_depth:
print("Your wallet does not contain the required number of mixdepths: ",
max_mix_depth)
print("Increase using this command: `python wallet-tool.py -m ",
max_mix_depth, " (yourwalletname) changemixdepth")
print("Then start the tumbler again with the same settings.")
sys.exit(0)
if jm_single().config.get("BLOCKCHAIN", if jm_single().config.get("BLOCKCHAIN",
"blockchain_source") == "electrum-server": "blockchain_source") == "electrum-server":
jm_single().bc_interface.synctype = "with-script" jm_single().bc_interface.synctype = "with-script"

Loading…
Cancel
Save