<p>The top-level <code>type</code> parameter of the <code>decodescript</code> RPC can tell you if a scriptPubKey is standard.  For example:</p>

<pre><code>bitcoin-cli decodescript deadbeef
{ 
  "asm": "OP_UNKNOWN OP_CHECKSIGVERIFY OP_UNKNOWN OP_UNKNOWN",
  "type": "nonstandard",
  "p2sh": "3PbdV4zdrjtFD4fyYebGR4oxeatrSzb2d1",
  "segwit": {
    "asm": "0 5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953",
    "hex": "00205f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953",
    "reqSigs": 1,
    "type": "witness_v0_scripthash",
    "addresses": [
      "bc1qtauvxvn5usl6nhjktyn9c8v30cjuqdezmjct35nahr2la25p89fssxejht"
    ],
    "p2sh-segwit": "37CpdZEgXUB7LS7rvTLsYopRifDf76eZrZ"
  }
}
</code></pre>

<p>However, I don't know of a way to test whether a P2SH/segwit redeem script is standard using the RPC.  If, instead, you want to know whether or not a particular spend would be accepted to your node's memory pool, Bitcoin Core's development branch (<code>master</code>) features a new <code>testmempoolaccept</code> RPC; here's it's current help:</p>

<pre><code>testmempoolaccept ["rawtxs"] ( allowhighfees )

Returns if raw transaction (serialized, hex-encoded) would be accepted by mempool.

This checks if the transaction violates the consensus or policy rules.

See sendrawtransaction call.

Arguments:
1. ["rawtxs"]       (array, required) An array of hex strings of raw transactions.
                                        Length must be one for now.                                                                                                           2. allowhighfees    (boolean, optional, default=false) Allow high fees

Result:
[                   (array) The result of the mempool acceptance test for each raw transaction in the input array.
                            Length is exactly one for now.
 {
  "txid"           (string) The transaction hash in hex
  "allowed"        (boolean) If the mempool allows this tx to be inserted
  "reject-reason"  (string) Rejection string (only present when 'allowed' is false)
 }
]

Examples:

Create a transaction
&gt; bitcoin-cli createrawtransaction "[{\"txid\" : \"mytxid\",\"vout\":0}]" "{\"myaddress\":0.01}"
Sign the transaction, and get back the hex
&gt; bitcoin-cli signrawtransaction "myhex"

Test acceptance of the transaction (signed hex)
&gt; bitcoin-cli testmempoolaccept "signedhex"
</code></pre>

<p>You could also test out the complete script using regtest.  By default regtest has the standardness checks disabled, by you can re-enable them by starting <code>bitcoind</code> with the <code>-acceptnonstdtxn=0</code> parameter.</p>

CC BY-SA 4.0
2018-05-13T11:08:21.967Z
2018-05-13T11:42:41.993Z
2018-05-13T11:42:41.993Z
David A. Harding
<p>I want to test if a script or is standard or not. Is it possible with Bitcoin Core's RPC?</p>

<bitcoin-core><json-rpc><non-standard-transaction>
Bitcoin RPC: Can I test for standardness?
nopara73
# Bitcoin RPC: Can I test for standardness?

(Asked by: username_0 on 2018-05-13)

I want to test if a script or is standard or not. Is it possible with Bitcoin Core's RPC?

**Tags:** bitcoin-core, json-rpc, non-standard-transaction


---

## 1 answers

### Answer by username_1 on 2018-05-13. Score: 1 | Accepted answer

The top-level `type` parameter of the `decodescript` RPC can tell you if a scriptPubKey is standard. For example:

```
bitcoin-cli decodescript deadbeef
{ 
  "asm": "OP_UNKNOWN OP_CHECKSIGVERIFY OP_UNKNOWN OP_UNKNOWN",
  "type": "nonstandard",
  "p2sh": "3PbdV4zdrjtFD4fyYebGR4oxeatrSzb2d1",
  "segwit": {
    "asm": "0 5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953",
    "hex": "00205f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953",
    "reqSigs": 1,
    "type": "witness_v0_scripthash",
    "addresses": [
      "bc1qtauvxvn5usl6nhjktyn9c8v30cjuqdezmjct35nahr2la25p89fssxejht"
    ],
    "p2sh-segwit": "37CpdZEgXUB7LS7rvTLsYopRifDf76eZrZ"
  }
}

```

However, I don't know of a way to test whether a P2SH/segwit redeem script is standard using the RPC. If, instead, you want to know whether or not a particular spend would be accepted to your node's memory pool, Bitcoin Core's development branch (`master`) features a new `testmempoolaccept` RPC; here's it's current help:

```
testmempoolaccept ["rawtxs"] ( allowhighfees )

Returns if raw transaction (serialized, hex-encoded) would be accepted by mempool.

This checks if the transaction violates the consensus or policy rules.

See sendrawtransaction call.

Arguments:
1. ["rawtxs"]       (array, required) An array of hex strings of raw transactions.
                                        Length must be one for now.                                                                                                           2. allowhighfees    (boolean, optional, default=false) Allow high fees

Result:
[                   (array) The result of the mempool acceptance test for each raw transaction in the input array.
                            Length is exactly one for now.
 {
  "txid"           (string) The transaction hash in hex
  "allowed"        (boolean) If the mempool allows this tx to be inserted
  "reject-reason"  (string) Rejection string (only present when 'allowed' is false)
 }
]

Examples:

Create a transaction
> bitcoin-cli createrawtransaction "[{\"txid\" : \"mytxid\",\"vout\":0}]" "{\"myaddress\":0.01}"
Sign the transaction, and get back the hex
> bitcoin-cli signrawtransaction "myhex"

Test acceptance of the transaction (signed hex)
> bitcoin-cli testmempoolaccept "signedhex"

```

You could also test out the complete script using regtest. By default regtest has the standardness checks disabled, by you can re-enable them by starting `bitcoind` with the `-acceptnonstdtxn=0` parameter.


---

