<p>You have to tell Bitcoin Core to allow non-standard transactions, This can be achieved by starting it with <code>-acceptnonstdtxn</code>.</p>

CC BY-SA 4.0
2022-05-04T17:52:24.180Z
Cool!  It works!  Now if I wanted to submit a similar spending transaction to testnet, I would spin up a testnet node here and submit the same way.  But would the transaction propagate enough to get into a block somewhere (via gettemplateblock, right?)?  Or do I have to mine my own block locally from templates from my local testnet node?
Dave M.
CC BY-SA 4.0
2022-05-04T18:52:22.907Z
Testnet allows non-standard transactions by default. You don't need to start with `-acceptnonstdtxn` on testnet, and any non-standard transactions you make should propagate.
Ava Chow
CC BY-SA 4.0
2022-05-04T15:28:11.323Z
2022-05-04T15:28:11.323Z
Ava Chow
<p>I'm trying to replicate an algebraic puzzle I saw in the scriptPubKey of a testnet transaction:</p>
<pre><code>OP_2DUP
OP_ADD
6e
OP_EQUAL
</code></pre>
<p>I think the intent was for this output to be spendable by a scriptSig of <code>0x37</code>, but the author used <code>OP_2DUP</code> instead of <code>OP_DUP</code>.  I think you should still be able to spend this with a scriptSig of <code>0x37 0x37</code>, although the stack after execution will have <code>1 0x37 0x37</code> instead of just <code>1</code>.</p>
<p>I wasn't able to submit a testnet transaction to try to spend the output, because <code>bitcoin-cli sendrawtransaction</code> enforces the <code>non-mandatory-script-verify-flag</code> (Stack size must be exactly one after execution).  So my next thought was to replicate the puzzle on a regnet server, and see if I could spend the coins there.</p>
<p>I created a raw transaction (funded from a different regnet output) with the corrected script:</p>
<p><code>010000000001013675d91ee12f196835c019afec15f8975bc1bcca23f50e0329376ae93e5bc15b0000000000ffffffff01c808e30500000000057693016e870247304402207f369a50b6deecaf6fc0ee15037ffe460eea9d9093d8e889def1ad93f173d11b022042dac5b3db93aa665b4d45073a3c397e4cdbdbd25880d6a8a15f97cc70b0228f0121029972f24e39b359e5e29267fab7d4cf752982f95e3428b0ef14f38937e6084c3f00000000</code></p>
<pre><code>{
  &quot;txid&quot;: &quot;4c56e2c6626e23f8d3afe7862332f3dbdef5e271f9931ecac8d8ffa67c43bf0b&quot;,
  &quot;hash&quot;: &quot;07662570c30e5505f35a328342ca6d0a3219ff2198814af44bfcc3dfad20d649&quot;,
  &quot;version&quot;: 1,
  &quot;size&quot;: 174,
  &quot;vsize&quot;: 93,
  &quot;weight&quot;: 369,
  &quot;locktime&quot;: 0,
  &quot;vin&quot;: [
    {
      &quot;txid&quot;: &quot;5bc15b3ee96a3729030ef523cabcc15b97f815ecaf19c03568192fe11ed97536&quot;,
      &quot;vout&quot;: 0,
      &quot;scriptSig&quot;: {
        &quot;asm&quot;: &quot;&quot;,
        &quot;hex&quot;: &quot;&quot;
      },
      &quot;txinwitness&quot;: [
        &quot;304402207f369a50b6deecaf6fc0ee15037ffe460eea9d9093d8e889def1ad93f173d11b022042dac5b3db93aa665b4d45073a3c397e4cdbdbd25880d6a8a15f97cc70b0228f01&quot;,
        &quot;029972f24e39b359e5e29267fab7d4cf752982f95e3428b0ef14f38937e6084c3f&quot;
      ],
      &quot;sequence&quot;: 4294967295
    }
  ],
  &quot;vout&quot;: [
    {
      &quot;value&quot;: 0.98765000,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;OP_DUP OP_ADD 110 OP_EQUAL&quot;,
        &quot;desc&quot;: &quot;raw(7693016e87)#tcc664ka&quot;,
        &quot;hex&quot;: &quot;7693016e87&quot;,
        &quot;type&quot;: &quot;nonstandard&quot;
      }
    }
  ]
}
</code></pre>
<p>But I can't submit this transaction to my regnet server either, because:</p>
<pre><code>% bitcoin-cli sendrawtransaction 010000000001013675d91ee12f196835c019afec15f8975bc1bcca23f50e0329376ae93e5bc15b0000000000ffffffff01c808e30500000000057693016e870247304402207f369a50b6deecaf6fc0ee15037ffe460eea9d9093d8e889def1ad93f173d11b022042dac5b3db93aa665b4d45073a3c397e4cdbdbd25880d6a8a15f97cc70b0228f0121029972f24e39b359e5e29267fab7d4cf752982f95e3428b0ef14f38937e6084c3f00000000
error code: -26
error message:
scriptpubkey
</code></pre>
<p>Do I have to write my own submitter to talk to the regnet node?  (Perhaps I'll need that anyway to submit the answering / spending transaction.)</p>
<p>(I think I can submit nonstandard scripts via P2SH, but that's not what I want, because the puzzle script itself needs to be in the blockchain, not just the answer script's hash.  That's the whole point of having a puzzle / reward / challenge: anyone can read the problem statement, and if they can solve it, they can submit a transaction where the scriptsig pushes the answer(s).  I understand that this is not secure, and that a mining pool could steal the answer and submit it with their own pay-to address as the output, but that's a problem for another day.)</p>
<p>Help!</p>

<script><raw-transaction><input-script><non-standard-transaction>
How to submit nonstandard scriptPubKey transaction to bitcoind in regtest mode?
Dave M.
# How to submit nonstandard scriptPubKey transaction to bitcoind in regtest mode?

(Asked by: username_0 on 2022-05-04)

I'm trying to replicate an algebraic puzzle I saw in the scriptPubKey of a testnet transaction:

```
OP_2DUP
OP_ADD
6e
OP_EQUAL

```

I think the intent was for this output to be spendable by a scriptSig of `0x37`, but the author used `OP_2DUP` instead of `OP_DUP`. I think you should still be able to spend this with a scriptSig of `0x37 0x37`, although the stack after execution will have `1 0x37 0x37` instead of just `1`.

I wasn't able to submit a testnet transaction to try to spend the output, because `bitcoin-cli sendrawtransaction` enforces the `non-mandatory-script-verify-flag` (Stack size must be exactly one after execution). So my next thought was to replicate the puzzle on a regnet server, and see if I could spend the coins there.

I created a raw transaction (funded from a different regnet output) with the corrected script:

`010000000001013675d91ee12f196835c019afec15f8975bc1bcca23f50e0329376ae93e5bc15b0000000000ffffffff01c808e30500000000057693016e870247304402207f369a50b6deecaf6fc0ee15037ffe460eea9d9093d8e889def1ad93f173d11b022042dac5b3db93aa665b4d45073a3c397e4cdbdbd25880d6a8a15f97cc70b0228f0121029972f24e39b359e5e29267fab7d4cf752982f95e3428b0ef14f38937e6084c3f00000000`

```
{
  "txid": "4c56e2c6626e23f8d3afe7862332f3dbdef5e271f9931ecac8d8ffa67c43bf0b",
  "hash": "07662570c30e5505f35a328342ca6d0a3219ff2198814af44bfcc3dfad20d649",
  "version": 1,
  "size": 174,
  "vsize": 93,
  "weight": 369,
  "locktime": 0,
  "vin": [
    {
      "txid": "5bc15b3ee96a3729030ef523cabcc15b97f815ecaf19c03568192fe11ed97536",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402207f369a50b6deecaf6fc0ee15037ffe460eea9d9093d8e889def1ad93f173d11b022042dac5b3db93aa665b4d45073a3c397e4cdbdbd25880d6a8a15f97cc70b0228f01",
        "029972f24e39b359e5e29267fab7d4cf752982f95e3428b0ef14f38937e6084c3f"
      ],
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.98765000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_ADD 110 OP_EQUAL",
        "desc": "raw(7693016e87)#tcc664ka",
        "hex": "7693016e87",
        "type": "nonstandard"
      }
    }
  ]
}

```

But I can't submit this transaction to my regnet server either, because:

```
% bitcoin-cli sendrawtransaction 010000000001013675d91ee12f196835c019afec15f8975bc1bcca23f50e0329376ae93e5bc15b0000000000ffffffff01c808e30500000000057693016e870247304402207f369a50b6deecaf6fc0ee15037ffe460eea9d9093d8e889def1ad93f173d11b022042dac5b3db93aa665b4d45073a3c397e4cdbdbd25880d6a8a15f97cc70b0228f0121029972f24e39b359e5e29267fab7d4cf752982f95e3428b0ef14f38937e6084c3f00000000
error code: -26
error message:
scriptpubkey

```

Do I have to write my own submitter to talk to the regnet node? (Perhaps I'll need that anyway to submit the answering / spending transaction.)

(I think I can submit nonstandard scripts via P2SH, but that's not what I want, because the puzzle script itself needs to be in the blockchain, not just the answer script's hash. That's the whole point of having a puzzle / reward / challenge: anyone can read the problem statement, and if they can solve it, they can submit a transaction where the scriptsig pushes the answer(s). I understand that this is not secure, and that a mining pool could steal the answer and submit it with their own pay-to address as the output, but that's a problem for another day.)

Help!

**Tags:** script, raw-transaction, input-script, non-standard-transaction


---

## 1 answers

### Answer by username_1 on 2022-05-04. Score: 1 | Accepted answer

You have to tell Bitcoin Core to allow non-standard transactions, This can be achieved by starting it with `-acceptnonstdtxn`.

> **Comments:**
> **username_0**: Cool!  It works!  Now if I wanted to submit a similar spending transaction to testnet, I would spin up a testnet node here and submit the same way.  But would the transaction propagate enough to get into a block somewhere (via gettemplateblock, right?)?  Or do I have to mine my own block locally from templates from my local testnet node?  
> **username_1**: Testnet allows non-standard transactions by default. You don't need to start with `-acceptnonstdtxn` on testnet, and any non-standard transactions you make should propagate.  

---

