Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Script conversion method p2wpkh_script_code #954

Merged
merged 1 commit into from Apr 20, 2022

Conversation

tcharding
Copy link
Member

In order to sign a utxo that does a p2wpkh spend we need to create the
script that can be used to create a sighash. In the libbitcoin docs this
is referred to as the 'script code' [0] (also described in BIP143)

The script is the same as a p2pkh script but the pubkey_hash is found in
the scriptPubkey.

Add a Script conversion method that checks if self is a v0 p2wpkh
script and if so extracts the pubkey_hash and returns the required
script.

Includes a link to BIP143

[0] https://github.com/libbitcoin/libbitcoin-system/wiki/P2WPKH-Transactions#spending-a-p2wpkh-output

In order to sign a utxo that does a p2wpkh spend we need to create the
script that can be used to create a sighash. In the libbitcoin docs this
is referred to as the 'script code' [0].

The script is the same as a p2pkh script but the pubkey_hash is found in
the scriptPubkey.

Add a `Script` conversion method that checks if `self` is a v0 p2wpkh
script and if so extracts the pubkey_hash and returns the required
script.

[0] https://github.com/libbitcoin/libbitcoin-system/wiki/P2WPKH-Transactions#spending-a-p2wpkh-output
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK d882b68

I'm slightly inclined to say "this would be better in rust-miniscript" but I think it's a useful script-agnostic utility function. So ACK.

Copy link
Member

@sanket1729 sanket1729 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 ACK d882b68.

@sanket1729 sanket1729 merged commit 3057402 into rust-bitcoin:master Apr 20, 2022
@tcharding tcharding deleted the script-code-method branch July 11, 2022 01:36
ChallengeDev210 pushed a commit to ChallengeDev210/rust-bitcoin that referenced this pull request Aug 1, 2022
…pkh_script_code

d882b68 Add Script conversion method p2wpkh_script_code (Tobin Harding)

Pull request description:

  In order to sign a utxo that does a p2wpkh spend we need to create the
  script that can be used to create a sighash. In the libbitcoin docs this
  is referred to as the 'script code' [0] (also described in BIP143)

  The script is the same as a p2pkh script but the pubkey_hash is found in
  the scriptPubkey.

  Add a `Script` conversion method that checks if `self` is a v0 p2wpkh
  script and if so extracts the pubkey_hash and returns the required
  script.

  Includes a link to BIP143

  [0] https://github.com/libbitcoin/libbitcoin-system/wiki/P2WPKH-Transactions#spending-a-p2wpkh-output

ACKs for top commit:
  apoelstra:
    ACK d882b68
  sanket1729:
    code review ACK d882b68.

Tree-SHA512: 9a3244b5aac4e2911edf4d3bb634d3d2b98006b864280a2a04b45c55c263c2541bf25f01196f2a65bf9acbdd0cf28c69c3a020a7e6c8da6fddf7c7cfbb62836d
@Kixunil Kixunil added the minor API Change This PR should get a minor version bump label Aug 1, 2022
@Kixunil Kixunil added this to the 0.29.0 milestone Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor API Change This PR should get a minor version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants