Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/blocktools.py
Show All 25 Lines | |||||
) | ) | ||||
from .txtools import pad_tx | from .txtools import pad_tx | ||||
from .util import assert_equal, satoshi_round | from .util import assert_equal, satoshi_round | ||||
# Genesis block time (regtest) | # Genesis block time (regtest) | ||||
TIME_GENESIS_BLOCK = 1296688602 | TIME_GENESIS_BLOCK = 1296688602 | ||||
def create_block(hashprev, coinbase, ntime=None): | def create_block(hashprev, coinbase, ntime=None, *, version=1): | ||||
"""Create a block (with regtest difficulty).""" | """Create a block (with regtest difficulty).""" | ||||
block = CBlock() | block = CBlock() | ||||
block.nVersion = version | |||||
if ntime is None: | if ntime is None: | ||||
import time | import time | ||||
block.nTime = int(time.time() + 600) | block.nTime = int(time.time() + 600) | ||||
else: | else: | ||||
block.nTime = ntime | block.nTime = ntime | ||||
block.hashPrevBlock = hashprev | block.hashPrevBlock = hashprev | ||||
# difficulty retargeting is disabled in REGTEST chainparams | # difficulty retargeting is disabled in REGTEST chainparams | ||||
block.nBits = 0x207fffff | block.nBits = 0x207fffff | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |