mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Compare commits
4 commits
e836b2987b
...
9ad0c3fe00
Author | SHA1 | Date | |
---|---|---|---|
|
9ad0c3fe00 | ||
|
c5e44a0435 | ||
|
32d55e28af | ||
|
9ab4e3fe7e |
3 changed files with 23 additions and 1 deletions
|
@ -26,12 +26,14 @@ from test_framework.messages import (
|
|||
COutPoint,
|
||||
CTransaction,
|
||||
CTxIn,
|
||||
CTxInWitness,
|
||||
CTxOut,
|
||||
MAX_MONEY,
|
||||
SEQUENCE_FINAL,
|
||||
)
|
||||
from test_framework.blocktools import create_tx_with_script, MAX_BLOCK_SIGOPS
|
||||
from test_framework.script import (
|
||||
OP_TRUE,
|
||||
CScript,
|
||||
OP_0,
|
||||
OP_2DIV,
|
||||
|
@ -129,6 +131,22 @@ class SizeTooSmall(BadTxTemplate):
|
|||
tx.calc_sha256()
|
||||
return tx
|
||||
|
||||
# reject a transaction that contains a witness
|
||||
# but doesnt spend a segwit output
|
||||
class ExtraWitness(BadTxTemplate):
|
||||
expect_disconnect = False
|
||||
valid_in_block = False
|
||||
block_reject_reason = "mandatory-script-verify-flag-failed (Witness provided for non-witness script)"
|
||||
|
||||
def get_tx(self):
|
||||
tx = CTransaction()
|
||||
tx.vin.append(self.valid_txin)
|
||||
tx.vout.append(CTxOut(0, CScript()))
|
||||
tx.wit.vtxinwit = [CTxInWitness()]
|
||||
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
|
||||
tx.calc_sha256()
|
||||
return tx
|
||||
|
||||
|
||||
class BadInputOutpointIndex(BadTxTemplate):
|
||||
# Won't be rejected - nonexistent outpoint index is treated as an orphan since the coins
|
||||
|
|
|
@ -7,6 +7,7 @@ import copy
|
|||
import time
|
||||
|
||||
from test_framework.blocktools import (
|
||||
add_witness_commitment,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
create_tx_with_script,
|
||||
|
@ -1400,6 +1401,9 @@ class FullBlockTest(BitcoinTestFramework):
|
|||
self.add_transactions_to_block(block, new_transactions)
|
||||
old_sha256 = block.sha256
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
has_witness_tx = any(not tx.wit.is_null() for tx in block.vtx)
|
||||
if has_witness_tx:
|
||||
add_witness_commitment(block)
|
||||
block.solve()
|
||||
# Update the internal state just like in next_block
|
||||
self.tip = block
|
||||
|
|
|
@ -87,7 +87,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
|||
# 0.21.x and 22.x would both produce bad derivation paths when topping up an inactive hd chain
|
||||
# Make sure that this is being automatically cleaned up by migration
|
||||
node_master = self.nodes[1]
|
||||
node_v22 = self.nodes[self.num_nodes - 5]
|
||||
node_v22 = self.nodes[self.num_nodes - 3]
|
||||
wallet_name = "bad_deriv_path"
|
||||
node_v22.createwallet(wallet_name=wallet_name, descriptors=False)
|
||||
bad_deriv_wallet = node_v22.get_wallet_rpc(wallet_name)
|
||||
|
|
Loading…
Add table
Reference in a new issue