mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
qa: timelock coinbase transactions created in functional tests
This commit is contained in:
parent
80e6ad9e30
commit
a5f52cfcc4
3 changed files with 10 additions and 1 deletions
|
@ -831,6 +831,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||||
self.log.info("Reject a block with a transaction with a duplicate hash of a previous transaction (BIP30)")
|
self.log.info("Reject a block with a transaction with a duplicate hash of a previous transaction (BIP30)")
|
||||||
self.move_tip(60)
|
self.move_tip(60)
|
||||||
b61 = self.next_block(61)
|
b61 = self.next_block(61)
|
||||||
|
b61.vtx[0].nLockTime = 0
|
||||||
b61.vtx[0].vin[0].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
|
b61.vtx[0].vin[0].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
|
||||||
b61.vtx[0].rehash()
|
b61.vtx[0].rehash()
|
||||||
b61 = self.update_block(61, [])
|
b61 = self.update_block(61, [])
|
||||||
|
@ -853,6 +854,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||||
b_spend_dup_cb = self.update_block('spend_dup_cb', [tx])
|
b_spend_dup_cb = self.update_block('spend_dup_cb', [tx])
|
||||||
|
|
||||||
b_dup_2 = self.next_block('dup_2')
|
b_dup_2 = self.next_block('dup_2')
|
||||||
|
b_dup_2.vtx[0].nLockTime = 0
|
||||||
b_dup_2.vtx[0].vin[0].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
|
b_dup_2.vtx[0].vin[0].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
|
||||||
b_dup_2.vtx[0].rehash()
|
b_dup_2.vtx[0].rehash()
|
||||||
b_dup_2 = self.update_block('dup_2', [])
|
b_dup_2 = self.update_block('dup_2', [])
|
||||||
|
|
|
@ -30,6 +30,7 @@ from test_framework.blocktools import (
|
||||||
|
|
||||||
from test_framework.messages import (
|
from test_framework.messages import (
|
||||||
CBlock,
|
CBlock,
|
||||||
|
SEQUENCE_FINAL,
|
||||||
)
|
)
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
@ -61,6 +62,10 @@ class MiningMainnetTest(BitcoinTestFramework):
|
||||||
block.nBits = DIFF_1_N_BITS
|
block.nBits = DIFF_1_N_BITS
|
||||||
block.nNonce = blocks['nonces'][height - 1]
|
block.nNonce = blocks['nonces'][height - 1]
|
||||||
block.vtx = [create_coinbase(height=height, script_pubkey=bytes.fromhex(COINBASE_SCRIPT_PUBKEY), retarget_period=2016)]
|
block.vtx = [create_coinbase(height=height, script_pubkey=bytes.fromhex(COINBASE_SCRIPT_PUBKEY), retarget_period=2016)]
|
||||||
|
# The alternate mainnet chain was mined with non-timelocked coinbase txs.
|
||||||
|
block.vtx[0].nLockTime = 0
|
||||||
|
block.vtx[0].vin[0].nSequence = SEQUENCE_FINAL
|
||||||
|
block.vtx[0].rehash()
|
||||||
block.hashMerkleRoot = block.calc_merkle_root()
|
block.hashMerkleRoot = block.calc_merkle_root()
|
||||||
block.rehash()
|
block.rehash()
|
||||||
block_hex = block.serialize(with_witness=False).hex()
|
block_hex = block.serialize(with_witness=False).hex()
|
||||||
|
|
|
@ -29,6 +29,7 @@ from .messages import (
|
||||||
tx_from_hex,
|
tx_from_hex,
|
||||||
uint256_from_compact,
|
uint256_from_compact,
|
||||||
WITNESS_SCALE_FACTOR,
|
WITNESS_SCALE_FACTOR,
|
||||||
|
MAX_SEQUENCE_NONFINAL,
|
||||||
)
|
)
|
||||||
from .script import (
|
from .script import (
|
||||||
CScript,
|
CScript,
|
||||||
|
@ -151,7 +152,8 @@ def create_coinbase(height, pubkey=None, *, script_pubkey=None, extra_output_scr
|
||||||
If extra_output_script is given, make a 0-value output to that
|
If extra_output_script is given, make a 0-value output to that
|
||||||
script. This is useful to pad block weight/sigops as needed. """
|
script. This is useful to pad block weight/sigops as needed. """
|
||||||
coinbase = CTransaction()
|
coinbase = CTransaction()
|
||||||
coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), script_BIP34_coinbase_height(height), SEQUENCE_FINAL))
|
coinbase.nLockTime = height - 1
|
||||||
|
coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), script_BIP34_coinbase_height(height), MAX_SEQUENCE_NONFINAL))
|
||||||
coinbaseoutput = CTxOut()
|
coinbaseoutput = CTxOut()
|
||||||
coinbaseoutput.nValue = nValue * COIN
|
coinbaseoutput.nValue = nValue * COIN
|
||||||
if nValue == 50:
|
if nValue == 50:
|
||||||
|
|
Loading…
Add table
Reference in a new issue