Difference between revisions of "Finalize Transaction"
Jump to navigation
Jump to search
(Created page with "<div style="float: right"><include iframe src="https://www.lucidchart.com/documents/embeddedchart/79c726f4-9d4e-4a3c-bd20-6556099d24ab" width="300" height="1004" frameborder="...") |
|||
Line 21: | Line 21: | ||
# Calculate an [[ntxid]] for the transaction for tracking purposes. | # Calculate an [[ntxid]] for the transaction for tracking purposes. | ||
# Loop through every (non-change) output in the transaction and update the [[withdrawal status]] object for the corresponding output. | # Loop through every (non-change) output in the transaction and update the [[withdrawal status]] object for the corresponding output. | ||
− | ## The withdrawal status object contain an entry for every output in the transaction, where each entry has an <code> | + | ## The withdrawal status object contain an entry for every output in the transaction, where each entry has an <code>outpoints</code> object containing a nil <code>ntxid</code>, an <code>index</code> matching the output position index, and a matching <code>amount</code>. |
## Update the <code>ntxid</code> value from nil to the ntxid for the transaction. | ## Update the <code>ntxid</code> value from nil to the ntxid for the transaction. | ||
# Add the fees from this transaction to the <code>fees</code> property of the withdrawal status object. | # Add the fees from this transaction to the <code>fees</code> property of the withdrawal status object. |
Revision as of 10:23, 23 October 2014
Initial Conditions
- An unfinished transaction is ready for processing.
- The transaction may or may not have have a useful (non-change) output
- The transaction is valid
- Not too big
- Inputs are sufficient to cover outputs and required fees
- A change output may exist in the transaction
- If a change output exists, it has a nil position and a nil value.
Sequence
- If the transaction only contains a change output and no inputs, then it may be discarded.
- The change amount is calculated by: Σ(txin) - ( Σ(txout) + fees )
- If the change amount is greater than zero:
- Set the value of the output
- Set the position of the output to the next unused value after the last non-change output.
- If the change amount is zero, then the change output is removed from the transaction.
- If the change amount is greater than zero:
- Calculate an ntxid for the transaction for tracking purposes.
- Loop through every (non-change) output in the transaction and update the withdrawal status object for the corresponding output.
- The withdrawal status object contain an entry for every output in the transaction, where each entry has an
outpoints
object containing a nilntxid
, anindex
matching the output position index, and a matchingamount
. - Update the
ntxid
value from nil to the ntxid for the transaction.
- The withdrawal status object contain an entry for every output in the transaction, where each entry has an
- Add the fees from this transaction to the
fees
property of the withdrawal status object. - Move the transaction to the finished transaction list.