Creating the transaction to double-spend

The double-spendable transaction is a transaction with the same value as the first transaction but with a different recipient address. The fund transfer is reversed by addressing the entire fund back to the attacker. All the transaction outputs except the transaction output carrying change are removed from the transaction. Since the change transaction output is addressed to the attacker, the entire fund value is assigned to this output transaction.

A similar process is used as before to calculate the fee for the entire transaction. A higher transaction fee per byte, feeperbyte2, is used when calculating the fee for the transaction:

tx.vout = tx.vout[0:1] change_txout = tx.vout[0] value_out = value_in ...

Get Foundations of Blockchain now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.