I have a simple transaction that I want to sign the digest of, but I'm not sure if I've got the raw transaction correct, therefore my digest is incorrect.

The transaction has one input and one output, but with a P2WPKH transaction, I'm not sure what to use in the SigScript field so that I can sha256(sha256) and get the right digest to sign. (for P2PKH you use a OP_DUP, OP_HASH160 PUBKEY_HASH OP_EQUALVERIFY OP_CHECKSIG that you can get from the input UTXO in the SigScript field)

This is my raw transaction:

These are the bytes that I am calculating the sha256(sha256) on and as you can see, I have 00 byte in the SigScript field. Is this right? Should I be using something else here?

I take my signature and then create the signed transaction like this:
17160014d99f1ea19e98d9ed10e5d442be37a44b6b63c477ffffffff  (hash160 of public key)
02 (number of stack items)    
(public key)    

But this doesn't seem to work and says my signature is invalid, so I can only assume that my digest isn't right. Any help would be appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.