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
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
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.
Should be "inconsistent" :-)
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']
Indentation is not a multiple of four :-)
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:
>>> def test(i, i_arr=[]):
... i_arr.append(i)
... return i_arr
...
>>> test(1)
[1]
>>> test(2)
[1, 2]
>>> test(3)
[1, 2, 3]
Suggested alternative:
>>> def test(i, i_arr=None):
... if i_arr is None:
... i_arr=[]
... i_arr.append(i)
... return i_arr
...
>>> test(1)
[1]
>>> test(2)
[2]
>>> test(3)
[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.
Meanwhile, concept ACK on wallet_util.py
Picked up in #15108
@amitiuttarwar has offered to pick this up in #15108. Reviewers, please leave review comments there.