I've created a raw transaction, and I get this error when I try to send it with sendrawtransaction
to my local bitcoin regtest.
{
"error": {
"code": -26,
"message": "mandatory-script-verify-flag-failed (Data push larger than necessary)"
},
"id": "1",
"result": null
}
This is the transaction from which I want to spend:
{
"error": null,
"id": "1",
"result": {
"hash": "5fd0ca7c1fa3ef3b04dbf8aa096999604d30c47b88cd41d3ba1b6fba91f919a3",
"hex": "0200000000010116402fe74ebc194f15f19ca11c5d49266608b024363c0b077a17c02bee4d1d820100000000feffffff0200ca9a3b000000001976a91485defe3226b7ec0a1dda4130a7808771a251fbfc88ace81a70eb0000000016001457026508dac7e8d071392868751eaebd6dc4f4d50247304402203752e4d8a536427c0865033b6bafd5972e9a58f6021d45f2c9e04cf5c253f3bc022075efc85af662dbd91aff1623e54295c68ce57e32963433e5215cab0041fac530012102de4a99f805dab29bb0035a496ceca72e7078d53f7bec92ebb44560ef019d505600000000",
"locktime": 0,
"size": 225,
"txid": "97ab9a72367ad6b7a4c2ee122366e625b4049f795e4f15450bf857ea49d9e43c",
"version": 2,
"vin": [
{
"scriptSig": {
"asm": "",
"hex": ""
},
"sequence": 4294967294,
"txid": "821d4dee2bc0177a070b3c3624b0086626495d1ca19cf1154f19bc4ee72f4016",
"txinwitness": [
"304402203752e4d8a536427c0865033b6bafd5972e9a58f6021d45f2c9e04cf5c253f3bc022075efc85af662dbd91aff1623e54295c68ce57e32963433e5215cab0041fac53001",
"02de4a99f805dab29bb0035a496ceca72e7078d53f7bec92ebb44560ef019d5056"
],
"vout": 1
}
],
"vout": [
{
"n": 0,
"scriptPubKey": {
"addresses": [
"msioJPYMmXYkXieUQfVWyFwcXBvoCYhy2Q"
],
"asm": "OP_DUP OP_HASH160 85defe3226b7ec0a1dda4130a7808771a251fbfc OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91485defe3226b7ec0a1dda4130a7808771a251fbfc88ac",
"reqSigs": 1,
"type": "pubkeyhash"
},
"value": 10
},
{
"n": 1,
"scriptPubKey": {
"addresses": [
"bcrt1q2upx2zx6cl5dqufe9p58284wh4kufax477qlqr"
],
"asm": "0 57026508dac7e8d071392868751eaebd6dc4f4d5",
"hex": "001457026508dac7e8d071392868751eaebd6dc4f4d5",
"reqSigs": 1,
"type": "witness_v0_keyhash"
},
"value": 39.4999268
}
],
"vsize": 144,
"weight": 573
}
}
I performed the following steps:
- Create the raw transaction. This is the raw transaction:
01000000013ce4d949ea57f80b45154f5e799f04b425e6662312eec2a4b7d67a36729aab970000000000ffffffff0100ca9a3b000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac00000000
{
"error": null,
"id": "1",
"result": {
"hash": "1495eb8ada986cfaed1dc6dce56dc667fe7264c924ee75018190e3c39947b391",
"locktime": 0,
"size": 85,
"txid": "1495eb8ada986cfaed1dc6dce56dc667fe7264c924ee75018190e3c39947b391",
"version": 1,
"vin": [
{
"scriptSig": {
"asm": "",
"hex": ""
},
"sequence": 4294967295,
"txid": "97ab9a72367ad6b7a4c2ee122366e625b4049f795e4f15450bf857ea49d9e43c",
"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": 10
}
],
"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.
This is the singed transaction:
01000000013ce4d949ea57f80b45154f5e799f04b425e6662312eec2a4b7d67a36729aab9700000000440101410454a3553d447e4589d165d6fbe76e7bc3e472f107d223e1d051db37875bac09ba9b2ce89676b2e3c571d797bed67a525ecc16e904186692cdee40968cffaf5576ffffffff01e07b9a3b000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac00000000
{
"error": null,
"id": "1",
"result": {
"hash": "24dbf04b3070c9b8eb4b2eac37a7a1ec355763d9c008b5dc1ebc636867b322b8",
"locktime": 0,
"size": 153,
"txid": "24dbf04b3070c9b8eb4b2eac37a7a1ec355763d9c008b5dc1ebc636867b322b8",
"version": 1,
"vin": [
{
"scriptSig": {
"asm": "1 0454a3553d447e4589d165d6fbe76e7bc3e472f107d223e1d051db37875bac09ba9b2ce89676b2e3c571d797bed67a525ecc16e904186692cdee40968cffaf5576",
"hex": "0101410454a3553d447e4589d165d6fbe76e7bc3e472f107d223e1d051db37875bac09ba9b2ce89676b2e3c571d797bed67a525ecc16e904186692cdee40968cffaf5576"
},
"sequence": 4294967295,
"txid": "97ab9a72367ad6b7a4c2ee122366e625b4049f795e4f15450bf857ea49d9e43c",
"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": 9.9998
}
],
"vsize": 153,
"weight": 612
}
}
What am I doing wrong?
Update 1: Based on the answer of MCCCS I changed 0101 to 0x51. Now my signed transaction looks like this:
{
"error": null,
"id": "1",
"result": {
"hash": "f1b87be3d529004e14a9e13cb59849a027191862872fc8c964e37c1a60d05e81",
"locktime": 0,
"size": 153,
"txid": "f1b87be3d529004e14a9e13cb59849a027191862872fc8c964e37c1a60d05e81",
"version": 1,
"vin": [
{
"scriptSig": {
"asm": "81 0454a3553d447e4589d165d6fbe76e7bc3e472f107d223e1d051db37875bac09ba9b2ce89676b2e3c571d797bed67a525ecc16e904186692cdee40968cffaf5576",
"hex": "0151410454a3553d447e4589d165d6fbe76e7bc3e472f107d223e1d051db37875bac09ba9b2ce89676b2e3c571d797bed67a525ecc16e904186692cdee40968cffaf5576"
},
"sequence": 4294967295,
"txid": "97ab9a72367ad6b7a4c2ee122366e625b4049f795e4f15450bf857ea49d9e43c",
"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": 9.9998
}
],
"vsize": 153,
"weight": 612
}
}
Now I get the following error when broadcasting the transaction:
{
"error": {
"code": -26,
"message": "mandatory-script-verify-flag-failed (Non-canonical DER signature)"
},
"id": "1",
"result": null
}
What does that mean?