January 2019
Beginner to intermediate
372 pages
11h 17m
English
Transaction inputs are constructed by selecting the unspent transactions that will satisfy the required transaction value (0.1 BTC) and transaction fees.
The while loop in the code is terminated only after enough input values are created to satisfy the output values and the minimum transaction fee for the transaction. The delta_fee represents the additional fee required to satisfy the transaction fee. The delta_fee is deducted from the value_out if it is a positive value, else it is added:
value_in = 0 value_out = sum([vout.nValue for vout in tx.vout]) unspent = sorted(rpc.listunspent(1), key=lambda x: x['amount']) while (value_in - value_out) / len(tx.serialize()) < feeperbyte1: delta_fee = math.ceil((feeperbyte1 ...