Skip to content

Commit 1be0b1f

Browse files
committed
test: add functional test for non-standard bare multisig txs
A transaction is rejected by the mempool with reason "bare-multisig" if any of the outputs' scriptPubKey has bare multisig format (M <PubKey1> <PubKey2> ... <PubKeyN> N OP_CHECKSIG) and bitcoind is started with "-permitbaremultisig=0".
1 parent a8d9f7d commit 1be0b1f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/functional/mempool_accept.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import math
99

1010
from test_framework.test_framework import BitcoinTestFramework
11+
from test_framework.key import ECKey
1112
from test_framework.messages import (
1213
BIP125_SEQUENCE_NUMBER,
1314
COIN,
@@ -20,6 +21,9 @@
2021
hash160,
2122
CScript,
2223
OP_0,
24+
OP_2,
25+
OP_3,
26+
OP_CHECKMULTISIG,
2327
OP_EQUAL,
2428
OP_HASH160,
2529
OP_RETURN,
@@ -35,7 +39,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
3539
def set_test_params(self):
3640
self.num_nodes = 1
3741
self.extra_args = [[
38-
'-txindex',
42+
'-txindex','-permitbaremultisig=0',
3943
]] * self.num_nodes
4044

4145
def skip_test_if_missing_module(self):
@@ -261,6 +265,15 @@ def run_test(self):
261265
rawtxs=[tx.serialize().hex()],
262266
)
263267
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_reference)))
268+
key = ECKey()
269+
key.generate()
270+
pubkey = key.get_pubkey().get_bytes()
271+
tx.vout[0].scriptPubKey = CScript([OP_2, pubkey, pubkey, pubkey, OP_3, OP_CHECKMULTISIG]) # Some bare multisig script (2-of-3)
272+
self.check_mempool_result(
273+
result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'bare-multisig'}],
274+
rawtxs=[tx.serialize().hex()],
275+
)
276+
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_reference)))
264277
tx.vin[0].scriptSig = CScript([OP_HASH160]) # Some not-pushonly scriptSig
265278
self.check_mempool_result(
266279
result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'scriptsig-not-pushonly'}],

0 commit comments

Comments
 (0)