Improve handling of INVALID in IsMine#13491
Conversation
Note to 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. |
|
Concept ACK.
👍 |
|
utACK bb582a5. Commits are clean, refactor and new tests LGTM (some nits aside). |
| CScript redeemscript = GetScriptForDestination(CScriptID(redeemscript_inner)); | ||
| scriptPubKey = GetScriptForDestination(CScriptID(redeemscript)); | ||
|
|
||
| keystore.AddCScript(redeemscript); |
There was a problem hiding this comment.
The test passes if these keystore.Add* are removed. How could this be updated so that these are meaningful?
There was a problem hiding this comment.
They are meaningful. The tests verifies that even when all scripts are known the output isn't treated as ours. The positive test case is the variant without 2 nested P2SHs, where adding all scripts does result in treating the output as ours.
There was a problem hiding this comment.
I understand. I was thinking in adding:
result = IsMine(keystore, redeemscript);
BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE);So that these keystore.Add* make sense and can't be removed. Feel free to ignore.
|
utACK bb582a5. |
| @@ -637,9 +637,7 @@ static UniValue decodescript(const JSONRPCRequest& request) | |||
| } else { | |||
| // Scripts that are not fit for P2WPKH are encoded as P2WSH. | |||
| // Newer segwit program versions should be considered when then become available. | |||
|
utACK bb582a5 |
|
utACK bb582a5 |
bb582a5 Add P2WSH destination helper and use it instead of manual hashing (Pieter Wuille) eaba1c1 Add additional unit tests for invalid IsMine combinations (Pieter Wuille) e6b9730 Do not expose invalidity from IsMine (Pieter Wuille) Pull request description: This improves the handling of INVALID in IsMine: * Extra INVALID conditions were added to `IsMine` (following https://github.com/bitcoin/bitcoin/pull/13142/files#r185349057), but these were untested. Add unit tests for them. * In #13142 (comment) it was suggested to merge `isInvalid` into the return status. This PR takes a different approach, and removes the `isInvalid` entirely. It was only ever used inside tests, as normal users of IsMine don't care about the reason for non-mine-ness, only whether it is or not. As the unit tests are extensive enough, it seems sufficient to have a black box text (with tests for both compressed and uncompressed keys). Some addition code simplification is done as well. Tree-SHA512: 3267f8846f3fa4e994f57504b155b0e1bbdf13808c4c04dab7c6886c2c0b88716169cee9c5b350513297e0ca2a00812e3401acf30ac9cde5d892f9fb59ad7fef
Summary: * Do not expose invalidity from IsMine * Add additional unit tests for invalid IsMine combinations * Add P2WSH destination helper and use it instead of manual hashing This is a backport of Core [[bitcoin/bitcoin#13491 | PR13491]] Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D6381
Summary: * Do not expose invalidity from IsMine * Add additional unit tests for invalid IsMine combinations * Add P2WSH destination helper and use it instead of manual hashing This is a backport of Core [[bitcoin/bitcoin#13491 | PR13491]] Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D6381
bb582a5 Add P2WSH destination helper and use it instead of manual hashing (Pieter Wuille) eaba1c1 Add additional unit tests for invalid IsMine combinations (Pieter Wuille) e6b9730 Do not expose invalidity from IsMine (Pieter Wuille) Pull request description: This improves the handling of INVALID in IsMine: * Extra INVALID conditions were added to `IsMine` (following https://github.com/bitcoin/bitcoin/pull/13142/files#r185349057), but these were untested. Add unit tests for them. * In bitcoin#13142 (comment) it was suggested to merge `isInvalid` into the return status. This PR takes a different approach, and removes the `isInvalid` entirely. It was only ever used inside tests, as normal users of IsMine don't care about the reason for non-mine-ness, only whether it is or not. As the unit tests are extensive enough, it seems sufficient to have a black box text (with tests for both compressed and uncompressed keys). Some addition code simplification is done as well. Tree-SHA512: 3267f8846f3fa4e994f57504b155b0e1bbdf13808c4c04dab7c6886c2c0b88716169cee9c5b350513297e0ca2a00812e3401acf30ac9cde5d892f9fb59ad7fef
This improves the handling of INVALID in IsMine:
IsMine(following https://github.com/bitcoin/bitcoin/pull/13142/files#r185349057), but these were untested. Add unit tests for them.isInvalidinto the return status. This PR takes a different approach, and removes theisInvalidentirely. It was only ever used inside tests, as normal users of IsMine don't care about the reason for non-mine-ness, only whether it is or not. As the unit tests are extensive enough, it seems sufficient to have a black box text (with tests for both compressed and uncompressed keys).Some addition code simplification is done as well.