Based on #14565. Please don’t review this until that PR is merged.
Fixes review comments from @ryanofsky here: #14886#pullrequestreview-183772779
Based on #14565. Please don’t review this until that PR is merged.
Fixes review comments from @ryanofsky here: #14886#pullrequestreview-183772779
This introduces various changes to the importmulti logic:
* Instead of processing input and importing things at the same time, first
process all input data and verify it, so no changes are made in case of
an error.
* Verify that no superfluous information is provided (no keys or scripts
that don't contribute to solvability in particular).
* Add way more sanity checks, by means of descending into all involved
scripts.
Fixes review comments from PR 14886.
Adds a new wallet_util.py module and moves generic helper functions
there:
- get_key
- get_multisig
- test_address
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
0@@ -0,0 +1,5 @@
1+Low-level RPC changes
2+---------------------
3+
4+The `importmulti` RPC will now contain a new per-request `warnings` field with strings
5+that explain when fields are being ignored or inconsistant, if any.
87+ def test_importmulti(self, req, success, error_code=None, error_message=None, warnings=[]):
88 """Run importmulti and assert success"""
89 result = self.nodes[1].importmulti([req])
90+ observed_warnings = []
91+ if 'warnings' in result[0]:
92+ observed_warnings = result[0]['warnings']
82- script_to_p2wsh(script_code), # p2wsh addr
83- CScript([OP_HASH160, witness_script, OP_EQUAL]).hex(), # p2sh-p2wsh
84- script_to_p2sh_p2wsh(script_code)) # p2sh-p2wsh addr
85-
86- def test_importmulti(self, req, success, error_code=None, error_message=None):
87+ def test_importmulti(self, req, success, error_code=None, error_message=None, warnings=[]):
I suggest using warnings=None
instead to clarify that warnings
is not meant to be remembered across calls.
Background:
0>>> def test(i, i_arr=[]):
1... i_arr.append(i)
2... return i_arr
3...
4>>> test(1)
5[1]
6>>> test(2)
7[1, 2]
8>>> test(3)
9[1, 2, 3]
Suggested alternative:
0>>> def test(i, i_arr=None):
1... if i_arr is None:
2... i_arr=[]
3... i_arr.append(i)
4... return i_arr
5...
6>>> test(1)
7[1]
8>>> test(2)
9[2]
10>>> test(3)
11[3]
@practicalswift - please see the PR text:
Based on #14565. Please don’t review this until that PR is merged.
All of your review comments above are for commits in #14565.
wallet_util.py