0

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:
02000000010a02214430acee2ed509798187210171bb387075ce2c82ef5a73774d6159387500000000
00
ffffffff018ca1b404000000001976a914906ec1c4804632c0b067e5a2732c41cdf620c4e688ac0000000001000000

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:
020000000001010a02214430acee2ed509798187210171bb387075ce2c82ef5a73774d6159387500000000
17160014d99f1ea19e98d9ed10e5d442be37a44b6b63c477ffffffff  (hash160 of public key)
018ca1b404000000001976a914906ec1c4804632c0b067e5a2732c41cdf620c4e688ac
02 (number of stack items)    
(signature)
4830460221009f5d0f24faff44fc6ffd364ef4af87d366b95058c60497b87f9fd51bb3e60f59022100f768fb09286f8c9f5aba7295e6a2ce243f2f1eac29b717feb18108b6e8c0003a
(public key)    
41047d011958b661181242addd300b6d5c51f80d62674555831dd855b34358b57e05fb46477ba167a57b23bf8a492305c0085d8c34aa04d483b7f15a2d551e2ff66200000000

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.