Skip to Content
Foundations of Blockchain
book

Foundations of Blockchain

by Koshik Raj
January 2019
Beginner to intermediate
372 pages
11h 17m
English
Packt Publishing
Content preview from Foundations of Blockchain

Creating the first transaction

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Blockchain Basics

Blockchain Basics

Daniel Drescher
What Is Blockchain?

What Is Blockchain?

Sir John Hargrave, Evan Karnoupakis
Mastering Blockchain

Mastering Blockchain

Lorne Lantz, Daniel Cawrey

Publisher Resources

ISBN: 9781789139396Supplemental Content