Skip to content

Conversation

@sipa
Copy link
Member

@sipa sipa commented Jun 18, 2018

This improves the handling of INVALID in IsMine:

Some addition code simplification is done as well.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 19, 2018

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.

@promag
Copy link
Contributor

promag commented Jun 20, 2018

Concept ACK.

users of IsMine don't care about the reason for non-mine-ness, only whether it is or not

👍

@promag
Copy link
Contributor

promag commented Jun 26, 2018

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test passes if these keystore.Add* are removed. How could this be updated so that these are meaningful?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jimpo
Copy link
Contributor

jimpo commented Jul 2, 2018

utACK bb582a5.

segwitScr = GetScriptForDestination(WitnessV0KeyHash(solutions_data[0]));
} else {
// Scripts that are not fit for P2WPKH are encoded as P2WSH.
// Newer segwit program versions should be considered when then become available.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: existing typo they

@Empact
Copy link
Contributor

Empact commented Jul 2, 2018

utACK bb582a5

Copy link
Contributor

@jb55 jb55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK bb582a5 seems reasonable

@laanwj
Copy link
Member

laanwj commented Jul 4, 2018

utACK bb582a5

@laanwj laanwj merged commit bb582a5 into bitcoin:master Jul 4, 2018
laanwj added a commit that referenced this pull request Jul 4, 2018
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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 5, 2020
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
ftrader pushed a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this pull request Aug 17, 2020
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
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 28, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants