<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.bitcoinsv.io/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Joshua+Henslee</id>
	<title>Bitcoin Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.bitcoinsv.io/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Joshua+Henslee"/>
	<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php/Special:Contributions/Joshua_Henslee"/>
	<updated>2026-05-28T03:59:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=The_Byzantine_Generals_Problem&amp;diff=1853</id>
		<title>The Byzantine Generals Problem</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=The_Byzantine_Generals_Problem&amp;diff=1853"/>
		<updated>2020-02-05T17:09:52Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Byzantine Generals Problem was first proposed by Leslie Lamport, Robert Shostak, and Marshall Pease as part of research being conducted at NASA. The problem deals with how to define how to direct a network of disconnected units in a leaderless situation. It has been somewhat adapted to the problem of Bitcoin for this description however the original paper can be found here: https://people.eecs.berkeley.edu/~luca/cs174/byzantine.pdf.&lt;br /&gt;
&lt;br /&gt;
The problem defines how generals can issue commands without a centralised communication structure while remaining robust in the face of bad actors who might try to issue malicious commands to the army.&lt;br /&gt;
&lt;br /&gt;
The Byzantine army is encamped outside a city broken into divisions, each controlled by a general. Generals have no means to communicate other than through messengers. There are traitorous generals in the army who will try to issue commands that prevent the loyal generals from reaching agreement on a reasonable plan forward, so the messaging protocol must ensure that message receivers can know that they are from a loyal general.&lt;br /&gt;
&lt;br /&gt;
Anyone can present a message to a general claiming it to be from another general so the protocol must have a means for generals to know with certainty that any proposed moves are from another general. A cipher that demonstrates the message is from a real general is needed. In Bitcoin, [[Proof of Work]] demonstrates a node's authority to write blocks to the ledger. This is a core element of [[Nakamoto Consensus]]. &lt;br /&gt;
&lt;br /&gt;
The army sometimes becomes divided when two generals find valid moves at around the same time. It takes a short period of time for orders to be propagated so the generals may end up following divergent moves.&lt;br /&gt;
&lt;br /&gt;
If the army starts moving apart, generals in the group that falls behind the front will stop what they are doing and catch up. This is what happens in a network [[Re-org]], with the abandoned move creating an [[Orphan Block]].&lt;br /&gt;
&lt;br /&gt;
The need for generals to always be at the front of the army incentivizes the best generals to form direct lines of communication with each other leading to much faster communication. In Bitcoin, this incentive drives miners to find the best way to connect to each other, driving the [[Bitcoin Core Network]] members into forming a [[Small World Network]] with large highly connected systems. This core trends towards a [[Nearly Complete Graph]] where all nodes are connected to almost all other nodes.&lt;br /&gt;
&lt;br /&gt;
Finding valid solutions to proof of work is generally limited to 6 nodes an hour so the center of the mandala trends towards a size maxima constrained by [[wikipedia:Metcalfe's law|Metcalfes law]]. As more nodes join the competition, it becomes more expensive to maintain connections, so miners will instinctively cut ties with non-performing miners to connect with newer, more powerful nodes. This element of constant building to maintain position can be described as a [[wikipedia:Red_Queen's race|Red Queen's race]] where participants must continuously accelerate in order to maintain their position in the field.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1827</id>
		<title>Paper wallet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1827"/>
		<updated>2020-02-04T02:46:27Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Bitcoin ATMs and paper wallets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''paper wallet''' is the name given to a method of storing bitcoin which involves printing a paired [[Private Keys|Bitcoin private key]] and [[address]] onto paper and depositing funds into a [[Bitcoin Transactions#P2PHK|P2PKH]] script using the address. Funds can be spent by accessing the physical paper and entering the private key into a wallet. This is usually achieved by scanning a QR code of the private key in [[Wallet import format]] (WIF).&lt;br /&gt;
&lt;br /&gt;
== Redeeming bitcoins and withdrawing funds ==&lt;br /&gt;
&lt;br /&gt;
The best way to redeem the bitcoins from a private key is to use the &amp;quot;sweep&amp;quot; feature of certain wallet software. This process creates a new transaction that sends the entire balance of the paper wallet to a new address controlled by that wallet.&lt;br /&gt;
&lt;br /&gt;
There are various wallets capable of doing this including:&lt;br /&gt;
&lt;br /&gt;
* [https://electrumsv.io/ ElectrumSV]&lt;br /&gt;
* [https://simply.cash/ Simply Cash]&lt;br /&gt;
&lt;br /&gt;
==Downsides/Risks==&lt;br /&gt;
&lt;br /&gt;
Paper wallets are generally regarded as a secure method of long-term storage of funds; however there are downsides to using this method.&lt;br /&gt;
&lt;br /&gt;
===Printing and Print Media===&lt;br /&gt;
Paper wallets require using a printer to transfer them to paper which presents a risk if networked printers are used in an insecure environment.&lt;br /&gt;
&lt;br /&gt;
Additionally, while QR codes have a checksum and robust error correction, print media can be damaged by water, soilage or through crumpling or folding of the paper.&lt;br /&gt;
&lt;br /&gt;
=== Address reuse ===&lt;br /&gt;
&lt;br /&gt;
Paper wallets have just one bitcoin address, leading to [[address reuse]].&lt;br /&gt;
&lt;br /&gt;
=== Poor user experience ===&lt;br /&gt;
&lt;br /&gt;
Dealing with raw private keys can be unintuitive and may lead to loss of funds if not managed properly. It is recommended that users of paper wallets understand how they function before using them as long-term funds storage.&lt;br /&gt;
&lt;br /&gt;
== Bitcoin ATMs and paper wallets ==&lt;br /&gt;
&lt;br /&gt;
Many bitcoin ATMs use a paper-wallet-like system for delivering bitcoins if the customer doesn't have a bitcoin wallet. The ATMs can print out a private key/address pair onto paper which contain the customer's bitcoins. Ideally the customer should sweep the bitcoins into their own wallet as soon as they can.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Seed phrase]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1807</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1807"/>
		<updated>2020-02-04T02:22:52Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a [[Payment Channels|Payment Channel]] using [[nLocktime and nSequence]] interlocks, or sent directly to [[the Core Network|The Bitcoin Network]] for inscription into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double [[SHA-256]] hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution that unlocks the Bitcoin held in the ScriptPubKey. Outputs may have zero value in Bitcoin, but may carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]]. This can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
==General format of a Bitcoin transaction==&lt;br /&gt;
The following outlines the elements that are serialised to build a valid Bitcoin transaction.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#Format_of_a_Transaction_Input|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Transaction Inputs and Outputs==&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction, and a transactions can include between 1 and 2&amp;lt;super&amp;gt;32&amp;lt;/super&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is consumed by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input ScriptSig may contain many components. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Elliptic Curve Digital Signature Algorithm|ECDSA]] signature. Dependent on the [[SIGHASH flags]] used, the signature may cover a hash representing part or all of the transaction. Combined with the public key, this proves the transaction was created by a person or process that controls the keys needed to spend the Bitcoin in the input.&lt;br /&gt;
&lt;br /&gt;
=== Format of a Transaction Input ===&lt;br /&gt;
Otherwise known as a TXIN, the following table outlines the required elements of a valid transaction input.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[SHA-256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|Sequence_no&lt;br /&gt;
|Used to iterate inputs inside a payment channel. Input is final when nSequence = 0xFFFFFFFF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the [[Coinbase]] message and includes information about which block it was mined in and a miner configurable data element.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins, requiring a certain set of keys or information to be provided to unlock them. Outputs can also be used to inscribe data onto the ledger.&lt;br /&gt;
&lt;br /&gt;
This '''ScriptPubKey''' is the second half of a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. &lt;br /&gt;
The '''Value''' of each output is the number of Satoshis that the script unlocks when solved.&lt;br /&gt;
Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any [[Satoshis]] left unallocated are considered to be paid in mining fees and are awarded to the miner whose node generates the block that the transaction is included in.&lt;br /&gt;
&lt;br /&gt;
If a user's input is larger than the value they want to send, the transaction must create at least two outputs, one sending the required funds to the destination, and one sending the [[change]] back to the user.&lt;br /&gt;
&lt;br /&gt;
Outputs can have a value of zero satoshis. Currently, these outputs are limited to [[False Return]] scripts and are typically used to carry other information or tokens for [[Application layer protocol|Application layer protocols]].&lt;br /&gt;
&lt;br /&gt;
===Format of a Transaction Output===&lt;br /&gt;
Otherwise known as a TXOUT, the following table outlines the required elements of a valid transaction output.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output's scriptPubKey sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
== Transaction Validation ==&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a [[wikipedia:Forth_(programming_language)|Forth]]-like [[Advanced Bitcoin Scripting|scripting]] system. The input's scriptSig and the referenced output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by the scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that must be met in order to claim the output's value.&lt;br /&gt;
&lt;br /&gt;
For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if the script returns true. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script validates that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for '[[R-Puzzles#k|k]]' rather than a random number. To redeem the script, the spending party provides both the signature and the public key.&lt;br /&gt;
&lt;br /&gt;
The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair.&lt;br /&gt;
&lt;br /&gt;
This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are arrayed on the stack when it is executed. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG indicates to the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Examples of more complex script can be found [[Complex Script Examples| here]]&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1806</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1806"/>
		<updated>2020-02-04T02:22:43Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a [[Payment Channels|Payment Channel]] using [[nLocktime and nSequence]] interlocks, or sent directly to [[the Core Network|The Bitcoin Network]] for inscription into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double [[SHA-256]] hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution that unlocks the Bitcoin held in the ScriptPubKey. Outputs may have zero value in Bitcoin, but may carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]]. This can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
==General format of a Bitcoin transaction==&lt;br /&gt;
The following outlines the elements that are serialised to build a valid Bitcoin transaction.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#Format_of_a_Transaction_Input|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Transaction Inputs and Outputs==&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction, and a transactions can include between 1 and 2&amp;lt;super&amp;gt;32&amp;lt;/super&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is consumed by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input ScriptSig may contain many components. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Elliptic Curve Digital Signature Algorithm|ECDSA]] signature. Dependent on the [[SIGHASH flags]] used, the signature may cover a hash representing part or all of the transaction. Combined with the public key, this proves the transaction was created by a person or process that controls the keys needed to spend the Bitcoin in the input.&lt;br /&gt;
&lt;br /&gt;
=== Format of a Transaction Input ===&lt;br /&gt;
Otherwise known as a TXIN, the following table outlines the required elements of a valid transaction input.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[SHA-256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|Sequence_no&lt;br /&gt;
|Used to iterate inputs inside a payment channel. Input is final when nSequence = 0xFFFFFFFF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the [[Coinbase]] message and includes information about which block it was mined in and a miner configurable data element.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins, requiring a certain set of keys or information to be provided to unlock them. Outputs can also be used to inscribe data onto the ledger.&lt;br /&gt;
&lt;br /&gt;
This '''ScriptPubKey''' is the second half of a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. &lt;br /&gt;
The '''Value''' of each output is the number of Satoshis that the script unlocks when solved.&lt;br /&gt;
Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any [[Satoshis]] left unallocated are considered to be paid in mining fees and are awarded to the miner whose node generates the block that the transaction is included in..&lt;br /&gt;
&lt;br /&gt;
If a user's input is larger than the value they want to send, the transaction must create at least two outputs, one sending the required funds to the destination, and one sending the [[change]] back to the user.&lt;br /&gt;
&lt;br /&gt;
Outputs can have a value of zero satoshis. Currently, these outputs are limited to [[False Return]] scripts and are typically used to carry other information or tokens for [[Application layer protocol|Application layer protocols]].&lt;br /&gt;
&lt;br /&gt;
===Format of a Transaction Output===&lt;br /&gt;
Otherwise known as a TXOUT, the following table outlines the required elements of a valid transaction output.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output's scriptPubKey sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
== Transaction Validation ==&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a [[wikipedia:Forth_(programming_language)|Forth]]-like [[Advanced Bitcoin Scripting|scripting]] system. The input's scriptSig and the referenced output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by the scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that must be met in order to claim the output's value.&lt;br /&gt;
&lt;br /&gt;
For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if the script returns true. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script validates that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for '[[R-Puzzles#k|k]]' rather than a random number. To redeem the script, the spending party provides both the signature and the public key.&lt;br /&gt;
&lt;br /&gt;
The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair.&lt;br /&gt;
&lt;br /&gt;
This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are arrayed on the stack when it is executed. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG indicates to the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Examples of more complex script can be found [[Complex Script Examples| here]]&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1804</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1804"/>
		<updated>2020-02-04T02:22:03Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a [[Payment Channels|Payment Channel]] using [[nLocktime and nSequence]] interlocks, or sent directly to [[the Core Network|The Bitcoin Network]] for inscription into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double [[SHA-256]] hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution that unlocks the Bitcoin held in the ScriptPubKey. Outputs may have zero value in Bitcoin, but may carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]]. This can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
==General format of a Bitcoin transaction==&lt;br /&gt;
The following outlines the elements that are serialised to build a valid Bitcoin transaction.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#Format_of_a_Transaction_Input|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Transaction Inputs and Outputs==&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction, and a transactions can include between 1 and 2&amp;lt;super&amp;gt;32&amp;lt;/super&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is consumed by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input ScriptSig may contain many components. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Elliptic Curve Digital Signature Algorithm|ECDSA]] signature. Dependent on the [[SIGHASH flags]] used, the signature may cover a hash representing part or all of the transaction. Combined with the public key, this proves the transaction was created by a person or process that controls the keys needed to spend the Bitcoin in the input.&lt;br /&gt;
&lt;br /&gt;
=== Format of a Transaction Input ===&lt;br /&gt;
Otherwise known as a TXIN, the following table outlines the required elements of a valid transaction input.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|Sequence_no&lt;br /&gt;
|Used to iterate inputs inside a payment channel. Input is final when nSequence = 0xFFFFFFFF&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the [[Coinbase]] message and includes information about which block it was mined in and a miner configurable data element.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins, requiring a certain set of keys or information to be provided to unlock them. Outputs can also be used to inscribe data onto the ledger.&lt;br /&gt;
&lt;br /&gt;
This '''ScriptPubKey''' is the second half of a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. &lt;br /&gt;
The '''Value''' of each output is the number of Satoshis that the script unlocks when solved.&lt;br /&gt;
Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any [[Satoshis]] left unallocated are considered to be paid in mining fees] and are awarded to the miner whos node generates the block that the transaction is included in..&lt;br /&gt;
&lt;br /&gt;
If a user's input is larger than the value they want to send, the transaction must create at least two outputs, one sending the required funds to the destination, and one sending the [[change]] back to the user.&lt;br /&gt;
&lt;br /&gt;
Outputs can have a value of zero satoshis. Currently, these outputs are limited to [[False Return]] scripts and are typically used to carry other information or tokens for [[Application layer protocol|Application layer protocols]].&lt;br /&gt;
&lt;br /&gt;
===Format of a Transaction Output===&lt;br /&gt;
Otherwise known as a TXOUT, the following table outlines the required elements of a valid transaction output.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output's scriptPubKey sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
== Transaction Validation ==&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a [[wikipedia:Forth_(programming_language)|Forth]]-like [[Advanced Bitcoin Scripting|scripting]] system. The input's scriptSig and the referenced output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by the scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that must be met in order to claim the output's value.&lt;br /&gt;
&lt;br /&gt;
For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if the script returns true. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script validates that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for '[[R-Puzzles#k|k]]' rather than a random number. To redeem the script, the spending party provides both the signature and the public key.&lt;br /&gt;
&lt;br /&gt;
The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair.&lt;br /&gt;
&lt;br /&gt;
This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are arrayed on the stack when it is executed. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG indicates to the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Examples of more complex script can be found [[Complex Script Examples| here]]&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Satoshi_Vision&amp;diff=1485</id>
		<title>Bitcoin Satoshi Vision</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Satoshi_Vision&amp;diff=1485"/>
		<updated>2020-01-23T21:28:57Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Bitcoin V0.1 and the return to Genesis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin Satoshi Vision (BitcoinSV) was created to maintain the integrity of the Bitcoin public ledger by reverting back to the original Bitcoin protocol with a view to keeping it stable and secure, and allowing it to scale massively to accommodate global demand for open public ledger technology.&lt;br /&gt;
&lt;br /&gt;
Bitcoin SV will maintain the vision set out by Satoshi Nakamoto’s visionary 2008 white paper titled [file:bitcoin.pdf Bitcoin: A Peer-to-Peer Electronic Cash System].&lt;br /&gt;
&lt;br /&gt;
==Past Ledger Migrations==&lt;br /&gt;
The Bitcoin ledger has twice been migrated to competing networks to preserve the integrity of the ledger. The first migration was performed on August 1st, 2017 when the ledger was moved from the BTC network onto the newly created Bitcoin Cash (BCH) network. The ledger was duplicated giving all BTC users an airdrop of coins on the BTC network just prior to the protocol having the irreversible Segregated Witness (SegWit) change applied.&lt;br /&gt;
&lt;br /&gt;
The BitcoinSV network was created on November 15th, 2008 when miners again chose to migrate the ledger to protect it from the introduction of malicious changes. The BitcoinSV network is operated by miners who understand that the future of Bitcoin is through massive global scaling and have begun works to build new infrastructure and software to improve the transactional capacity of the network.&lt;br /&gt;
&lt;br /&gt;
==Bitcoin V0.1 and the return to Genesis==&lt;br /&gt;
Since the creation of the BitcoinSV network, Bitcoin has undergone a series of upgrades which have each removed selected limits that have impact the network's throughput or re-enable features that had previously been disabled or even removed.&lt;br /&gt;
&lt;br /&gt;
In February 2020, the BitcoinSV network underwent the [[Genesis upgrade]], which removed all remaining limitations on the Bitcoin protocol. These included limits on transaction size, script size, multi-signature usage, block size and more. &lt;br /&gt;
&lt;br /&gt;
The BitcoinSV network is the [[Capacity Metrics|highest performing public ledger network in the world]].&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Satoshi_Vision&amp;diff=1484</id>
		<title>Bitcoin Satoshi Vision</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Satoshi_Vision&amp;diff=1484"/>
		<updated>2020-01-23T21:27:17Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Bitcoin V0.1 and the return to Genesis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin Satoshi Vision (BitcoinSV) was created to maintain the integrity of the Bitcoin public ledger by reverting back to the original Bitcoin protocol with a view to keeping it stable and secure, and allowing it to scale massively to accommodate global demand for open public ledger technology.&lt;br /&gt;
&lt;br /&gt;
Bitcoin SV will maintain the vision set out by Satoshi Nakamoto’s visionary 2008 white paper titled [file:bitcoin.pdf Bitcoin: A Peer-to-Peer Electronic Cash System].&lt;br /&gt;
&lt;br /&gt;
==Past Ledger Migrations==&lt;br /&gt;
The Bitcoin ledger has twice been migrated to competing networks to preserve the integrity of the ledger. The first migration was performed on August 1st, 2017 when the ledger was moved from the BTC network onto the newly created Bitcoin Cash (BCH) network. The ledger was duplicated giving all BTC users an airdrop of coins on the BTC network just prior to the protocol having the irreversible Segregated Witness (SegWit) change applied.&lt;br /&gt;
&lt;br /&gt;
The BitcoinSV network was created on November 15th, 2008 when miners again chose to migrate the ledger to protect it from the introduction of malicious changes. The BitcoinSV network is operated by miners who understand that the future of Bitcoin is through massive global scaling and have begun works to build new infrastructure and software to improve the transactional capacity of the network.&lt;br /&gt;
&lt;br /&gt;
==Bitcoin V0.1 and the return to Genesis==&lt;br /&gt;
Since the creation of the BitcoinSV network, Bitcoin has undergone a series of upgrades which have each removed selected limits that have impact the network's throughput, or re-enable features that had previously been disabled or even removed.&lt;br /&gt;
&lt;br /&gt;
In February 2020, the BitcoinSV network underwent the [[Genesis upgrade]], which removed all remaining limitations on the Bitcoin protocol. These included limits on transaction size, script size, multisignature usage, block size and more. &lt;br /&gt;
&lt;br /&gt;
The BitcoinSV network is the [[Capacity Metrics|highest performing public ledger network in the world]].&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Satoshi_Vision&amp;diff=1483</id>
		<title>Bitcoin Satoshi Vision</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Satoshi_Vision&amp;diff=1483"/>
		<updated>2020-01-23T21:26:10Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Past Ledger Migrations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin Satoshi Vision (BitcoinSV) was created to maintain the integrity of the Bitcoin public ledger by reverting back to the original Bitcoin protocol with a view to keeping it stable and secure, and allowing it to scale massively to accommodate global demand for open public ledger technology.&lt;br /&gt;
&lt;br /&gt;
Bitcoin SV will maintain the vision set out by Satoshi Nakamoto’s visionary 2008 white paper titled [file:bitcoin.pdf Bitcoin: A Peer-to-Peer Electronic Cash System].&lt;br /&gt;
&lt;br /&gt;
==Past Ledger Migrations==&lt;br /&gt;
The Bitcoin ledger has twice been migrated to competing networks to preserve the integrity of the ledger. The first migration was performed on August 1st, 2017 when the ledger was moved from the BTC network onto the newly created Bitcoin Cash (BCH) network. The ledger was duplicated giving all BTC users an airdrop of coins on the BTC network just prior to the protocol having the irreversible Segregated Witness (SegWit) change applied.&lt;br /&gt;
&lt;br /&gt;
The BitcoinSV network was created on November 15th, 2008 when miners again chose to migrate the ledger to protect it from the introduction of malicious changes. The BitcoinSV network is operated by miners who understand that the future of Bitcoin is through massive global scaling and have begun works to build new infrastructure and software to improve the transactional capacity of the network.&lt;br /&gt;
&lt;br /&gt;
==Bitcoin V0.1 and the return to Genesis==&lt;br /&gt;
Since the creation of the BitcoinSV network, Bitcoin has undergone a series of upgrades which have each removed selected limits that impact the network's throughput, or re-enable features that had previously been disabled or even removed.&lt;br /&gt;
&lt;br /&gt;
In February 2020, the BitcoinSV network underwent the [[Genesis upgrade]], which removed all remaining limitations on the Bitcoin protocol. These included limits on transaction size, script size, multisignature usage, block size and more. &lt;br /&gt;
&lt;br /&gt;
The BitcoinSV network is the [[Capacity Metrics|highest performing public ledger network in the world]].&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Satoshi_Vision&amp;diff=1482</id>
		<title>Bitcoin Satoshi Vision</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Satoshi_Vision&amp;diff=1482"/>
		<updated>2020-01-23T21:25:33Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Past Ledger Migrations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin Satoshi Vision (BitcoinSV) was created to maintain the integrity of the Bitcoin public ledger by reverting back to the original Bitcoin protocol with a view to keeping it stable and secure, and allowing it to scale massively to accommodate global demand for open public ledger technology.&lt;br /&gt;
&lt;br /&gt;
Bitcoin SV will maintain the vision set out by Satoshi Nakamoto’s visionary 2008 white paper titled [file:bitcoin.pdf Bitcoin: A Peer-to-Peer Electronic Cash System].&lt;br /&gt;
&lt;br /&gt;
==Past Ledger Migrations==&lt;br /&gt;
The Bitcoin ledger has twice been migrated to competing networks to preserve the integrity of the ledger. The first migration was performed on August 1st, 2017 when the ledger was moved from the BTC network onto the newly created Bitcoin Cash (BCH) network. The ledger was duplicated giving all BTC users an airdrop of coins on the BTC network just prior to the protocol having the irreversible Segregated Witness (SegWit) change applied.&lt;br /&gt;
&lt;br /&gt;
The BitcoinSV network was created on November 15 2008 when miners again chose to migrate the ledger to protect it from the introduction of malicious changes. The BitcoinSV network is operated by miners who understand that the future of Bitcoin is through massive global scaling and have begun works to build new infrastructure and software to improve the transactional capacity of the network.&lt;br /&gt;
&lt;br /&gt;
==Bitcoin V0.1 and the return to Genesis==&lt;br /&gt;
Since the creation of the BitcoinSV network, Bitcoin has undergone a series of upgrades which have each removed selected limits that impact the network's throughput, or re-enable features that had previously been disabled or even removed.&lt;br /&gt;
&lt;br /&gt;
In February 2020, the BitcoinSV network underwent the [[Genesis upgrade]], which removed all remaining limitations on the Bitcoin protocol. These included limits on transaction size, script size, multisignature usage, block size and more. &lt;br /&gt;
&lt;br /&gt;
The BitcoinSV network is the [[Capacity Metrics|highest performing public ledger network in the world]].&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Change&amp;diff=1481</id>
		<title>Change</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Change&amp;diff=1481"/>
		<updated>2020-01-23T21:24:01Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Consolidating UTXOs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Introduction ===&lt;br /&gt;
When a UTXO is spent, it must be consumed entirely. If the value of the UTXO is greater than the amount being spent, then the difference in the amount must be allocated to a new address that the spender owns; this is a change address.&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
In a standard payment scenario, the sender consumes a single UTXO, paying the spending amount to the receiver's address, then receiving the change into a new address that they control to take advantage of privacy.&lt;br /&gt;
&lt;br /&gt;
In [https://whatsonchain.com/tx/d0033a539a426de7142f4b230328c84306b6ebc1c985515d522a411c397522df this example], we can see that address 197vdcD73wQF5FviYXXgv6cXJBibc9phdq held a UTXO containing 47,097 [[Satoshis]].&lt;br /&gt;
&lt;br /&gt;
The sender paid 10,000 Satoshis to 1C7UVhVnspkxot82j6ooMxUUFEWy4Pj1tc and received 36,871 Satoshis as change into address 1LNq2ZePCj2mycctrvQqBVnTLeaJeyDeR4.&lt;br /&gt;
&lt;br /&gt;
The difference of 226 Satoshis was paid as [[Transaction fees]] to the miner who found block 605,046.&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
In [https://whatsonchain.com/tx/defaaec6d8687a27da68d2bd445dac9c1333c4460246309070a5a3cf40f3d6f0 this example], we can see more clearly that the difference between the input and output is the mining fee.&lt;br /&gt;
&lt;br /&gt;
In this transaction a UTXO held by address 13N2c1uxZee4LYGruhWED6K4P4D8Ncmepq is spent in a transaction that writes a message onto the ledger in an [[False_Return#OP_RETURN_Outputs|OP_RETURN output]], and receives the original amount minus the 276 Satoshi mining fee back into the same address.&lt;br /&gt;
&lt;br /&gt;
=== Consolidating UTXOs ===&lt;br /&gt;
In some cases, the spender may have many UTXOs that they would like to consolidate. In this situation, the only output is their 'change' address where the total amount less mining fees is sent.&lt;br /&gt;
&lt;br /&gt;
These 'consolidation transactions' have the added benefit of reducing the size of the UTXO set, shrinking the database that all nodes maintain. While the computation for processing these inputs could be expensive it is envisaged that the savings in storage will encourage Miners to potentially process these types of transactions for a lower fee.&lt;br /&gt;
&lt;br /&gt;
An example can be found [https://whatsonchain.com/tx/682e4ee70f5ba2a174e5427e4bdd645ee229ed64d2b9ca55d315035de6d85668 here].&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Change&amp;diff=1480</id>
		<title>Change</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Change&amp;diff=1480"/>
		<updated>2020-01-23T21:22:03Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Consolidating UTXOs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Introduction ===&lt;br /&gt;
When a UTXO is spent, it must be consumed entirely. If the value of the UTXO is greater than the amount being spent, then the difference in the amount must be allocated to a new address that the spender owns; this is a change address.&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
In a standard payment scenario, the sender consumes a single UTXO, paying the spending amount to the receiver's address, then receiving the change into a new address that they control to take advantage of privacy.&lt;br /&gt;
&lt;br /&gt;
In [https://whatsonchain.com/tx/d0033a539a426de7142f4b230328c84306b6ebc1c985515d522a411c397522df this example], we can see that address 197vdcD73wQF5FviYXXgv6cXJBibc9phdq held a UTXO containing 47,097 [[Satoshis]].&lt;br /&gt;
&lt;br /&gt;
The sender paid 10,000 Satoshis to 1C7UVhVnspkxot82j6ooMxUUFEWy4Pj1tc and received 36,871 Satoshis as change into address 1LNq2ZePCj2mycctrvQqBVnTLeaJeyDeR4.&lt;br /&gt;
&lt;br /&gt;
The difference of 226 Satoshis was paid as [[Transaction fees]] to the miner who found block 605,046.&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
In [https://whatsonchain.com/tx/defaaec6d8687a27da68d2bd445dac9c1333c4460246309070a5a3cf40f3d6f0 this example], we can see more clearly that the difference between the input and output is the mining fee.&lt;br /&gt;
&lt;br /&gt;
In this transaction a UTXO held by address 13N2c1uxZee4LYGruhWED6K4P4D8Ncmepq is spent in a transaction that writes a message onto the ledger in an [[False_Return#OP_RETURN_Outputs|OP_RETURN output]], and receives the original amount minus the 276 Satoshi mining fee back into the same address.&lt;br /&gt;
&lt;br /&gt;
=== Consolidating UTXOs ===&lt;br /&gt;
In some cases, the spender may have many UTXOs that they would like to consolidate. In this situation, the only output is their 'change' address where the total amount less mining fees is sent.&lt;br /&gt;
&lt;br /&gt;
These 'consolidation transactions' have the added benefit of reducing the size of the UTXO set, shrinking the database that all nodes maintain. &lt;br /&gt;
&lt;br /&gt;
While the computation for processing these inputs could be expensive it is envisaged that the savings in storage will encourage Miners to potentially process these types of transactions for a lower fee.&lt;br /&gt;
&lt;br /&gt;
An example can be found [https://whatsonchain.com/tx/682e4ee70f5ba2a174e5427e4bdd645ee229ed64d2b9ca55d315035de6d85668 here].&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Change&amp;diff=1479</id>
		<title>Change</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Change&amp;diff=1479"/>
		<updated>2020-01-23T21:20:53Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Example 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Introduction ===&lt;br /&gt;
When a UTXO is spent, it must be consumed entirely. If the value of the UTXO is greater than the amount being spent, then the difference in the amount must be allocated to a new address that the spender owns; this is a change address.&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
In a standard payment scenario, the sender consumes a single UTXO, paying the spending amount to the receiver's address, then receiving the change into a new address that they control to take advantage of privacy.&lt;br /&gt;
&lt;br /&gt;
In [https://whatsonchain.com/tx/d0033a539a426de7142f4b230328c84306b6ebc1c985515d522a411c397522df this example], we can see that address 197vdcD73wQF5FviYXXgv6cXJBibc9phdq held a UTXO containing 47,097 [[Satoshis]].&lt;br /&gt;
&lt;br /&gt;
The sender paid 10,000 Satoshis to 1C7UVhVnspkxot82j6ooMxUUFEWy4Pj1tc and received 36,871 Satoshis as change into address 1LNq2ZePCj2mycctrvQqBVnTLeaJeyDeR4.&lt;br /&gt;
&lt;br /&gt;
The difference of 226 Satoshis was paid as [[Transaction fees]] to the miner who found block 605,046.&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
In [https://whatsonchain.com/tx/defaaec6d8687a27da68d2bd445dac9c1333c4460246309070a5a3cf40f3d6f0 this example], we can see more clearly that the difference between the input and output is the mining fee.&lt;br /&gt;
&lt;br /&gt;
In this transaction a UTXO held by address 13N2c1uxZee4LYGruhWED6K4P4D8Ncmepq is spent in a transaction that writes a message onto the ledger in an [[False_Return#OP_RETURN_Outputs|OP_RETURN output]], and receives the original amount minus the 276 Satoshi mining fee back into the same address.&lt;br /&gt;
&lt;br /&gt;
=== Consolidating UTXOs ===&lt;br /&gt;
In some cases, the spender may have many UTXOs that they would like to consolidate. In this situation, the only output is their 'change' address where the total amount less mining fees is sent.&lt;br /&gt;
&lt;br /&gt;
These 'consolidation transactions' have the added benefit of reducing the size of the UTXO set, shrinking the database that all nodes maintain. While the computation for processing these inputs could be expensive it is envisaged that the savings in storage will encourage Miners to potentially process these types of transactions for a lower fee.&lt;br /&gt;
&lt;br /&gt;
An example can be found [https://whatsonchain.com/tx/682e4ee70f5ba2a174e5427e4bdd645ee229ed64d2b9ca55d315035de6d85668 here].&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1478</id>
		<title>Payments in Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1478"/>
		<updated>2020-01-23T21:12:06Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* BIP-0021 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Payments are an important aspect of Bitcoin. Every transaction is a payment of some sort. Transactions are the only means through which information can be written onto the ledger. The process of block discovery is agreed upon through the acceptance of a [[Coinbase]] transaction as a valid payment. A block is simply the process of having a collection of payments set down, collated and agreed upon as valid.&lt;br /&gt;
&lt;br /&gt;
There are many different ways to request and make payments.&lt;br /&gt;
&lt;br /&gt;
==BIP-0270==&lt;br /&gt;
[https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki BIP270] is a simplified version of the [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki BIP70 Payment Protocol] introduced in 2013. It is a protocol for communication between a payment host (usually either a merchant, a payment processor, or simply the recipient's wallet) and their customer (the sender of the funds), enabling both a better experience, simpler wallet infrastructure, advanced features such as multiple outputs, and better security against man-in-the-middle attacks. Designed for wallets that use [[Simplified Payment Verification]] to achieve huge improvements at scale. Transactions can be exchanged partially or in iterations. This is far faster when done peer to peer between the payer and the payee, writing to the ledger only at the end to settle the transaction(s).&lt;br /&gt;
&lt;br /&gt;
This BIP is an optimisation of BIP-0070. Changes include:&lt;br /&gt;
* Moves all signature exchange and validation to the communication later (usually HTTPS)&lt;br /&gt;
* Add multiple outputs&lt;br /&gt;
* A library optimised for peer to peer transaction management&lt;br /&gt;
&lt;br /&gt;
==BSVAlias==&lt;br /&gt;
[[BSVAlias]] is a set of protocols that lay out a structure for making and receiving payments using identity as the means to link sender and receiver. [[Paymail]] is the first practical implementation of BSVAlias.&lt;br /&gt;
&lt;br /&gt;
==Payment Channels==&lt;br /&gt;
Any transaction that has both an nLocktime in the future or an nSequence that is less than 0xFFFFFFFF is in a [[Payment Channels|payment channel]].&lt;br /&gt;
The transaction can be updated once, or many times between peers until either nSequence is finalised or nLocktime runs out and one of the parties transmits the transaction to the blockchain.&lt;br /&gt;
Payment channels are useful for streaming data, operating a sequence of events or operating with a live dataset in applications such as gaming and more.&lt;br /&gt;
Payment channels have been unavailable since early versions of Bitcoin and are a new field with huge potential in many areas.&lt;br /&gt;
&lt;br /&gt;
==Legacy Payment Protocols==&lt;br /&gt;
These are payment protocols where the payer is asked to broadcast a transaction to the network (instead of the payee) so the payee can scan the network for relevant transactions rather than handling the transaction peer-to-peer as with [[Simplified_Payment_Verification|SPV]].&lt;br /&gt;
&lt;br /&gt;
===BIP-0021===&lt;br /&gt;
[https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki BIP-0021] has been one of the predominant means of making mobile payments in Bitcoin throughout it's history. Almost all QR codes based payment gateways used within Bitcoin are or are an extension of BIP0021. BIP0021 itself is an extension of [https://tools.ietf.org/html/rfc3986 RFC-3986], the RFC standard for URIs (Universal Resource Identifiers).&lt;br /&gt;
&lt;br /&gt;
===BIP-0070===&lt;br /&gt;
[https://bitcoinj.github.io/payment-protocol#protocol-overview BIP-0070] was a payment protocol for reaching out to receivers using an extension of BIP-0021 that added a URL. The URL directed the phone to reach out to a server and provide it the address at the front of the QR code. This server would instruct the device making the query which address to send money to.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1477</id>
		<title>Payments in Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1477"/>
		<updated>2020-01-23T21:11:45Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* BIP-0021 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Payments are an important aspect of Bitcoin. Every transaction is a payment of some sort. Transactions are the only means through which information can be written onto the ledger. The process of block discovery is agreed upon through the acceptance of a [[Coinbase]] transaction as a valid payment. A block is simply the process of having a collection of payments set down, collated and agreed upon as valid.&lt;br /&gt;
&lt;br /&gt;
There are many different ways to request and make payments.&lt;br /&gt;
&lt;br /&gt;
==BIP-0270==&lt;br /&gt;
[https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki BIP270] is a simplified version of the [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki BIP70 Payment Protocol] introduced in 2013. It is a protocol for communication between a payment host (usually either a merchant, a payment processor, or simply the recipient's wallet) and their customer (the sender of the funds), enabling both a better experience, simpler wallet infrastructure, advanced features such as multiple outputs, and better security against man-in-the-middle attacks. Designed for wallets that use [[Simplified Payment Verification]] to achieve huge improvements at scale. Transactions can be exchanged partially or in iterations. This is far faster when done peer to peer between the payer and the payee, writing to the ledger only at the end to settle the transaction(s).&lt;br /&gt;
&lt;br /&gt;
This BIP is an optimisation of BIP-0070. Changes include:&lt;br /&gt;
* Moves all signature exchange and validation to the communication later (usually HTTPS)&lt;br /&gt;
* Add multiple outputs&lt;br /&gt;
* A library optimised for peer to peer transaction management&lt;br /&gt;
&lt;br /&gt;
==BSVAlias==&lt;br /&gt;
[[BSVAlias]] is a set of protocols that lay out a structure for making and receiving payments using identity as the means to link sender and receiver. [[Paymail]] is the first practical implementation of BSVAlias.&lt;br /&gt;
&lt;br /&gt;
==Payment Channels==&lt;br /&gt;
Any transaction that has both an nLocktime in the future or an nSequence that is less than 0xFFFFFFFF is in a [[Payment Channels|payment channel]].&lt;br /&gt;
The transaction can be updated once, or many times between peers until either nSequence is finalised or nLocktime runs out and one of the parties transmits the transaction to the blockchain.&lt;br /&gt;
Payment channels are useful for streaming data, operating a sequence of events or operating with a live dataset in applications such as gaming and more.&lt;br /&gt;
Payment channels have been unavailable since early versions of Bitcoin and are a new field with huge potential in many areas.&lt;br /&gt;
&lt;br /&gt;
==Legacy Payment Protocols==&lt;br /&gt;
These are payment protocols where the payer is asked to broadcast a transaction to the network (instead of the payee) so the payee can scan the network for relevant transactions rather than handling the transaction peer-to-peer as with [[Simplified_Payment_Verification|SPV]].&lt;br /&gt;
&lt;br /&gt;
===BIP-0021===&lt;br /&gt;
[https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki BIP-0021] has been one of the predominant means of making mobile payments in Bitcoin throughout it's history. Almost all QR codes based payment gateways used within Bitcoin are or are an extension of BIP0021. It itself is an extension of [https://tools.ietf.org/html/rfc3986 RFC-3986], the RFC standard for URIs (Universal Resource Identifiers).&lt;br /&gt;
&lt;br /&gt;
===BIP-0070===&lt;br /&gt;
[https://bitcoinj.github.io/payment-protocol#protocol-overview BIP-0070] was a payment protocol for reaching out to receivers using an extension of BIP-0021 that added a URL. The URL directed the phone to reach out to a server and provide it the address at the front of the QR code. This server would instruct the device making the query which address to send money to.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1476</id>
		<title>Payments in Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1476"/>
		<updated>2020-01-23T21:11:10Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* BIP-0070 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Payments are an important aspect of Bitcoin. Every transaction is a payment of some sort. Transactions are the only means through which information can be written onto the ledger. The process of block discovery is agreed upon through the acceptance of a [[Coinbase]] transaction as a valid payment. A block is simply the process of having a collection of payments set down, collated and agreed upon as valid.&lt;br /&gt;
&lt;br /&gt;
There are many different ways to request and make payments.&lt;br /&gt;
&lt;br /&gt;
==BIP-0270==&lt;br /&gt;
[https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki BIP270] is a simplified version of the [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki BIP70 Payment Protocol] introduced in 2013. It is a protocol for communication between a payment host (usually either a merchant, a payment processor, or simply the recipient's wallet) and their customer (the sender of the funds), enabling both a better experience, simpler wallet infrastructure, advanced features such as multiple outputs, and better security against man-in-the-middle attacks. Designed for wallets that use [[Simplified Payment Verification]] to achieve huge improvements at scale. Transactions can be exchanged partially or in iterations. This is far faster when done peer to peer between the payer and the payee, writing to the ledger only at the end to settle the transaction(s).&lt;br /&gt;
&lt;br /&gt;
This BIP is an optimisation of BIP-0070. Changes include:&lt;br /&gt;
* Moves all signature exchange and validation to the communication later (usually HTTPS)&lt;br /&gt;
* Add multiple outputs&lt;br /&gt;
* A library optimised for peer to peer transaction management&lt;br /&gt;
&lt;br /&gt;
==BSVAlias==&lt;br /&gt;
[[BSVAlias]] is a set of protocols that lay out a structure for making and receiving payments using identity as the means to link sender and receiver. [[Paymail]] is the first practical implementation of BSVAlias.&lt;br /&gt;
&lt;br /&gt;
==Payment Channels==&lt;br /&gt;
Any transaction that has both an nLocktime in the future or an nSequence that is less than 0xFFFFFFFF is in a [[Payment Channels|payment channel]].&lt;br /&gt;
The transaction can be updated once, or many times between peers until either nSequence is finalised or nLocktime runs out and one of the parties transmits the transaction to the blockchain.&lt;br /&gt;
Payment channels are useful for streaming data, operating a sequence of events or operating with a live dataset in applications such as gaming and more.&lt;br /&gt;
Payment channels have been unavailable since early versions of Bitcoin and are a new field with huge potential in many areas.&lt;br /&gt;
&lt;br /&gt;
==Legacy Payment Protocols==&lt;br /&gt;
These are payment protocols where the payer is asked to broadcast a transaction to the network (instead of the payee) so the payee can scan the network for relevant transactions rather than handling the transaction peer-to-peer as with [[Simplified_Payment_Verification|SPV]].&lt;br /&gt;
&lt;br /&gt;
===BIP-0021===&lt;br /&gt;
[https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki BIP-0021] has been one of the predominant means of making mobile payments in Bitcoin throughout it's history. Almost all QR codes based payment gateways used within Bitcoin are or are an extention of BIP0021. It itself is an extension of [https://tools.ietf.org/html/rfc3986 RFC-3986], the RFC standard for URIs (Universal Resource Identifiers).&lt;br /&gt;
&lt;br /&gt;
===BIP-0070===&lt;br /&gt;
[https://bitcoinj.github.io/payment-protocol#protocol-overview BIP-0070] was a payment protocol for reaching out to receivers using an extension of BIP-0021 that added a URL. The URL directed the phone to reach out to a server and provide it the address at the front of the QR code. This server would instruct the device making the query which address to send money to.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1475</id>
		<title>Payments in Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1475"/>
		<updated>2020-01-23T21:10:48Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Payments are an important aspect of Bitcoin. Every transaction is a payment of some sort. Transactions are the only means through which information can be written onto the ledger. The process of block discovery is agreed upon through the acceptance of a [[Coinbase]] transaction as a valid payment. A block is simply the process of having a collection of payments set down, collated and agreed upon as valid.&lt;br /&gt;
&lt;br /&gt;
There are many different ways to request and make payments.&lt;br /&gt;
&lt;br /&gt;
==BIP-0270==&lt;br /&gt;
[https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki BIP270] is a simplified version of the [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki BIP70 Payment Protocol] introduced in 2013. It is a protocol for communication between a payment host (usually either a merchant, a payment processor, or simply the recipient's wallet) and their customer (the sender of the funds), enabling both a better experience, simpler wallet infrastructure, advanced features such as multiple outputs, and better security against man-in-the-middle attacks. Designed for wallets that use [[Simplified Payment Verification]] to achieve huge improvements at scale. Transactions can be exchanged partially or in iterations. This is far faster when done peer to peer between the payer and the payee, writing to the ledger only at the end to settle the transaction(s).&lt;br /&gt;
&lt;br /&gt;
This BIP is an optimisation of BIP-0070. Changes include:&lt;br /&gt;
* Moves all signature exchange and validation to the communication later (usually HTTPS)&lt;br /&gt;
* Add multiple outputs&lt;br /&gt;
* A library optimised for peer to peer transaction management&lt;br /&gt;
&lt;br /&gt;
==BSVAlias==&lt;br /&gt;
[[BSVAlias]] is a set of protocols that lay out a structure for making and receiving payments using identity as the means to link sender and receiver. [[Paymail]] is the first practical implementation of BSVAlias.&lt;br /&gt;
&lt;br /&gt;
==Payment Channels==&lt;br /&gt;
Any transaction that has both an nLocktime in the future or an nSequence that is less than 0xFFFFFFFF is in a [[Payment Channels|payment channel]].&lt;br /&gt;
The transaction can be updated once, or many times between peers until either nSequence is finalised or nLocktime runs out and one of the parties transmits the transaction to the blockchain.&lt;br /&gt;
Payment channels are useful for streaming data, operating a sequence of events or operating with a live dataset in applications such as gaming and more.&lt;br /&gt;
Payment channels have been unavailable since early versions of Bitcoin and are a new field with huge potential in many areas.&lt;br /&gt;
&lt;br /&gt;
==Legacy Payment Protocols==&lt;br /&gt;
These are payment protocols where the payer is asked to broadcast a transaction to the network (instead of the payee) so the payee can scan the network for relevant transactions rather than handling the transaction peer-to-peer as with [[Simplified_Payment_Verification|SPV]].&lt;br /&gt;
&lt;br /&gt;
===BIP-0021===&lt;br /&gt;
[https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki BIP-0021] has been one of the predominant means of making mobile payments in Bitcoin throughout it's history. Almost all QR codes based payment gateways used within Bitcoin are or are an extention of BIP0021. It itself is an extension of [https://tools.ietf.org/html/rfc3986 RFC-3986], the RFC standard for URIs (Universal Resource Identifiers).&lt;br /&gt;
&lt;br /&gt;
===BIP-0070===&lt;br /&gt;
[[https://bitcoinj.github.io/payment-protocol#protocol-overview BIP-0070]] was a payment protocol for reaching out to receivers using an extension of BIP-0021 that added a URL. The URL directed the phone to reach out to a server and provide it the address at the front of the QR code. This server would instruct the device making the query which address to send money to.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1474</id>
		<title>Payments in Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1474"/>
		<updated>2020-01-23T21:10:28Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Legacy Payment Protocols */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Payments are an important aspect of Bitcoin. Every transaction is a payment of some sort. Transactions are the only means through which information can be written onto the ledger. The process of block discovery is agreed upon through the acceptance of a [[Coinbase]] transaction as a valid payment. A block is simply the process of having a collection of payments set down, collated and agreed upon as valid.&lt;br /&gt;
&lt;br /&gt;
There are many different ways to request and make payments.&lt;br /&gt;
&lt;br /&gt;
==BIP-0270==&lt;br /&gt;
[https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki BIP270] is a simplified version of the [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki BIP70 Payment Protocol] introduced in 2013. It is a protocol for communication between a payment host (usually either a merchant, a payment processor, or simply the recipient's wallet) and their customer (the sender of the funds), enabling both a better experience, simpler wallet infrastructure, advanced features such as multiple outputs, and better security against man-in-the-middle attacks. Designed for wallets that use [[Simplified Payment Verification]] to achieve huge improvements at scale. Transactions can be exchanged partially or in iterations. This is far faster when done peer to peer between the payer and the payee, writing to the ledger only at the end to settle the transaction(s).&lt;br /&gt;
&lt;br /&gt;
This BIP is an optimisation of BIP-0070. Changes include:&lt;br /&gt;
* Moves all signature exchange and validation to the communication later (usually HTTPS)&lt;br /&gt;
* Add multiple outputs&lt;br /&gt;
* A library optimised for peer to peer transaction management&lt;br /&gt;
&lt;br /&gt;
==BSVAlias==&lt;br /&gt;
[[BSVAlias]] is a set of protocols that lay out a structure for making and receiving payments using identity as the means to link sender and receiver. [[Paymail]] is the first practical implementation of BSVAlias.&lt;br /&gt;
&lt;br /&gt;
==Payment Channels==&lt;br /&gt;
Any transaction that has both an nLocktime in the future or an nSequence that is less than 0xFFFFFFFF is in a [[Payment Channels|payment channel]].&lt;br /&gt;
The transaction can be updated once, or many times between peers until either nSequence is finalised or nLocktime runs out and one of the parties transmits the transaction to the blockchain.&lt;br /&gt;
Payment channels are useful for streaming data, operating a sequence of events or operating with a live dataset in applications such as gaming and more.&lt;br /&gt;
Payment channels have been unavailable since early versions of Bitcoin and are a new field with huge potential in many areas.&lt;br /&gt;
&lt;br /&gt;
==Legacy Payment Protocols==&lt;br /&gt;
These are payment protocols where the payer is asked to broadcast a transaction to the network (instead of the payee) so the payee can scan the network for relevant transactions rather than handling the transaction peer-to-peer as with [Simplified_Payment_Verification|SPV].&lt;br /&gt;
&lt;br /&gt;
===BIP-0021===&lt;br /&gt;
[https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki BIP-0021] has been one of the predominant means of making mobile payments in Bitcoin throughout it's history. Almost all QR codes based payment gateways used within Bitcoin are or are an extention of BIP0021. It itself is an extension of [https://tools.ietf.org/html/rfc3986 RFC-3986], the RFC standard for URIs (Universal Resource Identifiers).&lt;br /&gt;
&lt;br /&gt;
===BIP-0070===&lt;br /&gt;
[[https://bitcoinj.github.io/payment-protocol#protocol-overview BIP-0070]] was a payment protocol for reaching out to receivers using an extension of BIP-0021 that added a URL. The URL directed the phone to reach out to a server and provide it the address at the front of the QR code. This server would instruct the device making the query which address to send money to.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1473</id>
		<title>Payments in Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1473"/>
		<updated>2020-01-23T21:07:41Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* BIP-0270 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Payments are an important aspect of Bitcoin. Every transaction is a payment of some sort. Transactions are the only means through which information can be written onto the ledger. The process of block discovery is agreed upon through the acceptance of a [[Coinbase]] transaction as a valid payment. A block is simply the process of having a collection of payments set down, collated and agreed upon as valid.&lt;br /&gt;
&lt;br /&gt;
There are many different ways to request and make payments.&lt;br /&gt;
&lt;br /&gt;
==BIP-0270==&lt;br /&gt;
[https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki BIP270] is a simplified version of the [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki BIP70 Payment Protocol] introduced in 2013. It is a protocol for communication between a payment host (usually either a merchant, a payment processor, or simply the recipient's wallet) and their customer (the sender of the funds), enabling both a better experience, simpler wallet infrastructure, advanced features such as multiple outputs, and better security against man-in-the-middle attacks. Designed for wallets that use [[Simplified Payment Verification]] to achieve huge improvements at scale. Transactions can be exchanged partially or in iterations. This is far faster when done peer to peer between the payer and the payee, writing to the ledger only at the end to settle the transaction(s).&lt;br /&gt;
&lt;br /&gt;
This BIP is an optimisation of BIP-0070. Changes include:&lt;br /&gt;
* Moves all signature exchange and validation to the communication later (usually HTTPS)&lt;br /&gt;
* Add multiple outputs&lt;br /&gt;
* A library optimised for peer to peer transaction management&lt;br /&gt;
&lt;br /&gt;
==BSVAlias==&lt;br /&gt;
[[BSVAlias]] is a set of protocols that lay out a structure for making and receiving payments using identity as the means to link sender and receiver. [[Paymail]] is the first practical implementation of BSVAlias.&lt;br /&gt;
&lt;br /&gt;
==Payment Channels==&lt;br /&gt;
Any transaction that has both an nLocktime in the future or an nSequence that is less than 0xFFFFFFFF is in a [[Payment Channels|payment channel]].&lt;br /&gt;
The transaction can be updated once, or many times between peers until either nSequence is finalised or nLocktime runs out and one of the parties transmits the transaction to the blockchain.&lt;br /&gt;
Payment channels are useful for streaming data, operating a sequence of events or operating with a live dataset in applications such as gaming and more.&lt;br /&gt;
Payment channels have been unavailable since early versions of Bitcoin and are a new field with huge potential in many areas.&lt;br /&gt;
&lt;br /&gt;
==Legacy Payment Protocols==&lt;br /&gt;
These are payment protocols where the payer is asked to broadcast a transaction to the network (instead of the payee) so the payee can scan the network for relevant transactions rather than handling the transaction peer-to-peer as with SPV.&lt;br /&gt;
&lt;br /&gt;
===BIP-0021===&lt;br /&gt;
[https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki BIP-0021] has been one of the predominant means of making mobile payments in Bitcoin throughout it's history. Almost all QR codes based payment gateways used within Bitcoin are or are an extention of BIP0021. It itself is an extension of [https://tools.ietf.org/html/rfc3986 RFC-3986], the RFC standard for URIs (Universal Resource Identifiers).&lt;br /&gt;
&lt;br /&gt;
===BIP-0070===&lt;br /&gt;
[[https://bitcoinj.github.io/payment-protocol#protocol-overview BIP-0070]] was a payment protocol for reaching out to receivers using an extension of BIP-0021 that added a URL. The URL directed the phone to reach out to a server and provide it the address at the front of the QR code. This server would instruct the device making the query which address to send money to.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1472</id>
		<title>Payments in Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1472"/>
		<updated>2020-01-23T21:07:28Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Payments are an important aspect of Bitcoin. Every transaction is a payment of some sort. Transactions are the only means through which information can be written onto the ledger. The process of block discovery is agreed upon through the acceptance of a [[Coinbase]] transaction as a valid payment. A block is simply the process of having a collection of payments set down, collated and agreed upon as valid.&lt;br /&gt;
&lt;br /&gt;
There are many different ways to request and make payments.&lt;br /&gt;
&lt;br /&gt;
==BIP-0270==&lt;br /&gt;
[https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki BIP270] is a simplified version of the [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki BIP70 Payment Protocol] introduced in 2013. It is a protocol for communication between a payment host (usually either a merchant, a payment processor, or simply the recipient's wallet) and their customer (the sender of the funds), enabling both a better experience, simpler wallet infrastructure, advanced features such as multiple outputs, and better security against man-in-the-middle attacks. Designed for wallets that use [[Simplified Payment Verification]] to achieve huge improvements at scale. Transactions can be exchanged partially or in iterations. This is far faster when done peer to peer between the payer and the payee, writing to the ledger only at the end to settle the transaction(s).&lt;br /&gt;
&lt;br /&gt;
This BIP is an optimisation of BIP-0070. Changes include:&lt;br /&gt;
* Moves all signature exchange and validation to the communication later (usually HTTPS)&lt;br /&gt;
* Add multiple outputs&lt;br /&gt;
* An library optimised for peer to peer transaction management&lt;br /&gt;
&lt;br /&gt;
==BSVAlias==&lt;br /&gt;
[[BSVAlias]] is a set of protocols that lay out a structure for making and receiving payments using identity as the means to link sender and receiver. [[Paymail]] is the first practical implementation of BSVAlias.&lt;br /&gt;
&lt;br /&gt;
==Payment Channels==&lt;br /&gt;
Any transaction that has both an nLocktime in the future or an nSequence that is less than 0xFFFFFFFF is in a [[Payment Channels|payment channel]].&lt;br /&gt;
The transaction can be updated once, or many times between peers until either nSequence is finalised or nLocktime runs out and one of the parties transmits the transaction to the blockchain.&lt;br /&gt;
Payment channels are useful for streaming data, operating a sequence of events or operating with a live dataset in applications such as gaming and more.&lt;br /&gt;
Payment channels have been unavailable since early versions of Bitcoin and are a new field with huge potential in many areas.&lt;br /&gt;
&lt;br /&gt;
==Legacy Payment Protocols==&lt;br /&gt;
These are payment protocols where the payer is asked to broadcast a transaction to the network (instead of the payee) so the payee can scan the network for relevant transactions rather than handling the transaction peer-to-peer as with SPV.&lt;br /&gt;
&lt;br /&gt;
===BIP-0021===&lt;br /&gt;
[https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki BIP-0021] has been one of the predominant means of making mobile payments in Bitcoin throughout it's history. Almost all QR codes based payment gateways used within Bitcoin are or are an extention of BIP0021. It itself is an extension of [https://tools.ietf.org/html/rfc3986 RFC-3986], the RFC standard for URIs (Universal Resource Identifiers).&lt;br /&gt;
&lt;br /&gt;
===BIP-0070===&lt;br /&gt;
[[https://bitcoinj.github.io/payment-protocol#protocol-overview BIP-0070]] was a payment protocol for reaching out to receivers using an extension of BIP-0021 that added a URL. The URL directed the phone to reach out to a server and provide it the address at the front of the QR code. This server would instruct the device making the query which address to send money to.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1471</id>
		<title>Payments in Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Payments_in_Bitcoin&amp;diff=1471"/>
		<updated>2020-01-23T21:05:27Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Payments are an important aspect of Bitcoin. Every transaction is a payment of some sort. Transactions are the only means through which information can be written onto the ledger. The process of block discovery is agreed upon through the acceptance of a [[Coinbase]] transaction as a valid payment. A block is simply the process of having a collection of payments set down, collated and agreed upon as valid.&lt;br /&gt;
&lt;br /&gt;
There are many different ways to request and make payments.&lt;br /&gt;
&lt;br /&gt;
==BIP-0270==&lt;br /&gt;
[https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki BIP270] is a simplified version of the BIP70 Payment Protocol introduced in 2013. It is a protocol for communication between a payment host (usually either a merchant, a payment processor, or simply the recipient's wallet) and their customer (the sender of the funds), enabling both a better experience, simpler wallet infrastructure, advanced features such as multiple outputs, and better security against man-in-the-middle attacks. Designed for wallets that use [[Simplified Payment Verification]] to achieve huge improvements at scale. Transactions can be exchanged partially or in iterations. This is far faster when done peer to peer between the payer and the payee, writing to the ledger only at the end to settle the transaction(s).&lt;br /&gt;
&lt;br /&gt;
This BIP is an optimisation of BIP-0070. Changes include:&lt;br /&gt;
* Moves all signature exchange and validation to the communication later (usually HTTPS)&lt;br /&gt;
* Add multiple outputs&lt;br /&gt;
* An library optimised for peer to peer transaction management&lt;br /&gt;
&lt;br /&gt;
==BSVAlias==&lt;br /&gt;
[[BSVAlias]] is a set of protocols that lay out a structure for making and receiving payments using identity as the means to link sender and receiver. [[Paymail]] is the first practical implementation of BSVAlias.&lt;br /&gt;
&lt;br /&gt;
==Payment Channels==&lt;br /&gt;
Any transaction that has both an nLocktime in the future or an nSequence that is less than 0xFFFFFFFF is in a [[Payment Channels|payment channel]].&lt;br /&gt;
The transaction can be updated once, or many times between peers until either nSequence is finalised or nLocktime runs out and one of the parties transmits the transaction to the blockchain.&lt;br /&gt;
Payment channels are useful for streaming data, operating a sequence of events or operating with a live dataset in applications such as gaming and more.&lt;br /&gt;
Payment channels have been unavailable since early versions of Bitcoin and are a new field with huge potential in many areas.&lt;br /&gt;
&lt;br /&gt;
==Legacy Payment Protocols==&lt;br /&gt;
These are payment protocols where the payer is asked to broadcast a transaction to the network (instead of the payee) so the payee can scan the network for relevant transactions rather than handling the transaction peer-to-peer as with SPV.&lt;br /&gt;
&lt;br /&gt;
===BIP-0021===&lt;br /&gt;
[https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki BIP-0021] has been one of the predominant means of making mobile payments in Bitcoin throughout it's history. Almost all QR codes based payment gateways used within Bitcoin are or are an extention of BIP0021. It itself is an extension of [https://tools.ietf.org/html/rfc3986 RFC-3986], the RFC standard for URIs (Universal Resource Identifiers).&lt;br /&gt;
&lt;br /&gt;
===BIP-0070===&lt;br /&gt;
[[https://bitcoinj.github.io/payment-protocol#protocol-overview BIP-0070]] was a payment protocol for reaching out to receivers using an extension of BIP-0021 that added a URL. The URL directed the phone to reach out to a server and provide it the address at the front of the QR code. This server would instruct the device making the query which address to send money to.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1470</id>
		<title>Paper wallet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1470"/>
		<updated>2020-01-23T20:49:31Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Downsides/Risks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''paper wallet''' is the name given to a method of storing bitcoin which involves printing a single [[Private Keys|private key]] and bitcoin [[address]] onto paper and depositing funds into a [[Bitcoin Transactions#P2PHK|P2PKH]] script using the address. Funds can be accessed by accessing the physical paper and entering the private key into a wallet. This is usually achieved by scanning a QR code of the private key in [[Wallet import format]] (WIF).&lt;br /&gt;
&lt;br /&gt;
== Redeeming bitcoins and withdrawing funds ==&lt;br /&gt;
&lt;br /&gt;
The best way to redeem the bitcoins from a private key is to use the &amp;quot;sweep&amp;quot; feature of certain wallet software. This sends the entire balance of the paper wallet to a [[deterministic wallet]]. &lt;br /&gt;
&lt;br /&gt;
Alternatively, the private key could be imported and the entire balance sent to an address in the wallet.&lt;br /&gt;
&lt;br /&gt;
There are various wallets for doing this:&lt;br /&gt;
&lt;br /&gt;
* [https://electrumsv.io/ ElectrumSV] and [https://simply.cash/ Simply Cash] support sweeping private keys.&lt;br /&gt;
&lt;br /&gt;
==Downsides/Risks==&lt;br /&gt;
&lt;br /&gt;
Paper wallets are generally regarded as a secure method of long-term storage of funds; however there are downsides to using this method.&lt;br /&gt;
&lt;br /&gt;
===Printing===&lt;br /&gt;
&lt;br /&gt;
Paper wallets require using a printer to transfer them to paper. Most printers have internal storage where the image of the wallet could be saved allowing an attacker with access to the printer to see the private key and steal the stored bitcoins. Shared printers such as in schools, offices or internet cafes are also usually centrally logged. If the printer is accessed over WiFi then any radio wave listener could also obtain the private keys and steal the money.&lt;br /&gt;
&lt;br /&gt;
=== Address reuse ===&lt;br /&gt;
&lt;br /&gt;
Paper wallets have just one bitcoin address, leading to [[address reuse]].&lt;br /&gt;
&lt;br /&gt;
=== Poor user experience ===&lt;br /&gt;
&lt;br /&gt;
Dealing with raw private keys can be unintuitive and may lead to loss of funds if not managed properly. It is recommended that users of paper wallets understand how they function before using them as long-term funds storage.&lt;br /&gt;
&lt;br /&gt;
=== Low error correction ===&lt;br /&gt;
&lt;br /&gt;
The private keys are typically printed in small fonts. Sometimes characters may be mistaken for another letter. One single wrong character will invalidate the key. Private keys in WIF format have a checksum but there are a lack of tools for regular users to correct mistakes.&lt;br /&gt;
&lt;br /&gt;
While QR codes have a checksum and robust error correction, they can be damaged by water, crumpling or folding of the paper.&lt;br /&gt;
&lt;br /&gt;
== Bitcoin ATMs and paper wallets ==&lt;br /&gt;
&lt;br /&gt;
Many bitcoin ATMs use a paper-wallet-like system for delivering bitcoins if the customer doesn't have a bitcoin wallet. The ATMs can print out a private key/address pair onto paper which contain the customer's bitcoins. Ideally the customer would sweep the bitcoins into their own wallet as soon as they can.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Private Keys]]&lt;br /&gt;
* [[Seed phrase]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1469</id>
		<title>Paper wallet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1469"/>
		<updated>2020-01-23T20:49:05Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''paper wallet''' is the name given to a method of storing bitcoin which involves printing a single [[Private Keys|private key]] and bitcoin [[address]] onto paper and depositing funds into a [[Bitcoin Transactions#P2PHK|P2PKH]] script using the address. Funds can be accessed by accessing the physical paper and entering the private key into a wallet. This is usually achieved by scanning a QR code of the private key in [[Wallet import format]] (WIF).&lt;br /&gt;
&lt;br /&gt;
== Redeeming bitcoins and withdrawing funds ==&lt;br /&gt;
&lt;br /&gt;
The best way to redeem the bitcoins from a private key is to use the &amp;quot;sweep&amp;quot; feature of certain wallet software. This sends the entire balance of the paper wallet to a [[deterministic wallet]]. &lt;br /&gt;
&lt;br /&gt;
Alternatively, the private key could be imported and the entire balance sent to an address in the wallet.&lt;br /&gt;
&lt;br /&gt;
There are various wallets for doing this:&lt;br /&gt;
&lt;br /&gt;
* [https://electrumsv.io/ ElectrumSV] and [https://simply.cash/ Simply Cash] support sweeping private keys.&lt;br /&gt;
&lt;br /&gt;
==Downsides/Risks==&lt;br /&gt;
&lt;br /&gt;
Paper wallets are seen as a secure method of long-term storage of funds however there are downsides to using this method.&lt;br /&gt;
&lt;br /&gt;
===Printing===&lt;br /&gt;
&lt;br /&gt;
Paper wallets require using a printer to transfer them to paper. Most printers have internal storage where the image of the wallet could be saved allowing an attacker with access to the printer to see the private key and steal the stored bitcoins. Shared printers such as in schools, offices or internet cafes are also usually centrally logged. If the printer is accessed over WiFi then any radio wave listener could also obtain the private keys and steal the money.&lt;br /&gt;
&lt;br /&gt;
=== Address reuse ===&lt;br /&gt;
&lt;br /&gt;
Paper wallets have just one bitcoin address, leading to [[address reuse]].&lt;br /&gt;
&lt;br /&gt;
=== Poor user experience ===&lt;br /&gt;
&lt;br /&gt;
Dealing with raw private keys can be unintuitive and may lead to loss of funds if not managed properly. It is recommended that users of paper wallets understand how they function before using them as long-term funds storage.&lt;br /&gt;
&lt;br /&gt;
=== Low error correction ===&lt;br /&gt;
&lt;br /&gt;
The private keys are typically printed in small fonts. Sometimes characters may be mistaken for another letter. One single wrong character will invalidate the key. Private keys in WIF format have a checksum but there are a lack of tools for regular users to correct mistakes.&lt;br /&gt;
&lt;br /&gt;
While QR codes have a checksum and robust error correction, they can be damaged by water, crumpling or folding of the paper.&lt;br /&gt;
&lt;br /&gt;
== Bitcoin ATMs and paper wallets ==&lt;br /&gt;
&lt;br /&gt;
Many bitcoin ATMs use a paper-wallet-like system for delivering bitcoins if the customer doesn't have a bitcoin wallet. The ATMs can print out a private key/address pair onto paper which contain the customer's bitcoins. Ideally the customer would sweep the bitcoins into their own wallet as soon as they can.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Private Keys]]&lt;br /&gt;
* [[Seed phrase]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1468</id>
		<title>Paper wallet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1468"/>
		<updated>2020-01-23T20:44:09Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Poor user experience */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''paper wallet''' is the name given to a method of storing bitcoin which involves printing a single [[Private Keys|private key]] and bitcoin [[address]] onto paper and depositing funds into a [[Bitcoin Transactions#P2PHK|P2PKH]] script using the address. Funds can be accessed by accessing the physical paper and entering the private key into a wallet. This is usually achieved by scanning a QR code of the private key in [[Wallet import format]].&lt;br /&gt;
&lt;br /&gt;
== Redeeming bitcoins and withdrawing funds ==&lt;br /&gt;
&lt;br /&gt;
The best way to redeem the bitcoins from a private key is to use the &amp;quot;sweep&amp;quot; feature of certain wallet software. This sends the entire balance of the paper wallet to a [[deterministic wallet]]. &lt;br /&gt;
&lt;br /&gt;
Alternatively, the private key could be imported and the entire balance sent to an address in the wallet.&lt;br /&gt;
&lt;br /&gt;
There are various wallets for doing this:&lt;br /&gt;
&lt;br /&gt;
* [https://electrumsv.io/ ElectrumSV] and [https://simply.cash/ Simply Cash] support sweeping private keys.&lt;br /&gt;
&lt;br /&gt;
==Downsides/Risks==&lt;br /&gt;
&lt;br /&gt;
Paper wallets are seen as a secure method of long-term storage of funds however there are downsides to using this method.&lt;br /&gt;
&lt;br /&gt;
===Printing===&lt;br /&gt;
&lt;br /&gt;
Paper wallets require using a printer to transfer them to paper. Most printers have internal storage where the image of the wallet could be saved allowing an attacker with access to the printer to see the private key and steal the stored bitcoins. Shared printers such as in schools, offices or internet cafes are also usually centrally logged. If the printer is accessed over WiFi then any radio wave listener could also obtain the private keys and steal the money.&lt;br /&gt;
&lt;br /&gt;
=== Address reuse ===&lt;br /&gt;
&lt;br /&gt;
Paper wallets have just one bitcoin address, leading to [[address reuse]].&lt;br /&gt;
&lt;br /&gt;
=== Poor user experience ===&lt;br /&gt;
&lt;br /&gt;
Dealing with raw private keys can be unintuitive and may lead to loss of funds if not managed properly. It is recommended that users of paper wallets understand how they function before using them as long-term funds storage.&lt;br /&gt;
&lt;br /&gt;
=== Low error correction ===&lt;br /&gt;
&lt;br /&gt;
The private keys are typically printed in small fonts. Sometimes characters may be mistaken for another letter. One single wrong character will invalidate the key. Private keys in WIF format have a checksum but there are a lack of tools for regular users to correct mistakes.&lt;br /&gt;
&lt;br /&gt;
While QR codes have a checksum and robust error correction, they can be damaged by water, crumpling or folding of the paper.&lt;br /&gt;
&lt;br /&gt;
== Bitcoin ATMs and paper wallets ==&lt;br /&gt;
&lt;br /&gt;
Many bitcoin ATMs use a paper-wallet-like system for delivering bitcoins if the customer doesn't have a bitcoin wallet. The ATMs can print out a private key/address pair onto paper which contain the customer's bitcoins. Ideally the customer would sweep the bitcoins into their own wallet as soon as they can.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Private Keys]]&lt;br /&gt;
* [[Seed phrase]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1467</id>
		<title>Paper wallet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1467"/>
		<updated>2020-01-23T20:42:50Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Downsides/Risks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''paper wallet''' is the name given to a method of storing bitcoin which involves printing a single [[Private Keys|private key]] and bitcoin [[address]] onto paper and depositing funds into a [[Bitcoin Transactions#P2PHK|P2PKH]] script using the address. Funds can be accessed by accessing the physical paper and entering the private key into a wallet. This is usually achieved by scanning a QR code of the private key in [[Wallet import format]].&lt;br /&gt;
&lt;br /&gt;
== Redeeming bitcoins and withdrawing funds ==&lt;br /&gt;
&lt;br /&gt;
The best way to redeem the bitcoins from a private key is to use the &amp;quot;sweep&amp;quot; feature of certain wallet software. This sends the entire balance of the paper wallet to a [[deterministic wallet]]. &lt;br /&gt;
&lt;br /&gt;
Alternatively, the private key could be imported and the entire balance sent to an address in the wallet.&lt;br /&gt;
&lt;br /&gt;
There are various wallets for doing this:&lt;br /&gt;
&lt;br /&gt;
* [https://electrumsv.io/ ElectrumSV] and [https://simply.cash/ Simply Cash] support sweeping private keys.&lt;br /&gt;
&lt;br /&gt;
==Downsides/Risks==&lt;br /&gt;
&lt;br /&gt;
Paper wallets are seen as a secure method of long-term storage of funds however there are downsides to using this method.&lt;br /&gt;
&lt;br /&gt;
===Printing===&lt;br /&gt;
&lt;br /&gt;
Paper wallets require using a printer to transfer them to paper. Most printers have internal storage where the image of the wallet could be saved allowing an attacker with access to the printer to see the private key and steal the stored bitcoins. Shared printers such as in schools, offices or internet cafes are also usually centrally logged. If the printer is accessed over WiFi then any radio wave listener could also obtain the private keys and steal the money.&lt;br /&gt;
&lt;br /&gt;
=== Address reuse ===&lt;br /&gt;
&lt;br /&gt;
Paper wallets have just one bitcoin address, leading to [[address reuse]].&lt;br /&gt;
&lt;br /&gt;
=== Poor user experience ===&lt;br /&gt;
&lt;br /&gt;
Dealing with raw private keys can be unintuitive and may lead to loss of funds if not managed properly. It is recommended that users of paper wallets understand how they function before using them as long term funds storage.&lt;br /&gt;
&lt;br /&gt;
=== Low error correction ===&lt;br /&gt;
&lt;br /&gt;
The private keys are typically printed in small fonts. Sometimes characters may be mistaken for another letter. One single wrong character will invalidate the key. Private keys in WIF format have a checksum but there are a lack of tools for regular users to correct mistakes.&lt;br /&gt;
&lt;br /&gt;
While QR codes have a checksum and robust error correction, they can be damaged by water, crumpling or folding of the paper.&lt;br /&gt;
&lt;br /&gt;
== Bitcoin ATMs and paper wallets ==&lt;br /&gt;
&lt;br /&gt;
Many bitcoin ATMs use a paper-wallet-like system for delivering bitcoins if the customer doesn't have a bitcoin wallet. The ATMs can print out a private key/address pair onto paper which contain the customer's bitcoins. Ideally the customer would sweep the bitcoins into their own wallet as soon as they can.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Private Keys]]&lt;br /&gt;
* [[Seed phrase]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1466</id>
		<title>Paper wallet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1466"/>
		<updated>2020-01-23T20:42:00Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Redeeming bitcoins and withdrawing funds */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''paper wallet''' is the name given to a method of storing bitcoin which involves printing a single [[Private Keys|private key]] and bitcoin [[address]] onto paper and depositing funds into a [[Bitcoin Transactions#P2PHK|P2PKH]] script using the address. Funds can be accessed by accessing the physical paper and entering the private key into a wallet. This is usually achieved by scanning a QR code of the private key in [[Wallet import format]].&lt;br /&gt;
&lt;br /&gt;
== Redeeming bitcoins and withdrawing funds ==&lt;br /&gt;
&lt;br /&gt;
The best way to redeem the bitcoins from a private key is to use the &amp;quot;sweep&amp;quot; feature of certain wallet software. This sends the entire balance of the paper wallet to a [[deterministic wallet]]. &lt;br /&gt;
&lt;br /&gt;
Alternatively, the private key could be imported and the entire balance sent to an address in the wallet.&lt;br /&gt;
&lt;br /&gt;
There are various wallets for doing this:&lt;br /&gt;
&lt;br /&gt;
* [https://electrumsv.io/ ElectrumSV] and [https://simply.cash/ Simply Cash] support sweeping private keys.&lt;br /&gt;
&lt;br /&gt;
==Downsides/Risks==&lt;br /&gt;
&lt;br /&gt;
Paper wallets are seen as a secure method of long term storage of funds however there are downsides to using this method.&lt;br /&gt;
&lt;br /&gt;
===Printing===&lt;br /&gt;
&lt;br /&gt;
Paper wallets require using a printer to transfer them to paper. Most printers have internal storage where the image of the wallet could be saved allowing an attacker with access to the printer to see the private key and steal the stored bitcoins. Shared printers such as in schools, offices or internet cafes are also usually centrally logged. If the printer is accessed over WiFi then any radio wave listener could also obtain the private keys and steal the money.&lt;br /&gt;
&lt;br /&gt;
=== Address reuse ===&lt;br /&gt;
&lt;br /&gt;
Paper wallets have just one bitcoin address, leading to [[address reuse]].&lt;br /&gt;
&lt;br /&gt;
=== Poor user experience ===&lt;br /&gt;
&lt;br /&gt;
Dealing with raw private keys can be unintuitive and may lead to loss of funds if not managed properly. It is recommended that users of paper wallets understand how they function before using them as long term funds storage.&lt;br /&gt;
&lt;br /&gt;
=== Low error correction ===&lt;br /&gt;
&lt;br /&gt;
The private keys are typically printed in small fonts. Sometimes characters may be mistaken for another letter. One single wrong character will invalidate the key. Private keys in WIF format have a checksum but there are a lack of tools for regular users to correct mistakes.&lt;br /&gt;
&lt;br /&gt;
While QR codes have a checksum and robust error correction, they can be damaged by water, crumpling or folding of the paper.&lt;br /&gt;
&lt;br /&gt;
== Bitcoin ATMs and paper wallets ==&lt;br /&gt;
&lt;br /&gt;
Many bitcoin ATMs use a paper-wallet-like system for delivering bitcoins if the customer doesn't have a bitcoin wallet. The ATMs can print out a private key/address pair onto paper which contain the customer's bitcoins. Ideally the customer would sweep the bitcoins into their own wallet as soon as they can.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Private Keys]]&lt;br /&gt;
* [[Seed phrase]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1465</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1465"/>
		<updated>2020-01-23T20:30:56Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Generation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. Combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications and/or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extraNonce contributes to enlarge the domain for the proof of work function. Miners can easily modify the nonce (4byte), timestamp and extraNonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1464</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1464"/>
		<updated>2020-01-23T20:30:20Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Generation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. Combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications and/or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extranonce contributes to enlarge the domain for the proof of work function. Miners can easily modify the nonce (4byte), timestamp and extraNonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1463</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1463"/>
		<updated>2020-01-23T20:24:14Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Transaction Verification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. Combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications and/or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extranonce contributes to enlarge the domain for the proof of work function. Miners can easily modify nonce (4byte), timestamp and extranonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1462</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1462"/>
		<updated>2020-01-23T20:21:12Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. Combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications and/or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys, or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extranonce contributes to enlarge the domain for the proof of work function. Miners can easily modify nonce (4byte), timestamp and extranonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1461</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1461"/>
		<updated>2020-01-23T20:15:44Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. Combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys, or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extranonce contributes to enlarge the domain for the proof of work function. Miners can easily modify nonce (4byte), timestamp and extranonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1460</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1460"/>
		<updated>2020-01-23T20:12:28Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Inputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. Combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys, or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extranonce contributes to enlarge the domain for the proof of work function. Miners can easily modify nonce (4byte), timestamp and extranonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1459</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1459"/>
		<updated>2020-01-23T20:10:34Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Inputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemer's signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. It, combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys, or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extranonce contributes to enlarge the domain for the proof of work function. Miners can easily modify nonce (4byte), timestamp and extranonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1458</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1458"/>
		<updated>2020-01-23T20:10:10Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Inputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script the public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemers signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. It, combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys, or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extranonce contributes to enlarge the domain for the proof of work function. Miners can easily modify nonce (4byte), timestamp and extranonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1457</id>
		<title>Bitcoin Transactions</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Bitcoin_Transactions&amp;diff=1457"/>
		<updated>2020-01-23T20:07:50Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* General format of a Bitcoin transaction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''transaction''' is a serialised data item that authorises an exchange between inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
A transaction can be created and iterated inside a Payment Channel using [[nLocktime and nSequence]] interlocks, or sent directly to [[The Bitcoin Network]] and collected into a [[block]].&lt;br /&gt;
A transaction uses [[UTXO|unspent transaction outputs (UTXOs)]] as inputs and distributes their value to new outputs. UTXOs are the 'coins' in which all Bitcoins are stored.&lt;br /&gt;
&lt;br /&gt;
Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions have been seen and validated by a majority of block creating nodes in the Bitcoin network, they can be considered settled. When they are eventually mined into a block, miners collaboratively agree on the order in which they were seen by the network.&lt;br /&gt;
&lt;br /&gt;
Transactions are referenced using their [[TXID]] which is a double SHA256 hash of the fully serialised transaction.&lt;br /&gt;
&lt;br /&gt;
Transaction outputs are puzzle scripts called ScriptPubKeys which are typically used to lock the contained Bitcoin value. Outputs are redeemed by making them inputs to new transactions and providing a ScriptSig which is a valid solution to the puzzle that locks the Bitcoin. Some outputs may have zero Bitcoin, but carry value in another form such as data or tokens. Scripts can be complex and specialised and may have more than one way to be redeemed.&lt;br /&gt;
&lt;br /&gt;
All transactions are captured on the ledger in [[Block|blocks]] on the [[block chain]], and can be viewed with a [[block explorer]], which is a website where transactions can be viewed in human-readable terms. These can be useful for seeing the technical details of transactions in action and for verifying payments.&lt;br /&gt;
&lt;br /&gt;
See also: [[Payment Channels]]&lt;br /&gt;
&lt;br /&gt;
= General format of a Bitcoin transaction =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Version no&lt;br /&gt;
|currently 1&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|In-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes &lt;br /&gt;
|-&lt;br /&gt;
|list of inputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_input_of_a_transaction_-_Txin|Input Structure]]&lt;br /&gt;
|&amp;lt;in-counter&amp;gt; qty with variable length per input&lt;br /&gt;
|-&lt;br /&gt;
|Out-counter&lt;br /&gt;
| positive integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
| 1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|list of outputs&lt;br /&gt;
|[[Bitcoin_Transactions#General_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout|Output Structure]]&lt;br /&gt;
|&amp;lt;out-counter&amp;gt; qty with variable length per output&lt;br /&gt;
|-&lt;br /&gt;
|[[NLocktime_and_nSequence#nLockTime|nLocktime]]&lt;br /&gt;
|if non-zero and sequence numbers are &amp;lt; 0xFFFFFFFF: block height or timestamp when transaction is final&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example of a Bitcoin transaction with 1 input and 1 output only ===&lt;br /&gt;
&lt;br /&gt;
==== Data ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Input:&lt;br /&gt;
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6&lt;br /&gt;
Index: 0&lt;br /&gt;
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10&lt;br /&gt;
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
Value: 5000000000&lt;br /&gt;
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d&lt;br /&gt;
OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Explanation ====&lt;br /&gt;
&lt;br /&gt;
The input in this transaction spends 50 BSV from output #0 in transaction f5d8... Then the output sends 50 BSV to a P2PKH puzzle. When the recipient wants to spend this money, he will reference output #0 of this transaction in an input of his own transaction and provide the solution to the P2PKH.&lt;br /&gt;
&lt;br /&gt;
=Transaction Inputs and Outputs=&lt;br /&gt;
&lt;br /&gt;
Each Bitcoin transaction is comprised of Inputs and Outputs. Inputs provide the funds to be spent in the transaction, and Outputs define where those funds should be allocated.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
&lt;br /&gt;
An '''input''' is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any [[transaction_fees|transaction fee]]) is completely used by the outputs of the new transaction. '''Previous tx''' is a [[Wikipedia:Cryptographic_hash_function|hash]] of a previous transaction. '''Index''' is the specific output in the referenced transaction. '''ScriptSig''' is the first half of a [[Opcodes_used_in_Bitcoin_Script|script]] which is provided when a UTXO is spent as an input to a transaction.&lt;br /&gt;
&lt;br /&gt;
An input scriptSig may contain many components. In the above example two items are needed to solve the script, being a signature and a public key. In a P2PKH script The public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemers signature, which is the second component. More precisely, the second component is an [[Digital_Signatures_(ECDSA)|ECDSA]] signature over a hash of a simplified version of the transaction. It, combined with the public key, proves the transaction was created by someone who controls the keys needed to spend the Bitcoin in the input. Various [[SIGHASH flags]] define how the transaction is simplified and can be used to create different types of payment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General format of each input of a transaction - Txin ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|Previous Transaction hash &lt;br /&gt;
| doubled [[Wikipedia:SHA-256|SHA256]]-[[Wikipedia:Cryptographic_hash_function|hashed]] of a (previous) to-be-used transaction&lt;br /&gt;
|32 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Previous Txout-index&lt;br /&gt;
| non negative integer indexing an output of the to-be-used transaction&lt;br /&gt;
|4 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script length&lt;br /&gt;
|non negative integer [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|1 - 9 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txin-script / scriptSig&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;in-script length&amp;gt;-many bytes&lt;br /&gt;
|-&lt;br /&gt;
|sequence_no&lt;br /&gt;
|normally 0xFFFFFFFF; irrelevant unless transaction's lock_time is &amp;gt; 0&lt;br /&gt;
|4 bytes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The input sufficiently describes where and how to get the bitcoin amount to be redeemed.&lt;br /&gt;
If it is the (only) input of the first transaction of a block, it is called the generation transaction input and its content completely ignored. (Historically the Previous Transaction hash is 0 and the Previous Txout-index is -1.)&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
An '''output''' contains a piece of [[Opcodes_used_in_Bitcoin_Script|Bitcoin Script]] which can be used to lock Bitcoins to a certain set of keys and/or inscribe data onto the ledger. The '''Value''' of an output is the number of Satoshis that this output will be worth when claimed. This '''ScriptPubKey''' is the second half of a a full script and is only completed when the output is spent. There can be more than one output, and they share the combined value of the inputs. Because each output from one transaction can only ever be referenced once by an input of a subsequent transaction, the entire value of the combined inputs needs to be allocated to the transaction outputs. Any remaining fees  If the input is worth 50 BTC but you only want to send 25 BTC, Bitcoin will create two outputs worth 25 BTC: one to the destination, and one back to you (known as &amp;quot;[[change]]&amp;quot;, though you send it to yourself). Any input bitcoins not redeemed in an output is considered a [[transaction_fees|transaction fee]], which is awarded to whoever generates the block that the transaction is mined in.&lt;br /&gt;
&lt;br /&gt;
Outputs don't necessarily contain value as Bitcoins, and can carry zero satoshis. These outputs are typically used to carry other information or tokens for second layer applications or data handling. &lt;br /&gt;
&lt;br /&gt;
=== General format of each output of a transaction - Txout ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Description&lt;br /&gt;
! Size&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|non negative integer giving the number of [[Satoshis]] to be transferred&lt;br /&gt;
|8 bytes&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script length&lt;br /&gt;
|non negative integer&lt;br /&gt;
|1 - 9 bytes [[ Protocol#Variable_length_integer|VI = VarInt]]&lt;br /&gt;
|-&lt;br /&gt;
|Txout-script / scriptPubKey&lt;br /&gt;
|[[Opcodes_used_in_Bitcoin_Script|Script]]&lt;br /&gt;
|&amp;lt;out-script length&amp;gt;-many bytes&lt;br /&gt;
|}&lt;br /&gt;
The output sets the conditions to release this bitcoin amount later. The sum of the output values of the first transaction is the value of the mined bitcoins for the block plus possible transactions fees of the other transactions in the block.&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
&lt;br /&gt;
To verify that inputs are authorized to collect the values of referenced outputs, Bitcoin uses a Forth-like [[Opcodes_used_in_Bitcoin_Script|scripting]] system. The input's scriptSig and the ''referenced'' output's scriptPubKey are evaluated (in that order), with scriptPubKey using the values left on the stack by scriptSig. The input is authorized if scriptPubKey returns true. Through the scripting system, the sender can create very complex conditions that people have to meet in order to claim the output's value. For example, it's possible to create an output that can be claimed by anyone without any authorization. It's also possible to require that an input be signed by ten different keys, or be redeemable with a password instead of a key.&lt;br /&gt;
&lt;br /&gt;
= Puzzles and Solutions =&lt;br /&gt;
&lt;br /&gt;
The flexible scripting language enabled by the Bitcoin protocol allows a multitude of different transaction types to be created. Each scriptSig/scriptPubKey pair is validated by the network miners and mined into a block if found to be valid. Some commonly used Bitcoin puzzle types are described below:&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key (P2PK) ==&lt;br /&gt;
&lt;br /&gt;
scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When redeeming coins that have been sent to a Bitcoin public key the script verifies that the provided signature was generated by the private key that also corresponds to the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
| &amp;lt;pubKey&amp;gt; OP_CHECKSIG &lt;br /&gt;
| Signature is added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG &lt;br /&gt;
| Pubkey is added to stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Public Key Hash (P2PKH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Bitcoin [[address]] is only a hash, so the sender can't provide a full public key in scriptPubKey. When redeeming coins that have been sent to a Bitcoin address, the recipient provides both the signature and the public key. The script verifies that the provided public key does hash to the hash in scriptPubKey, and then it also checks the signature against the public key.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to R-Puzzle Hash (P2RPH) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bitcoins are locked in an R-Puzzle script requiring the spending party to sign using a known value for k rather than a random number. To redeem the script, the spending party provides both the signature and the public key. The script verifies that the provided signature was signed using the correct k-value, then checks the signature against the public key. Because the public key is not checked as part of the script solution, it is possible to sign the transaction using any keypair. This can be useful when dealing with tokens that are associated with a Bitcoin address as the pubkey that corresponds to that address can be used to sign the transaction without the requirement for there to be Bitcoin in the address. The technique is also relevant for Metanet node signing as the Metanet keys can be signed with an R-Puzzle without needing a separate signature.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_OVER OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;gt;&lt;br /&gt;
| OP_3 OP_SPLIT OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Second from top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;3 bytes&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_NIP OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| First 3 bytes of signature are split&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig'&amp;gt;&lt;br /&gt;
| OP_1 OP_SPLIT OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 3 byte data item is removed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R Length&amp;gt; &amp;lt;sig&amp;quot;&amp;gt;&lt;br /&gt;
| OP_SWAP OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| 1 byte containing R length is split from sig'&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;sig&amp;quot;&amp;gt; &amp;lt;R Length&amp;gt;&lt;br /&gt;
| OP_SPLIT OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R Length parameter is moved to top of stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt; &amp;lt;sig'&amp;quot;&amp;gt;&lt;br /&gt;
| OP_DROP OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is split from sig&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;R&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| sig'&amp;quot;== is dropped from stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt;&lt;br /&gt;
| &amp;lt;rHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| R is double hashed (SHA256 followed by RIPEMD160) and result left on stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;rHashA&amp;gt; &amp;lt;rHash&amp;gt;&lt;br /&gt;
| OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Previously defined R-Hash is pushed onto stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
| Script checks if rHashA = rHash&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Pay to Multi Signature (P2MS) ==&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
 scriptSig: OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; &lt;br /&gt;
&lt;br /&gt;
OP_CHECKMULTISIG offers users the capability to lock coins with a requirement for multiple parties to sign the scriptSig before coins can be spent. OP_CHECKMULTISIG can check many signatures against many public keys as long as the signatures in the scriptSig are provided in an order that corresponds to the order in which the public keys are placed in the scriptPubKey. The first opcode in the ScriptPubKey defines how many signatures must be provided in order for the coin to be successfully spent. The last one before OP_CHECKMULTISIG tells the scripting engine how many public keys to evaluate those signatures against. There must be at least as many items on the stack as are required for the OP_CHECKMULTISIG opcode to process or the script will be invalid.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
The current version of the scripting engine also includes a bug that requires an additional value to be placed on the stack before the signatures. In this example, OP_1 has been used to push a 1 to the top of the stack, but in theory any piece of data can be used. This value is consumed by the checking process but is not evaluated.&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| OP_1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt;&lt;br /&gt;
| OP_3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; OP_5 OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptSig are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|1 &amp;lt;sig1&amp;gt; &amp;lt;sig2&amp;gt; &amp;lt;sig4&amp;gt; 3 &amp;lt;pubKey1&amp;gt; &amp;lt;pubKey2&amp;gt; &amp;lt;pubKey3&amp;gt; &amp;lt;pubKey4&amp;gt; &amp;lt;pubKey5&amp;gt; 5 &lt;br /&gt;
| OP_CHECKMULTISIG&lt;br /&gt;
| Constants from scriptPubKey are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Multisignature script evaluation is performed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
Generations have a single input, and this input has a &amp;quot;[[Coinbase |coinbase]]&amp;quot; parameter instead of a scriptSig. The data in &amp;quot;coinbase&amp;quot; can be anything; it isn't used. Bitcoin puts the current compact-format [[target]] and the arbitrary-precision &amp;quot;extraNonce&amp;quot; number there, which increments every time the Nonce field in the [[block_hashing_algorithm|block header]] overflows. Outputs can be anything, but Bitcoin creates one exactly like an IP address transaction.&lt;br /&gt;
The extranonce contributes to enlarge the domain for the proof of work function. Miners can easily modify nonce (4byte), timestamp and extranonce (2 to 100bytes).&lt;br /&gt;
&lt;br /&gt;
== Other Puzzle Types ==&lt;br /&gt;
Bitcoin's scripting language is rich and diverse and allows a user to create almost any kind of financial instrument that we have today, and many that we don't have. Puzzles do not need to conform to any particular standard or template however it is expected that the vast majority of transactions will be built using template scripts.&lt;br /&gt;
&lt;br /&gt;
Pieces of script can be combined to make larger and more complex transactions, and scripts can be built inside conditional loops allowing a single transaction output to be redeemed in multiple different ways.&lt;br /&gt;
&lt;br /&gt;
Prior to the Genesis upgrade, complex scripts that fell outside the 'isstandard' testing schema were required to be compressed into a transaction format called '[[P2SH|Pay to Script Hash (P2SH)]]' This format is now deprecated in favour of using the full, rich scripting language inside transactions.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[Opcodes used in Bitcoin Script]]&lt;br /&gt;
* [[Protocol#&amp;quot;tx&amp;quot; messages|Protocol rules - &amp;quot;tx&amp;quot; messages]]&lt;br /&gt;
* [[Protocol#Transaction Verification|Protocol documentation - Transaction Verification]]&lt;br /&gt;
* [[Transaction Malleability]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Transaction_fees&amp;diff=1456</id>
		<title>Transaction fees</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Transaction_fees&amp;diff=1456"/>
		<updated>2020-01-23T20:01:40Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Loss of fees */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Miner fees''' are a fee that spenders may include in any [[Bitcoin Transactions]].  The fees may be collected by the miner who includes the transaction in a [[Block]].&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
Every Bitcoin transaction spends zero or more bitcoins to zero or more recipients.  The difference between the amount being spent and the amount being received is the transaction fee (which must be zero or more).&lt;br /&gt;
&lt;br /&gt;
Bitcoin's design makes it easy and efficient for the sending party to specify how much fee to pay however it is theoretically possible for a merchant to pay the mining fees on behalf of their customers as an incentive to use their service. Services that make this possible have been proposed.&lt;br /&gt;
&lt;br /&gt;
When a miner creates a [[GetBlockTemplate interface|block template]], they are entitled to specify where the fees paid by the transactions in that block proposal should be sent.  If the proposal results in a valid block that becomes a part of the [[Block chain]], the fee income will be sent to the specified recipient. Miners are forced to wait 100 blocks before they can move coins received in a [[Coinbase]] transaction.&lt;br /&gt;
&lt;br /&gt;
==Loss of fees==&lt;br /&gt;
&lt;br /&gt;
If a valid block awards its finder less than the available fees plus the [[Block subsidy]], the [[Satoshis]] which are not collected are permanently destroyed. This has happened on more than 1,000 occasions in Bitcoin's history reducing the token supply by over 50 Bitcoins.&lt;br /&gt;
&lt;br /&gt;
==The Bitcoin Fee Market==&lt;br /&gt;
&lt;br /&gt;
A default minimum fee is usually needed for a transaction to be propagated across the network and mined into a block however a market has arisen offering discounted transactions for bulk generators. The upcoming MinerAPI package will give miners a means by which to interface with regular users and to offer their own unique pricing on a per-node basis. User wallets will be able to make use of this service to present users with fee rates that present estimated 'time to confirmation' giving them flexibility to choose lower fees for larger or less important transactions, without having to worry about those transactions failing to propagate.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Main_Page&amp;diff=1305</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Main_Page&amp;diff=1305"/>
		<updated>2020-01-18T20:08:37Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* The Ledger */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Special:UserLogin|&amp;lt;span style=&amp;quot;color:red;font-size:1.2em;font-weight:bold;text-decoration:underline;&amp;quot;&amp;gt;Temporary log in link&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Welcome to the BitcoinSV wiki. Here we aim to provide a correct and up-to date set of information on the Bitcoin network and its features and functionality.&lt;br /&gt;
&lt;br /&gt;
===Bitcoin===&lt;br /&gt;
&lt;br /&gt;
'''Bitcoin''' is a peer to peer cash system created by [https://craigwright.net/ Dr. Craig Wright] under the pseudonym [[Satoshi Nakamoto]] and released as open-source software in 2009. It does not rely on a central server to process transactions or store funds. The leaderless structure of the network famously solves [[The Byzantine Generals Problem]] allowing disconnected entities to follow a common direction without centralised instruction.&lt;br /&gt;
&lt;br /&gt;
===The Ledger===&lt;br /&gt;
The Bitcoin ledger is also formed as a [[wikipedia:Directed Acyclic Graph|Directed acyclic graph]] (DAG) where each transaction is a node. Following this graph back can trace every the ownership of every coin in an unbroken chain of signatures back to the original [[Coinbase]] transactions. &lt;br /&gt;
The ledger is held on a [https://en.wikipedia.org/wiki/Distributed_networking distributed network] of nodes who compete with each other to extend it. &lt;br /&gt;
&lt;br /&gt;
Miners gather transactions from the network and evaluate whether they want to mine them or not. &lt;br /&gt;
&lt;br /&gt;
[[GetBlockTemplate interface|Block templates]] are created by a node which calculates the root of a [https://en.wikipedia.org/wiki/Merkle_tree Merkle tree] containing all of the transactions they are attempting to mine. As new transactions arrive, they are added to the tree.&lt;br /&gt;
&lt;br /&gt;
===Nodes===&lt;br /&gt;
Nodes are operated by the [[Mining|Bitcoin mining enterprises]] who build the network. Bitcoin's economic incentives are structured such that for the nodes to be most profitable at building the ledger they must be as closely connected to other well performing nodes as possible. This leads to miners forming a [[Small World Network]] which trends towards a [[Nearly Complete Graph]] where all miners are connected to all other miners. Miners gather transactions from users who connect in a layered network over the nodes at the core forming a [[Mandala Network]]. In this shell network, peers use [[Simplified Payment Verification]] to form a much less densely packed structure where information is exchanged in [[Payment Channels]].&lt;br /&gt;
&lt;br /&gt;
As Bitcoin scales, the nodes who comprise the network will be variously compartmentalised into specialised hardware. These clustered systems will be distributed globally, each being placed in a location optimised for its task.&lt;br /&gt;
&lt;br /&gt;
===Proof of Work===&lt;br /&gt;
The miners use hash based [[Proof of Work]] to compete for the right to extend the ledger, and as a means to vote on [[Network|network rules]].&lt;br /&gt;
&lt;br /&gt;
===Unit of account===&lt;br /&gt;
[[Satoshis]] are the ledger's native unit of account and 100,000,000 satoshis is abstracted to one Bitcoin. Satoshis are held in script puzzles called [[UTXO|Unspent Transaction Outputs or UTXOs]]. These are [[VOUT|outputs]] from [[Bitcoin Transactions]] which are held by miners in a quick access database called the UTXO set. During the spending process, UTXOs being used in a transaction are consumed and the solution to their puzzle script is recorded in the transaction.&lt;br /&gt;
&lt;br /&gt;
===Subsidy===&lt;br /&gt;
Satoshis are issued by miners to themselves as a [[Block subsidy|subsidy payment]] during the network establishment phase. As the network matures, the the subsidy dissipates forcing the miners to find alternate revenue streams. The payment allows miners to finance their operations through the payment of goods and services in Bitcoin, spreading them through the economy.&lt;br /&gt;
&lt;br /&gt;
===Transactions===&lt;br /&gt;
All transactions are [[Payments in Bitcoin|payments]]. Transactions are written in a flexible [[Opcodes used in Bitcoin Script|scripting language]] that is used to assign ownership rights to each transaction output.&lt;br /&gt;
All network events including the creation of a block are inscribed in transactions.&lt;br /&gt;
&lt;br /&gt;
Valid transactions that are broadcast on [[The Bitcoin Network]] are committed to the Bitcoin public ledger by miners in [[Block|Blocks]]. Blocks are discovered just under every 10 minutes on average and held in a a [[wikipedia:Directed Acyclic Graph|Directed acyclic graph]] (DAG) structured as a [[Block chain]]. Each block forms a node in the graph. This graph is consistent in structure and can be traced back to the [[Genesis block|first block mined]].&lt;br /&gt;
&lt;br /&gt;
Transactions can be exchanged peer to peer, allowing them to be modified in payment channels. Once a transactions is sent to the network in a closed channel, global [[consensus|Consensus]] can be reached on the validity in less than 2 seconds. &lt;br /&gt;
&lt;br /&gt;
===Network rules===&lt;br /&gt;
Bitcoin operates on a fixed ruleset. consensus is based on things such as the rate at which new bitcoins are issued, the mathematical rules outlining the target for the [[Difficulty]] algorithm and more. The protocol is agreed upon by the miners who control network operation.&lt;br /&gt;
&lt;br /&gt;
===Limits===&lt;br /&gt;
There are no limits in the [[Protocol|Bitcoin protocol]]. Any limits imposed are are put in place by miners who are incentivised to catch the largest profitable pools of transactions they can. Miners compete to offer better service to fee paying users by scaling their own capabilities.&lt;br /&gt;
&lt;br /&gt;
===History===&lt;br /&gt;
[[Bitcoin until today|Bitcoin has a rich history]] and has been [[Attacks on Bitcoin|attacked]] in many ways since its inception.&lt;br /&gt;
&lt;br /&gt;
===Tools and Building on Bitcoin===&lt;br /&gt;
Bitcoin has a rich and diverse [[Building on Bitcoin|set of tools]] which are being added to all the time.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Double-spending&amp;diff=1304</id>
		<title>Double-spending</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Double-spending&amp;diff=1304"/>
		<updated>2020-01-18T20:06:24Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Definition===&lt;br /&gt;
Double spending is the act of sending a [[Bitcoin_Transactions|transaction]] containing inputs that have already been spent, in an attempt to commit fraud on the network.&lt;br /&gt;
&lt;br /&gt;
===Consequences===&lt;br /&gt;
Double spends are one of the most commonly discussed attacks on Bitcoin however there has yet to be a documented case of someone executing a successful double spend using Bitcoin in commerce. &lt;br /&gt;
&lt;br /&gt;
The reason for this is that double spending is a crime and analogous to intentionally bouncing a check - the difference is that the merchant would have cryptographic proof that the customer attempted such an act.&lt;br /&gt;
&lt;br /&gt;
===Economic incentives===&lt;br /&gt;
Bitcoin solves the double spending problem via its economic incentives. Miners have a strong incentive not to include these transactions in a block because they are at risk of having their block rejected by other miners as well as would be complicit in carrying out a crime. &lt;br /&gt;
&lt;br /&gt;
These factors highlight why the solution to double spending is an economic solution, not a technical one. Many arguments have been made by developers in the past that changes are necessary to the protocol to fix this issue, but they are all unnecessary.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Double-spending&amp;diff=1303</id>
		<title>Double-spending</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Double-spending&amp;diff=1303"/>
		<updated>2020-01-18T20:06:03Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Definition===&lt;br /&gt;
Double spending is the act of sending a [[Bitcoin_Transactions|transaction]] containing inputs that have already been spent, in an attempt to commit fraud on the network.&lt;br /&gt;
&lt;br /&gt;
===Consequences===&lt;br /&gt;
Double spends are one of the most commonly discussed attacks on Bitcoin however there has yet to be a documented case of someone executing a successful double spend using Bitcoin in commerce. &lt;br /&gt;
&lt;br /&gt;
The reason for this is that double spending is a crime and analogous to intentionally bouncing a check - the difference is that the merchant would have cryptographic proof that the customer attempted such an act.&lt;br /&gt;
&lt;br /&gt;
===Economic incentives===&lt;br /&gt;
Bitcoin solves the double spending problem via its economic incentives. Miners have a strong incentive not to include these transactions in a block because they are at risk of having their block rejected by other miners as well as would be complicit in carrying out a crime. &lt;br /&gt;
&lt;br /&gt;
These factors highlight why the solution to double spending is an economic solution, not a technical one. Many arguments have been made by developers in the past that changes are necessary to the protocol to fix this issue, but they are all unnecessary.&lt;br /&gt;
&lt;br /&gt;
[[Bitcoin Transactions]] are typically [[Irreversible Transactions|irreversible]] once they have been broadcast to the mining network.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Double-spending&amp;diff=1302</id>
		<title>Double-spending</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Double-spending&amp;diff=1302"/>
		<updated>2020-01-18T20:03:27Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Definition===&lt;br /&gt;
Double spending is the act of sending a transaction containing inputs that have already been spent, in an attempt to commit fraud on the network. &lt;br /&gt;
&lt;br /&gt;
===Consequences===&lt;br /&gt;
Double spends are one of the most commonly discussed attacks on Bitcoin however there has yet to be a documented case of someone executing a successful double spend using Bitcoin in commerce. &lt;br /&gt;
&lt;br /&gt;
The reason for this is that double spending is a crime and analogous to intentionally bouncing a check - the difference is that the merchant would have cryptographic proof that the customer attempted such an act.&lt;br /&gt;
&lt;br /&gt;
===Economic incentives===&lt;br /&gt;
Bitcoin solves the double spending problem via its economic incentives. Miners have a strong incentive not to include these transactions in a block because they are at risk of having their block rejected by other miners as well as would be complicit in carrying out a crime. &lt;br /&gt;
&lt;br /&gt;
These factors highlight why the solution to double spending is an economic solution, not a technical one. Many arguments have been made by developers in the past that changes are necessary to the protocol to fix this issue, but they are all unnecessary.&lt;br /&gt;
&lt;br /&gt;
[[Bitcoin Transactions]] are typically [[Irreversible Transactions|irreversible]] once they have been broadcast to the mining network.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1301</id>
		<title>Paper wallet</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Paper_wallet&amp;diff=1301"/>
		<updated>2020-01-18T19:52:14Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Redeeming bitcoins and withdrawing funds */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''paper wallet''' is the name given to a method of storing bitcoin which involves printing a single [[Private Keys|private key]] and bitcoin [[address]] onto paper and depositing funds into a [[Bitcoin Transactions#P2PHK|P2PKH]] script using the address. Funds can be accessed by accessing the physical paper and entering the private key into a wallet. This is usually achieved by scanning a QR code of the private key in [[Wallet import format]].&lt;br /&gt;
&lt;br /&gt;
== Redeeming bitcoins and withdrawing funds ==&lt;br /&gt;
&lt;br /&gt;
The best way to redeem the bitcoins from a private key is to use the &amp;quot;sweep&amp;quot; feature of certain wallet software. This sends the entire balance of the paper wallet to a [[deterministic wallet]]. Alternatively the private key could be imported and the entire balance sent to an address in the wallet.&lt;br /&gt;
&lt;br /&gt;
There are various wallets for doing this:&lt;br /&gt;
&lt;br /&gt;
* [https://electrumsv.io/ ElectrumSV] and [https://simply.cash/ Simply Cash] support sweeping private keys.&lt;br /&gt;
&lt;br /&gt;
==Downsides/Risks==&lt;br /&gt;
&lt;br /&gt;
Paper wallets are seen as a secure method of long term storage of funds however there are downsides to using this method.&lt;br /&gt;
&lt;br /&gt;
===Printing===&lt;br /&gt;
&lt;br /&gt;
Paper wallets require using a printer to transfer them to paper. Most printers have internal storage where the image of the wallet could be saved allowing an attacker with access to the printer to see the private key and steal the stored bitcoins. Shared printers such as in schools, offices or internet cafes are also usually centrally logged. If the printer is accessed over WiFi then any radio wave listener could also obtain the private keys and steal the money.&lt;br /&gt;
&lt;br /&gt;
[[Seed phrase]]s avoid this problem by having the user transfer the sensitive information to paper without a printer but via their own handwriting.&lt;br /&gt;
&lt;br /&gt;
=== Address reuse ===&lt;br /&gt;
&lt;br /&gt;
Paper wallets have just one bitcoin address, leading to [[address reuse]].&lt;br /&gt;
&lt;br /&gt;
=== Poor user experience ===&lt;br /&gt;
&lt;br /&gt;
Dealing with raw private keys can be unintuitive and may lead to loss of funds if not managed properly. It is recommended that users of paper wallets understand how they function before using them as long term funds storage.&lt;br /&gt;
&lt;br /&gt;
=== Low error correction ===&lt;br /&gt;
&lt;br /&gt;
The private keys are typically printed in small fonts. Sometimes characters may be mistaken for another letter. One single wrong character will invalidate the key. Private keys in WIF format have a checksum but there are a lack of tools for regular users to correct mistakes.&lt;br /&gt;
&lt;br /&gt;
While QR codes have a checksum and robust error correction, they can be damaged by water, crumpling or folding of the paper.&lt;br /&gt;
&lt;br /&gt;
=== Paper wallet software ===&lt;br /&gt;
&lt;br /&gt;
Many paper wallets are created with website using Javascript cryptography, which is considered unsafe for anything related to bitcoin.&lt;br /&gt;
&lt;br /&gt;
== Bitcoin ATMs and paper wallets ==&lt;br /&gt;
&lt;br /&gt;
Many bitcoin ATMs use a paper-wallet-like system for delivering bitcoins if the customer doesn't have a bitcoin wallet. The ATMs can print out a private key/address pair onto paper which contain the customer's bitcoins. Ideally the customer would sweep the bitcoins into their own wallet as soon as they can.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Private Keys]]&lt;br /&gt;
* [[Seed phrase]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Seed_phrase&amp;diff=1300</id>
		<title>Seed phrase</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Seed_phrase&amp;diff=1300"/>
		<updated>2020-01-18T19:51:34Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Two-Factor Seed Phrases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''seed phrase''', '''seed recovery phrase''' or '''backup seed phrase''' is a list of words which correspond to the master private key of a Bitcoin SV wallet. In typical usage, a wallet will generate a seed phrase and instruct the user to write it down on paper. If the user's computer breaks or their hard drive becomes corrupted, they can download the same wallet software again and use the paper backup to deterministically re-generate their wallet. Seed phrases are the most frequently encountered means of backing up Bitcoin SV wallets.&lt;br /&gt;
&lt;br /&gt;
Anybody with access to the phrase can steal the bitcoins, so it must be kept safe. Phrases should not be transmitted electronically and should never be written on any website.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
An example of a seed phrase is:&lt;br /&gt;
&lt;br /&gt;
    witch collapse practice feed shame open despair creek road again ice least&lt;br /&gt;
&lt;br /&gt;
The word order is important.&lt;br /&gt;
&lt;br /&gt;
== Explanation ==&lt;br /&gt;
&lt;br /&gt;
A simplified explanation of how seed phrases work is that the wallet software has a list of words taken from a dictionary, with each word assigned to a number. The words in the seed phrase are each converted to their corresponding number and concatenated to generate the seed integer to a [[Deterministic wallet|deterministic wallet]]. From this seed integer the wallet generates all [[Private Keys|key pairs]] used in the wallet.&lt;br /&gt;
&lt;br /&gt;
The English-language wordlist for the BIP39 standard has 2048 words, so if the phrase contained only 12 random words, the number of possible combinations would be 2048^12 = 2^132 and the phrase would have 132 bits of security.  However, some of the data in a BIP39 phrase is not random (see: [https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#Generating_the_mnemonic BIP39: Generating the mnemonic]), so the actual security of a 12-word BIP39 seed phrase is only 128 bits.&lt;br /&gt;
&lt;br /&gt;
== Two-Factor Seed Phrases ==&lt;br /&gt;
&lt;br /&gt;
Several wallets enable their users to generate seed phrases with an added layer of encryption to prevent someone who discovers the words from accessing the wallet. The password can be used to create a two-factor seed phrase where both ''&amp;quot;something you have&amp;quot;'' plus ''&amp;quot;something you know&amp;quot;'' is required to recover the wallet.&lt;br /&gt;
&lt;br /&gt;
This works by the wallet creating a seed phrase and asking the user for a password. Then both the seed phrase and extra word are required to recover the wallet. [https://electrumsv.io/ ElectrumSV] and some other wallets call the passphrase a '''&amp;quot;seed extension&amp;quot;''', '''&amp;quot;extension word&amp;quot;''' or '''&amp;quot;13th/25th word&amp;quot;'''. The BIP39 standard defines a way of passphrase-protecting a seed phrase. A similar scheme is also used in the Electrum SV standard. If a passphrase is not present, an empty string &amp;quot;&amp;quot; is used instead.&lt;br /&gt;
&lt;br /&gt;
== Storing Seed Phrases for the Long Term == &lt;br /&gt;
&lt;br /&gt;
Most people write down phrases on paper but they can be stored in many other ways such as [[Brainwallet|memorizing]], engraving on metal, writing in the margins of a book or any other creative and inventive way.&lt;br /&gt;
&lt;br /&gt;
For storing on paper writing with pencil is much better than pen [http://www.joethorn.net/blog/2011/12/07/pencil-does-not-fade Pencil Does Not Fade] [https://www.quora.com/How-do-I-maintain-a-paper-notebook-that-can-remain-for-years How do I maintain a paper notebook that can remain for years?]. Paper should be acid-free or archival paper, and stored in the dark avoiding extremes of heat and moisture [https://www.loc.gov/preservation/care/deterioratebrochure.html Essential facts about preservation of Paper] [https://www.quora.com/If-I-write-with-a-pencil-on-my-notebook-will-the-writing-last-for-a-long-time-say-50-years-or-will-it-just-fade-away-gradually Writing in a notebook with pencil] [http://copar.org/bulletin14.htm CoPAR: Creating records that will last] .&lt;br /&gt;
&lt;br /&gt;
== Word Lists ==&lt;br /&gt;
&lt;br /&gt;
Generally a seed phrase only works with the same wallet software that created it. If storing for a long period of time it's a good idea to write the name of the wallet too.&lt;br /&gt;
&lt;br /&gt;
The BIP39 English word list has each word being uniquely identified by the first four letters, which can be useful when space to write them is scarce.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md BIP39 wordlists]&lt;br /&gt;
* [https://github.com/spesmilo/electrum/blob/1.9.8/lib/mnemonic.py Electrum old-style wordlist]&lt;br /&gt;
* [https://github.com/spesmilo/electrum/blob/master/electrum/wordlist/english.txt Electrum new-style wordlist]&lt;br /&gt;
&lt;br /&gt;
== Alternative name &amp;quot;Mnemonic Phrase&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
Seed phrases are sometimes called &amp;quot;mnemonic phrases&amp;quot; especially in older literature. This is a bad name because the word mnemonic implies that the phrase should be memorized. It is less misleading to call them seed phrases.&lt;br /&gt;
&lt;br /&gt;
== The power of backups ==&lt;br /&gt;
&lt;br /&gt;
An especially interesting aspect in the power of paper backups is allowing your money to be two places at once. You can store backups on multiple devices/physical media in different locations and with password encryption. With that one can carry $100,000 which can instantly be moved to a phone or transferred yet with total security. If it's stolen then there is no risk because it is backed up elsewhere. That is powerful. [https://www.reddit.com/r/Bitcoin/comments/2hmnru/poll_do_you_use_paper_wallets_why_why_not_what]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[Deterministic wallet]] &lt;br /&gt;
* [[Brainwallet]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=The_Bitcoin_Network&amp;diff=1298</id>
		<title>The Bitcoin Network</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=The_Bitcoin_Network&amp;diff=1298"/>
		<updated>2020-01-18T19:50:49Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Thin SPV Clients */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin SV uses a simple broadcast network to propagate transactions and blocks. All communications are done over TCP. Bitcoin SV is fully able to use ports other than 8333 via the -port parameter. IPv6 is [https://bitcointalk.org/index.php?topic=81378.0 supported] with all versions later than Bitcoind/Bitcoin-Qt v0.7. &lt;br /&gt;
&lt;br /&gt;
== Messages ==&lt;br /&gt;
* ''version'' - Information about program version and block count. Exchanged when first connecting.&lt;br /&gt;
* ''verack'' - 'Version Acknowledgement'. Sent in response to a version message to acknowledge that the peer is willing to connect.&lt;br /&gt;
* ''addr'' - List of one or more IP addresses and ports.&lt;br /&gt;
* ''inv'' - &amp;quot;I have these blocks/transactions: ...&amp;quot; Normally sent only when a ''new'' block or transaction is being relayed. This is only a list, not the actual data.&lt;br /&gt;
* ''getdata'' - Request a single block or transaction by hash.&lt;br /&gt;
* ''merkleblock'' - Request a filtered block using the inventory type MSG_MERKLEBLOCK. Normally used to communicate transaction data to an SPV client.&lt;br /&gt;
* ''getblocks'' - Request an ''inv'' of all blocks in a range.&lt;br /&gt;
* ''getheaders'' - Request a ''headers'' message containing all block headers in a range.&lt;br /&gt;
* ''tx'' - Send a transaction. This is sent only in response to a ''getdata'' request.&lt;br /&gt;
* ''block'' - Send a block. This is sent only in response to a ''getdata'' request.&lt;br /&gt;
* ''headers'' - Send up to 2,000 block headers. Non-generators can download the headers of blocks instead of entire blocks.&lt;br /&gt;
* ''getaddr'' - Request an ''addr'' message containing a bunch of known-active peers (for bootstrapping).&lt;br /&gt;
* ''mempool'' - Requests TXIDs of transactions that the receiving node has validated but has not appeared in a block.&lt;br /&gt;
* ''submitorder'', ''checkorder'', and ''reply'' - Used when performing an [[IP Transactions|IP transaction]].&lt;br /&gt;
* ''alert'' - Send a network alert.&lt;br /&gt;
* ''ping'' - Does nothing. Used to check that the connection is still online. A TCP error will occur if the connection has died.&lt;br /&gt;
* ''pong'' - the pong message replies to a ping message, proving to the pining node that the ponging node is still responsive.&lt;br /&gt;
* ''notfound'' - Reply to a 'getdata' message which requested an object not available for relay. &lt;br /&gt;
* ''reject'' - Informs the receiving node that one of it's previous messages has been rejected.&lt;br /&gt;
* ''sendheaders'' -  Indicates that the node prefers to receive new block announcements via 'headers' as opposed to 'inv' messages.&lt;br /&gt;
* ''feefilter'' - Tells the receiving peer not to send any transactions that do not meet the specified fee rate.&lt;br /&gt;
* ''sendcmpct'' - Indicates that a node is wiling to receive new block announcements via 'cmpctblock' message rather than an 'inv'. &lt;br /&gt;
* ''cmpctblock'' - Contains a 'CBlockHeaderAndShortTxIDs' object providing a header and list of short txids.&lt;br /&gt;
* ''getblocktxn'' - Block transactions request used to request a list transaction by specifying their indexes and block hash.&lt;br /&gt;
* ''blocktxn'' -  Block transaction message provides the transactions requested by a 'getblocktxn' message.&lt;br /&gt;
* ''protoconf'' - Sent after 'verack' message, regardless of the peer's protocol version.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
More information and in-depth technical information is in the [https://github.com/bitcoin-sv/bitcoin-sv/blob/a64b6a349a68207477ec8848c9c8c025d249fe35/src/protocol.h Protocol Specification].&lt;br /&gt;
&lt;br /&gt;
== Connection ==&lt;br /&gt;
&lt;br /&gt;
To connect to a peer, you send a ''version'' message containing your version number, block count, and current time. The remote peer will send back a ''verack'' message and his own ''version'' message if he is accepting connections from your version. You will respond with your own ''verack'' if you are accepting connections from his version.&lt;br /&gt;
&lt;br /&gt;
The time data from all of your peers is collected, and the median is used by Bitcoin for all network tasks that use the time (except for other version messages).&lt;br /&gt;
&lt;br /&gt;
You then exchange ''getaddr'' and ''addr'' messages, storing all addresses that you don't know about. ''addr'' messages often contain only one address, but sometimes contain up to 1000. This is most common at the beginning of an exchange.&lt;br /&gt;
&lt;br /&gt;
== Standard relaying ==&lt;br /&gt;
&lt;br /&gt;
When someone sends a transaction, they send an ''inv'' message containing it to all of their peers. Their peers will request the full transaction with ''getdata''. If they consider the transaction valid after receiving it, they will also broadcast the transaction to all of their peers with an ''inv'', and so on. Peers ask for or relay transactions only if they don't already have them. A peer will never rebroadcast a transaction that it already knows about, though transactions will eventually be forgotten if they don't get into a block after a while. The sender and receiver of the transaction will rebroadcast, however.&lt;br /&gt;
&lt;br /&gt;
Anyone who is generating will collect valid received transactions and work on including them in a block. When someone does find a block, they send an ''inv'' containing it to all of their peers, as above. It works the same as transactions.&lt;br /&gt;
&lt;br /&gt;
Everyone broadcasts an ''addr'' containing their own IP address every 24 hours. Nodes relay these messages to a couple of their peers and store the address if it's new to them. Through this system, everyone has a reasonably clear picture of which IPs are connected to the network at the moment. After connecting to the network, you get added to everyone's address database almost instantly because of your initial ''addr''.&lt;br /&gt;
&lt;br /&gt;
Network alerts are broadcast with ''alert'' messages. No ''inv''-like system is used; these contain the entire alert. If a received alert is valid (signed by one of the people with the private key), it is relayed to all peers. For as long as an alert is still in effect, it is rebroadcast at the start of every new connection.&lt;br /&gt;
&lt;br /&gt;
== Initial block download ==&lt;br /&gt;
&lt;br /&gt;
At the start of a connection, you send a ''getblocks'' message containing the hash of the latest block you know about. If the peer doesn't think that this is the latest block, it will send an ''inv'' that contains up to 500 blocks ahead of the one you listed. You will then request all of these blocks with ''getdata'', and the peer will send them to you with ''block'' messages. After you have downloaded and processed all of these blocks, you will send another ''getblocks'', etc., until you have all of the blocks.&lt;br /&gt;
&lt;br /&gt;
== Thin SPV Clients ==&lt;br /&gt;
&lt;br /&gt;
Simplified Payment Verification was introduced as part of the Bitcoin whitepaper. [https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki BIP 0037] introduced support for thin or lite clients by way of Simple Payment Verification. SPV clients do not need to download the full block contents to verify the existence of funds in the blockchain, but rely on the chain of block headers and bloom filters to obtain the data they need from other nodes. This method of client communication allows high security trustless communication with full nodes, but at the expensive of some privacy as the peers can deduce which addresses the SPV client is seeking information about. &lt;br /&gt;
&lt;br /&gt;
The desktop wallet [https://electrumsv.io/ ElectrumSV] works in this fashion using the Python library [https://github.com/kyuupichan/bitcoinX/tree/master/bitcoinx bitcoinX] as their foundation. [https://www.moneybutton.com/ Moneybutton] on the other hand uses [https://github.com/moneybutton/bsv Javascript Bitcoin SV library] for client communication.&lt;br /&gt;
&lt;br /&gt;
== Bootstrapping ==&lt;br /&gt;
&lt;br /&gt;
You choose which peers to connect to by sorting your address database by the time since you last saw the address and then adding a bit of randomization.&lt;br /&gt;
&lt;br /&gt;
Bitcoin has three methods of finding peers.&lt;br /&gt;
&lt;br /&gt;
=== Addr ===&lt;br /&gt;
&lt;br /&gt;
The ''addr'' messages described above create an effect similar to the IRC bootstrapping method. You know reasonably quickly whenever a peer joins, though you won't know for a while when they leave.&lt;br /&gt;
&lt;br /&gt;
Bitcoin SV comes with a list of addresses known as &amp;quot;seed nodes&amp;quot;. If you are unable to connect to IRC and you've never connected to the network before, the client will update the address database by connecting to one of the nodes from this list.&lt;br /&gt;
&lt;br /&gt;
The -addnode command line option can be used to manually add a node.  The -connect option can force bitcoin to connect only to a specific node.&lt;br /&gt;
&lt;br /&gt;
=== DNS ===&lt;br /&gt;
&lt;br /&gt;
Bitcoin SV looks up the IP Addresses of several host names and adds those to the list of potential addresses.  This is the default seeding mechanism, as of v0.6.x and later.&lt;br /&gt;
&lt;br /&gt;
=== IRC ===&lt;br /&gt;
&lt;br /&gt;
As-of version 0.6.x of the Bitcoin client IRC bootstrapping is no longer enabled by default, and as of version 0.8.2 support for IRC bootstrapping has been removed completely.  The information below is accurate for most versions prior.&lt;br /&gt;
&lt;br /&gt;
Bitcoin joins a random channel between #bitcoin00 and #bitcoin99 on irc.lfnet.org. Your nick is set to an encoded form of your IP address. By decoding all the nicks of all users on the channel, you get a list of all IP addresses currently connected to Bitcoin.&lt;br /&gt;
&lt;br /&gt;
== Heartbeat ==&lt;br /&gt;
&lt;br /&gt;
If thirty minutes or more has passed since the client has transmitted any messages it will transmit a message to keep the connection to the peer node alive.&lt;br /&gt;
&lt;br /&gt;
If ninety minutes has passed since a peer node has communicated any messages, then the client will assume that connection has closed.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Peer-to-Peer Network Architecture]]&lt;br /&gt;
* [[Exchanging &amp;quot;Inventory&amp;quot;]]&lt;br /&gt;
* [[Encrypted and Authenticated Connections]]&lt;br /&gt;
* [[Transaction Pools]]&lt;br /&gt;
* [[Protocol|Protocol Specification]]&lt;br /&gt;
* [http://bitcoinstatus.rowit.co.uk/ Historical Network Status (no longer updated)]&lt;br /&gt;
* [http://getaddr.bitnodes.io/ Bitnodes.io's network size estimate]&lt;br /&gt;
* [http://fullnode.info/howto.html How to run your own cheap full bitcoin node]&lt;br /&gt;
* [https://www.bitcoinmining.com/ Bitcoin Mining]&lt;br /&gt;
* [https://www.youtube.com/watch?v=GmOzih6I1zs Video: What is Bitcoin Mining]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Difficulty&amp;diff=1297</id>
		<title>Difficulty</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Difficulty&amp;diff=1297"/>
		<updated>2020-01-18T19:48:45Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* What is the maximum difficulty? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''See also: [[Target]]''&lt;br /&gt;
&lt;br /&gt;
=== What is difficulty? ===&lt;br /&gt;
&lt;br /&gt;
Difficulty is a measure of how difficult it is to find a hash below a given [[target]]. Difficulty answers the question: &amp;quot;how many times more difficult is it to mine a block now, compared with how difficult it was to mine the [[Genesis block|Genesis Block]]?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Bitcoin network has a global block difficulty. Valid blocks must have a hash below this target.&lt;br /&gt;
Mining pools also have a pool-specific share difficulty setting a lower limit for shares.&lt;br /&gt;
&lt;br /&gt;
=== How often does the network difficulty change? ===&lt;br /&gt;
&lt;br /&gt;
See [[Target|target]].&lt;br /&gt;
&lt;br /&gt;
=== What is the formula for difficulty? ===&lt;br /&gt;
difficulty = difficulty_1_target / current_target &lt;br /&gt;
&lt;br /&gt;
''target is a 256 bit number''&lt;br /&gt;
&lt;br /&gt;
''difficulty_1_target is the target used in the Genesis Block and represents a difficulty of 1.''&lt;br /&gt;
&lt;br /&gt;
difficulty_1_target can be different for various ways to measure difficulty.&lt;br /&gt;
Traditionally, it represents a hash where the leading 32 bits are zero and the rest are one (this is known as &amp;quot;pool difficulty&amp;quot; or &amp;quot;pdiff&amp;quot;).&lt;br /&gt;
The Bitcoin protocol represents targets as a custom floating point type with limited precision; as a result, Bitcoin clients often approximate difficulty based on this (this is known as &amp;quot;bdiff&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===How is difficulty stored in blocks?===&lt;br /&gt;
&lt;br /&gt;
Each block stores a packed representation in its block header (called [[Block hashing algorithm|Bits]]) for its actual hexadecimal [[target]]. The target can be derived from Bits via a predefined formula. For example, if the packed target in the block is 0x1b0404cb, the hexadecimal target is:&lt;br /&gt;
 0x0404cb * 2**(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000&lt;br /&gt;
&lt;br /&gt;
Note that the 0x0404cb value is a signed value in this format. The largest legal value for this field is 0x7fffff. To make a larger value you must shift it down one full byte. Also 0x008000 is the smallest positive valid value.&lt;br /&gt;
&lt;br /&gt;
===How is difficulty calculated? What is the difference between bdiff and pdiff?===&lt;br /&gt;
&lt;br /&gt;
The highest possible target (difficulty 1) is defined as 0x1d00ffff, which gives us a hex target of&lt;br /&gt;
 0x00ffff * 2**(8*(0x1d - 3)) = 0x00000000FFFF0000000000000000000000000000000000000000000000000000&lt;br /&gt;
&lt;br /&gt;
It should be noted that pooled mining often uses non-truncated targets, which puts &amp;quot;pool difficulty 1&amp;quot; at&lt;br /&gt;
 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF&lt;br /&gt;
&lt;br /&gt;
So the difficulty at 0x1b0404cb is therefore:&lt;br /&gt;
 0x00000000FFFF0000000000000000000000000000000000000000000000000000 /&lt;br /&gt;
 0x00000000000404CB000000000000000000000000000000000000000000000000 &lt;br /&gt;
 = 16307.420938523983 (bdiff)&lt;br /&gt;
And:&lt;br /&gt;
 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF /&lt;br /&gt;
 0x00000000000404CB000000000000000000000000000000000000000000000000 &lt;br /&gt;
 = 16307.669773817162 (pdiff)&lt;br /&gt;
&lt;br /&gt;
Here's a fast way to calculate bitcoin difficulty. It uses a modified Taylor series for the logarithm (you can see tutorials on flipcode and wikipedia) and relies on logs to transform the difficulty calculation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;cmath&amp;gt;&lt;br /&gt;
&lt;br /&gt;
inline float fast_log(float val)&lt;br /&gt;
{&lt;br /&gt;
   int * const exp_ptr = reinterpret_cast &amp;lt;int *&amp;gt;(&amp;amp;val);&lt;br /&gt;
   int x = *exp_ptr;&lt;br /&gt;
   const int log_2 = ((x &amp;gt;&amp;gt; 23) &amp;amp; 255) - 128;&lt;br /&gt;
   x &amp;amp;= ~(255 &amp;lt;&amp;lt; 23);&lt;br /&gt;
   x += 127 &amp;lt;&amp;lt; 23;&lt;br /&gt;
   *exp_ptr = x;&lt;br /&gt;
&lt;br /&gt;
   val = ((-1.0f/3) * val + 2) * val - 2.0f/3;&lt;br /&gt;
   return ((val + log_2) * 0.69314718f);&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
float difficulty(unsigned int bits)&lt;br /&gt;
{&lt;br /&gt;
    static double max_body = fast_log(0x00ffff), scaland = fast_log(256);&lt;br /&gt;
    return exp(max_body - fast_log(bits &amp;amp; 0x00ffffff) + scaland * (0x1d - ((bits &amp;amp; 0xff000000) &amp;gt;&amp;gt; 24)));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; difficulty(0x1b0404cb) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see the math to go from the normal difficulty calculations (which require large big ints bigger than the space in any normal integer) to the calculation above, here's some python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import decimal, math&lt;br /&gt;
l = math.log&lt;br /&gt;
e = math.e&lt;br /&gt;
&lt;br /&gt;
print 0x00ffff * 2**(8*(0x1d - 3)) / float(0x0404cb * 2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff * 2**(8*(0x1d - 3)) / float(0x0404cb * 2**(8*(0x1b - 3))))&lt;br /&gt;
print l(0x00ffff * 2**(8*(0x1d - 3))) - l(0x0404cb * 2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff) + l(2**(8*(0x1d - 3))) - l(0x0404cb) - l(2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff) + (8*(0x1d - 3))*l(2) - l(0x0404cb) - (8*(0x1b - 3))*l(2)&lt;br /&gt;
print l(0x00ffff / float(0x0404cb)) + (8*(0x1d - 3))*l(2) - (8*(0x1b - 3))*l(2)&lt;br /&gt;
print l(0x00ffff / float(0x0404cb)) + (0x1d - 0x1b)*l(2**8)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What is the current difficulty? ===&lt;br /&gt;
[https://whatsonchain.com/ Current difficulty]&lt;br /&gt;
&lt;br /&gt;
=== What is the maximum difficulty? ===&lt;br /&gt;
&lt;br /&gt;
There is no minimum target. The maximum difficulty is roughly: maximum_target / 1 (since 0 would result in infinity), which is a ridiculously huge number (about 2^224).&lt;br /&gt;
&lt;br /&gt;
The actual maximum difficulty is when current_target=0, but we would not be able to calculate the difficulty if that happened. (fortunately it never will, so we're ok.)&lt;br /&gt;
&lt;br /&gt;
The difficulty can rise by a maximum of 400% of the current difficulty, or by a factor of 4.&lt;br /&gt;
&lt;br /&gt;
=== Can the network difficulty decrease? ===&lt;br /&gt;
Yes it can. See discussion in [[target]]. &lt;br /&gt;
&lt;br /&gt;
The network's difficulty can adjust downwards by up to 75% of the current difficulty.&lt;br /&gt;
&lt;br /&gt;
=== What is the minimum difficulty? ===&lt;br /&gt;
The minimum difficulty, when the target is at the maximum allowed value, is 1. This is the difficulty of the [[Genesis block]].&lt;br /&gt;
&lt;br /&gt;
=== What network hash rate results in a given difficulty? ===&lt;br /&gt;
The difficulty is adjusted every 2016 blocks based on the [[Block_timestamp|time]] it took to find the previous 2016 blocks.  At the desired rate of one block each 10 minutes, 2016 blocks would take exactly two weeks to find.  If the previous 2016 blocks took more than two weeks to find, the difficulty is reduced.  If they took less than two weeks, the difficulty is increased.  The change in difficulty is in proportion to the amount of time over or under two weeks the previous 2016 blocks took to find.&lt;br /&gt;
&lt;br /&gt;
To find a block, the hash must be less than the target.  The hash is effectively a random number between 0 and 2**256-1.  The offset for difficulty 1 is&lt;br /&gt;
 0xffff * 2**208&lt;br /&gt;
and for difficulty D is&lt;br /&gt;
 (0xffff * 2**208)/D&lt;br /&gt;
&lt;br /&gt;
The expected number of hashes we need to calculate to find a block with difficulty D is therefore&lt;br /&gt;
 D * 2**256 / (0xffff * 2**208)&lt;br /&gt;
or just&lt;br /&gt;
 D * 2**48 / 0xffff&lt;br /&gt;
&lt;br /&gt;
The difficulty is set such that the previous 2016 blocks would have been found at the rate of one every 10 minutes, so we were calculating (D * 2**48 / 0xffff) hashes in 600 seconds.  That means the hash rate of the network was&lt;br /&gt;
 D * 2**48 / 0xffff / 600&lt;br /&gt;
over the previous 2016 blocks.  Can be further simplified to&lt;br /&gt;
 D * 2**32 / 600&lt;br /&gt;
without much loss of accuracy.&lt;br /&gt;
&lt;br /&gt;
At difficulty 1, that is around 7 Mhashes per second.&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the difficulty is 22012.4941572, which means that over the previous set of 2016 blocks found the average network hash rate was&lt;br /&gt;
 22012.4941572 * 2**32 / 600 = around 157 Ghashes per second.&lt;br /&gt;
&lt;br /&gt;
=== How soon might I expect to generate a block? ===&lt;br /&gt;
The average time to find a block can be approximated by calculating:&lt;br /&gt;
 time = difficulty * 2**32 / hashrate&lt;br /&gt;
where difficulty is the current difficulty, hashrate is the number of hashes your miner calculates per second, and time is the average in seconds between the blocks you find.&lt;br /&gt;
&lt;br /&gt;
For example, using Python we calculate the average time to generate a block using a 1Ghash/s mining rig when the difficulty is 20000:&lt;br /&gt;
 $ python -c &amp;quot;print 20000 * 2**32 / 10**9 / 60 / 60.0&amp;quot;&lt;br /&gt;
 23.85&lt;br /&gt;
and find that it takes just under 24 hours on average.&lt;br /&gt;
&lt;br /&gt;
Remember - any one grinding of the hash stands the same chance of &amp;quot;winning&amp;quot; as any other.  The numbers game is how many attempts hardware can make per second.&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
&lt;br /&gt;
* See also: [[Target]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Difficulty&amp;diff=1296</id>
		<title>Difficulty</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Difficulty&amp;diff=1296"/>
		<updated>2020-01-18T19:48:02Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Can the network difficulty go down? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''See also: [[Target]]''&lt;br /&gt;
&lt;br /&gt;
=== What is difficulty? ===&lt;br /&gt;
&lt;br /&gt;
Difficulty is a measure of how difficult it is to find a hash below a given [[target]]. Difficulty answers the question: &amp;quot;how many times more difficult is it to mine a block now, compared with how difficult it was to mine the [[Genesis block|Genesis Block]]?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Bitcoin network has a global block difficulty. Valid blocks must have a hash below this target.&lt;br /&gt;
Mining pools also have a pool-specific share difficulty setting a lower limit for shares.&lt;br /&gt;
&lt;br /&gt;
=== How often does the network difficulty change? ===&lt;br /&gt;
&lt;br /&gt;
See [[Target|target]].&lt;br /&gt;
&lt;br /&gt;
=== What is the formula for difficulty? ===&lt;br /&gt;
difficulty = difficulty_1_target / current_target &lt;br /&gt;
&lt;br /&gt;
''target is a 256 bit number''&lt;br /&gt;
&lt;br /&gt;
''difficulty_1_target is the target used in the Genesis Block and represents a difficulty of 1.''&lt;br /&gt;
&lt;br /&gt;
difficulty_1_target can be different for various ways to measure difficulty.&lt;br /&gt;
Traditionally, it represents a hash where the leading 32 bits are zero and the rest are one (this is known as &amp;quot;pool difficulty&amp;quot; or &amp;quot;pdiff&amp;quot;).&lt;br /&gt;
The Bitcoin protocol represents targets as a custom floating point type with limited precision; as a result, Bitcoin clients often approximate difficulty based on this (this is known as &amp;quot;bdiff&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===How is difficulty stored in blocks?===&lt;br /&gt;
&lt;br /&gt;
Each block stores a packed representation in its block header (called [[Block hashing algorithm|Bits]]) for its actual hexadecimal [[target]]. The target can be derived from Bits via a predefined formula. For example, if the packed target in the block is 0x1b0404cb, the hexadecimal target is:&lt;br /&gt;
 0x0404cb * 2**(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000&lt;br /&gt;
&lt;br /&gt;
Note that the 0x0404cb value is a signed value in this format. The largest legal value for this field is 0x7fffff. To make a larger value you must shift it down one full byte. Also 0x008000 is the smallest positive valid value.&lt;br /&gt;
&lt;br /&gt;
===How is difficulty calculated? What is the difference between bdiff and pdiff?===&lt;br /&gt;
&lt;br /&gt;
The highest possible target (difficulty 1) is defined as 0x1d00ffff, which gives us a hex target of&lt;br /&gt;
 0x00ffff * 2**(8*(0x1d - 3)) = 0x00000000FFFF0000000000000000000000000000000000000000000000000000&lt;br /&gt;
&lt;br /&gt;
It should be noted that pooled mining often uses non-truncated targets, which puts &amp;quot;pool difficulty 1&amp;quot; at&lt;br /&gt;
 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF&lt;br /&gt;
&lt;br /&gt;
So the difficulty at 0x1b0404cb is therefore:&lt;br /&gt;
 0x00000000FFFF0000000000000000000000000000000000000000000000000000 /&lt;br /&gt;
 0x00000000000404CB000000000000000000000000000000000000000000000000 &lt;br /&gt;
 = 16307.420938523983 (bdiff)&lt;br /&gt;
And:&lt;br /&gt;
 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF /&lt;br /&gt;
 0x00000000000404CB000000000000000000000000000000000000000000000000 &lt;br /&gt;
 = 16307.669773817162 (pdiff)&lt;br /&gt;
&lt;br /&gt;
Here's a fast way to calculate bitcoin difficulty. It uses a modified Taylor series for the logarithm (you can see tutorials on flipcode and wikipedia) and relies on logs to transform the difficulty calculation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;cmath&amp;gt;&lt;br /&gt;
&lt;br /&gt;
inline float fast_log(float val)&lt;br /&gt;
{&lt;br /&gt;
   int * const exp_ptr = reinterpret_cast &amp;lt;int *&amp;gt;(&amp;amp;val);&lt;br /&gt;
   int x = *exp_ptr;&lt;br /&gt;
   const int log_2 = ((x &amp;gt;&amp;gt; 23) &amp;amp; 255) - 128;&lt;br /&gt;
   x &amp;amp;= ~(255 &amp;lt;&amp;lt; 23);&lt;br /&gt;
   x += 127 &amp;lt;&amp;lt; 23;&lt;br /&gt;
   *exp_ptr = x;&lt;br /&gt;
&lt;br /&gt;
   val = ((-1.0f/3) * val + 2) * val - 2.0f/3;&lt;br /&gt;
   return ((val + log_2) * 0.69314718f);&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
float difficulty(unsigned int bits)&lt;br /&gt;
{&lt;br /&gt;
    static double max_body = fast_log(0x00ffff), scaland = fast_log(256);&lt;br /&gt;
    return exp(max_body - fast_log(bits &amp;amp; 0x00ffffff) + scaland * (0x1d - ((bits &amp;amp; 0xff000000) &amp;gt;&amp;gt; 24)));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; difficulty(0x1b0404cb) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see the math to go from the normal difficulty calculations (which require large big ints bigger than the space in any normal integer) to the calculation above, here's some python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import decimal, math&lt;br /&gt;
l = math.log&lt;br /&gt;
e = math.e&lt;br /&gt;
&lt;br /&gt;
print 0x00ffff * 2**(8*(0x1d - 3)) / float(0x0404cb * 2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff * 2**(8*(0x1d - 3)) / float(0x0404cb * 2**(8*(0x1b - 3))))&lt;br /&gt;
print l(0x00ffff * 2**(8*(0x1d - 3))) - l(0x0404cb * 2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff) + l(2**(8*(0x1d - 3))) - l(0x0404cb) - l(2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff) + (8*(0x1d - 3))*l(2) - l(0x0404cb) - (8*(0x1b - 3))*l(2)&lt;br /&gt;
print l(0x00ffff / float(0x0404cb)) + (8*(0x1d - 3))*l(2) - (8*(0x1b - 3))*l(2)&lt;br /&gt;
print l(0x00ffff / float(0x0404cb)) + (0x1d - 0x1b)*l(2**8)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What is the current difficulty? ===&lt;br /&gt;
[https://whatsonchain.com/ Current difficulty]&lt;br /&gt;
&lt;br /&gt;
=== What is the maximum difficulty? ===&lt;br /&gt;
&lt;br /&gt;
There is no minimum target. The maximum difficulty is roughly: maximum_target / 1 (since 0 would result in infinity), which is a ridiculously huge number (about 2^224).&lt;br /&gt;
&lt;br /&gt;
The actual maximum difficulty is when current_target=0, but we would not be able to calculate the difficulty if that happened. (fortunately it never will, so we're ok.)&lt;br /&gt;
&lt;br /&gt;
=== Can the network difficulty decrease? ===&lt;br /&gt;
Yes it can. See discussion in [[target]]. &lt;br /&gt;
&lt;br /&gt;
The network's difficulty can adjust downwards by up to 75% of the current difficulty.&lt;br /&gt;
&lt;br /&gt;
=== What is the minimum difficulty? ===&lt;br /&gt;
The minimum difficulty, when the target is at the maximum allowed value, is 1. This is the difficulty of the [[Genesis block]].&lt;br /&gt;
&lt;br /&gt;
=== What network hash rate results in a given difficulty? ===&lt;br /&gt;
The difficulty is adjusted every 2016 blocks based on the [[Block_timestamp|time]] it took to find the previous 2016 blocks.  At the desired rate of one block each 10 minutes, 2016 blocks would take exactly two weeks to find.  If the previous 2016 blocks took more than two weeks to find, the difficulty is reduced.  If they took less than two weeks, the difficulty is increased.  The change in difficulty is in proportion to the amount of time over or under two weeks the previous 2016 blocks took to find.&lt;br /&gt;
&lt;br /&gt;
To find a block, the hash must be less than the target.  The hash is effectively a random number between 0 and 2**256-1.  The offset for difficulty 1 is&lt;br /&gt;
 0xffff * 2**208&lt;br /&gt;
and for difficulty D is&lt;br /&gt;
 (0xffff * 2**208)/D&lt;br /&gt;
&lt;br /&gt;
The expected number of hashes we need to calculate to find a block with difficulty D is therefore&lt;br /&gt;
 D * 2**256 / (0xffff * 2**208)&lt;br /&gt;
or just&lt;br /&gt;
 D * 2**48 / 0xffff&lt;br /&gt;
&lt;br /&gt;
The difficulty is set such that the previous 2016 blocks would have been found at the rate of one every 10 minutes, so we were calculating (D * 2**48 / 0xffff) hashes in 600 seconds.  That means the hash rate of the network was&lt;br /&gt;
 D * 2**48 / 0xffff / 600&lt;br /&gt;
over the previous 2016 blocks.  Can be further simplified to&lt;br /&gt;
 D * 2**32 / 600&lt;br /&gt;
without much loss of accuracy.&lt;br /&gt;
&lt;br /&gt;
At difficulty 1, that is around 7 Mhashes per second.&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the difficulty is 22012.4941572, which means that over the previous set of 2016 blocks found the average network hash rate was&lt;br /&gt;
 22012.4941572 * 2**32 / 600 = around 157 Ghashes per second.&lt;br /&gt;
&lt;br /&gt;
=== How soon might I expect to generate a block? ===&lt;br /&gt;
The average time to find a block can be approximated by calculating:&lt;br /&gt;
 time = difficulty * 2**32 / hashrate&lt;br /&gt;
where difficulty is the current difficulty, hashrate is the number of hashes your miner calculates per second, and time is the average in seconds between the blocks you find.&lt;br /&gt;
&lt;br /&gt;
For example, using Python we calculate the average time to generate a block using a 1Ghash/s mining rig when the difficulty is 20000:&lt;br /&gt;
 $ python -c &amp;quot;print 20000 * 2**32 / 10**9 / 60 / 60.0&amp;quot;&lt;br /&gt;
 23.85&lt;br /&gt;
and find that it takes just under 24 hours on average.&lt;br /&gt;
&lt;br /&gt;
Remember - any one grinding of the hash stands the same chance of &amp;quot;winning&amp;quot; as any other.  The numbers game is how many attempts hardware can make per second.&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
&lt;br /&gt;
* See also: [[Target]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Difficulty&amp;diff=1295</id>
		<title>Difficulty</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Difficulty&amp;diff=1295"/>
		<updated>2020-01-18T19:47:42Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Can the network difficulty go down? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''See also: [[Target]]''&lt;br /&gt;
&lt;br /&gt;
=== What is difficulty? ===&lt;br /&gt;
&lt;br /&gt;
Difficulty is a measure of how difficult it is to find a hash below a given [[target]]. Difficulty answers the question: &amp;quot;how many times more difficult is it to mine a block now, compared with how difficult it was to mine the [[Genesis block|Genesis Block]]?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The Bitcoin network has a global block difficulty. Valid blocks must have a hash below this target.&lt;br /&gt;
Mining pools also have a pool-specific share difficulty setting a lower limit for shares.&lt;br /&gt;
&lt;br /&gt;
=== How often does the network difficulty change? ===&lt;br /&gt;
&lt;br /&gt;
See [[Target|target]].&lt;br /&gt;
&lt;br /&gt;
=== What is the formula for difficulty? ===&lt;br /&gt;
difficulty = difficulty_1_target / current_target &lt;br /&gt;
&lt;br /&gt;
''target is a 256 bit number''&lt;br /&gt;
&lt;br /&gt;
''difficulty_1_target is the target used in the Genesis Block and represents a difficulty of 1.''&lt;br /&gt;
&lt;br /&gt;
difficulty_1_target can be different for various ways to measure difficulty.&lt;br /&gt;
Traditionally, it represents a hash where the leading 32 bits are zero and the rest are one (this is known as &amp;quot;pool difficulty&amp;quot; or &amp;quot;pdiff&amp;quot;).&lt;br /&gt;
The Bitcoin protocol represents targets as a custom floating point type with limited precision; as a result, Bitcoin clients often approximate difficulty based on this (this is known as &amp;quot;bdiff&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===How is difficulty stored in blocks?===&lt;br /&gt;
&lt;br /&gt;
Each block stores a packed representation in its block header (called [[Block hashing algorithm|Bits]]) for its actual hexadecimal [[target]]. The target can be derived from Bits via a predefined formula. For example, if the packed target in the block is 0x1b0404cb, the hexadecimal target is:&lt;br /&gt;
 0x0404cb * 2**(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000&lt;br /&gt;
&lt;br /&gt;
Note that the 0x0404cb value is a signed value in this format. The largest legal value for this field is 0x7fffff. To make a larger value you must shift it down one full byte. Also 0x008000 is the smallest positive valid value.&lt;br /&gt;
&lt;br /&gt;
===How is difficulty calculated? What is the difference between bdiff and pdiff?===&lt;br /&gt;
&lt;br /&gt;
The highest possible target (difficulty 1) is defined as 0x1d00ffff, which gives us a hex target of&lt;br /&gt;
 0x00ffff * 2**(8*(0x1d - 3)) = 0x00000000FFFF0000000000000000000000000000000000000000000000000000&lt;br /&gt;
&lt;br /&gt;
It should be noted that pooled mining often uses non-truncated targets, which puts &amp;quot;pool difficulty 1&amp;quot; at&lt;br /&gt;
 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF&lt;br /&gt;
&lt;br /&gt;
So the difficulty at 0x1b0404cb is therefore:&lt;br /&gt;
 0x00000000FFFF0000000000000000000000000000000000000000000000000000 /&lt;br /&gt;
 0x00000000000404CB000000000000000000000000000000000000000000000000 &lt;br /&gt;
 = 16307.420938523983 (bdiff)&lt;br /&gt;
And:&lt;br /&gt;
 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF /&lt;br /&gt;
 0x00000000000404CB000000000000000000000000000000000000000000000000 &lt;br /&gt;
 = 16307.669773817162 (pdiff)&lt;br /&gt;
&lt;br /&gt;
Here's a fast way to calculate bitcoin difficulty. It uses a modified Taylor series for the logarithm (you can see tutorials on flipcode and wikipedia) and relies on logs to transform the difficulty calculation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;cmath&amp;gt;&lt;br /&gt;
&lt;br /&gt;
inline float fast_log(float val)&lt;br /&gt;
{&lt;br /&gt;
   int * const exp_ptr = reinterpret_cast &amp;lt;int *&amp;gt;(&amp;amp;val);&lt;br /&gt;
   int x = *exp_ptr;&lt;br /&gt;
   const int log_2 = ((x &amp;gt;&amp;gt; 23) &amp;amp; 255) - 128;&lt;br /&gt;
   x &amp;amp;= ~(255 &amp;lt;&amp;lt; 23);&lt;br /&gt;
   x += 127 &amp;lt;&amp;lt; 23;&lt;br /&gt;
   *exp_ptr = x;&lt;br /&gt;
&lt;br /&gt;
   val = ((-1.0f/3) * val + 2) * val - 2.0f/3;&lt;br /&gt;
   return ((val + log_2) * 0.69314718f);&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
float difficulty(unsigned int bits)&lt;br /&gt;
{&lt;br /&gt;
    static double max_body = fast_log(0x00ffff), scaland = fast_log(256);&lt;br /&gt;
    return exp(max_body - fast_log(bits &amp;amp; 0x00ffffff) + scaland * (0x1d - ((bits &amp;amp; 0xff000000) &amp;gt;&amp;gt; 24)));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; difficulty(0x1b0404cb) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see the math to go from the normal difficulty calculations (which require large big ints bigger than the space in any normal integer) to the calculation above, here's some python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import decimal, math&lt;br /&gt;
l = math.log&lt;br /&gt;
e = math.e&lt;br /&gt;
&lt;br /&gt;
print 0x00ffff * 2**(8*(0x1d - 3)) / float(0x0404cb * 2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff * 2**(8*(0x1d - 3)) / float(0x0404cb * 2**(8*(0x1b - 3))))&lt;br /&gt;
print l(0x00ffff * 2**(8*(0x1d - 3))) - l(0x0404cb * 2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff) + l(2**(8*(0x1d - 3))) - l(0x0404cb) - l(2**(8*(0x1b - 3)))&lt;br /&gt;
print l(0x00ffff) + (8*(0x1d - 3))*l(2) - l(0x0404cb) - (8*(0x1b - 3))*l(2)&lt;br /&gt;
print l(0x00ffff / float(0x0404cb)) + (8*(0x1d - 3))*l(2) - (8*(0x1b - 3))*l(2)&lt;br /&gt;
print l(0x00ffff / float(0x0404cb)) + (0x1d - 0x1b)*l(2**8)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What is the current difficulty? ===&lt;br /&gt;
[https://whatsonchain.com/ Current difficulty]&lt;br /&gt;
&lt;br /&gt;
=== What is the maximum difficulty? ===&lt;br /&gt;
&lt;br /&gt;
There is no minimum target. The maximum difficulty is roughly: maximum_target / 1 (since 0 would result in infinity), which is a ridiculously huge number (about 2^224).&lt;br /&gt;
&lt;br /&gt;
The actual maximum difficulty is when current_target=0, but we would not be able to calculate the difficulty if that happened. (fortunately it never will, so we're ok.)&lt;br /&gt;
&lt;br /&gt;
=== Can the network difficulty go down? ===&lt;br /&gt;
Yes it can. See discussion in [[target]]. &lt;br /&gt;
&lt;br /&gt;
The network's difficulty can adjust downwards by up to 75% of the current difficulty.&lt;br /&gt;
&lt;br /&gt;
=== What is the minimum difficulty? ===&lt;br /&gt;
The minimum difficulty, when the target is at the maximum allowed value, is 1. This is the difficulty of the [[Genesis block]].&lt;br /&gt;
&lt;br /&gt;
=== What network hash rate results in a given difficulty? ===&lt;br /&gt;
The difficulty is adjusted every 2016 blocks based on the [[Block_timestamp|time]] it took to find the previous 2016 blocks.  At the desired rate of one block each 10 minutes, 2016 blocks would take exactly two weeks to find.  If the previous 2016 blocks took more than two weeks to find, the difficulty is reduced.  If they took less than two weeks, the difficulty is increased.  The change in difficulty is in proportion to the amount of time over or under two weeks the previous 2016 blocks took to find.&lt;br /&gt;
&lt;br /&gt;
To find a block, the hash must be less than the target.  The hash is effectively a random number between 0 and 2**256-1.  The offset for difficulty 1 is&lt;br /&gt;
 0xffff * 2**208&lt;br /&gt;
and for difficulty D is&lt;br /&gt;
 (0xffff * 2**208)/D&lt;br /&gt;
&lt;br /&gt;
The expected number of hashes we need to calculate to find a block with difficulty D is therefore&lt;br /&gt;
 D * 2**256 / (0xffff * 2**208)&lt;br /&gt;
or just&lt;br /&gt;
 D * 2**48 / 0xffff&lt;br /&gt;
&lt;br /&gt;
The difficulty is set such that the previous 2016 blocks would have been found at the rate of one every 10 minutes, so we were calculating (D * 2**48 / 0xffff) hashes in 600 seconds.  That means the hash rate of the network was&lt;br /&gt;
 D * 2**48 / 0xffff / 600&lt;br /&gt;
over the previous 2016 blocks.  Can be further simplified to&lt;br /&gt;
 D * 2**32 / 600&lt;br /&gt;
without much loss of accuracy.&lt;br /&gt;
&lt;br /&gt;
At difficulty 1, that is around 7 Mhashes per second.&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the difficulty is 22012.4941572, which means that over the previous set of 2016 blocks found the average network hash rate was&lt;br /&gt;
 22012.4941572 * 2**32 / 600 = around 157 Ghashes per second.&lt;br /&gt;
&lt;br /&gt;
=== How soon might I expect to generate a block? ===&lt;br /&gt;
The average time to find a block can be approximated by calculating:&lt;br /&gt;
 time = difficulty * 2**32 / hashrate&lt;br /&gt;
where difficulty is the current difficulty, hashrate is the number of hashes your miner calculates per second, and time is the average in seconds between the blocks you find.&lt;br /&gt;
&lt;br /&gt;
For example, using Python we calculate the average time to generate a block using a 1Ghash/s mining rig when the difficulty is 20000:&lt;br /&gt;
 $ python -c &amp;quot;print 20000 * 2**32 / 10**9 / 60 / 60.0&amp;quot;&lt;br /&gt;
 23.85&lt;br /&gt;
and find that it takes just under 24 hours on average.&lt;br /&gt;
&lt;br /&gt;
Remember - any one grinding of the hash stands the same chance of &amp;quot;winning&amp;quot; as any other.  The numbers game is how many attempts hardware can make per second.&lt;br /&gt;
&lt;br /&gt;
==Related Links==&lt;br /&gt;
&lt;br /&gt;
* See also: [[Target]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Main_Page&amp;diff=1294</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Main_Page&amp;diff=1294"/>
		<updated>2020-01-18T19:44:21Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Unit of account */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Special:UserLogin|&amp;lt;span style=&amp;quot;color:red;font-size:1.2em;font-weight:bold;text-decoration:underline;&amp;quot;&amp;gt;Temporary log in link&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Welcome to the BitcoinSV wiki. Here we aim to provide a correct and up-to date set of information on the Bitcoin network and its features and functionality.&lt;br /&gt;
&lt;br /&gt;
===Bitcoin===&lt;br /&gt;
&lt;br /&gt;
'''Bitcoin''' is a peer to peer cash system created by [https://craigwright.net/ Dr. Craig Wright] under the pseudonym [[Satoshi Nakamoto]] and released as open-source software in 2009. It does not rely on a central server to process transactions or store funds. The leaderless structure of the network famously solves [[The Byzantine Generals Problem]] allowing disconnected entities to follow a common direction without centralised instruction.&lt;br /&gt;
&lt;br /&gt;
===The Ledger===&lt;br /&gt;
The Bitcoin ledger is also formed as a DAG where each transaction is a node. Following this graph back can trace every the ownership of every coin in an unbroken chain of signatures back to the original [[Coinbase]] transactions. &lt;br /&gt;
The ledger is held on a [https://en.wikipedia.org/wiki/Distributed_networking distributed network] of nodes who compete with each other to extend it. &lt;br /&gt;
&lt;br /&gt;
Miners gather transactions from the network and evaluate whether they want to mine them or not. &lt;br /&gt;
&lt;br /&gt;
[[GetBlockTemplate interface|Block templates]] are created by a node which calculates the root of a [https://en.wikipedia.org/wiki/Merkle_tree Merkle tree] containing all of the transactions they are attempting to mine. As new transactions arrive, they are added to the tree.&lt;br /&gt;
&lt;br /&gt;
===Nodes===&lt;br /&gt;
Nodes are operated by the [[Mining|Bitcoin mining enterprises]] who build the network. Bitcoin's economic incentives are structured such that for the nodes to be most profitable at building the ledger they must be as closely connected to other well performing nodes as possible. This leads to miners forming a [[Small World Network]] which trends towards a [[Nearly Complete Graph]] where all miners are connected to all other miners. Miners gather transactions from users who connect in a layered network over the nodes at the core forming a [[Mandala Network]]. In this shell network, peers use [[Simplified Payment Verification]] to form a much less densely packed structure where information is exchanged in [[Payment Channels]].&lt;br /&gt;
&lt;br /&gt;
As Bitcoin scales, the nodes who comprise the network will be variously compartmentalised into specialised hardware. These clustered systems will be distributed globally, each being placed in a location optimised for its task.&lt;br /&gt;
&lt;br /&gt;
===Proof of Work===&lt;br /&gt;
The miners use hash based [[Proof of Work]] to compete for the right to extend the ledger, and as a means to vote on [[Network|network rules]].&lt;br /&gt;
&lt;br /&gt;
===Unit of account===&lt;br /&gt;
[[Satoshis]] are the ledger's native unit of account and 100,000,000 satoshis is abstracted to one Bitcoin. Satoshis are held in script puzzles called [[UTXO|Unspent Transaction Outputs or UTXOs]]. These are [[VOUT|outputs]] from [[Bitcoin Transactions]] which are held by miners in a quick access database called the UTXO set. During the spending process, UTXOs being used in a transaction are consumed and the solution to their puzzle script is recorded in the transaction.&lt;br /&gt;
&lt;br /&gt;
===Subsidy===&lt;br /&gt;
Satoshis are issued by miners to themselves as a [[Block subsidy|subsidy payment]] during the network establishment phase. As the network matures, the the subsidy dissipates forcing the miners to find alternate revenue streams. The payment allows miners to finance their operations through the payment of goods and services in Bitcoin, spreading them through the economy.&lt;br /&gt;
&lt;br /&gt;
===Transactions===&lt;br /&gt;
All transactions are [[Payments in Bitcoin|payments]]. Transactions are written in a flexible [[Opcodes used in Bitcoin Script|scripting language]] that is used to assign ownership rights to each transaction output.&lt;br /&gt;
All network events including the creation of a block are inscribed in transactions.&lt;br /&gt;
&lt;br /&gt;
Valid transactions that are broadcast on [[The Bitcoin Network]] are committed to the Bitcoin public ledger by miners in [[Block|Blocks]]. Blocks are discovered just under every 10 minutes on average and held in a a [[wikipedia:Directed Acyclic Graph|Directed acyclic graph]] (DAG) structured as a [[Block chain]]. Each block forms a node in the graph. This graph is consistent in structure and can be traced back to the [[Genesis block|first block mined]].&lt;br /&gt;
&lt;br /&gt;
Transactions can be exchanged peer to peer, allowing them to be modified in payment channels. Once a transactions is sent to the network in a closed channel, global [[consensus|Consensus]] can be reached on the validity in less than 2 seconds. &lt;br /&gt;
&lt;br /&gt;
===Network rules===&lt;br /&gt;
Bitcoin operates on a fixed ruleset. consensus is based on things such as the rate at which new bitcoins are issued, the mathematical rules outlining the target for the [[Difficulty]] algorithm and more. The protocol is agreed upon by the miners who control network operation.&lt;br /&gt;
&lt;br /&gt;
===Limits===&lt;br /&gt;
There are no limits in the [[Protocol|Bitcoin protocol]]. Any limits imposed are are put in place by miners who are incentivised to catch the largest profitable pools of transactions they can. Miners compete to offer better service to fee paying users by scaling their own capabilities.&lt;br /&gt;
&lt;br /&gt;
===History===&lt;br /&gt;
[[Bitcoin until today|Bitcoin has a rich history]] and has been [[Attacks on Bitcoin|attacked]] in many ways since its inception.&lt;br /&gt;
&lt;br /&gt;
===Tools and Building on Bitcoin===&lt;br /&gt;
Bitcoin has a rich and diverse [[Building on Bitcoin|set of tools]] which are being added to all the time.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Main_Page&amp;diff=1293</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Main_Page&amp;diff=1293"/>
		<updated>2020-01-18T19:44:04Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: /* Proof of Work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Special:UserLogin|&amp;lt;span style=&amp;quot;color:red;font-size:1.2em;font-weight:bold;text-decoration:underline;&amp;quot;&amp;gt;Temporary log in link&amp;lt;/span&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
Welcome to the BitcoinSV wiki. Here we aim to provide a correct and up-to date set of information on the Bitcoin network and its features and functionality.&lt;br /&gt;
&lt;br /&gt;
===Bitcoin===&lt;br /&gt;
&lt;br /&gt;
'''Bitcoin''' is a peer to peer cash system created by [https://craigwright.net/ Dr. Craig Wright] under the pseudonym [[Satoshi Nakamoto]] and released as open-source software in 2009. It does not rely on a central server to process transactions or store funds. The leaderless structure of the network famously solves [[The Byzantine Generals Problem]] allowing disconnected entities to follow a common direction without centralised instruction.&lt;br /&gt;
&lt;br /&gt;
===The Ledger===&lt;br /&gt;
The Bitcoin ledger is also formed as a DAG where each transaction is a node. Following this graph back can trace every the ownership of every coin in an unbroken chain of signatures back to the original [[Coinbase]] transactions. &lt;br /&gt;
The ledger is held on a [https://en.wikipedia.org/wiki/Distributed_networking distributed network] of nodes who compete with each other to extend it. &lt;br /&gt;
&lt;br /&gt;
Miners gather transactions from the network and evaluate whether they want to mine them or not. &lt;br /&gt;
&lt;br /&gt;
[[GetBlockTemplate interface|Block templates]] are created by a node which calculates the root of a [https://en.wikipedia.org/wiki/Merkle_tree Merkle tree] containing all of the transactions they are attempting to mine. As new transactions arrive, they are added to the tree.&lt;br /&gt;
&lt;br /&gt;
===Nodes===&lt;br /&gt;
Nodes are operated by the [[Mining|Bitcoin mining enterprises]] who build the network. Bitcoin's economic incentives are structured such that for the nodes to be most profitable at building the ledger they must be as closely connected to other well performing nodes as possible. This leads to miners forming a [[Small World Network]] which trends towards a [[Nearly Complete Graph]] where all miners are connected to all other miners. Miners gather transactions from users who connect in a layered network over the nodes at the core forming a [[Mandala Network]]. In this shell network, peers use [[Simplified Payment Verification]] to form a much less densely packed structure where information is exchanged in [[Payment Channels]].&lt;br /&gt;
&lt;br /&gt;
As Bitcoin scales, the nodes who comprise the network will be variously compartmentalised into specialised hardware. These clustered systems will be distributed globally, each being placed in a location optimised for its task.&lt;br /&gt;
&lt;br /&gt;
===Proof of Work===&lt;br /&gt;
The miners use hash based [[Proof of Work]] to compete for the right to extend the ledger, and as a means to vote on [[Network|network rules]].&lt;br /&gt;
&lt;br /&gt;
==Unit of account==&lt;br /&gt;
[[Satoshis]] are the ledger's native unit of account and 100,000,000 satoshis is abstracted to one Bitcoin. Satoshis are held in script puzzles called [[UTXO|Unspent Transaction Outputs or UTXOs]]. These are [[VOUT|outputs]] from [[Bitcoin Transactions]] which are held by miners in a quick access database called the UTXO set. During the spending process, UTXOs being used in a transaction are consumed and the solution to their puzzle script is recorded in the transaction.&lt;br /&gt;
&lt;br /&gt;
===Subsidy===&lt;br /&gt;
Satoshis are issued by miners to themselves as a [[Block subsidy|subsidy payment]] during the network establishment phase. As the network matures, the the subsidy dissipates forcing the miners to find alternate revenue streams. The payment allows miners to finance their operations through the payment of goods and services in Bitcoin, spreading them through the economy.&lt;br /&gt;
&lt;br /&gt;
===Transactions===&lt;br /&gt;
All transactions are [[Payments in Bitcoin|payments]]. Transactions are written in a flexible [[Opcodes used in Bitcoin Script|scripting language]] that is used to assign ownership rights to each transaction output.&lt;br /&gt;
All network events including the creation of a block are inscribed in transactions.&lt;br /&gt;
&lt;br /&gt;
Valid transactions that are broadcast on [[The Bitcoin Network]] are committed to the Bitcoin public ledger by miners in [[Block|Blocks]]. Blocks are discovered just under every 10 minutes on average and held in a a [[wikipedia:Directed Acyclic Graph|Directed acyclic graph]] (DAG) structured as a [[Block chain]]. Each block forms a node in the graph. This graph is consistent in structure and can be traced back to the [[Genesis block|first block mined]].&lt;br /&gt;
&lt;br /&gt;
Transactions can be exchanged peer to peer, allowing them to be modified in payment channels. Once a transactions is sent to the network in a closed channel, global [[consensus|Consensus]] can be reached on the validity in less than 2 seconds. &lt;br /&gt;
&lt;br /&gt;
===Network rules===&lt;br /&gt;
Bitcoin operates on a fixed ruleset. consensus is based on things such as the rate at which new bitcoins are issued, the mathematical rules outlining the target for the [[Difficulty]] algorithm and more. The protocol is agreed upon by the miners who control network operation.&lt;br /&gt;
&lt;br /&gt;
===Limits===&lt;br /&gt;
There are no limits in the [[Protocol|Bitcoin protocol]]. Any limits imposed are are put in place by miners who are incentivised to catch the largest profitable pools of transactions they can. Miners compete to offer better service to fee paying users by scaling their own capabilities.&lt;br /&gt;
&lt;br /&gt;
===History===&lt;br /&gt;
[[Bitcoin until today|Bitcoin has a rich history]] and has been [[Attacks on Bitcoin|attacked]] in many ways since its inception.&lt;br /&gt;
&lt;br /&gt;
===Tools and Building on Bitcoin===&lt;br /&gt;
Bitcoin has a rich and diverse [[Building on Bitcoin|set of tools]] which are being added to all the time.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Building_on_Bitcoin&amp;diff=1292</id>
		<title>Building on Bitcoin</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Building_on_Bitcoin&amp;diff=1292"/>
		<updated>2020-01-18T19:41:52Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Introduction===&lt;br /&gt;
Bitcoin's ability to store data on the blockchain enables any and all types of applications to be built on top of it. With a defined, locked down protocol and immutable transactions Bitcoin enables robust applications that can inter-operate with each other paving the way for limitless use-cases. Additionally, the flexible [[VOUT#Unspent_Transaction_Outputs|UTXO]] model of storing transactions paves the way for massive scale-ability, instilling confidence that the Bitcoin SV network can handle the transaction volume that robust applications require.&lt;br /&gt;
&lt;br /&gt;
===Popular tools===&lt;br /&gt;
* [https://neon.planaria.network/#/ Neon Planaria] - Javascript framework that generates a state machine and database as well as an API to interface other applications with.&lt;br /&gt;
* [https://bitbus.network/docs#/ Bitbus] - Creates a filtered subledger of Bitcoin transactions in your file system, eliminating the need for application developers to run a node.&lt;br /&gt;
* [https://github.com/unwriter/datapay Datapay] - Simple JS library that enables broadcasting of Bitcoin transactions with as little as 4 lines of code.&lt;br /&gt;
* [https://www.moneybutton.com Moneybutton] - Robust payment API where users swipe a button to generate a Bitcoin transaction for payment and/or write data to the blockchain.&lt;br /&gt;
* [https://www.cashport.io Cashport] - API framework that enables developers to easily manage and implement micro-payments for services in your application.&lt;br /&gt;
* [https://www.bsvalias.org Paymail] - Protocol that defines how to send Bitcoin to a human readable, email like namespace instead of a Bitcoin address.&lt;br /&gt;
* Contact Brendan Lee at b.lee@bitcoinassociation.com to have your stable tool added.&lt;br /&gt;
&lt;br /&gt;
Further information about how to practically build on top of Bitcoin can be found here:&lt;br /&gt;
&lt;br /&gt;
#[[Bitcoin Test Blockchains]]&lt;br /&gt;
#[[Bitcoin wallet libraries]]&lt;br /&gt;
#[[The Metanet]]&lt;br /&gt;
#[[BSVAlias]]&lt;br /&gt;
#[[Application layer protocol]]&lt;br /&gt;
#[[Advanced Bitcoin Scripting]]&lt;br /&gt;
#[[Payment Channels]]&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Smart_contracts&amp;diff=1261</id>
		<title>Smart contracts</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Smart_contracts&amp;diff=1261"/>
		<updated>2020-01-17T17:48:06Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Introduction===&lt;br /&gt;
A smart contract is a self executing contract where terms of the contract are implemented in code. A common misconception is that Bitcoin is incapable of executing smart contracts, paving the way for the creation of other blockchains like [https://ethereum.org/ Ethereum]. &lt;br /&gt;
&lt;br /&gt;
Bitcoin Script as originally implement is capable of simple yet powerful smart contracts that can be written, deployed and deferred to the miners on the network for execution.&lt;br /&gt;
&lt;br /&gt;
===Smart contract platforms===&lt;br /&gt;
[http://scrypt.studio/ sCrypt] is a web-based integrated development environment (IDE) where developers can implement Bitcoin script in a higher level, more familiar programming language.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/gear-sv GearSV] is a means of writing and running smart contracts on the Bitcoin SV network. Leveraging other development tools, contracts can be deployed on-chain as data, then run and validated off-chain by oracles or software agents.&lt;br /&gt;
&lt;br /&gt;
Contact Brendan Lee at b.lee@bitcoinassociation.com to have your smart contract platform added.&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.bitcoinsv.io/index.php?title=Smart_contracts&amp;diff=1260</id>
		<title>Smart contracts</title>
		<link rel="alternate" type="text/html" href="https://wiki.bitcoinsv.io/index.php?title=Smart_contracts&amp;diff=1260"/>
		<updated>2020-01-17T17:47:22Z</updated>

		<summary type="html">&lt;p&gt;Joshua Henslee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Introduction===&lt;br /&gt;
A smart contract is a self executing contract where terms of the contract are implemented in code. A common misconception is that Bitcoin is incapable of executing smart contracts, paving the way for the creation of other blockchains like [https://ethereum.org/ Ethereum]. &lt;br /&gt;
&lt;br /&gt;
Bitcoin Script as originally implement is capable of simple yet powerful smart contracts that can be written, deployed and deferred to the miners on the network for execution.&lt;br /&gt;
&lt;br /&gt;
===Smart contract platforms===&lt;br /&gt;
[http://scrypt.studio/ sCrypt] is a web-based integrated development environment (IDE) where developers can implement Bitcoin script in a higher level, more familiar programming language.&lt;br /&gt;
&lt;br /&gt;
[https://github.com/gear-sv GearSV] is a means of writing and running smart contracts on the Bitcoin SV network. Leveraging other development tools, contracts can be deployed on-chain as data, then run and validated off-chain by oracles or software agents.&lt;br /&gt;
&lt;br /&gt;
To have your smart contract platform added, please contact Brendan Lee (b.lee@bitcoinassociation.net).&lt;/div&gt;</summary>
		<author><name>Joshua Henslee</name></author>
		
	</entry>
</feed>