Bitcoin

Blockchain – Fix incorrect data structure of BTC transactions

There is a problem with the raw Bitcoin transaction data structure. I get an error after committing. On the internet, some say it’s due to incorrect implementation of private and public keys, some say it’s due to incorrect data structure, so I’m checking. If my data structure from the stackoverflow community is ok, I will figure out the signature implementation issues myself.

This is the transaction I did and I put 10000 satoshi in the address bc1qqs5lcmj58lmmfd6ap34xqqfuzfvz02nxjayrjx I would like to send 2500 to myself and 2500 back to the original address.

This is the data structure before signing the tx.

01000000
01
14fe532eec4ddc9bfd8686a7234300c24a47c60e437ae26e966a43e47f947def
00000000
16
00140429fc6e543ff7b4b75d0c6a60013c125827aa66
ffffffff

02
c409000000000000
1976a9140429fc6e543ff7b4b75d0c6a60013c125827aa6688ac

c409000000000000
1976a9145951ac8720b1865ba633d19eaa6473afae7c46b388ac
00000000
01000000

The data structure after signing is as follows:

01000000
01
14fe532eec4ddc9bfd8686a7234300c24a47c60e437ae26e966a43e47f947def
00000000
6b48304402206b6fde1ca4cac9873f5f2c08edcdf65b621d4c5f49bf187bcd457e2bccbd4dfd02202002f6f82c98979a79efd54234691fdbda684bd33395d810a077effebb0e910f6f01210280a1bfa268074c9171ed0e30f332706789c5138e1428e92506e671b1997eb874
ffffffff

02c409000000000000
1976a9140429fc6e543ff7b4b75d0c6a60013c125827aa6688ac
c409000000000000
1976a9145951ac8720b1865ba633d19eaa6473afae7c46b388ac
00000000

I get an error: “Code: -26, error: non-required-script-verify-flag (witness requires an empty scriptSig)”

I researched the error but the answers weren’t helpful.

Related Articles

Back to top button