mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
test: Add test case for spending bare multisig
Co-authored-by: Anthony Towns <aj@erisian.com.au>
This commit is contained in:
parent
d48d55e0d3
commit
e504b1fa1f
2 changed files with 22 additions and 1 deletions
|
@ -636,7 +636,7 @@ void SetupServerArgs(ArgsManager& argsman)
|
||||||
MAX_OP_RETURN_RELAY),
|
MAX_OP_RETURN_RELAY),
|
||||||
ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
|
ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
|
||||||
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);
|
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);
|
||||||
argsman.AddArg("-permitbaremultisig", strprintf("Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
|
argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
|
||||||
OptionsCategory::NODE_RELAY);
|
OptionsCategory::NODE_RELAY);
|
||||||
argsman.AddArg("-minrelaytxfee=<amt>", strprintf("Fees (in %s/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",
|
argsman.AddArg("-minrelaytxfee=<amt>", strprintf("Fees (in %s/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",
|
||||||
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
|
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
|
||||||
|
|
|
@ -28,6 +28,8 @@ from test_framework.script import (
|
||||||
OP_HASH160,
|
OP_HASH160,
|
||||||
OP_RETURN,
|
OP_RETURN,
|
||||||
OP_TRUE,
|
OP_TRUE,
|
||||||
|
SIGHASH_ALL,
|
||||||
|
sign_input_legacy,
|
||||||
)
|
)
|
||||||
from test_framework.script_util import (
|
from test_framework.script_util import (
|
||||||
DUMMY_MIN_OP_RETURN_SCRIPT,
|
DUMMY_MIN_OP_RETURN_SCRIPT,
|
||||||
|
@ -386,5 +388,24 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||||
maxfeerate=0,
|
maxfeerate=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.log.info('Spending a confirmed bare multisig is okay')
|
||||||
|
address = self.wallet.get_address()
|
||||||
|
tx = tx_from_hex(raw_tx_reference)
|
||||||
|
privkey, pubkey = generate_keypair()
|
||||||
|
tx.vout[0].scriptPubKey = keys_to_multisig_script([pubkey] * 3, k=1) # Some bare multisig script (1-of-3)
|
||||||
|
tx.rehash()
|
||||||
|
self.generateblock(node, address, [tx.serialize().hex()])
|
||||||
|
tx_spend = CTransaction()
|
||||||
|
tx_spend.vin.append(CTxIn(COutPoint(tx.sha256, 0), b""))
|
||||||
|
tx_spend.vout.append(CTxOut(tx.vout[0].nValue - int(fee*COIN), script_to_p2wsh_script(CScript([OP_TRUE]))))
|
||||||
|
tx_spend.rehash()
|
||||||
|
sign_input_legacy(tx_spend, 0, tx.vout[0].scriptPubKey, privkey, sighash_type=SIGHASH_ALL)
|
||||||
|
tx_spend.vin[0].scriptSig = bytes(CScript([OP_0])) + tx_spend.vin[0].scriptSig
|
||||||
|
self.check_mempool_result(
|
||||||
|
result_expected=[{'txid': tx_spend.rehash(), 'allowed': True, 'vsize': tx_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}],
|
||||||
|
rawtxs=[tx_spend.serialize().hex()],
|
||||||
|
maxfeerate=0,
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
MempoolAcceptanceTest().main()
|
MempoolAcceptanceTest().main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue