Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/blocktools.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2019 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Utilities for manipulating blocks and transactions.""" | """Utilities for manipulating blocks and transactions.""" | ||||
from .script import ( | from .script import ( | ||||
CScript, | CScript, | ||||
OP_CHECKSIG, | OP_CHECKSIG, | ||||
OP_DUP, | OP_DUP, | ||||
Show All 11 Lines | from .messages import ( | ||||
CTxOut, | CTxOut, | ||||
FromHex, | FromHex, | ||||
ToHex, | ToHex, | ||||
ser_string, | ser_string, | ||||
) | ) | ||||
from .txtools import pad_tx | from .txtools import pad_tx | ||||
from .util import assert_equal, satoshi_round | from .util import assert_equal, satoshi_round | ||||
# Create a block (with regtest difficulty) | # Genesis block time (regtest) | ||||
TIME_GENESIS_BLOCK = 1296688602 | |||||
def create_block(hashprev, coinbase, nTime=None): | def create_block(hashprev, coinbase, nTime=None): | ||||
"""Create a block (with regtest difficulty).""" | |||||
block = CBlock() | block = CBlock() | ||||
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 | ||||
block.nBits = 0x207fffff # Will break after a difficulty adjustment... | block.nBits = 0x207fffff # Will break after a difficulty adjustment... | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |