Difference between revisions of "Add Next Output"

From Open Transactions
Jump to navigation Jump to search
(Created page with "<div style="float: right"><include iframe src="https://www.lucidchart.com/documents/embeddedchart/3e9b2758-338e-40f7-8fe2-e036fda68157" width="600" height="800" frameborder="0...")
 
(Sequence)
 
Line 19: Line 19:
 
###* <code>index</code>: next unused
 
###* <code>index</code>: next unused
 
###* <code>amount</code>: copied from [[Outputs (Voting Pool Wallet API)|outputs]] list.
 
###* <code>amount</code>: copied from [[Outputs (Voting Pool Wallet API)|outputs]] list.
# Check that the transaction does not exceed size limits. If it does, follow the [[Oversize Transaction]] procedure.
+
# Check that the transaction does not exceed [[Initialize_New_Transaction#Size checking|size limits]]. If it does, follow the [[Oversize Transaction]] procedure.
 
# Compare the sum of the inputs to the sum of the outputs and required transaction fee to determine if more inputs are required.
 
# Compare the sum of the inputs to the sum of the outputs and required transaction fee to determine if more inputs are required.
 
## If no more inputs are required, then update the <code>status</code> for this output to "success".
 
## If no more inputs are required, then update the <code>status</code> for this output to "success".

Latest revision as of 11:01, 4 November 2014

Initial Conditions

The output stack contains at least one output.

There is a transaction in progress which is ready to accept new outputs. This transaction is either empty or it contains 1 or more outputs.

If the transaction already contains outputs, then it also contains sufficient inputs to cover those outputs and any required transaction fees without exceeding size limits. This is because it must have already successfully passed through this procedure before.

Sequence

  1. Locate the entry for this output in the withdrawal status object by finding the corresponding outBailmentID.
  2. Validate the output address.
    1. If it is invalid, update status entry for this output to "invalid" and exit from this procedure.
    2. If it is valid, add it to the transaction.
      1. Add a new entry to the transaction array for this output:
        • ntxid: nil
        • index: next unused
        • amount: copied from outputs list.
  3. Check that the transaction does not exceed size limits. If it does, follow the Oversize Transaction procedure.
  4. Compare the sum of the inputs to the sum of the outputs and required transaction fee to determine if more inputs are required.
    1. If no more inputs are required, then update the status for this output to "success".
  5. If more inputs are required, then check to see if any more are available.
    1. According to the initial conditions, the input stack can not be empty on the first run through this loop.
    2. If the input stack is empty at this point, then the output has added at least one input beyond what was needed to satisfy the prior output (if there was a prior output)
    3. If the input stack is empty, then the output can only be partially fulfilled. Follow the Split Output procedure.
  6. Add the next input from the stack, and continue the loop at step 2.

The loop will continue until either:

  • The transaction contains sufficient input value to satisfy the output plus transaction fees
  • The transaction exceeds size limits
  • There is not enough input value, but no more inputs are available