Error mandatory-script-verify-flag-failed (Signature is found in scriptCode)

1

I found a few questions with the specific error, but couldn't find also the appropriate answer. So, here I am.

I am working on regtest in a Python library that create transactions and then use JSON-RPC to broadcast it on bitcoind server I have locally.

Here is the test:

  1. Initialize a new regtest blockchain
  2. Generate 101 blocks
  3. Get the address that generates those blocks with the respective private key. Let's call this one Bob.

Then I have Steve, who wants to create a script with an absolute locktime (1000 blocks height) and receive 10 bitcoins from Bob.

  1. Steve has a private key and an address. I use that address to create a script

    redeem_script = Script([1000,'OP_CHECKLOCKTIMEVERIFY','OP_DROP', 'OP_DUP', 'OP_HASH160', steve_address.to_hash160(),'OP_EQUALVERIFY', 'OP_CHECKSIG'])

  2. I get the new P2SH Address from the above script

  3. With the listunspent, I get a UTXO from Bob with the related txId and vout

  4. I create a TXInput with the above (txin = TxInput(txid, vout))

  5. Then I create a TXOutput with the amount I want to send and the redeem_script (txout = TxOutput( amount-0.001, redeem_script.to_p2sh_script_pub_key() )

  6. I sign the input with the address of Bob (sig = bob_private_key.sign_input(tx, vout, bob_address.to_script_pub_key() ))

  7. And add the script signature to the TXInput (txin.script_sig = Script( [sig, pk] ))

Then, I broadcast the signed, raw transaction to bitcoind, but I get the error:

'mandatory-script-verify-flag-failed (Signature is found in scriptCode) (code 16)'

The raw transaction and the decoded one are:

02000000010006fc2306a9089e5e45b58ce0386845c139aeec02c6361519ef5afed3a61fc2000000006a47304402202a740d313de85fda558b12951508a73d9512c807d50d9ffab8a59a03ba2423c802200f1199877e3861a24a127f79436156978519c092f8883a9053babcb5bbdda43a012103ef124954caa832374ff31e5ae6c46736489a72b154ab14754fb3bf39f4a6c3f9ffffffff01a0373f250000000017a914d924aa439960faac94c4d74a81e54331ce92b9c58700000000

{
  "txid": "bba3f9881381999c668078af17b41aff23a4adaeed5656be5bc8112a4631ab61",
  "hash": "bba3f9881381999c668078af17b41aff23a4adaeed5656be5bc8112a4631ab61",
  "version": 2,
  "size": 189,
  "vsize": 189,
  "weight": 756,
  "locktime": 0,
  "vin": [
    {
      "txid": "c21fa6d3fe5aef191536c602ecae39c1456838e08cb5455e9e08a90623fc0600",
      "vout": 0,
      "scriptSig": {
        "asm": "304402202a740d313de85fda558b12951508a73d9512c807d50d9ffab8a59a03ba2423c802200f1199877e3861a24a127f79436156978519c092f8883a9053babcb5bbdda43a[ALL] 03ef124954caa832374ff31e5ae6c46736489a72b154ab14754fb3bf39f4a6c3f9",
        "hex": "47304402202a740d313de85fda558b12951508a73d9512c807d50d9ffab8a59a03ba2423c802200f1199877e3861a24a127f79436156978519c092f8883a9053babcb5bbdda43a012103ef124954caa832374ff31e5ae6c46736489a72b154ab14754fb3bf39f4a6c3f9"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 6.24900000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_HASH160 d924aa439960faac94c4d74a81e54331ce92b9c5 OP_EQUAL",
        "hex": "a914d924aa439960faac94c4d74a81e54331ce92b9c587",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "2ND3NYSrRqp742acVwYGSDSxbsm5Ce8wbXe"
        ]
      }
    }
  ]
}

Any idea? I am newbie and I might overlooked something important or trivial.

Tasos

Posted 2019-04-12T18:16:13.023

Reputation: 129

No answers