Merge #17541: test: add functional test for non-standard bare multisig txs

1be0b1fb2a test: add functional test for non-standard bare multisig txs (Sebastian Falbesoner)

Pull request description:

  Approaches another missing functional test of issue #17394 (counterpart to unit test in PR #17502): 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 the argument `-permitbaremultisig=0`.

ACKs for top commit:
  instagibbs:
    utACK 1be0b1fb2a
  kristapsk:
    ACK 1be0b1fb2a

Tree-SHA512: 2cade68c4454029b62278b38d0f137c2605a0e4450c435cdda2833667234edd4406f017ed12fa8df9730618654acbaeb68b16dcabb9f5aa84bad9f1c76c6d476
This commit is contained in:
MarcoFalke 2020-01-16 15:41:32 -05:00
commit ec9b964cc9
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -8,6 +8,7 @@ from io import BytesIO
import math import math
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.key import ECKey
from test_framework.messages import ( from test_framework.messages import (
BIP125_SEQUENCE_NUMBER, BIP125_SEQUENCE_NUMBER,
COIN, COIN,
@ -20,6 +21,9 @@ from test_framework.script import (
hash160, hash160,
CScript, CScript,
OP_0, OP_0,
OP_2,
OP_3,
OP_CHECKMULTISIG,
OP_EQUAL, OP_EQUAL,
OP_HASH160, OP_HASH160,
OP_RETURN, OP_RETURN,
@ -35,7 +39,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1
self.extra_args = [[ self.extra_args = [[
'-txindex', '-txindex','-permitbaremultisig=0',
]] * self.num_nodes ]] * self.num_nodes
self.supports_cli = False self.supports_cli = False
@ -262,6 +266,15 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
rawtxs=[tx.serialize().hex()], rawtxs=[tx.serialize().hex()],
) )
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_reference))) tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_reference)))
key = ECKey()
key.generate()
pubkey = key.get_pubkey().get_bytes()
tx.vout[0].scriptPubKey = CScript([OP_2, pubkey, pubkey, pubkey, OP_3, OP_CHECKMULTISIG]) # Some bare multisig script (2-of-3)
self.check_mempool_result(
result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'bare-multisig'}],
rawtxs=[tx.serialize().hex()],
)
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_reference)))
tx.vin[0].scriptSig = CScript([OP_HASH160]) # Some not-pushonly scriptSig tx.vin[0].scriptSig = CScript([OP_HASH160]) # Some not-pushonly scriptSig
self.check_mempool_result( self.check_mempool_result(
result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'scriptsig-not-pushonly'}], result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'scriptsig-not-pushonly'}],