Difference between revisions of "Finalize Transaction"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
* An unfinished transaction is ready for processing. | * An unfinished transaction is ready for processing. | ||
− | ** The transaction may or may not have have | + | ** The transaction may or may not have have an output |
** The transaction is valid | ** The transaction is valid | ||
*** Not too big | *** Not too big | ||
*** Inputs are sufficient to cover outputs and required fees | *** Inputs are sufficient to cover outputs and required fees | ||
− | ** A change output | + | ** A change output does not yet exist in the transaction |
− | *** | + | *** A change output may be added without causing the transaction to exceed size limits |
==Sequence== | ==Sequence== | ||
− | # If the transaction | + | # If the transaction contains no outputs and no inputs, then it may be discarded. |
# The change amount is calculated by: Σ(txin) - ( Σ(txout) + fees ) | # The change amount is calculated by: Σ(txin) - ( Σ(txout) + fees ) | ||
## If the change amount is greater than zero: | ## If the change amount is greater than zero: | ||
− | ### | + | ### Add a change output of the appropriate value |
− | + | ### Increment the <code>nextchangestart</code> object in the withdrawal status list | |
− | ## | ||
# 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. |
Revision as of 11:09, 4 November 2014
Initial Conditions
- An unfinished transaction is ready for processing.
- The transaction may or may not have have an output
- The transaction is valid
- Not too big
- Inputs are sufficient to cover outputs and required fees
- A change output does not yet exist in the transaction
- A change output may be added without causing the transaction to exceed size limits
Sequence
- If the transaction contains no outputs 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:
- Add a change output of the appropriate value
- Increment the
nextchangestart
object in the withdrawal status list
- 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.