Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-transaction-ordering.py
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | def next_block(self, number, spend=None, tx_count=0): | ||||
# This also ensures that transaction are larger than 100 bytes. | # This also ensures that transaction are larger than 100 bytes. | ||||
rand = random.getrandbits(256) | rand = random.getrandbits(256) | ||||
tx.vout.append(CTxOut(0, CScript([rand, OP_RETURN]))) | tx.vout.append(CTxOut(0, CScript([rand, OP_RETURN]))) | ||||
return tx | return tx | ||||
tx = get_base_transaction() | tx = get_base_transaction() | ||||
# Make it the same format as transaction added for padding and save the size. | # Make it the same format as transaction added for padding and save the size. | ||||
# It's missing the padding output, so we add a constant to account for it. | # It's missing the padding output, so we add a constant to account | ||||
# for it. | |||||
tx.rehash() | tx.rehash() | ||||
# Add the transaction to the block | # Add the transaction to the block | ||||
self.add_transactions_to_block(block, [tx]) | self.add_transactions_to_block(block, [tx]) | ||||
# If we have a transaction count requirement, just fill the block until we get there | # If we have a transaction count requirement, just fill the block | ||||
# until we get there | |||||
while len(block.vtx) < tx_count: | while len(block.vtx) < tx_count: | ||||
# Create the new transaction and add it. | # Create the new transaction and add it. | ||||
tx = get_base_transaction() | tx = get_base_transaction() | ||||
self.add_transactions_to_block(block, [tx]) | self.add_transactions_to_block(block, [tx]) | ||||
# Now that we added a bunch of transaction, we need to recompute | # Now that we added a bunch of transaction, we need to recompute | ||||
# the merkle root. | # the merkle root. | ||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |