<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://opentransactions.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=GuilhermeSalgado</id>
	<title>Open Transactions - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://opentransactions.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=GuilhermeSalgado"/>
	<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/Special:Contributions/GuilhermeSalgado"/>
	<updated>2026-04-28T23:05:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.32.2</generator>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Split_Output&amp;diff=3137</id>
		<title>Split Output</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Split_Output&amp;diff=3137"/>
		<updated>2014-12-02T22:57:58Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/c72ce59c-65c0-4a90-943a-c669bac5a737&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is used when either the inputs required to satisfy a single output can not fit within transaction size limits (due to a large output or small inputs) or there are not enough inputs to satisfy the last output added to the transaction.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;outBailment&amp;lt;/code&amp;gt; will be split across two or more transactions in the case of an oversize transaction, or be partially satisfied in the case of not sufficient inputs.&lt;br /&gt;
&lt;br /&gt;
==Initial Conditions==&lt;br /&gt;
&lt;br /&gt;
* The transaction being constructed contains one or more outputs, and many inputs.&lt;br /&gt;
* The transaction did not exceed any size limits until the most recent input was added.&lt;br /&gt;
&lt;br /&gt;
==Sequence==&lt;br /&gt;
&lt;br /&gt;
# Update the value of the last output in the transaction to be the sum of the inputs minus the required transaction fee and the total of all outputs except the last one.&lt;br /&gt;
# Make a copy of the [[Outputs (Voting Pool Wallet API)|outputs]] object corresponding to this outBailmentID.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; field of the copied output by subtracting the value determined in step 1.&lt;br /&gt;
# Push this new output to the output stack.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field for this outBailmentID in the [[withdrawal status]] object to &amp;quot;partial-&amp;quot;.&lt;br /&gt;
# Perform the [[Finalize Transaction]] Procedure.&lt;br /&gt;
# [[Initialize New Transaction|Initialize]] a new transaction.&lt;br /&gt;
&lt;br /&gt;
[[Category:Transaction Construction Algorithm (voting pools)|12]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Split_Output&amp;diff=3136</id>
		<title>Split Output</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Split_Output&amp;diff=3136"/>
		<updated>2014-12-02T16:32:24Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/c72ce59c-65c0-4a90-943a-c669bac5a737&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is used when either the inputs required to satisfy a single output can not fit within transaction size limits (due to a large output or small inputs) or there are not enough inputs to satisfy the last output added to the transaction.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;outBailment&amp;lt;/code&amp;gt; will be split across two or more transactions in the case of an oversize transaction, or be partially satisfied in the case of not sufficient inputs.&lt;br /&gt;
&lt;br /&gt;
==Initial Conditions==&lt;br /&gt;
&lt;br /&gt;
* The transaction being constructed contains one or more outputs, and many inputs.&lt;br /&gt;
* The transaction did not exceed any size limits until the most recent input was added.&lt;br /&gt;
&lt;br /&gt;
==Sequence==&lt;br /&gt;
&lt;br /&gt;
# Update the value of the last output in the transaction to be the sum of the inputs minus the required transaction fee and the total of all inputs except the last one.&lt;br /&gt;
# Make a copy of the [[Outputs (Voting Pool Wallet API)|outputs]] object corresponding to this outBailmentID.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; field of the copied output by subtracting the value determined in step 1.&lt;br /&gt;
# Push this new output to the output stack.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field for this outBailmentID in the [[withdrawal status]] object to &amp;quot;partial-&amp;quot;.&lt;br /&gt;
# Perform the [[Finalize Transaction]] Procedure.&lt;br /&gt;
# [[Initialize New Transaction|Initialize]] a new transaction.&lt;br /&gt;
&lt;br /&gt;
[[Category:Transaction Construction Algorithm (voting pools)|12]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Split_Output&amp;diff=3135</id>
		<title>Split Output</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Split_Output&amp;diff=3135"/>
		<updated>2014-12-02T10:19:39Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/c72ce59c-65c0-4a90-943a-c669bac5a737&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is used when either the inputs required to satisfy a single output can not fit within transaction size limits (due to a large output or small inputs) or there are not enough inputs to satisfy a given output.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;outBailment&amp;lt;/code&amp;gt; will be split across two or more transactions in the case of an oversize transaction, or be partially satisfied in the case of not sufficient inputs.&lt;br /&gt;
&lt;br /&gt;
==Initial Conditions==&lt;br /&gt;
&lt;br /&gt;
* The transaction being constructed contains one or more outputs, and many inputs.&lt;br /&gt;
* The transaction did not exceed any size limits until the most recent input was added.&lt;br /&gt;
&lt;br /&gt;
==Sequence==&lt;br /&gt;
&lt;br /&gt;
# Update the value of the output in the transaction to be the sum of the inputs minus the required transaction fee.&lt;br /&gt;
# Make a copy of the [[Outputs (Voting Pool Wallet API)|outputs]] object corresponding to this outBailmentID.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; field of the copied output by subtracting the value determined in step 1.&lt;br /&gt;
# Push this new output to the output stack.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field for this outBailmentID in the [[withdrawal status]] object to &amp;quot;partial-&amp;quot;.&lt;br /&gt;
# Perform the [[Finalize Transaction]] Procedure.&lt;br /&gt;
# [[Initialize New Transaction|Initialize]] a new transaction.&lt;br /&gt;
&lt;br /&gt;
[[Category:Transaction Construction Algorithm (voting pools)|12]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Split_Output&amp;diff=3134</id>
		<title>Split Output</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Split_Output&amp;diff=3134"/>
		<updated>2014-12-02T10:14:58Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/c72ce59c-65c0-4a90-943a-c669bac5a737&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is used when, either due to a large output or small inputs, the inputs required to satisfy a single output can not fit within transaction size limits.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;outBailment&amp;lt;/code&amp;gt; will be split across two or more transactions.&lt;br /&gt;
&lt;br /&gt;
==Initial Conditions==&lt;br /&gt;
&lt;br /&gt;
* The transaction being constructed contains one output, and many inputs.&lt;br /&gt;
* The transaction did not exceed any size limits until the most recent input was added.&lt;br /&gt;
&lt;br /&gt;
==Sequence==&lt;br /&gt;
&lt;br /&gt;
# Update the value of the output in the transaction to be the sum of the inputs minus the required transaction fee.&lt;br /&gt;
# Make a copy of the [[Outputs (Voting Pool Wallet API)|outputs]] object corresponding to this outBailmentID.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; field of the copied output by subtracting the value determined in step 1.&lt;br /&gt;
# Push this new output to the output stack.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field for this outBailmentID in the [[withdrawal status]] object to &amp;quot;partial-&amp;quot;.&lt;br /&gt;
# Perform the [[Finalize Transaction]] Procedure.&lt;br /&gt;
# [[Initialize New Transaction|Initialize]] a new transaction.&lt;br /&gt;
&lt;br /&gt;
[[Category:Transaction Construction Algorithm (voting pools)|12]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Finalize_Transaction&amp;diff=3104</id>
		<title>Finalize Transaction</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Finalize_Transaction&amp;diff=3104"/>
		<updated>2014-10-23T10:23:43Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/79c726f4-9d4e-4a3c-bd20-6556099d24ab&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Initial Conditions==&lt;br /&gt;
&lt;br /&gt;
* An unfinished transaction is ready for processing.&lt;br /&gt;
** The transaction may or may not have have a useful (non-change) output&lt;br /&gt;
** The transaction is valid&lt;br /&gt;
*** Not too big&lt;br /&gt;
*** Inputs are sufficient to cover outputs and required fees&lt;br /&gt;
** A change output may exist in the transaction&lt;br /&gt;
*** If a change output exists, it has a nil position and a nil value.&lt;br /&gt;
&lt;br /&gt;
==Sequence==&lt;br /&gt;
&lt;br /&gt;
# If the transaction only contains a change output and no inputs, then it may be discarded.&lt;br /&gt;
# The change amount is calculated by: Σ(txin) - ( Σ(txout) + fees )&lt;br /&gt;
## If the change amount is greater than zero:&lt;br /&gt;
### Set the value of the output&lt;br /&gt;
### Set the position of the output to the next unused value after the last non-change output.&lt;br /&gt;
## If the change amount is zero, then the change output is removed from the transaction.&lt;br /&gt;
# Calculate an [[ntxid]] for the transaction for tracking purposes.&lt;br /&gt;
# Loop through every (non-change) output in the transaction and update the [[withdrawal status]] object for the corresponding output.&lt;br /&gt;
## The withdrawal status object contain an entry for every output in the transaction, where each entry has an &amp;lt;code&amp;gt;outpoints&amp;lt;/code&amp;gt; object containing a nil &amp;lt;code&amp;gt;ntxid&amp;lt;/code&amp;gt;, an &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; matching the output position index, and a matching &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;.&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;ntxid&amp;lt;/code&amp;gt; value from nil to the ntxid for the transaction.&lt;br /&gt;
# Add the fees from this transaction to the &amp;lt;code&amp;gt;fees&amp;lt;/code&amp;gt; property of the withdrawal status object.&lt;br /&gt;
# Move the transaction to the finished transaction list.&lt;br /&gt;
&lt;br /&gt;
[[Category:Transaction Construction Algorithm (voting pools)|05]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Update_Status&amp;diff=3103</id>
		<title>Update Status</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Update_Status&amp;diff=3103"/>
		<updated>2014-10-23T10:13:13Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/b4dcbb56-3b87-4f56-b249-dfd4276c7cc4&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;800&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Initial Conditions==&lt;br /&gt;
&lt;br /&gt;
* Every outBailmentID in the [[Outputs (Voting Pool Wallet API)|output]] list provided has a non-nil &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value in the [[withdrawal status]] object.&lt;br /&gt;
&lt;br /&gt;
==Sequence==&lt;br /&gt;
&lt;br /&gt;
# Update the status for any split outBailments which exist:&lt;br /&gt;
## Split outBailments have more than one item in their &amp;lt;code&amp;gt;outpoints&amp;lt;/code&amp;gt; array and have an existing &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value of &amp;quot;success&amp;quot;.&lt;br /&gt;
## Change the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; for all split outBailments from &amp;quot;success&amp;quot; to &amp;quot;split&amp;quot;.&lt;br /&gt;
# Update the status for any partial outBailments which exist:&lt;br /&gt;
## Partial outBailments have existing &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value of &amp;quot;partial-&amp;quot;.&lt;br /&gt;
## Calculate the total missing value needed to satisfy the partial outputs.&lt;br /&gt;
## The missing value of an outBailment is the originally-requested size of the outBailment minus the sum of all outputs created to satisfy it (if any exist).&lt;br /&gt;
### Obtain a list of eligible inputs from the next un-thawed series and calculate their total value.&lt;br /&gt;
### If the eligible value of the next un-thawed series is greater than the total missing value, then the next un-thawed series is the target series.&lt;br /&gt;
#### If not, repeat the above process while keeping a running total of eligible value until a target series is located.&lt;br /&gt;
### Append the number of the target series to the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value for every partial series.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; value.&lt;br /&gt;
## If the input stack is empty, &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; is the first [[address identifier]] for the next un-thawed series.&lt;br /&gt;
## If the input stack is not empty, &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; is the [[address identifier]] for the next input in the stack.&lt;br /&gt;
&lt;br /&gt;
[[Category:Transaction Construction Algorithm (voting pools)|07]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Transaction_Construction_Algorithm_(voting_pools)&amp;diff=3013</id>
		<title>Transaction Construction Algorithm (voting pools)</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Transaction_Construction_Algorithm_(voting_pools)&amp;diff=3013"/>
		<updated>2014-10-02T17:16:45Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: /* Sequence */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
In order to avoid an expensive and error-prone consensus process, it is mandatory for wallets to be able to construct withdrawal transactions in a deterministic manner, assuming they are given the withdrawal requests in a deterministic order. Once this is accomplished, then it only becomes necessary for wallets to share signatures among themselves because they know they all signed the exact same bitcoin transaction.&lt;br /&gt;
&lt;br /&gt;
==Procedure==&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/eb960c32-71d4-4cfc-8f49-63a82b343608/0&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
The [[startwithdrawal]] API call has been received by the wallet, and all the arguments have been checked for errors.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
The basic flow of the procedure is:&lt;br /&gt;
&lt;br /&gt;
# Gather accounting information from the API call arguments&lt;br /&gt;
# Validate and sort the output list&lt;br /&gt;
# Start a new transactions&lt;br /&gt;
# Add outputs to the transaction until either all outputs are added or all inputs are used.&lt;br /&gt;
# Make sure all generated transactions are ready for signing.&lt;br /&gt;
# Create a list of all signatures which the wallet is capable of generating.&lt;br /&gt;
# Create a status list containing the deposition of every output the caller specified.&lt;br /&gt;
# Return the status list and signature list to the caller.&lt;br /&gt;
&lt;br /&gt;
Each step in this chart is more fully described below.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Preparation===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/0dd5f7d6-8511-4440-a535-32ad8508d146&amp;quot; width=&amp;quot;150&amp;quot; height=&amp;quot;502&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
The [[startwithdrawal]] API call has been received by the wallet, and all the arguments have been checked for errors.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# The algorithm must keep track of the next change address to be used. The initial value is supplied as the &amp;lt;code&amp;gt;[[Startwithdrawal#Arguments|changestart]]&amp;lt;/code&amp;gt; argument. Any time a change output is allocated, the index value of the [[address identifier]] is incremented, and if a change output is remove from a transaction the index value is decremented. The final value will be returned to the caller as the &amp;lt;code&amp;gt;[[Withdrawal status|nextchangestart]]&amp;lt;/code&amp;gt; value in the [[Withdrawal status| withdrawal status list]].&lt;br /&gt;
# Prepare an empty list for holding transactions as they are constructed and before they are signed.&lt;br /&gt;
# Prepare an empty array to hold the transaction signatures which will be returned to the caller as the &amp;lt;code&amp;gt;[[siglist| signatures]]&amp;lt;/code&amp;gt; value.&lt;br /&gt;
# Prepare an &amp;lt;code&amp;gt;withdrawal status&amp;lt;/code&amp;gt; object.&lt;br /&gt;
## &amp;lt;code&amp;gt;roundID&amp;lt;/code&amp;gt;: copied from &amp;lt;code&amp;gt;roundID&amp;lt;/code&amp;gt; argument&lt;br /&gt;
## &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt;: nil&lt;br /&gt;
## &amp;lt;code&amp;gt;nextchangestart&amp;lt;/code&amp;gt;: nil&lt;br /&gt;
## &amp;lt;code&amp;gt;fees&amp;lt;/code&amp;gt;: 0&lt;br /&gt;
## &amp;lt;code&amp;gt;outputs&amp;lt;/code&amp;gt;: should contain an entry for every output passed:&lt;br /&gt;
### &amp;lt;code&amp;gt;outBailmentID&amp;lt;/code&amp;gt;: copied from &amp;lt;code&amp;gt;outBailmentID&amp;lt;/code&amp;gt; entry in &amp;lt;code&amp;gt;outputs&amp;lt;/code&amp;gt; argument&lt;br /&gt;
### &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;: empty string&lt;br /&gt;
### &amp;lt;code&amp;gt;transactions&amp;lt;/code&amp;gt;: nil&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Output List Initialization===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/56b10d7d-bbd4-4590-8200-c837c5ad953c&amp;quot; width=&amp;quot;450&amp;quot; height=&amp;quot;800&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
The [[startwithdrawal]] API call has been received by the wallet, and all the arguments have been checked for errors.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Pass the &amp;lt;code&amp;gt;inputstart&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;inputstop&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;dustthreshold&amp;lt;/code&amp;gt; parameters to the [[Input Selection Algorithm (voting pools)|input selection algorithm]] to obtain an ordered list of eligible inputs.&lt;br /&gt;
# Perform a first pass check to determine if the requested outputs exceed the size of the eligible inputs. Note that this check is only definitive in the case where the output sum is greater than the input sum. At this stage of the algorithm, the input sum exceeding the output sum does not prove that all outputs will be successfully created.&lt;br /&gt;
## Take the sum of both lists.&lt;br /&gt;
## If the sum of the outputs exceeds the sum of the inputs, remove outputs in descending size order until this is no longer true. Note this may result in the output list being an empty set.&lt;br /&gt;
# If the output list is non-empty, sort it by &amp;lt;code&amp;gt;outBailmentID&amp;lt;/code&amp;gt;&lt;br /&gt;
# Move both the input lists and outputs lists into separate stacks by pushing them in reverse list order. The first input and first output should be on the top of their respective stacks.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initialize New Transaction===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/506ed019-070c-44d6-b5e4-994169ab0704&amp;quot; width=&amp;quot;150&amp;quot; height=&amp;quot;450&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* There are no pending transactions in the process of being constructed, either because this is the first transaction of the algorithm or because a previous pending transaction has been moved to the finished transaction list.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Create a minimal transaction skeleton with a header and one change output.&lt;br /&gt;
## The change output will be the last output of the transaction, but the number of other outputs in this transaction is not yet known.&lt;br /&gt;
## The change output must be included in the skeleton for transaction size calculations.&lt;br /&gt;
## The position index for the change output is nil.&lt;br /&gt;
## The first non-change output for the transaction will be placed at position index 0.&lt;br /&gt;
&lt;br /&gt;
After creating the transaction skeleton, and after any action which alters it, the new transaction size (bytes) and minimum required transaction fee must be recalculated.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Next Output===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/3e9b2758-338e-40f7-8fe2-e036fda68157&amp;quot; width=&amp;quot;600&amp;quot; height=&amp;quot;800&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
The output stack contains at least one output.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Locate the entry for this output in the [[Withdrawal status|withdrawal status]] object by finding the corresponding outBailmentID.&lt;br /&gt;
# Validate the output address.&lt;br /&gt;
## If it is invalid, update &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; entry for this output to &amp;quot;invalid&amp;quot; and exit from this procedure.&lt;br /&gt;
## If it is valid, add it to the transaction.&lt;br /&gt;
### Add a new entry to the &amp;lt;code&amp;gt;transaction&amp;lt;/code&amp;gt; array for this output:&lt;br /&gt;
###* &amp;lt;code&amp;gt;nxid&amp;lt;/code&amp;gt;: nil&lt;br /&gt;
###* &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt;: next unused&lt;br /&gt;
###* &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;: copied from [[Outputs (Voting Pool Wallet API)|outputs]] list.&lt;br /&gt;
# Check that the transaction does not exceed size limits. If it does, follow the [[Transaction Construction Algorithm (voting pools)#Oversize Transaction|Oversize Transaction]] procedure.&lt;br /&gt;
# Compare the sum of the inputs to the sum of the outputs and required transaction fee to determine if more inputs are required.&lt;br /&gt;
## If no more inputs are required, then update the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; for this output to &amp;quot;success&amp;quot;.&lt;br /&gt;
# If more inputs are required, then check to see if any more are available.&lt;br /&gt;
## According to the initial conditions, the input stack can not be empty on the first run through this loop.&lt;br /&gt;
## 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)&lt;br /&gt;
## If the input stack is empty, then the output can only be partially fulfilled. Follow the [[Transaction Construction Algorithm (voting pools)#Split Output|Split Output]] procedure.&lt;br /&gt;
# Add the next input from the stack, and continue the loop at step 2.&lt;br /&gt;
&lt;br /&gt;
The loop will continue until either:&lt;br /&gt;
&lt;br /&gt;
* The transaction contains sufficient input value to satisfy the output plus transaction fees&lt;br /&gt;
* The transaction exceeds size limits&lt;br /&gt;
* There is not enough input value, but no more inputs are available&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Finalize Transaction===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/79c726f4-9d4e-4a3c-bd20-6556099d24ab&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* An unfinished transaction is ready for processing.&lt;br /&gt;
** The transaction may or may not have have a useful (non-change) output&lt;br /&gt;
** The transaction is valid&lt;br /&gt;
*** Not too big&lt;br /&gt;
*** Inputs are sufficient to cover outputs and required fees&lt;br /&gt;
** A change output may exist in the transaction&lt;br /&gt;
*** If a change output exists, it has a nil position and a nil value.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# If the transaction only contains a change output and no inputs, then it may be discarded.&lt;br /&gt;
# The change amount is calculated by: Σ(txin) - ( Σ(txout) + fees )&lt;br /&gt;
## If the change amount is greater than zero:&lt;br /&gt;
### Set the value of the output&lt;br /&gt;
### Set the position of the output to the next unused value after the last non-change output.&lt;br /&gt;
## If the change amount is zero, then the change output is removed from the transaction.&lt;br /&gt;
# Calculate an [[ntxid]] for the transaction for tracking purposes.&lt;br /&gt;
# Loop through every (non-change) output in the transaction and update the [[withdrawal status]] object for the corresponding output.&lt;br /&gt;
## The withdrawal status object contain an entry for every output in the transaction, where each entry has an &amp;lt;code&amp;gt;transactions&amp;lt;/code&amp;gt; object containing a nil &amp;lt;code&amp;gt;ntxid&amp;lt;/code&amp;gt;, an &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; matching the output position index, and a matching &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;.&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;nxid&amp;lt;/code&amp;gt; value from nil to the ntxid for the transaction.&lt;br /&gt;
# Add the fees from this transaction to the &amp;lt;code&amp;gt;fees&amp;lt;/code&amp;gt; property of the withdrawal status object.&lt;br /&gt;
# Move the transaction to the finished transaction list.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
===Update Signatures===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/97025b62-3720-4810-ae85-5ae678031aed&amp;quot; width=&amp;quot;600&amp;quot; height=&amp;quot;1100&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* The finished transaction list contains zero or more finalized transactions &lt;br /&gt;
* The transactions are valid in all respects except for missing signatures&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
* If the finished transaction list is empty, the rest of the procedure can be skipped.&lt;br /&gt;
* Loop through each transaction.&lt;br /&gt;
** Within each transaction, loop through every input.&lt;br /&gt;
*** Within each input, loop through every pubkey in the [[redeem script]].&lt;br /&gt;
**** If the wallet possesses the private key corresponding to the pubkey, create the appropriate signature.&lt;br /&gt;
***** Add the signature to the transaction.&lt;br /&gt;
***** Add the signature to the [[siglist|signature list]] in the appropriate position.&lt;br /&gt;
* Move all transactions in the finished transaction list to the pending transaction database, where they will wait for additional signatures from other voting pool members.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Update Status===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/b4dcbb56-3b87-4f56-b249-dfd4276c7cc4&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;800&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* Every outBailmentID in the [[Outputs (Voting Pool Wallet API)|output]] list provided has a non-nil &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value in the [[withdrawal status]] object.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Update the status for any split outBailments which exist:&lt;br /&gt;
## Split outBailments have more than one item in their &amp;lt;code&amp;gt;transactions&amp;lt;/code&amp;gt; array and have an existing &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value of &amp;quot;success&amp;quot;.&lt;br /&gt;
## Change the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; for all split outBailments from &amp;quot;success&amp;quot; to &amp;quot;split&amp;quot;.&lt;br /&gt;
# Update the status for any partial outBailments which exist:&lt;br /&gt;
## Partial outBailments have existing &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value of &amp;quot;partial-&amp;quot;.&lt;br /&gt;
## Calculate the total missing value needed to satisfy the partial outputs.&lt;br /&gt;
## The missing value of an outBailment is the originally-requested size of the outBailment minus the sum of all outputs created to satisfy it (if any exist).&lt;br /&gt;
### Obtain a list of eligible inputs from the next un-thawed series and calculate their total value.&lt;br /&gt;
### If the eligible value of the next un-thawed series is greater than the total missing value, then the next un-thawed series is the target series.&lt;br /&gt;
#### If not, repeat the above process while keeping a running total of eligible value until a target series is located.&lt;br /&gt;
### Append the number of the target series to the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value for every partial series.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; value.&lt;br /&gt;
## If the input stack is empty, &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; is the first [[address identifier]] for the next un-thawed series.&lt;br /&gt;
## If the input stack is not empty, &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; is the [[address identifier]] for the next input in the stack.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Oversize Transaction===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/4abd7b4f-1079-48d7-af9d-d892433cd65a&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;400&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An oversize transaction may occur while attempting to add inputs to satisfy an output which has been added to a transaction as part of the [[#Add Next Output|Add Next Output]] step.&lt;br /&gt;
&lt;br /&gt;
Even with the worst case of high &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; and/or &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; values, inputs will never be large enough that a transaction can be oversized while attempting to add the first input to a transaction.&lt;br /&gt;
&lt;br /&gt;
Oversize transactions will have one change output, at least one non-change output, and many inputs.&lt;br /&gt;
&lt;br /&gt;
If an oversize has two or more non-change outputs, then Add Next Output was successful for the previous output. In this case, the transaction was valid before attempting to add the current output, so the current output should be removed from the current transaction and moved to the next one.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the transaction has become too large while adding its first non-change output. This can happen due to a series of small inputs, or a large output, or a combination of the two. In this case the [[outBailment]] can not be satisfied with a single transaction and must be split across multiple transactions.&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* The Add Next Output procedure has created a transaction that exceeds size limits, in one of the following circumstances:&lt;br /&gt;
** Immediately upon adding an output to the transaction&lt;br /&gt;
*** The transaction contains other outputs which were added successfully. All inputs currently in the transaction are required to satisfy the previous output(s) before the output that failed.&lt;br /&gt;
** After adding the first input to the transaction to satisfy an output&lt;br /&gt;
*** The transaction contains other outputs which were added successfully. All inputs currently in the transaction are required to satisfy the previous output(s) before the output that failed.&lt;br /&gt;
** After having added at least one input to the transaction to satisfy an output without causing an oversize condition.&lt;br /&gt;
*** At least one of the inputs in this transaction are only required to satisfy the current output, not any previous outputs (if any exist).&lt;br /&gt;
&lt;br /&gt;
====Procedure====&lt;br /&gt;
&lt;br /&gt;
# Count the number of non-change outputs in the transaction.&lt;br /&gt;
# If the number exceeds one, follow the [[#Rollback Last Output|Rollback Last Output]] procedure.&lt;br /&gt;
# If the number is one, follow the [[#Split Output|Split Output]] procedure.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Rollback Last Output===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/81fbb6f6-b150-4a06-915e-7633b05da9af&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;600&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is used if a transaction has exceeded the size limit, and can be brought back under the limit by removing the most-recently added output and the inputs needed to support it from the transaction &lt;br /&gt;
&lt;br /&gt;
The removed inputs and outputs will be added to the beginning of a new transaction.&lt;br /&gt;
&lt;br /&gt;
This procedure will remove one more input than is required to bring the transaction below size limits, and then add exactly one more. This will always result in a valid transaction because the only way to reach this procedure is by having successfully completed at least one [[#Add Next Output|Add Next Output]] cycle for the current transaction prior to adding an output or input that pushes the transaction over the size limit.&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* An oversize transaction contains one or more outputs and their supporting inputs which do not exceed transaction size limits, and one output which does not.&lt;br /&gt;
* The number of inputs which are solely dedicated to satisfying the most recently-added output (not required for previous outputs) may be zero or more.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Remove the most-recently added output from the transaction and return it to the output stack.&lt;br /&gt;
#* This will cause the output to be the first one added to the next transaction.&lt;br /&gt;
# Remove the most-recently added input from the transaction and return it to the input stack.&lt;br /&gt;
# If the sum of input values exceeds the sum of output values by an amount greater than the required transaction fee:&lt;br /&gt;
#* Continue removing inputs one at a time until the sum of the input values falls below the needed output + transaction fee value.&lt;br /&gt;
# Add the next input from the stack to the transaction.&lt;br /&gt;
# Perform the [[#Finalize Transaction|Finalize Transaction]] procedure.&lt;br /&gt;
# [[#Initialize Transaction|Initialize]] a new transaction.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Split Output===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/c72ce59c-65c0-4a90-943a-c669bac5a737&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is used when, either due to a large output or small inputs, the inputs required to satisfy a single output can not fit within transaction size limits.&lt;br /&gt;
&lt;br /&gt;
The outBailment will be split across two or more transactions.&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* The transaction being constructed contains one change output, one non-change output, and many inputs.&lt;br /&gt;
* The transaction did not exceed any size limits until the most recent input was added.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Remove the change output from the transaction.&lt;br /&gt;
# Decrement the value of the &amp;lt;code&amp;gt;nextchangestart&amp;lt;/code&amp;gt; property of the [[withdrawal status]] object.&lt;br /&gt;
# Determine if the transaction still exceeds size limits.&lt;br /&gt;
## If yes, then remove the most-recently added input.&lt;br /&gt;
# Update the value of the output in the transaction to be the sum of the inputs minus the required transaction fee.&lt;br /&gt;
# Make a copy of the [[Outputs (Voting Pool Wallet API)|outputs]] object corresponding to this outBailmentID.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; field of the copied output by subtracting the value determined in step 4.&lt;br /&gt;
# Push this new output to the output stack.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field for this outBailmentID in the [[withdrawal status]] object to &amp;quot;partial-&amp;quot;.&lt;br /&gt;
# Perform the [[#Finalize Transaction|Finalize Transaction]] Procedure.&lt;br /&gt;
# [[#Initialize Transaction|Initialize]] a new transaction.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Insufficient Inputs===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/9b471e6e-0a62-408a-ad0e-a5d7c491aa43&amp;quot; width=&amp;quot;150&amp;quot; height=&amp;quot;500&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is followed when the [[#Output List Initialization|Output List Initialization]] step estimated that that the input list was sufficient to fulfill the valid outputs but, due to change and/or transaction fees, one or more outputs can not be fulfilled.&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* [[#Add Next Output|Add Next Output]] has been completed successfully at least once.&lt;br /&gt;
* An empty transaction skeleton has been created.&lt;br /&gt;
* At least one output remains in the stack, but the input stack is empty.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
* Pop all outputs from the output stack and update their &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; property in the [[withdrawal status]] list to &amp;quot;partial-&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
No further action is necessary. After completing this procedure the algorithm moves on to the [[#Finalize Transaction|Finalize Transaction]] procedure which will discard the empty transaction skeleton which would have otherwise contained the outputs which were processed in this procedure.&lt;br /&gt;
&lt;br /&gt;
[[Category:Voting Pool Technical Specifications]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Transaction_Construction_Algorithm_(voting_pools)&amp;diff=3012</id>
		<title>Transaction Construction Algorithm (voting pools)</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Transaction_Construction_Algorithm_(voting_pools)&amp;diff=3012"/>
		<updated>2014-10-02T17:07:55Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: /* Sequence */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
In order to avoid an expensive and error-prone consensus process, it is mandatory for wallets to be able to construct withdrawal transactions in a deterministic manner, assuming they are given the withdrawal requests in a deterministic order. Once this is accomplished, then it only becomes necessary for wallets to share signatures among themselves because they know they all signed the exact same bitcoin transaction.&lt;br /&gt;
&lt;br /&gt;
==Procedure==&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/eb960c32-71d4-4cfc-8f49-63a82b343608/0&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
The [[startwithdrawal]] API call has been received by the wallet, and all the arguments have been checked for errors.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
The basic flow of the procedure is:&lt;br /&gt;
&lt;br /&gt;
# Gather accounting information from the API call arguments&lt;br /&gt;
# Validate and sort the output list&lt;br /&gt;
# Start a new transactions&lt;br /&gt;
# Add outputs to the transaction until either all outputs are added or all inputs are used.&lt;br /&gt;
# Make sure all generated transactions are ready for signing.&lt;br /&gt;
# Create a list of all signatures which the wallet is capable of generating.&lt;br /&gt;
# Create a status list containing the deposition of every output the caller specified.&lt;br /&gt;
# Return the status list and signature list to the caller.&lt;br /&gt;
&lt;br /&gt;
Each step in this chart is more fully described below.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Preparation===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/0dd5f7d6-8511-4440-a535-32ad8508d146&amp;quot; width=&amp;quot;150&amp;quot; height=&amp;quot;502&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
The [[startwithdrawal]] API call has been received by the wallet, and all the arguments have been checked for errors.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# The algorithm must keep track of the next change address to be used. The initial value is supplied as the &amp;lt;code&amp;gt;[[Startwithdrawal#Arguments|changestart]]&amp;lt;/code&amp;gt; argument. Any time a change output is allocated, the index value of the [[address identifier]] is incremented, and if a change output is remove from a transaction the index value is decremented. The final value will be returned to the caller as the &amp;lt;code&amp;gt;[[Withdrawal status|nextchangestart]]&amp;lt;/code&amp;gt; value in the [[Withdrawal status| withdrawal status list]].&lt;br /&gt;
# Prepare an empty list for holding transactions as they are constructed and before they are signed.&lt;br /&gt;
# Prepare an empty array to hold the transaction signatures which will be returned to the caller as the &amp;lt;code&amp;gt;[[siglist| signatures]]&amp;lt;/code&amp;gt; value.&lt;br /&gt;
# Prepare an &amp;lt;code&amp;gt;withdrawal status&amp;lt;/code&amp;gt; object.&lt;br /&gt;
## &amp;lt;code&amp;gt;roundID&amp;lt;/code&amp;gt;: copied from &amp;lt;code&amp;gt;roundID&amp;lt;/code&amp;gt; argument&lt;br /&gt;
## &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt;: nil&lt;br /&gt;
## &amp;lt;code&amp;gt;nextchangestart&amp;lt;/code&amp;gt;: nil&lt;br /&gt;
## &amp;lt;code&amp;gt;fees&amp;lt;/code&amp;gt;: 0&lt;br /&gt;
## &amp;lt;code&amp;gt;outputs&amp;lt;/code&amp;gt;: should contain an entry for every output passed:&lt;br /&gt;
### &amp;lt;code&amp;gt;outBailmentID&amp;lt;/code&amp;gt;: copied from &amp;lt;code&amp;gt;outBailmentID&amp;lt;/code&amp;gt; entry in &amp;lt;code&amp;gt;outputs&amp;lt;/code&amp;gt; argument&lt;br /&gt;
### &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;: empty string&lt;br /&gt;
### &amp;lt;code&amp;gt;transactions&amp;lt;/code&amp;gt;: nil&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Output List Initialization===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/56b10d7d-bbd4-4590-8200-c837c5ad953c&amp;quot; width=&amp;quot;450&amp;quot; height=&amp;quot;800&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
The [[startwithdrawal]] API call has been received by the wallet, and all the arguments have been checked for errors.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Pass the &amp;lt;code&amp;gt;inputstart&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;inputstop&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;dustthreshold&amp;lt;/code&amp;gt; parameters to the [[Input Selection Algorithm (voting pools)|input selection algorithm]] to obtain an ordered list of eligible inputs.&lt;br /&gt;
# Perform a first pass check to determine if the requested outputs exceed the size of the eligible inputs. Note that this check is only definitive in the case where the output sum is greater than the input sum. At this stage of the algorithm, the input sum exceeding the output sum does not prove that all outputs will be successfully created.&lt;br /&gt;
## Take the sum of both lists.&lt;br /&gt;
## If the sum of the outputs exceeds the sum of the inputs, remove outputs in descending size order until this is no longer true. Note this may result in the output list being an empty set.&lt;br /&gt;
# If the output list is non-empty, sort it by &amp;lt;code&amp;gt;outBailmentID&amp;lt;/code&amp;gt;&lt;br /&gt;
# Move both the input lists and outputs lists into separate stacks by pushing them in reverse list order. The first input and first output should be on the top of their respective stacks.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initialize New Transaction===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/506ed019-070c-44d6-b5e4-994169ab0704&amp;quot; width=&amp;quot;150&amp;quot; height=&amp;quot;450&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* There are no pending transactions in the process of being constructed, either because this is the first transaction of the algorithm or because a previous pending transaction has been moved to the finished transaction list.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Create a minimal transaction skeleton with a header and one change output.&lt;br /&gt;
## The change output will be the last output of the transaction, but the number of other outputs in this transaction is not yet known.&lt;br /&gt;
## The change output must be included in the skeleton for transaction size calculations.&lt;br /&gt;
## The position index for the change output is nil.&lt;br /&gt;
## The first non-change output for the transaction will be placed at position index 0.&lt;br /&gt;
&lt;br /&gt;
After creating the transaction skeleton, and after any action which alters it, the new transaction size (bytes) and minimum required transaction fee must be recalculated.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add Next Output===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/3e9b2758-338e-40f7-8fe2-e036fda68157&amp;quot; width=&amp;quot;600&amp;quot; height=&amp;quot;800&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
The output stack contains at least one output.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Locate the entry for this output in the [[Withdrawal status|withdrawal status]] object by finding the corresponding outBailmentID.&lt;br /&gt;
# Validate the output address.&lt;br /&gt;
## If it is invalid, update &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; entry for this output to &amp;quot;invalid&amp;quot; and exit from this procedure.&lt;br /&gt;
## If it is valid, add it to the transaction.&lt;br /&gt;
### Add a new entry to the &amp;lt;code&amp;gt;transaction&amp;lt;/code&amp;gt; array for this output:&lt;br /&gt;
###* &amp;lt;code&amp;gt;nxid&amp;lt;/code&amp;gt;: nil&lt;br /&gt;
###* &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt;: next unused&lt;br /&gt;
###* &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;: copied from [[Outputs (Voting Pool Wallet API)|outputs]] list.&lt;br /&gt;
# Check that the transaction does not exceed size limits. If it does, follow the [[Transaction Construction Algorithm (voting pools)#Oversize Transaction|Oversize Transaction]] procedure.&lt;br /&gt;
# Compare the sum of the inputs to the sum of the outputs and required transaction fee to determine if more inputs are required.&lt;br /&gt;
## If no more inputs are required, then update the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; for this output to &amp;quot;success&amp;quot;.&lt;br /&gt;
# If more inputs are required, then check to see if any more are available.&lt;br /&gt;
## According to the initial conditions, the input stack can not be empty on the first run through this loop.&lt;br /&gt;
## 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)&lt;br /&gt;
## If the input stack is empty, then the output can only be partially fulfilled. Follow the [[Transaction Construction Algorithm (voting pools)#Split Output|Split Output]] procedure.&lt;br /&gt;
# Add the next input from the stack, and continue the loop at step 2.&lt;br /&gt;
&lt;br /&gt;
The loop will continue until either:&lt;br /&gt;
&lt;br /&gt;
* The transaction contains sufficient input value to satisfy the output plus transaction fees&lt;br /&gt;
* The transaction exceeds size limits&lt;br /&gt;
* There is not enough input value, but no more inputs are available&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Finalize Transaction===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/79c726f4-9d4e-4a3c-bd20-6556099d24ab&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* An unfinished transaction is ready for processing.&lt;br /&gt;
** The transaction may or may not have have a useful (non-change) output&lt;br /&gt;
** The transaction is valid&lt;br /&gt;
*** Not too big&lt;br /&gt;
*** Inputs are sufficient to cover outputs and required fees&lt;br /&gt;
** A change output may exist in the transaction&lt;br /&gt;
*** If a change output exists, it has a nil position and a nil value.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# If the transaction only contains a change output and no inputs, then it may be discarded.&lt;br /&gt;
# The change amount is calculated by: Σ(txin) - ( Σ(txout) + fees )&lt;br /&gt;
## If the change amount is greater than zero:&lt;br /&gt;
### Set the value of the output&lt;br /&gt;
### Set the position of the output to the next unused value after the last non-change output.&lt;br /&gt;
## If the change amount is zero, then the change output is removed from the transaction.&lt;br /&gt;
# Calculate an [[ntxid]] for the transaction for tracking purposes.&lt;br /&gt;
# Loop through every (non-change) output in the transaction and update the [[withdrawal status]] object for the corresponding output.&lt;br /&gt;
## The withdrawal status object contain an entry for every output in the transaction, where each entry has an &amp;lt;code&amp;gt;transactions&amp;lt;/code&amp;gt; object containing a nil &amp;lt;code&amp;gt;ntxid&amp;lt;/code&amp;gt;, an &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; matching the output position index, and a matching &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt;.&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;nxid&amp;lt;/code&amp;gt; value from nil to the ntxid for the transaction.&lt;br /&gt;
# Add the fees from this transaction to the &amp;lt;code&amp;gt;fees&amp;lt;/code&amp;gt; property of the withdrawal status object.&lt;br /&gt;
# Move the transaction to the finished transaction list.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
===Update Signatures===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/97025b62-3720-4810-ae85-5ae678031aed&amp;quot; width=&amp;quot;600&amp;quot; height=&amp;quot;1100&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* The finished transaction list contains zero or more finalized transactions &lt;br /&gt;
* The transactions are valid in all respects except for missing signatures&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
* If the finished transaction list is empty, the rest of the procedure can be skipped.&lt;br /&gt;
* Loop through each transaction.&lt;br /&gt;
** Within each transaction, loop through every input.&lt;br /&gt;
*** Within each input, loop through every pubkey in the [[redeem script]].&lt;br /&gt;
**** If the wallet has possesses the private key corresponding to the pubkey, create the appropriate signature.&lt;br /&gt;
***** Add the signature to the transaction.&lt;br /&gt;
***** Add the signature to the [[siglist|signature list]] in the appropriate position.&lt;br /&gt;
* Move all transactions in the finished transaction list to the pending transaction database, where they will wait for additional signatures from other voting pool members.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Update Status===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/b4dcbb56-3b87-4f56-b249-dfd4276c7cc4&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;800&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* Every outBailmentID in the [[Outputs (Voting Pool Wallet API)|output]] list provided has a non-nil &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value in the [[withdrawal status]] object.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Update the status for any split outBailments which exist:&lt;br /&gt;
## Split outBailments have more than one item in their &amp;lt;code&amp;gt;transactions&amp;lt;/code&amp;gt; array and have an existing &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value of &amp;quot;success&amp;quot;.&lt;br /&gt;
## Change the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; for all split outBailments from &amp;quot;success&amp;quot; to &amp;quot;split&amp;quot;.&lt;br /&gt;
# Update the status for any partial outBailments which exist:&lt;br /&gt;
## Partial outBailments have existing &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value of &amp;quot;partial-&amp;quot;.&lt;br /&gt;
## Calculate the total missing value needed to satisfy the partial outputs.&lt;br /&gt;
## The missing value of an outBailment is the originally-requested size of the outBailment minus the sum of all outputs created to satisfy it (if any exist).&lt;br /&gt;
### Obtain a list of eligible inputs from the next un-thawed series and calculate their total value.&lt;br /&gt;
### If the eligible value of the next un-thawed series is greater than the total missing value, then the next un-thawed series is the target series.&lt;br /&gt;
#### If not, repeat the above process while keeping a running total of eligible value until a target series is located.&lt;br /&gt;
### Append the number of the target series to the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; value for every partial series.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; value.&lt;br /&gt;
## If the input stack is empty, &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; is the first [[address identifier]] for the next un-thawed series.&lt;br /&gt;
## If the input stack is not empty, &amp;lt;code&amp;gt;nextinputstart&amp;lt;/code&amp;gt; is the [[address identifier]] for the next input in the stack.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Oversize Transaction===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/4abd7b4f-1079-48d7-af9d-d892433cd65a&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;400&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An oversize transaction may occur while attempting to add inputs to satisfy an output which has been added to a transaction as part of the [[#Add Next Output|Add Next Output]] step.&lt;br /&gt;
&lt;br /&gt;
Even with the worst case of high &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; and/or &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; values, inputs will never be large enough that a transaction can be oversized while attempting to add the first input to a transaction.&lt;br /&gt;
&lt;br /&gt;
Oversize transactions will have one change output, at least one non-change output, and many inputs.&lt;br /&gt;
&lt;br /&gt;
If an oversize has two or more non-change outputs, then Add Next Output was successful for the previous output. In this case, the transaction was valid before attempting to add the current output, so the current output should be removed from the current transaction and moved to the next one.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the transaction has become too large while adding its first non-change output. This can happen due to a series of small inputs, or a large output, or a combination of the two. In this case the [[outBailment]] can not be satisfied with a single transaction and must be split across multiple transactions.&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* The Add Next Output procedure has created a transaction that exceeds size limits, in one of the following circumstances:&lt;br /&gt;
** Immediately upon adding an output to the transaction&lt;br /&gt;
*** The transaction contains other outputs which were added successfully. All inputs currently in the transaction are required to satisfy the previous output(s) before the output that failed.&lt;br /&gt;
** After adding the first input to the transaction to satisfy an output&lt;br /&gt;
*** The transaction contains other outputs which were added successfully. All inputs currently in the transaction are required to satisfy the previous output(s) before the output that failed.&lt;br /&gt;
** After having added at least one input to the transaction to satisfy an output without causing an oversize condition.&lt;br /&gt;
*** At least one of the inputs in this transaction are only required to satisfy the current output, not any previous outputs (if any exist).&lt;br /&gt;
&lt;br /&gt;
====Procedure====&lt;br /&gt;
&lt;br /&gt;
# Count the number of non-change outputs in the transaction.&lt;br /&gt;
# If the number exceeds one, follow the [[#Rollback Last Output|Rollback Last Output]] procedure.&lt;br /&gt;
# If the number is one, follow the [[#Split Output|Split Output]] procedure.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Rollback Last Output===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/81fbb6f6-b150-4a06-915e-7633b05da9af&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;600&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is used if a transaction has exceeded the size limit, and can be brought back under the limit by removing the most-recently added output and the inputs needed to support it from the transaction &lt;br /&gt;
&lt;br /&gt;
The removed inputs and outputs will be added to the beginning of a new transaction.&lt;br /&gt;
&lt;br /&gt;
This procedure will remove one more input than is required to bring the transaction below size limits, and then add exactly one more. This will always result in a valid transaction because the only way to reach this procedure is by having successfully completed at least one [[#Add Next Output|Add Next Output]] cycle for the current transaction prior to adding an output or input that pushes the transaction over the size limit.&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* An oversize transaction contains one or more outputs and their supporting inputs which do not exceed transaction size limits, and one output which does not.&lt;br /&gt;
* The number of inputs which are solely dedicated to satisfying the most recently-added output (not required for previous outputs) may be zero or more.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Remove the most-recently added output from the transaction and return it to the output stack.&lt;br /&gt;
#* This will cause the output to be the first one added to the next transaction.&lt;br /&gt;
# Remove the most-recently added input from the transaction and return it to the input stack.&lt;br /&gt;
# If the sum of input values exceeds the sum of output values by an amount greater than the required transaction fee:&lt;br /&gt;
#* Continue removing inputs one at a time until the sum of the input values falls below the needed output + transaction fee value.&lt;br /&gt;
# Add the next input from the stack to the transaction.&lt;br /&gt;
# Perform the [[#Finalize Transaction|Finalize Transaction]] procedure.&lt;br /&gt;
# [[#Initialize Transaction|Initialize]] a new transaction.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Split Output===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/c72ce59c-65c0-4a90-943a-c669bac5a737&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;1004&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is used when, either due to a large output or small inputs, the inputs required to satisfy a single output can not fit within transaction size limits.&lt;br /&gt;
&lt;br /&gt;
The outBailment will be split across two or more transactions.&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* The transaction being constructed contains one change output, one non-change output, and many inputs.&lt;br /&gt;
* The transaction did not exceed any size limits until the most recent input was added.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
# Remove the change output from the transaction.&lt;br /&gt;
# Decrement the value of the &amp;lt;code&amp;gt;nextchangestart&amp;lt;/code&amp;gt; property of the [[withdrawal status]] object.&lt;br /&gt;
# Determine if the transaction still exceeds size limits.&lt;br /&gt;
## If yes, then remove the most-recently added input.&lt;br /&gt;
# Update the value of the output in the transaction to be the sum of the inputs minus the required transaction fee.&lt;br /&gt;
# Make a copy of the [[Outputs (Voting Pool Wallet API)|outputs]] object corresponding to this outBailmentID.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;amount&amp;lt;/code&amp;gt; field of the copied output by subtracting the value determined in step 4.&lt;br /&gt;
# Push this new output to the output stack.&lt;br /&gt;
# Update the &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; field for this outBailmentID in the [[withdrawal status]] object to &amp;quot;partial-&amp;quot;.&lt;br /&gt;
# Perform the [[#Finalize Transaction|Finalize Transaction]] Procedure.&lt;br /&gt;
# [[#Initialize Transaction|Initialize]] a new transaction.&lt;br /&gt;
&lt;br /&gt;
{{clear}}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Insufficient Inputs===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;float: right&amp;quot;&amp;gt;&amp;lt;include iframe src=&amp;quot;https://www.lucidchart.com/documents/embeddedchart/9b471e6e-0a62-408a-ad0e-a5d7c491aa43&amp;quot; width=&amp;quot;150&amp;quot; height=&amp;quot;500&amp;quot; frameborder=&amp;quot;0&amp;quot; scrolling=&amp;quot;yes&amp;quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is followed when the [[#Output List Initialization|Output List Initialization]] step estimated that that the input list was sufficient to fulfill the valid outputs but, due to change and/or transaction fees, one or more outputs can not be fulfilled.&lt;br /&gt;
&lt;br /&gt;
====Initial Conditions====&lt;br /&gt;
&lt;br /&gt;
* [[#Add Next Output|Add Next Output]] has been completed successfully at least once.&lt;br /&gt;
* An empty transaction skeleton has been created.&lt;br /&gt;
* At least one output remains in the stack, but the input stack is empty.&lt;br /&gt;
&lt;br /&gt;
====Sequence====&lt;br /&gt;
&lt;br /&gt;
* Pop all outputs from the output stack and update their &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; property in the [[withdrawal status]] list to &amp;quot;partial-&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
No further action is necessary. After completing this procedure the algorithm moves on to the [[#Finalize Transaction|Finalize Transaction]] procedure which will discard the empty transaction skeleton which would have otherwise contained the outputs which were processed in this procedure.&lt;br /&gt;
&lt;br /&gt;
[[Category:Voting Pool Technical Specifications]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Voting_Pool_Withdrawal_Process&amp;diff=2925</id>
		<title>Voting Pool Withdrawal Process</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Voting_Pool_Withdrawal_Process&amp;diff=2925"/>
		<updated>2014-09-22T11:02:43Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Procedure==&lt;br /&gt;
&lt;br /&gt;
===Initiation===&lt;br /&gt;
&lt;br /&gt;
Customers will normally request a withdrawal using one of the client applications that talk to the notary. These requests will end up in the auditor stream. The auditor will then validate and batch multiple withdrawal requests and ask the blockchain wallet to construct one or more transactions with one output for every withdrawal.&lt;br /&gt;
&lt;br /&gt;
'''TODO: explain why batching is important'''&lt;br /&gt;
&lt;br /&gt;
=== Consensus ===&lt;br /&gt;
&lt;br /&gt;
In order to withdrawal funds from a voting pool, M members must sign the blockchain transaction that moves the coins to the desired addresses. For that reason, auditors will have to periodically [[Consensus Process (voting pools)|agree on a set of parameters for the blockchain transactions]]. These parameters are then passed on to their wallets, allowing them to generate transactions deterministically.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Construction ===&lt;br /&gt;
&lt;br /&gt;
The auditor sends a [[Startwithdrawal|startwithdrawal]] command to the wallet, which then attempts to construct blockchain transactions to satisfy the requested ouputs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Transaction Signing &amp;amp; Broadcasting ===&lt;br /&gt;
&lt;br /&gt;
Once an auditor receives new [[Siglist|signature lists]] for an in-progress transaction, it will send a [[Updatewithdrawal|updatewithdrawal]] command to the blockchain wallet, passing those new signatures. Once the blockchain wallet has received the minimum number of required signatures for a given transaction, it will be broadcast.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Voting Pool Operations]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Voting_Pool_Withdrawal_Process&amp;diff=2924</id>
		<title>Voting Pool Withdrawal Process</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Voting_Pool_Withdrawal_Process&amp;diff=2924"/>
		<updated>2014-09-22T10:29:04Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: Created page with &amp;quot;==Procedure==  ===Initiation===   Category: Voting Pool Operations&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Procedure==&lt;br /&gt;
&lt;br /&gt;
===Initiation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Voting Pool Operations]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Wallet_(blockchain)&amp;diff=2899</id>
		<title>Wallet (blockchain)</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Wallet_(blockchain)&amp;diff=2899"/>
		<updated>2014-09-19T15:41:20Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
In order to avoid ambiguity, the terms &amp;quot;blockchain wallet&amp;quot; and &amp;quot;blockchain address&amp;quot; refers to the cryptocurrency for which is pool is tracking receipts. This differentiation is necessary to avoid confusion with [[wallet_(OT)|OT wallets]] or [[nym|nym addresses]].&lt;br /&gt;
&lt;br /&gt;
==Responsibilities==&lt;br /&gt;
&lt;br /&gt;
The blockchain wallet tracks and manipulates cryptocurrencies balances on the appropriate blockchain. The wallet notifies the audit server of received deposits, constructs outgoing transactions, and monitors the state of all relevant incoming and outgoing transactions.&lt;br /&gt;
&lt;br /&gt;
An audit server requires access to a wallet provider for every cryptocurrency its operator wishes to accept deposits for, and this wallet must support the [[Cryptocurrency wallet API|Voting Pool Wallet API]].&lt;br /&gt;
&lt;br /&gt;
Wallets should understand both hierarchical determinism and multisig capability, and also output coloring.&lt;br /&gt;
&lt;br /&gt;
==Address Identification==&lt;br /&gt;
&lt;br /&gt;
===Series Identifier===&lt;br /&gt;
&lt;br /&gt;
Since one wallet will need to handle multiple pools and series, a series identifier must include the pool for which it belongs.&lt;br /&gt;
&lt;br /&gt;
A wallet identifier is defined as JSON object and is composed of two parts:&lt;br /&gt;
&lt;br /&gt;
;Pool&lt;br /&gt;
:UUID for a specific voting pool. This UUID is persistent even as members are added or removed.&lt;br /&gt;
&lt;br /&gt;
;Series&lt;br /&gt;
:An index number that starts at 1 and increases monotonically (from the [[Keyset (voting pools)|Keyset Definition]])&lt;br /&gt;
&lt;br /&gt;
====Schema====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;$schema&amp;quot;: &amp;quot;http://json-schema.org/draft-04/schema#&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Wallet identifier&amp;quot;,&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;A unique identifier for a series in a voting pool&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;object&amp;quot;,&lt;br /&gt;
    &amp;quot;properties&amp;quot;: {&lt;br /&gt;
        &amp;quot;pool&amp;quot;: {&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the color definition of the pool's charter&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;series&amp;quot;: {&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;number&amp;quot;,&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the series number of the given voting pool&amp;quot;,&lt;br /&gt;
            &amp;quot;minimum&amp;quot;: 1,&lt;br /&gt;
            &amp;quot;exclusiveMinimum&amp;quot;: false&lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;required&amp;quot;: [ &amp;quot;pool&amp;quot;,&amp;quot;series&amp;quot; ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;pool&amp;quot;: &amp;quot;IFOC:a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d:0:57043&amp;quot;,&lt;br /&gt;
    &amp;quot;series&amp;quot;: 42&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Address Identifier===&lt;br /&gt;
&lt;br /&gt;
An address identifier is defined as a JSON object and is composed of three parts:&lt;br /&gt;
&lt;br /&gt;
;Series&lt;br /&gt;
:The series identifier which contains the address&lt;br /&gt;
&lt;br /&gt;
;Branch&lt;br /&gt;
:0 for change addresses, 1-through-n for deposit addresses.&lt;br /&gt;
&lt;br /&gt;
Note the branch represents the position of a server’s [[xpub]] in the standard order for a given series. The audit server must reference the [[Keyset (voting pools)|keyset definition]] to obtain the correct transaction server ID-to-branch  mapping for a given series since the standard order will change between series.&lt;br /&gt;
&lt;br /&gt;
;Index&lt;br /&gt;
:The index applied to the [[xpub|xpubs]] in a given series to obtain the desired multisig output script.&lt;br /&gt;
&lt;br /&gt;
When the audit server needs to query a specific address from the blockchain wallet, will pass the address identifier instead of a raw blockchain address or script.&lt;br /&gt;
&lt;br /&gt;
====Schema====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;$schema&amp;quot;: &amp;quot;http://json-schema.org/draft-04/schema#&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Address identifier&amp;quot;,&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;A unique identifier for a specific address in a voting pool&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;object&amp;quot;,&lt;br /&gt;
    &amp;quot;properties&amp;quot;: {&lt;br /&gt;
        &amp;quot;series&amp;quot;: {&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the series identifier containing the address&amp;quot;,&lt;br /&gt;
            &amp;quot;$ref&amp;quot;: &amp;quot;http://TBD&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;branch&amp;quot;: {&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;number&amp;quot;,&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the chain within the series containing the desired address&amp;quot;,&lt;br /&gt;
            &amp;quot;minimum&amp;quot;: 0,&lt;br /&gt;
            &amp;quot;exclusiveMinimum&amp;quot;: false&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;index&amp;quot;: {&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;number&amp;quot;,&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the value used to derive the public keys used to create the multisig script&amp;quot;,&lt;br /&gt;
            &amp;quot;minimum&amp;quot;: 0,&lt;br /&gt;
            &amp;quot;exclusiveMinimum&amp;quot;: false&lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;required&amp;quot;: [ &amp;quot;series&amp;quot;,&amp;quot;branch&amp;quot;,&amp;quot;index&amp;quot; ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;series&amp;quot;: { &amp;quot;pool&amp;quot;: &amp;quot;IFOC:a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d:0:57043&amp;quot;, &amp;quot;series&amp;quot;: 42 },&lt;br /&gt;
    &amp;quot;branch&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;index&amp;quot;: 21&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Wallet Creation==&lt;br /&gt;
&lt;br /&gt;
When an audit server first initializes a voting pool contract, it must create the appropriate cryptocurrency wallets via the [[Createseries]] call to a wallet provider of the appropriate coin type (Bitcoin, Litecoin, etc).&lt;br /&gt;
&lt;br /&gt;
The audit server must call this function for every defined series in the keyset.&lt;br /&gt;
&lt;br /&gt;
When the extended private keys for a series are brought online, the wallet must call [[Thawseries]] to load them into the blockchain wallet.&lt;br /&gt;
&lt;br /&gt;
The wallet must find the correct extended public key when it adds the extended private key to the wallet and must return an error to the operator if he attempts to load and extended private key for an extended public key not defined in that series.&lt;br /&gt;
&lt;br /&gt;
[[Category:Voting Pool Components]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Wallet_(blockchain)&amp;diff=2897</id>
		<title>Wallet (blockchain)</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Wallet_(blockchain)&amp;diff=2897"/>
		<updated>2014-09-19T15:29:57Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
In order to avoid ambiguity, the terms &amp;quot;blockchain wallet&amp;quot; and &amp;quot;blockchain address&amp;quot; refers to the cryptocurrency for which is pool is tracking receipts. This differentiation is necessary to avoid confusion with [[wallet_(OT)|OT wallets]] or [[nym|nym addresses]].&lt;br /&gt;
&lt;br /&gt;
==Responsibilities==&lt;br /&gt;
&lt;br /&gt;
The blockchain wallet tracks and manipulates cryptocurrencies balances on the appropriate blockchain. The wallet notifies the audit server of received deposits, constructs outgoing transactions, and monitors the state of all relevant incoming and outgoing transactions.&lt;br /&gt;
&lt;br /&gt;
An audit server requires access to a wallet provider for every cryptocurrency its operator wishes to accept deposits for, and this wallet must support the [[Cryptocurrency wallet API|Voting Pool Wallet API]].&lt;br /&gt;
&lt;br /&gt;
Wallets should understand both hierarchical determinism and multisig capability, and also output coloring.&lt;br /&gt;
&lt;br /&gt;
==Address Identification==&lt;br /&gt;
&lt;br /&gt;
===Series Identifier===&lt;br /&gt;
&lt;br /&gt;
Since one wallet will need to handle multiple pools and series, a series identifier must include the pool for which it belongs.&lt;br /&gt;
&lt;br /&gt;
A wallet identifier is defined as JSON object and is composed of two parts:&lt;br /&gt;
&lt;br /&gt;
;Pool&lt;br /&gt;
:UUID for a specific voting pool. This UUID is persistent even as members are added or removed.&lt;br /&gt;
&lt;br /&gt;
;Series&lt;br /&gt;
:An index number that starts at 1 and increases monotonically (from the [[Keyset (voting pools)|Keyset Definition]])&lt;br /&gt;
&lt;br /&gt;
====Schema====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;$schema&amp;quot;: &amp;quot;http://json-schema.org/draft-04/schema#&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Wallet identifier&amp;quot;,&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;A unique identifier for a series in a voting pool&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;object&amp;quot;,&lt;br /&gt;
    &amp;quot;properties&amp;quot;: {&lt;br /&gt;
        &amp;quot;pool&amp;quot;: {&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the color definition of the pool's charter&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;series&amp;quot;: {&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;number&amp;quot;,&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the series number of the given voting pool&amp;quot;,&lt;br /&gt;
            &amp;quot;minimum&amp;quot;: 1,&lt;br /&gt;
            &amp;quot;exclusiveMinimum&amp;quot;: false&lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;required&amp;quot;: [ &amp;quot;pool&amp;quot;,&amp;quot;series&amp;quot; ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;pool&amp;quot;: &amp;quot;IFOC:a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d:0:57043&amp;quot;,&lt;br /&gt;
    &amp;quot;series&amp;quot;: 42&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Address Identifier===&lt;br /&gt;
&lt;br /&gt;
An address identifier is defined as a JSON object and is composed of three parts:&lt;br /&gt;
&lt;br /&gt;
;Series&lt;br /&gt;
:The series identifier which contains the address&lt;br /&gt;
&lt;br /&gt;
;Branch&lt;br /&gt;
:0 for change addresses, 1-through-n for deposit addresses.&lt;br /&gt;
&lt;br /&gt;
Note the branch represents the position of a server’s [[xpub]] in the standard order for a given series. The audit server must reference the [[Keyset (voting pools)|keyset definition]] to obtain the correct transaction server ID-to-branch  mapping for a given series since the standard order will change between series.&lt;br /&gt;
&lt;br /&gt;
;Index&lt;br /&gt;
:The index applied to the [[xpub|xpubs]] in a given series to obtain the desired multisig output script.&lt;br /&gt;
&lt;br /&gt;
When the audit server needs to query a specific address from the blockchain wallet, will pass the address identifier instead of a raw blockchain address or script.&lt;br /&gt;
&lt;br /&gt;
====Schema====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;$schema&amp;quot;: &amp;quot;http://json-schema.org/draft-04/schema#&amp;quot;,&lt;br /&gt;
    &amp;quot;title&amp;quot;: &amp;quot;Address identifier&amp;quot;,&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;A unique identifier for a specific address in a voting pool&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;: &amp;quot;object&amp;quot;,&lt;br /&gt;
    &amp;quot;properties&amp;quot;: {&lt;br /&gt;
        &amp;quot;series&amp;quot;: {&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the series identifier containing the address&amp;quot;,&lt;br /&gt;
            &amp;quot;$ref&amp;quot;: &amp;quot;http://TBD&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;branch&amp;quot;: {&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;number&amp;quot;,&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the chain within the series containing the desired address&amp;quot;,&lt;br /&gt;
            &amp;quot;minimum&amp;quot;: 0,&lt;br /&gt;
            &amp;quot;exclusiveMinimum&amp;quot;: false&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;index&amp;quot;: {&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;number&amp;quot;,&lt;br /&gt;
            &amp;quot;description&amp;quot;: &amp;quot;the value used to derive the public keys used to create the multisig script&amp;quot;,&lt;br /&gt;
            &amp;quot;minimum&amp;quot;: 0,&lt;br /&gt;
            &amp;quot;exclusiveMinimum&amp;quot;: false&lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;required&amp;quot;: [ &amp;quot;series&amp;quot;,&amp;quot;branch&amp;quot;,&amp;quot;index&amp;quot; ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;series&amp;quot;: { &amp;quot;pool&amp;quot;: &amp;quot;IFOC:a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d:0:57043&amp;quot;, &amp;quot;series&amp;quot;: 42 },&lt;br /&gt;
    &amp;quot;branch&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;index&amp;quot;: 21&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Wallet Creation==&lt;br /&gt;
&lt;br /&gt;
When an audit server first initializes a voting pool contract, it must create the appropriate cryptocurrency wallets via the [[Voting Pool Wallet API#createseries|createseries]] call to a wallet provider of the appropriate coin type (Bitcoin, Litecoin, etc).&lt;br /&gt;
&lt;br /&gt;
The audit server must call this function for every defined series in the keyset.&lt;br /&gt;
&lt;br /&gt;
When the extended private keys for a series are brought online, the wallet must call [[Thawseries]] to load them into the blockchain wallet.&lt;br /&gt;
&lt;br /&gt;
The wallet must find the correct extended public key when it adds the extended private key to the wallet and must return an error to the operator if he attempts to load and extended private key for an extended public key not defined in that series.&lt;br /&gt;
&lt;br /&gt;
[[Category:Voting Pool Components]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Input_Selection_Algorithm_(voting_pools)&amp;diff=2890</id>
		<title>Input Selection Algorithm (voting pools)</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Input_Selection_Algorithm_(voting_pools)&amp;diff=2890"/>
		<updated>2014-09-19T13:24:38Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: fix a broken link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
In order to avoid an expensive and error-prone consensus process, it is mandatory for wallets to be able to construct withdrawal transactions in a deterministic manner, assuming they are given the withdrawal requests in a deterministic order. Once this is accomplished, then it only becomes necessary for wallets to share signatures among themselves because they know they all signed the exact same bitcoin transaction.&lt;br /&gt;
&lt;br /&gt;
One requirement to achieving this determinism is that the inputs used by the transaction construction algorithm are selected in a deterministic order.&lt;br /&gt;
&lt;br /&gt;
==Procedure==&lt;br /&gt;
&lt;br /&gt;
The input selection algorithm generates an ordered list of eligible inputs for a withdrawal transaction. It is called from [[startwithdrawal]] with a set of three parameters:&lt;br /&gt;
&lt;br /&gt;
# The first [[Wallet_(blockchain)#Address_Identification|address identifier]] to be considered.&lt;br /&gt;
# The last adress identifier to be considered.&lt;br /&gt;
# The minimum allowed input size.&lt;br /&gt;
&lt;br /&gt;
The algorithm returns all inputs associated with the inclusive range given by inputstart and inputstop which are considered eligable, in a specific order.&lt;br /&gt;
&lt;br /&gt;
===Eligibility criteria===&lt;br /&gt;
&lt;br /&gt;
An unspent output is considered eligable if it meets the following criteria:&lt;br /&gt;
&lt;br /&gt;
* Its size is larger than dustthreshold&lt;br /&gt;
* The transaction in which it was created has more than 100 confirmations&lt;br /&gt;
&lt;br /&gt;
The first criteria ensures the input will add more value to the transaction than the cost spend it in terms of fees.&lt;br /&gt;
&lt;br /&gt;
The second ensures determinism. &lt;br /&gt;
&lt;br /&gt;
Withdrawals are processed from the oldest deposits, in FIFO order and reuse of deposit addresses is not encouraged. However, it's not possible to prevent anyone from sending duplicate or unsolicited deposits to an address. The [[Duplicate Deposit]] procedure sweeps unsolicited deposits to their correct location, however at any given time it's not possible to ensure all nodes have performed this procedure at the exact same moment.&lt;br /&gt;
&lt;br /&gt;
If the recommended values of weekly key rotation and 95% cold storage are followed, then the inputs being selected should have about 20000 confirmations (two orders of magnitude higher than the limit.)&lt;br /&gt;
&lt;br /&gt;
By rejecting all inputs with less than 100 confirmations, the pool effectively has a 16 hour window in which to detect duplicate deposits and perform the duplicate deposit procedure before there is a risk of non-deterministic transaction construction.&lt;br /&gt;
&lt;br /&gt;
===Input Ordering===&lt;br /&gt;
&lt;br /&gt;
When moving from address to address, the various parameters of the address identifier are incremented in the following order:&lt;br /&gt;
&lt;br /&gt;
# branch (0 to n+1)&lt;br /&gt;
# index (0 to highest used for series)&lt;br /&gt;
# series (oldest to newest)&lt;br /&gt;
&lt;br /&gt;
If an address references more than one eligible inputs, they are all selected and are sorted by txid, then by output index.&lt;br /&gt;
&lt;br /&gt;
In an address contains no eligible inputs, it is skipped.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
[[File:Voting_Pools_Series_Table.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Voting Pool Technical Specifications]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Talk:Wallet_(blockchain)&amp;diff=2623</id>
		<title>Talk:Wallet (blockchain)</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Talk:Wallet_(blockchain)&amp;diff=2623"/>
		<updated>2014-09-03T16:34:51Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: Created page with &amp;quot;The Wallet Creation section mentions that, when bringing extended private keys online, the auditor must specify them in the order matching the extended public keys, but there'...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Wallet Creation section mentions that, when bringing extended private keys online, the auditor must specify them in the order matching the extended public keys, but there's no need for that as the wallet can figure out the matching extended public key for any given extended private key&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Voting_Pool_Deposit_Process&amp;diff=2147</id>
		<title>Voting Pool Deposit Process</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Voting_Pool_Deposit_Process&amp;diff=2147"/>
		<updated>2014-08-07T17:50:17Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: link to Deposit Address (voting pools)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Procedure==&lt;br /&gt;
&lt;br /&gt;
===Initiation===&lt;br /&gt;
&lt;br /&gt;
[[File:Voting_Pools_Inbailment_Procedure-01.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Customers will normally request a deposit address by interacting with the service front end web site or some other software application. When the service receives such a request,  it notifies the OT client via the OT client API function: &amp;lt;code&amp;gt;[[request_bailment]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When the OT client receives notice of a user desire to deposit funds to a voting pool, via any method, it sends a &amp;lt;code&amp;gt;[[bailment]]&amp;lt;/code&amp;gt; transaction request to the transaction server to initiate the deposit process.&lt;br /&gt;
&lt;br /&gt;
The transaction server validates this request, and replies with a signed receipt. A copy of this receipt is broadcasted to the &amp;lt;code&amp;gt;[[audit stream]]&amp;lt;/code&amp;gt;, and another copy is stored inside an &amp;lt;code&amp;gt;[[initiatedBailment]]&amp;lt;/code&amp;gt; notice that’s placed in the user’s inbox. The transaction server adds this association to a [[deposit database]] for future reference.&lt;br /&gt;
&lt;br /&gt;
===Payment script generation===&lt;br /&gt;
&lt;br /&gt;
[[File:Voting_Pools_Inbailment_Procedure-02.png|800px]]&lt;br /&gt;
&lt;br /&gt;
When an audit server validates the transaction server’s reply to the &amp;lt;code&amp;gt;bailment&amp;lt;/code&amp;gt; message from the transaction server to which it is assigned, it adds the receipt identifier to its &amp;lt;code&amp;gt;[[deposit database]]&amp;lt;/code&amp;gt; and calls &amp;lt;code&amp;gt;[[Voting Pool Wallet API#getdepositscript|getdepositscript]]&amp;lt;/code&amp;gt; via the websocket interface to the blockchain wallet, using the address identifier for the next unused deposit address.&lt;br /&gt;
&lt;br /&gt;
The wallet calculates and returns the designated [[Deposit Address (voting pools)|deposit address]] as [[P2SH]] output script. The audit server uses this information to update the deposit database, and to assemble and sign a &amp;lt;code&amp;gt;[[Payment Protocol (voting pools)|PaymentRequest]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===PaymentRequest delivery===&lt;br /&gt;
&lt;br /&gt;
[[File:Voting_Pools_Inbailment_Procedure-03.png|800px]]&lt;br /&gt;
&lt;br /&gt;
The audit server broadcasts the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; to all transaction servers and audit servers in the pool. The transaction server replaces the user’s &amp;lt;code&amp;gt;initiatedBailment&amp;lt;/code&amp;gt; notice in the inbox with a &amp;lt;code&amp;gt;[[pendingBailment]]&amp;lt;/code&amp;gt; notice containing a copy of the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When the other audit servers in the pool receive the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; broadcast they add the deposit to their respective deposit databases. The other transaction servers in the pool cache the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; to answer verification requests from the OT client.&lt;br /&gt;
&lt;br /&gt;
The OT client should validate the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; against the voting pool [[asset contract (voting pools)|asset contract]]. If it is valid then it should query a random selection of other transaction servers, at least &amp;lt;code&amp;gt;m-1&amp;lt;/code&amp;gt;, using the &amp;lt;code&amp;gt;[[Payment_Protocol_(voting_pools)|PaymentRequest identifier]]&amp;lt;/code&amp;gt; to verify whether they have seen it. If this check is successful, it then initiates the blockchain transaction by passing the &amp;lt;code&amp;gt;PaymentRequest &amp;lt;/code&amp;gt;to the user's local wallet application which is configured to handle &amp;lt;code&amp;gt;[[bitcoin:]] URIs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Deposit and crediting===&lt;br /&gt;
&lt;br /&gt;
[[File:Voting_Pools_Inbailment_Procedure-04.png|800px]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
;Type 1 Event - [[Fraudulent Deposit Address]]&lt;br /&gt;
:A malicious or hacked operator may give the customer an invalid &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; in an attempt to steal deposits.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Each pool member’s Bitcoin wallet must notify its audit server of any deposits received to an address which the pool controls. When an incoming transaction is received to an address the audit servers are expecting due to previously broadcast &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt;, they will use the &amp;lt;code&amp;gt;[[Voting Pool Wallet API#getinfomultisigwalletaddress|getinfomultisigwalletaddress]]&amp;lt;/code&amp;gt; calls to identify the incoming transaction, and &amp;lt;code&amp;gt;[[Voting Pool Wallet API#gettransactionstatus|gettransactionstatus]]&amp;lt;/code&amp;gt; to monitor its confirmation status.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
;Type 0 Event - [[Deposit Never Received]]&lt;br /&gt;
:It’s possible that the customer may never actually transfer bitcoins after requesting a PaymentRequest.&lt;br /&gt;
&lt;br /&gt;
;Type 1 Event - [[Unknown Deposit]]&lt;br /&gt;
:A deposit may be received to an address which has never been used, and for which a PaymentRequest was never created so no member of the pool knows to which nym it should be credited. &lt;br /&gt;
&lt;br /&gt;
;Type 1 Event - [[Duplicate Deposit]]&lt;br /&gt;
:A deposit may be received from an address which has been previously used, so the audit servers know to which nym the address is assigned.&lt;br /&gt;
&lt;br /&gt;
;Type 0 Event - [[Dust Handling]]:&lt;br /&gt;
The size of the deposit may be below the network dust threshold (small enough that it would require more in transaction fees to spend than it is worth).&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The audit server relays the number of confirmations the incoming transaction has received to the transaction server. Once the number is sufficient according to the [[Funds_Available_Policy_(voting_pools)|Funds Available Policy]] the transaction server will issue an OT asset for the amount of the deposit to the [[nym]] of the user.&lt;br /&gt;
&lt;br /&gt;
The transaction server will replace the &amp;lt;code&amp;gt;pendingBailment&amp;lt;/code&amp;gt; notice (in the inbox) with a &amp;lt;code&amp;gt;[[completedBailment]]&amp;lt;/code&amp;gt; notice, which includes a signed copy of the original &amp;lt;code&amp;gt;bailment&amp;lt;/code&amp;gt; request, as well as a copy of the audit server’s signed notice of confirmations, which includes the transaction identifier provided by the blockchain wallet.&lt;br /&gt;
&lt;br /&gt;
The OT client processes the user’s OT account inbox, removing the &amp;lt;code&amp;gt;completedBailment&amp;lt;/code&amp;gt; notice, which simultaneously closes the transaction number and updates his OT balance.&lt;br /&gt;
&lt;br /&gt;
The audit servers in the pool must monitor all deposits to ensure the [[Funds Available Policy (voting pools)|Funds Available Policy]] is satisfied to avoid the risk of a double spend or chain fork causing insolvency. Any server which offers more early deposit credits than what it can cover with its service account must have its audit status set to &amp;lt;code&amp;gt;[[Auditing (voting pools)|degraded]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
;Type 2 Event - [[Minority loss of consensus#Non-credited Deposit|Non-credited Deposit]]&lt;br /&gt;
:The transaction server fails to place a &amp;lt;code&amp;gt;completedBailment&amp;lt;/code&amp;gt; notice in the user’s inbox after a successful Bitcoin transfer.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
If an initially-seen deposit fails due to a chain fork, and if the user has not yet been credited with an OT receipt for the deposit, the status of the deposit remains pending. The audit server should notify the transaction server by setting the number of confirmations back to zero. In the typical case of blockchain [[reorg]] event, the deposit transaction should re-enter the [[mempool]] automatically and the wallet can assist with this by rebroadcasting it.&lt;br /&gt;
&lt;br /&gt;
If an initially-seen deposit has become invalid due to conflicting transactions which made it into the blockchain, the audit server should mark the deposit as &amp;lt;code&amp;gt;failed&amp;lt;/code&amp;gt; by setting the number of confirmations to -1. The audit server should notify the transaction server of the failure, who then replaces the user’s &amp;lt;code&amp;gt;pendingBailment&amp;lt;/code&amp;gt; notice with a &amp;lt;code&amp;gt;[[failedBailment]]&amp;lt;/code&amp;gt; notice. The transaction server should update the status to &amp;lt;code&amp;gt;failed&amp;lt;/code&amp;gt; in the deposit database and the address should not be intentionally reused. The OT client can then process the user’s inbox, removing the &amp;lt;code&amp;gt;failedBailment&amp;lt;/code&amp;gt; notice and closing the transaction number. In this case there is no change to the OT account balance, unlike with a &amp;lt;code&amp;gt;completeBailment&amp;lt;/code&amp;gt; notice.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
;Type 1 Event - [[Reversed Deposit]]&lt;br /&gt;
:A deposit could disappear from the blockchain after the user has already been issued an OT receipt&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Voting Pool Operations]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
	<entry>
		<id>http://opentransactions.org/wiki/index.php?title=Voting_Pool_Deposit_Process&amp;diff=2146</id>
		<title>Voting Pool Deposit Process</title>
		<link rel="alternate" type="text/html" href="http://opentransactions.org/wiki/index.php?title=Voting_Pool_Deposit_Process&amp;diff=2146"/>
		<updated>2014-08-07T16:29:44Z</updated>

		<summary type="html">&lt;p&gt;GuilhermeSalgado: Move a paragraph to the section where it belongs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Procedure==&lt;br /&gt;
&lt;br /&gt;
===Initiation===&lt;br /&gt;
&lt;br /&gt;
[[File:Voting_Pools_Inbailment_Procedure-01.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Customers will normally request a deposit address by interacting with the service front end web site or some other software application. When the service receives such a request,  it notifies the OT client via the OT client API function: &amp;lt;code&amp;gt;[[request_bailment]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When the OT client receives notice of a user desire to deposit funds to a voting pool, via any method, it sends a &amp;lt;code&amp;gt;[[bailment]]&amp;lt;/code&amp;gt; transaction request to the transaction server to initiate the deposit process.&lt;br /&gt;
&lt;br /&gt;
The transaction server validates this request, and replies with a signed receipt. A copy of this receipt is broadcasted to the &amp;lt;code&amp;gt;[[audit stream]]&amp;lt;/code&amp;gt;, and another copy is stored inside an &amp;lt;code&amp;gt;[[initiatedBailment]]&amp;lt;/code&amp;gt; notice that’s placed in the user’s inbox. The transaction server adds this association to a [[deposit database]] for future reference.&lt;br /&gt;
&lt;br /&gt;
===Payment script generation===&lt;br /&gt;
&lt;br /&gt;
[[File:Voting_Pools_Inbailment_Procedure-02.png|800px]]&lt;br /&gt;
&lt;br /&gt;
When an audit server validates the transaction server’s reply to the &amp;lt;code&amp;gt;bailment&amp;lt;/code&amp;gt; message from the transaction server to which it is assigned, it adds the receipt identifier to its &amp;lt;code&amp;gt;[[deposit database]]&amp;lt;/code&amp;gt; and calls &amp;lt;code&amp;gt;[[Voting Pool Wallet API#getdepositscript|getdepositscript]]&amp;lt;/code&amp;gt; via the websocket interface to the blockchain wallet, using the address identifier for the next unused deposit address.&lt;br /&gt;
&lt;br /&gt;
The wallet calculates and returns the designated deposit address as [[P2SH]] output script. The audit server uses this information to update the deposit database, and to assemble and sign a &amp;lt;code&amp;gt;[[Payment Protocol (voting pools)|PaymentRequest]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===PaymentRequest delivery===&lt;br /&gt;
&lt;br /&gt;
[[File:Voting_Pools_Inbailment_Procedure-03.png|800px]]&lt;br /&gt;
&lt;br /&gt;
The audit server broadcasts the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; to all transaction servers and audit servers in the pool. The transaction server replaces the user’s &amp;lt;code&amp;gt;initiatedBailment&amp;lt;/code&amp;gt; notice in the inbox with a &amp;lt;code&amp;gt;[[pendingBailment]]&amp;lt;/code&amp;gt; notice containing a copy of the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When the other audit servers in the pool receive the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; broadcast they add the deposit to their respective deposit databases. The other transaction servers in the pool cache the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; to answer verification requests from the OT client.&lt;br /&gt;
&lt;br /&gt;
The OT client should validate the &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; against the voting pool [[asset contract (voting pools)|asset contract]]. If it is valid then it should query a random selection of other transaction servers, at least &amp;lt;code&amp;gt;m-1&amp;lt;/code&amp;gt;, using the &amp;lt;code&amp;gt;[[Payment_Protocol_(voting_pools)|PaymentRequest identifier]]&amp;lt;/code&amp;gt; to verify whether they have seen it. If this check is successful, it then initiates the blockchain transaction by passing the &amp;lt;code&amp;gt;PaymentRequest &amp;lt;/code&amp;gt;to the user's local wallet application which is configured to handle &amp;lt;code&amp;gt;[[bitcoin:]] URIs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Deposit and crediting===&lt;br /&gt;
&lt;br /&gt;
[[File:Voting_Pools_Inbailment_Procedure-04.png|800px]]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
;Type 1 Event - [[Fraudulent Deposit Address]]&lt;br /&gt;
:A malicious or hacked operator may give the customer an invalid &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt; in an attempt to steal deposits.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Each pool member’s Bitcoin wallet must notify its audit server of any deposits received to an address which the pool controls. When an incoming transaction is received to an address the audit servers are expecting due to previously broadcast &amp;lt;code&amp;gt;PaymentRequest&amp;lt;/code&amp;gt;, they will use the &amp;lt;code&amp;gt;[[Voting Pool Wallet API#getinfomultisigwalletaddress|getinfomultisigwalletaddress]]&amp;lt;/code&amp;gt; calls to identify the incoming transaction, and &amp;lt;code&amp;gt;[[Voting Pool Wallet API#gettransactionstatus|gettransactionstatus]]&amp;lt;/code&amp;gt; to monitor its confirmation status.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
;Type 0 Event - [[Deposit Never Received]]&lt;br /&gt;
:It’s possible that the customer may never actually transfer bitcoins after requesting a PaymentRequest.&lt;br /&gt;
&lt;br /&gt;
;Type 1 Event - [[Unknown Deposit]]&lt;br /&gt;
:A deposit may be received to an address which has never been used, and for which a PaymentRequest was never created so no member of the pool knows to which nym it should be credited. &lt;br /&gt;
&lt;br /&gt;
;Type 1 Event - [[Duplicate Deposit]]&lt;br /&gt;
:A deposit may be received from an address which has been previously used, so the audit servers know to which nym the address is assigned.&lt;br /&gt;
&lt;br /&gt;
;Type 0 Event - [[Dust Handling]]:&lt;br /&gt;
The size of the deposit may be below the network dust threshold (small enough that it would require more in transaction fees to spend than it is worth).&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The audit server relays the number of confirmations the incoming transaction has received to the transaction server. Once the number is sufficient according to the [[Funds_Available_Policy_(voting_pools)|Funds Available Policy]] the transaction server will issue an OT asset for the amount of the deposit to the [[nym]] of the user.&lt;br /&gt;
&lt;br /&gt;
The transaction server will replace the &amp;lt;code&amp;gt;pendingBailment&amp;lt;/code&amp;gt; notice (in the inbox) with a &amp;lt;code&amp;gt;[[completedBailment]]&amp;lt;/code&amp;gt; notice, which includes a signed copy of the original &amp;lt;code&amp;gt;bailment&amp;lt;/code&amp;gt; request, as well as a copy of the audit server’s signed notice of confirmations, which includes the transaction identifier provided by the blockchain wallet.&lt;br /&gt;
&lt;br /&gt;
The OT client processes the user’s OT account inbox, removing the &amp;lt;code&amp;gt;completedBailment&amp;lt;/code&amp;gt; notice, which simultaneously closes the transaction number and updates his OT balance.&lt;br /&gt;
&lt;br /&gt;
The audit servers in the pool must monitor all deposits to ensure the [[Funds Available Policy (voting pools)|Funds Available Policy]] is satisfied to avoid the risk of a double spend or chain fork causing insolvency. Any server which offers more early deposit credits than what it can cover with its service account must have its audit status set to &amp;lt;code&amp;gt;[[Auditing (voting pools)|degraded]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
;Type 2 Event - [[Minority loss of consensus#Non-credited Deposit|Non-credited Deposit]]&lt;br /&gt;
:The transaction server fails to place a &amp;lt;code&amp;gt;completedBailment&amp;lt;/code&amp;gt; notice in the user’s inbox after a successful Bitcoin transfer.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
If an initially-seen deposit fails due to a chain fork, and if the user has not yet been credited with an OT receipt for the deposit, the status of the deposit remains pending. The audit server should notify the transaction server by setting the number of confirmations back to zero. In the typical case of blockchain [[reorg]] event, the deposit transaction should re-enter the [[mempool]] automatically and the wallet can assist with this by rebroadcasting it.&lt;br /&gt;
&lt;br /&gt;
If an initially-seen deposit has become invalid due to conflicting transactions which made it into the blockchain, the audit server should mark the deposit as &amp;lt;code&amp;gt;failed&amp;lt;/code&amp;gt; by setting the number of confirmations to -1. The audit server should notify the transaction server of the failure, who then replaces the user’s &amp;lt;code&amp;gt;pendingBailment&amp;lt;/code&amp;gt; notice with a &amp;lt;code&amp;gt;[[failedBailment]]&amp;lt;/code&amp;gt; notice. The transaction server should update the status to &amp;lt;code&amp;gt;failed&amp;lt;/code&amp;gt; in the deposit database and the address should not be intentionally reused. The OT client can then process the user’s inbox, removing the &amp;lt;code&amp;gt;failedBailment&amp;lt;/code&amp;gt; notice and closing the transaction number. In this case there is no change to the OT account balance, unlike with a &amp;lt;code&amp;gt;completeBailment&amp;lt;/code&amp;gt; notice.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
;Type 1 Event - [[Reversed Deposit]]&lt;br /&gt;
:A deposit could disappear from the blockchain after the user has already been issued an OT receipt&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[Category:Voting Pool Operations]]&lt;/div&gt;</summary>
		<author><name>GuilhermeSalgado</name></author>
		
	</entry>
</feed>