|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# Copyright (c) 2015-2022 The Bitcoin Core developers
|
|
|
|
|
# Copyright (c) 2015-present The Bitcoin Core developers
|
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
"""Utilities for manipulating blocks and transactions."""
|
|
|
|
@ -74,7 +74,7 @@ def create_block(hashprev=None, coinbase=None, ntime=None, *, version=None, tmpl
|
|
|
|
|
block.nVersion = version or tmpl.get('version') or VERSIONBITS_LAST_OLD_BLOCK_VERSION
|
|
|
|
|
block.nTime = ntime or tmpl.get('curtime') or int(time.time() + 600)
|
|
|
|
|
block.hashPrevBlock = hashprev or int(tmpl['previousblockhash'], 0x10)
|
|
|
|
|
if tmpl and not tmpl.get('bits') is None:
|
|
|
|
|
if tmpl and tmpl.get('bits') is not None:
|
|
|
|
|
block.nBits = struct.unpack('>I', bytes.fromhex(tmpl['bits']))[0]
|
|
|
|
|
else:
|
|
|
|
|
block.nBits = 0x207fffff # difficulty retargeting is disabled in REGTEST chainparams
|
|
|
|
|