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

fix: pkh script #55

Merged
merged 2 commits into from
Apr 27, 2024
Merged

fix: pkh script #55

merged 2 commits into from
Apr 27, 2024

Conversation

coolaj86
Copy link
Member

@coolaj86 coolaj86 commented Apr 27, 2024

In short: fixed a code path that was never used until the dsf message.

Update: the issue was a leading 1a in front of the typical p2pkh script 76a914, ex: 1a1976a914xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx88ac. The key thing to remember is that the 19 is the size (25 in decimal, including the 74a9 and keysize 14 - meaning 20 - and the 88ac), so it should not be included in a string template - otherwise the 1a will appear.

The Long Story

There was a code path that was never exercised until I copied inputs from the dsf because the dsf is missing the script, whereas it always exists for utxo from Insight and RPC.

This code path put the size byte as part of the script - which was then calculated as part of the script with another size byte in front of it.

So as I've gone through the coinjoin message byte by byte, I just failed to notice the 1, single byte in front of the size byte (because there's always a few "header" bytes to the script that I skip over as "the size, type, op code, etc").

And the sigscript does have a double size header (the bitcoin size byte, followed by the ASN.1 size byte).

And the input script takes the place of the sigscript when hashing.

So in an input, it looks like a double size byte normally, and only in the in-memory representation is it a single-size byte.

In the output, the lockscript doesn't have the extra size byte like an input signature script does.

@coolaj86 coolaj86 merged commit 1dbc795 into main Apr 27, 2024
4 checks passed
@coolaj86 coolaj86 deleted the fix-pkh-script branch April 27, 2024 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant