Add Next Output

From Open Transactions
Jump to navigation Jump to search

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.


  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