Skip to content

Commit e504b1f

Browse files
test: Add test case for spending bare multisig
Co-authored-by: Anthony Towns <aj@erisian.com.au>
1 parent d48d55e commit e504b1f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ void SetupServerArgs(ArgsManager& argsman)
636636
MAX_OP_RETURN_RELAY),
637637
ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
638638
argsman.AddArg("-mempoolfullrbf", strprintf("Accept transaction replace-by-fee without requiring replaceability signaling (default: %u)", DEFAULT_MEMPOOL_FULL_RBF), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
639-
argsman.AddArg("-permitbaremultisig", strprintf("Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
639+
argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
640640
OptionsCategory::NODE_RELAY);
641641
argsman.AddArg("-minrelaytxfee=<amt>", strprintf("Fees (in %s/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",
642642
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);

test/functional/mempool_accept.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
OP_HASH160,
2929
OP_RETURN,
3030
OP_TRUE,
31+
SIGHASH_ALL,
32+
sign_input_legacy,
3133
)
3234
from test_framework.script_util import (
3335
DUMMY_MIN_OP_RETURN_SCRIPT,
@@ -386,5 +388,24 @@ def run_test(self):
386388
maxfeerate=0,
387389
)
388390

391+
self.log.info('Spending a confirmed bare multisig is okay')
392+
address = self.wallet.get_address()
393+
tx = tx_from_hex(raw_tx_reference)
394+
privkey, pubkey = generate_keypair()
395+
tx.vout[0].scriptPubKey = keys_to_multisig_script([pubkey] * 3, k=1) # Some bare multisig script (1-of-3)
396+
tx.rehash()
397+
self.generateblock(node, address, [tx.serialize().hex()])
398+
tx_spend = CTransaction()
399+
tx_spend.vin.append(CTxIn(COutPoint(tx.sha256, 0), b""))
400+
tx_spend.vout.append(CTxOut(tx.vout[0].nValue - int(fee*COIN), script_to_p2wsh_script(CScript([OP_TRUE]))))
401+
tx_spend.rehash()
402+
sign_input_legacy(tx_spend, 0, tx.vout[0].scriptPubKey, privkey, sighash_type=SIGHASH_ALL)
403+
tx_spend.vin[0].scriptSig = bytes(CScript([OP_0])) + tx_spend.vin[0].scriptSig
404+
self.check_mempool_result(
405+
result_expected=[{'txid': tx_spend.rehash(), 'allowed': True, 'vsize': tx_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}],
406+
rawtxs=[tx_spend.serialize().hex()],
407+
maxfeerate=0,
408+
)
409+
389410
if __name__ == '__main__':
390411
MempoolAcceptanceTest().main()

0 commit comments

Comments
 (0)