Skip to content

Conversation

@meshcollider
Copy link
Contributor

@meshcollider meshcollider commented Sep 10, 2019

As per this TODO in the code:

TODO: replace calls to GetScriptForWitness with GetScriptForDestination using the various witness-specific CTxDestination subtypes.

The commit "Add additional check for P2SH before adding extra wrapper" also adds an additional check that the scriptPubKey is a P2SH before auto-wrapping the witness script. We shouldn't wrap the witness script if not. Note: #16251 is even better than this check, please review that.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 10, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

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.

@DrahtBot
Copy link
Contributor

Needs rebase

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest not mixing up the semantically identical PKHash(pubkey) (line 161) and pubkey.GetID() (line 162) here for getting from a public key to a public key hash, see also comment below.

@theStack
Copy link
Contributor

Looks good to me. Just one pedantic addition:

To get from public key to public key hash, two variants are in use:

  1. using method CPubKey::GetID(), returns type CKeyID (inherited from uint160)
  2. using class constructor PKHash::PKHash(const CPubKey& pubkey), returns type PKHash (also inherited from uint160), internally calls method GetID()

I'm quite new to the Bitcoin code base, but personally I would find the PKHash(somePubKey) way more expressive and readable than somePubKey.getID() as the term ID doesn't imply that this has anything to do with a hash at all.
Is there even a reason for two distinct data types PKHash and CKeyID which currently seem to serve exactly the same purpose?

@meshcollider
Copy link
Contributor Author

@theStack thanks for the review!

The difference between PKHash and CKeyID is to make the difference between the two uses clear. PKHash is used as a destination type, whereas CKeyID is used internally to identify the key. It was introduced in #15452

@theStack
Copy link
Contributor

The difference between PKHash and CKeyID is to make the difference between the two uses clear. PKHash is used as a destination type, whereas CKeyID is used internally to identify the key. It was introduced in #15452

Okay, thanks for the explanation, this brought some clarity. So whenever a public key hash is only used for further processing but is not yet a destination, .GetID() is the way to go I guess?
Seeing it from this perspective, using PKHash(...) as argument for GetScriptForDestination() and on the other hand using .GetID() as argument for WitnessV0KeyHash(...) makes perfect sense and my review comment on line 162 is obsolete.

Copy link
Member

@achow101 achow101 left a comment

Choose a reason for hiding this comment

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

Concept ACK

Copy link
Member

Choose a reason for hiding this comment

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

This was already done in #18484. I think there's a hidden merge conflict here.

Copy link
Member

Choose a reason for hiding this comment

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

nit: It might be easier to read if you made a variable for these scripts instead of copying the same script generation line around.

Copy link
Member

Choose a reason for hiding this comment

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

this is resolved in the third commit(not to reviewers)

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@meshcollider
Copy link
Contributor Author

Rebased and review comments addressed

@achow101
Copy link
Member

achow101 commented Jul 2, 2020

ACK ed266f7ca52fd0df2dd2e25bb9fdf9e5c6888eb9

@meshcollider
Copy link
Contributor Author

@sipa thanks for the review, but all your comments were already addressed in the third commit :)

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK ed266f7ca52fd0df2dd2e25bb9fdf9e5c6888eb9

Edit: modulo #16841 (comment)

@jonatack
Copy link
Member

jonatack commented Jul 3, 2020

Sanity check: with only the changes in src/bitcoin-tx.cpp, the unit tests pass.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 3, 2020

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@achow101
Copy link
Member

re-ACK 7966aa4 only changes since last is rebase.

@fanquake fanquake requested a review from instagibbs August 14, 2020 07:33
@instagibbs
Copy link
Member

ACK 7966aa4

nice to see it gone, much easier to read

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Code review re-ACK 7966aa4 per git range-diff b4d0366 ed266f7 7966aa4

@jonatack
Copy link
Member

Perhaps note #16841 (comment) / keep in mind.

@sipa
Copy link
Member

sipa commented Aug 14, 2020

utACK

@fanquake fanquake merged commit d052f5e into bitcoin:master Aug 15, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 16, 2020
…tination

7966aa4 Add variables for repeated scripts (MeshCollider)
fec8336 Remove GetScriptForWitness function (MeshCollider)
b887060 Replace usage of GetScriptForWitness with GetScriptForDestination (MeshCollider)

Pull request description:

  As per this TODO in the code:

  > TODO: replace calls to GetScriptForWitness with GetScriptForDestination using the various witness-specific CTxDestination subtypes.

  The commit "Add additional check for P2SH before adding extra wrapper" also adds an additional check that the scriptPubKey is a P2SH before auto-wrapping the witness script. We shouldn't wrap the witness script if not. Note: bitcoin#16251 is even better than this check, please review that.

ACKs for top commit:
  instagibbs:
    ACK bitcoin@7966aa4
  jonatack:
    Code review re-ACK 7966aa4 per `git range-diff b4d0366 ed266f7 7966aa4`
  achow101:
    re-ACK 7966aa4 only changes since last is rebase.

Tree-SHA512: 3449e0e83bd842acc7c94544a85367da97ac20d859eefc1a618caef0c98204398c266fe8fb9600b78326df5175402e1ae4a132eb766e2c4485e7cda6a2a95c43
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
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