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

How to decode a Sighash type on a TX hex? #178

Open
zilveer opened this issue Aug 10, 2017 · 3 comments
Open

How to decode a Sighash type on a TX hex? #178

zilveer opened this issue Aug 10, 2017 · 3 comments

Comments

@zilveer
Copy link

zilveer commented Aug 10, 2017

Hello,
is there anyone here who can guide me on how to decode a Sighash type on a TX hex which is signed?

I am pretty new to this,
any help is appreciated.

regards

@sr-gi
Copy link

sr-gi commented Aug 10, 2017

You should check the input script (scriptSig) for the transaction you want to decode. Assuming you are analysing a P2PKH transaction, the structure of the script will be:

< signature >< hash_type >< public_key >

The hash_type is always 1 byte long.

For future questions I would recommend you to ask this type of questions in another place, like the Bitcoin Stack Exchange, since this repo is kind off discontinued.

@zilveer
Copy link
Author

zilveer commented Aug 10, 2017

@sr-gi thanks for replying back to me.

I will do that but meanwhile u r here what if it's a P2SH transaction how does it look like then?

Thanks for your kind reply.

regards

@sr-gi
Copy link

sr-gi commented Aug 10, 2017

P2SH are more tricky, since them not always require a signature. However, if there is a signature the hash type will be the next byte or the tailing byte, depending on how you interpret the signature (as it happened with P2PKH scripts).

Here you have the structure of a signature:

captura

and here an example where r and s are 32-byte values:

captura

Notice that ht represents the hash type.

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

No branches or pull requests

2 participants