2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								<pre>
							 
						 
					
						
							
								
									
										
										
										
											2016-09-23 10:03:34 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  BIP: 134
							 
						 
					
						
							
								
									
										
										
										
											2016-11-30 09:45:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  Layer: Consensus (hard fork)
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  Title: Flexible Transactions
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  Author: Tom Zander <tomz@freedommail.ch>
							 
						 
					
						
							
								
									
										
										
										
											2016-11-30 09:47:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  Comments-Summary: No comments yet.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0134
							 
						 
					
						
							
								
									
										
										
										
											2020-08-01 17:18:43 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  Status: Rejected
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  Type: Standards Track
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  Created: 2016-07-27
							 
						 
					
						
							
								
									
										
										
										
											2016-11-30 09:47:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  License: CC-BY-SA-4.0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								           OPL
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								</pre>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								==Abstract==
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								This BIP describes the next step in making Bitcoin's most basic element,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								the transaction, more flexible and easier to extend. At the same time this
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								fixes all known cases of malleability and resolves significant amounts of
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								technical debt.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								==Summary==
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Flexible Transactions uses the fact that the first 4 bytes in a transaction
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								determine the version and that the majority of the clients use a
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								non-consensus rule (a policy) to not accept transaction version numbers
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								other than those specifically defined by Bitcoin.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								This BIP chooses a new version number, 4, and defines that the data
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								following the bytes for the version is in a format called Compact Message
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Format (CMF). CMF is a flexible, token based format where each token is a
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								combination of a name, a format and a value. Because the name is added we
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								can skip unused tokens and we can freely add new tokens in a simple manner
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								in future. Soft fork upgrades will become much easier and cleaner this
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								way.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								This protocol upgrade cleans up past soft fork changes like BIP68 which
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								reuse existing fields and do them in a better to maintain and easier
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								to parse system. It creates the building blocks to allow new features to be
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								added much cleaner in the future.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								It also shows to be possible to remove signatures from transactions with
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								minimal upgrades of software and still maintain a coherent transaction
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								history. Tests show that this can reduce space usage to about 75%.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								==Motivation==
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								After 8 years of using essentially the same transaction version and layout
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Bitcoin is in need of an upgrade and lessons learned in that time are
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								taking into account when designing it.  The most important detail is that
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								we have seen a need for more flexibility.  For instance when the 'sequence'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								fields were introduced in the old transaction format, and later deprecated
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								again, the end result was that all transactions still were forced to keep
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								those fields and grow the blockchain while they all were set to the default
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The way towards that flexibility is to use a generic concept made popular
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								various decades ago with the XML format. The idea is that we give each
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								field a name and this means that new fields can be added or optional fields
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								can be omitted from individual transactions. Some other ideas are the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								standardization of data-formats (like integer and string encoding) so
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								we create a more consistent system.  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								One thing we shall not inherit from XML is its text-based format. Instead
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								we use the [https://github.com/bitcoinclassic/documentation/blob/master/spec/compactmessageformat.md Compact Message Format]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								(CMF) which is optimized to keep the size small and fast to parse.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								Token based file-formats are not new, systems like XML and HTMl use a
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								similar system to allow future growth and they have been quite successful
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for decades in part because of this property.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Next to that this protocol upgrade will re-order the data-fields which
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								allows us to cleanly fix the malleability issue which means that future
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								technologies like Lightning Network will depend on this BIP being deployed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								At the same time, due to this re-ordering of data fields, it becomes very
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								easy to remove signatures from a transaction without breaking its tx-id,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								which is great for future pruning features.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								=== Features ===
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* Fixes malleability
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* Linear scaling of signature checking
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* Very flexible future extensibility
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* Makes transactions smaller
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* Supports the Lightning Network
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Additionally, in the v4 (flextrans) format we add the support for the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								following proofs;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* input amount.  Including the amount means we sign this transaction only if the amount we are spending is the one provided. Wallets that do not have the full UTXO DB can safely sign knowing that if they were lied to about the amount being spent, their signature is useless.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* scriptBase is the combined script of input and output, without signatures naturally.  Providing this to a hardware wallet means it knows what output it is spending and can respond properly. Including it in the hash means its signature would be broken if we lied..
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* Double spent-proof.  Should a node detect a double spent he can notify his peers about this fact. Instead of sending the entire transactions, instead he sends only a proof.  The node needs to send two pairs of info that proves that in both transactions the CTxIn are identical.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								=== Tokens ===
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								In the compact message format we define tokens and in this specification we
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								define how these tokens are named, where they can be placed and which are
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional.  To refer to XML, this specification would be the schema of
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								a transaction.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[https://github.com/bitcoinclassic/documentation/blob/master/spec/compactmessageformat.md CMF]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								tokens are triplets of name, format (like PositiveInteger) and value.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								Names in this scope are defined much like an enumeration where the actual
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								integer value (id, below) is equally important to the written name.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-26 18:09:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								If any token found that is not covered in the next table it will make the
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								transaction that contains it invalid.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{| class="wikitable"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								! Name !! id !! Format !! Default Value !! Description
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxEnd              ||  0 ||BoolTrue ||   Required   ||A marker that is the end of the transaction
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxInPrevHash       ||  1 ||ByteArray||   Required   ||TxId we are spending
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxPrevIndex        ||  2 ||Integer  ||       0      ||Index in prev tx we are spending (applied to previous TxInPrevHash)
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxInputStackItem   ||  3 ||ByteArray||         ||A 'push' of the input script
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxInputStackItemContinued||4||ByteArray||   &nsbp;       ||Another section for the same input
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxOutValue         ||  5 ||Integer  ||   Required   ||Amount of Satoshis to transfer
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxOutScript        ||  6 ||ByteArray||   Required   ||The output script
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxRelativeBlockLock||  7 ||Integer  ||   Optional   ||Part of the input stating the amount of blocks (max 0XFFFF) after that input was mined, it can be mined
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxRelativeTimeLock ||  8 ||Integer  ||   Optional   ||Part of the input stating the amount of time (max 0XFFFF) after that input was mined, it can be mined. 1 Unit is 512 seconds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								|CoinbaseMessage    ||  9 ||ByteArray||   Optional   ||A message and some data for a coinbase transaction. Can't be used in combination with any TxIn\* tags
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								|NOP_1x             || 1x ||    ||   Optional   ||Values that will be ignored by anyone parsing the transaction
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								|}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								=== Scripting changes ===
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								In Bitcoin transactions version 1, checking of signatures is performed by
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								various opcodes. The OP_CHECKSIG, OP_CHECKMULTISIG and their equivalents
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								that immediately VERIFY.  These are used to validate the cryptographic
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								proofs that users have to provide in order to spend outputs.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								We additionally have some hashing-types in like SIGHASH_SINGLE that all
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								specify slightly different subsections of what part of a transaction will
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								be hashed in order to be signed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								For transactions with version 4 we calculate a sha256 hash for signing an
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								individual input based on the following content;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# If the hash-type is 0 or 1 we hash the tx-id of the transaction. For other hash types we selectively ignore parts of the transaction exactly like it has always worked. With the caveat that we never serialize any signatures.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# the TxId of the transaction we are spending in this input.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# the index of output of the transaction we are spending in this input.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# the input script we are signing (without the signature, naturally).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# the amount, as a var-int.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# the hash-type as a var-int.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								=== Serialization order===
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								To keep in line with the name Flexible Transactions, there is very little
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								requirement to have a specific order. The only exception is cases where
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								there are optional values and reordering would make unclear what is meant.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								For this reason the TxInPrevHash always has to be the first token to start
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								a new input. This is because the TxPrevIndex is optional. The tokens
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								TxRelativeTimeLock and TxRelativeBlockLock are part of the input and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								similarly have to be set after the TxInPrevHash they belong to.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Similarly, the TxInputStackItem always has to be the first and can be
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								followed by a number of TxInputStackItemContinued items.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								At a larger scope we define 3 sections of a transaction.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{| class="wikitable"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								!Segment !! Tags !! Description
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|Transaction||all not elsewhere used||This section is used to make the TxId
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|Signatures||TxInputStackItem, TxInputStackItemContinued||The input-proofs
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|-
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								|TxEnd||TxEnd|| 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								|}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The TxId is calculated by taking the serialized transaction without the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Signatures and the TxEnd and hashing that.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								TxEnd is there to allow a parser to know when one transaction in a stream
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								has ended, allowing the next to be parsed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								=== Block-malleability ===
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The effect of leaving the signatures out of the calculation of the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								transaction-id implies that the signatures are also not used for the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								calculation of the merkle tree.  This means that changes in signatures
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								would not be detectable and open an attack vector.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								For this reason the merkle tree is extended to include (append) the hash of
							 
						 
					
						
							
								
									
										
										
										
											2017-07-10 11:50:39 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								the v4 transactions. The merkle tree will continue to have all the
							 
						 
					
						
							
								
									
										
										
										
											2016-09-26 18:09:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								transactions' tx-ids but appended to that are the v4 hashes that include the
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								signatures as well.  Specifically the hash is taken over a data-blob that
							 
						 
					
						
							
								
									
										
										
										
											2016-09-26 18:09:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								is built up from:
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# the tx-id
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# The entire bytearray that makes up all of the transactions signatures.  This is a serialization of all of the signature tokens, so the TxInputStackItem and TxInputStackItemContinued in the order based on the inputs they are associated with.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								=== Future extensibility ===
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The NOP_1x wildcard used in the table explaining tokens is actually a list
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								of 10 values that currently are specified as NOP (no-operation) tags.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Any implementation that supports the v4 transaction format should ignore
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								this field in a transaction. Interpreting and using the transaction as if
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								that field was not present at all.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Future software may use these fields to decorate a transaction with
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								additional data or features. Transaction generating software should not
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								trivially use these tokens for their own usage without cooperation and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								communication with the rest of the Bitcoin ecosystem as miners certainly
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								have the option to reject transactions that use unknown-to-them tokens.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The amount of tokens that can be added after number 19 is practically
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								unlimited and they are currently specified to not be allowed in any
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								transaction and the transaction will be rejected if they are present.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								In the future a protocol upgrade may chance that and specify meaning for
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								any token not yet specified here. Future upgrades should thus be quite a
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								lot smoother because there is no change in concepts or in format. Just new
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								data.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								==Backwards compatibility ==
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Fully validating older clients will not be able to understand or validate
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								version 4 transactions and will need to be updated to restore that ability.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								SPV (simple payment validation) wallets need to be updated to receive or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								create the new transaction type.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								This BIP introduces a new transaction format without changing or
							 
						 
					
						
							
								
									
										
										
										
											2016-09-26 18:09:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								deprecating the existing one or any of its practices. Therefore it is
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								backwards compatible for any existing data or parsing-code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								==Reference Implementation==
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Bitcoin Classic includes an implementation that is following this spec.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The spec-author rejects the notion of reference implementation. The
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								specification is always authoritative, the implementation is not.
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-28 18:06:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The official spec can be found at;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								https://github.com/bitcoinclassic/documentation/blob/master/spec/transactionv4.md
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								==Deployment==
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								To be determined
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								==References==
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[https://github.com/bitcoinclassic/documentation/blob/master/spec/compactmessageformat.md] CMF
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								==Copyright==
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Copyright (c) 2016 Tom Zander <tomz@freedommail.ch>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-26 18:09:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								This document is dual-licensed under the Creative-Commons BY-SA license v4.0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								and the Open Publication License v1.0 with the following licence-options:
							 
						 
					
						
							
								
									
										
										
										
											2016-09-19 18:13:33 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.