Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/txtools.py
Show All 38 Lines | while required_padding > 0: | ||||
assert padding_len >= 0, "Can't pad less than 0 bytes, trying {}".format( | assert padding_len >= 0, "Can't pad less than 0 bytes, trying {}".format( | ||||
padding_len) | padding_len) | ||||
# We will end up with less than 1 UTXO of bytes after this, add | # We will end up with less than 1 UTXO of bytes after this, add | ||||
# them to this txn | # them to this txn | ||||
next_iteration_padding = required_padding - padding_len - extra_bytes | next_iteration_padding = required_padding - padding_len - extra_bytes | ||||
if next_iteration_padding > 0 and next_iteration_padding < extra_bytes: | if next_iteration_padding > 0 and next_iteration_padding < extra_bytes: | ||||
padding_len += next_iteration_padding | padding_len += next_iteration_padding | ||||
# If we're at exactly, or below, extra_bytes we don't want a 1 extra byte padding | # If we're at exactly, or below, extra_bytes we don't want a 1 extra | ||||
# byte padding | |||||
if padding_len <= extra_bytes: | if padding_len <= extra_bytes: | ||||
tx.vout.append(CTxOut(0, CScript([OP_RETURN]))) | tx.vout.append(CTxOut(0, CScript([OP_RETURN]))) | ||||
else: | else: | ||||
# Subtract the overhead for the TxOut | # Subtract the overhead for the TxOut | ||||
padding_len -= extra_bytes | padding_len -= extra_bytes | ||||
padding = random.randrange( | padding = random.randrange( | ||||
1 << 8 * padding_len - 2, 1 << 8 * padding_len - 1) | 1 << 8 * padding_len - 2, 1 << 8 * padding_len - 1) | ||||
tx.vout.append( | tx.vout.append( | ||||
Show All 16 Lines |