当前位置:   article > 正文

signature=bdb14df0d5cef98b44b3c25d46b78d29,bitcoin - Raw transaction Error: mandatory-script-verify-...

mandatory-script-verify-flag-failed

I'm trying to create and sign a raw transaction and broadcast it to the testnet.

This is input transaction:

{

"error": null,

"id": "1",

"result": {

"blockhash": "000000000000006ad3b6dcf2a1e1725eeb3f7c5e424feca4577d4c9e106d26e5",

"blocktime": 1587495286,

"confirmations": 689,

"hash": "c6cbe3462b78a072ef0ff3f0b436372ad55d811b4ba0feb581d0adfefdd8f815",

"hex": "02000000000101fd1819b6a5f2ca631fd7eafecdb021cb1e2ea28485cc72b8903967637d784aa40100000017160014030df68f3c20d14bd8e998588ca7e640ada02284feffffff0296361b00000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acde1745290100000017a9149c5fefdc8021652844976aa2ba3e49f0933933c887024730440220033b4acb8120f25db5c83fb8ed4d73dc1e4d45e271c98d9f8ac46f2cc6de32e502200405228466f0b07ae8edc7d80d81c6c2983c811ee6d4588bf46ce65fdf000bc80121039657df486ea7bf33580ce678a2ac90b0dc2b82e97edc23d36daf1743d618d355ca421a00",

"locktime": 1721034,

"size": 249,

"time": 1587495286,

"txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",

"version": 2,

"vin": [

{

"scriptSig": {

"asm": "0014030df68f3c20d14bd8e998588ca7e640ada02284",

"hex": "160014030df68f3c20d14bd8e998588ca7e640ada02284"

},

"sequence": 4294967294,

"txid": "a44a787d63673990b872cc8584a22e1ecb21b0cdfeead71f63caf2a5b61918fd",

"txinwitness": [

"30440220033b4acb8120f25db5c83fb8ed4d73dc1e4d45e271c98d9f8ac46f2cc6de32e502200405228466f0b07ae8edc7d80d81c6c2983c811ee6d4588bf46ce65fdf000bc801",

"039657df486ea7bf33580ce678a2ac90b0dc2b82e97edc23d36daf1743d618d355"

],

"vout": 1

}

],

"vout": [

{

"n": 0,

"scriptPubKey": {

"addresses": [

"msJaKN7KCGARZrKWyy169GzztFLx7aTRBf"

],

"asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",

"hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",

"reqSigs": 1,

"type": "pubkeyhash"

},

"value": 0.01783446

},

{

"n": 1,

"scriptPubKey": {

"addresses": [

"2N7W4L2UTnsTW4wYVLgBGLKoxHdFJ9L54WU"

],

"asm": "OP_HASH160 9c5fefdc8021652844976aa2ba3e49f0933933c8 OP_EQUAL",

"hex": "a9149c5fefdc8021652844976aa2ba3e49f0933933c887",

"reqSigs": 1,

"type": "scripthash"

},

"value": 49.87361246

}

],

"vsize": 168,

"weight": 669

}

}

I do the following steps:

Create the raw transaction. This is the serialized raw transaction:

0100000001dcabee1e490bc90c9b4d739baba71f6f060c0281d0f4a41f9d0dad67546cd3cc0000000000ffffffff0196361b00000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac00000000

Decode the raw transaction. This is the decoded transaction:

{

"error": null,

"id": "1",

"result": {

"hash": "787a2c60c4bd1d92590e6dfe132f18322c27a2667f134903393de0e6f973234a",

"locktime": 0,

"size": 85,

"txid": "787a2c60c4bd1d92590e6dfe132f18322c27a2667f134903393de0e6f973234a",

"version": 1,

"vin": [

{

"scriptSig": {

"asm": "",

"hex": ""

},

"sequence": 4294967295,

"txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",

"vout": 0

}

],

"vout": [

{

"n": 0,

"scriptPubKey": {

"addresses": [

"moinqaiuWShfsemB9nGcAGFZNMa3ZwPMq6"

],

"asm": "OP_DUP OP_HASH160 59fe1a9f9f0a5af33396c59990f064be1ca51274 OP_EQUALVERIFY OP_CHECKSIG",

"hex": "76a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac",

"reqSigs": 1,

"type": "pubkeyhash"

},

"value": 0.01783446

}

],

"vsize": 85,

"weight": 340

}

}

Sign the raw transaction. I don't have access to the private keys, because they are stored in a HSM. To sign the transaction, I have to send the serialized transaction and the public key to the HSM endpoint. It signs the transaction with the private key, which belongs to the public key and returns the signature.

The signature looks like this:

3045022100f1f05b567ff95997c60c6ece7b78df1b3ed12d145551e41986a682b807f9adaf02201c914c74297b28a9564b17fd1e94710ed2ad0c32147b26e44e71fefdce51df9a

This is the public key:

3056301006072a8648ce3d020106052b8104000a034200045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992

Decode the singed transaction. This is the decoded signed transaction:

{

"error": null,

"id": "1",

"result": {

"hash": "6d97a4e3239b375121b189ebb56af72c7f4111a03f1796e2ced241afe97d733a",

"locktime": 0,

"size": 224,

"txid": "6d97a4e3239b375121b189ebb56af72c7f4111a03f1796e2ced241afe97d733a",

"version": 1,

"vin": [

{

"scriptSig": {

"asm": "3045022100f1f05b567ff95997c60c6ece7b78df1b3ed12d145551e41986a682b807f9adaf02201c914c74297b28a9564b17fd1e94710ed2ad0c32147b26e44e71fefdce51df9a[ALL] 045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992",

"hex": "483045022100f1f05b567ff95997c60c6ece7b78df1b3ed12d145551e41986a682b807f9adaf02201c914c74297b28a9564b17fd1e94710ed2ad0c32147b26e44e71fefdce51df9a0141045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992"

},

"sequence": 4294967295,

"txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",

"vout": 0

}

],

"vout": [

{

"n": 0,

"scriptPubKey": {

"addresses": [

"moinqaiuWShfsemB9nGcAGFZNMa3ZwPMq6"

],

"asm": "OP_DUP OP_HASH160 59fe1a9f9f0a5af33396c59990f064be1ca51274 OP_EQUALVERIFY OP_CHECKSIG",

"hex": "76a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac",

"reqSigs": 1,

"type": "pubkeyhash"

},

"value": 0.01763446

}

],

"vsize": 224,

"weight": 896

}

}

Broadcast the signed transaction with RPC sendrawtransaction:

{"id":"1","jsonrpc":"1.0","method":"sendrawtransaction","params":["0100000001dcabee1e490bc90c9b4d739baba71f6f060c0281d0f4a41f9d0dad67546cd3cc000000008b483045022100f1f05b567ff95997c60c6ece7b78df1b3ed12d145551e41986a682b807f9adaf02201c914c74297b28a9564b17fd1e94710ed2ad0c32147b26e44e71fefdce51df9a0141045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992ffffffff0176e81a00000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac00000000"]}

I always get the following error:

{

"error": {

"code": -26,

"message": "mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)"

},

"id": "1",

"result": null

}

I also tried to broadcast it on https://live.blockcypher.com/btc/pushtx. There I get the following error:

Error validating transaction: Error running script for input 0 referencing ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc at 0: Script was NOT verified successfully..

What is wrong with my transaction?

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/831884
推荐阅读
  

闽ICP备14008679号