(self, height, prev_hash, blocks, node)
| 54 | ) |
| 55 | |
| 56 | def mine(self, height, prev_hash, blocks, node): |
| 57 | self.log.debug(f"height={height}") |
| 58 | block = CBlock() |
| 59 | block.nVersion = 0x20000000 |
| 60 | block.hashPrevBlock = int(prev_hash, 16) |
| 61 | block.nTime = blocks['timestamps'][height - 1] |
| 62 | block.nBits = DIFF_1_N_BITS if height < 2016 else DIFF_4_N_BITS |
| 63 | block.nNonce = blocks['nonces'][height - 1] |
| 64 | block.vtx = [create_coinbase(height=height, script_pubkey=bytes.fromhex(COINBASE_SCRIPT_PUBKEY), halving_period=210000)] |
| 65 | # The alternate mainnet chain was mined with non-timelocked coinbase txs. |
| 66 | block.vtx[0].nLockTime = 0 |
| 67 | block.vtx[0].vin[0].nSequence = SEQUENCE_FINAL |
| 68 | block.hashMerkleRoot = block.calc_merkle_root() |
| 69 | block_hex = block.serialize(with_witness=False).hex() |
| 70 | self.log.debug(block_hex) |
| 71 | assert_equal(node.submitblock(block_hex), None) |
| 72 | prev_hash = node.getbestblockhash() |
| 73 | assert_equal(prev_hash, block.hash_hex) |
| 74 | return prev_hash |
| 75 | |
| 76 | |
| 77 | def run_test(self): |
no test coverage detected