mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-28 17:12:58 +02:00
rpc: add nBits to getmininginfo
Also expands nBits test coverage.
This commit is contained in:
@@ -65,6 +65,10 @@ NORMAL_GBT_REQUEST_PARAMS = {"rules": ["segwit"]}
|
||||
VERSIONBITS_LAST_OLD_BLOCK_VERSION = 4
|
||||
MIN_BLOCKS_TO_KEEP = 288
|
||||
|
||||
REGTEST_N_BITS = 0x207fffff # difficulty retargeting is disabled in REGTEST chainparams"
|
||||
|
||||
def nbits_str(nbits):
|
||||
return f"{nbits:08x}"
|
||||
|
||||
def create_block(hashprev=None, coinbase=None, ntime=None, *, version=None, tmpl=None, txlist=None):
|
||||
"""Create a block (with regtest difficulty)."""
|
||||
@@ -77,7 +81,7 @@ def create_block(hashprev=None, coinbase=None, ntime=None, *, version=None, tmpl
|
||||
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
|
||||
block.nBits = REGTEST_N_BITS
|
||||
if coinbase is None:
|
||||
coinbase = create_coinbase(height=tmpl['height'])
|
||||
block.vtx.append(coinbase)
|
||||
|
Reference in New Issue
Block a user