diff --git a/_includes/guide_transactions.md b/_includes/guide_transactions.md index 54069f1d..7ce4d33f 100644 --- a/_includes/guide_transactions.md +++ b/_includes/guide_transactions.md @@ -23,9 +23,9 @@ and they're an exception to many of the rules listed below. Instead of pointing out the coinbase exception to each rule, we invite you to read about coinbase transactions in the block chain section of this guide. - +![The Parts Of A Transaction](/img/dev/en-tx-overview.svg) - Each +The figure above shows the main parts of a Bitcoin transaction. Each transaction has at least one input and one output. Each [input][]{:#term-input}{:.term} spends the satoshis paid to a previous output. Each [output][]{:#term-output}{:.term} then waits as an Unspent Transaction Output (UTXO) until a later input spends it. When your @@ -37,7 +37,22 @@ Bitcoin peers and miners which set of rules to use to validate it. This lets developers create new rules for future transactions without invalidating previous transactions. -The figures below help illustrate the other transaction features by +![Spending An Output](/img/dev/en-tx-overview-spending.svg) + +An output has an implied index number based on its location in the +transaction---the first output is output zero. The output also has an +amount in satoshis which it pays to a conditional pubkey script. Anyone +who can satisfy the conditions of that pubkey script can spend up to the +amount of satoshis paid to it. + +An input uses a transaction identifier (txid) and an output index number +(often called "vout" for output vector) to identify a particular output to +be spent. It also has a signature script which allows it to provide data +parameters that satisfy the conditionals in the pubkey script. (The sequence +number and locktime are related and will be covered together in +a later subsection.) + +The figures below help illustrate how these features are used by showing the workflow Alice uses to send Bob a transaction and which Bob later uses to spend that transaction. Both Alice and Bob will use the most common form of the standard Pay-To-Public-Key-Hash (P2PKH) transaction diff --git a/img/dev/en-tx-overview-spending.dot b/img/dev/en-tx-overview-spending.dot new file mode 100644 index 00000000..7ee80ffe --- /dev/null +++ b/img/dev/en-tx-overview-spending.dot @@ -0,0 +1,52 @@ +digraph tx_overview { + +size=6.25; +splines = "false"; +rankdir=TB; +ranksep=0.5; +nodesep=0.05; +//splines=ortho; + +node [ penwidth=1.75, fontname="Sans", shape = box ]; +edge [ penwidth=1.75, fontname="Sans" ]; +graph [ penwidth=1.75, fontname="Sans" ]; + + tx1_label [ shape = "none", label = "Transaction\n1" ] + tx0_label [ shape = "none", label = "Transaction\n0" ] + tx0_label -> tx1_label [ style = "invis" ]; + tx1_notshown [ shape = "none", label = "Not Shown:\nVersion, Outputs,\nLocktime" ] + tx0_notshown [ shape = "none", label = "Not Shown:\nVersion, Inputs,\nLocktime" ] + tx0_notshown -> tx1_notshown [ style = "invis" ]; + +subgraph cluster_tx0 { + + subgraph cluster_outputs { + pubkey_script [ label = "Pubkey\nScript" ]; + amount [ label = "Amount\n(satoshis)" ]; + output0_label [ shape = "none", label = "Output 0\n(Implied)" ] + label = "Example Output Paying A Pubkey Script" + } + graph [ penwidth = 0 ]; +} + +subgraph cluster_tx1 { + subgraph cluster_inputs { + index [ label = "Output\nIndex" ]; + sequence [ label = "Sequence\nNumber" ]; + signature_script [ label = "Signature\nScript" ]; + txid [ label = "Transaction\nIdentifier" ]; + label = "Example Input Spending The Example Output"; + labelloc = b; + } + graph [ penwidth = 0 ]; +} + +pubkey_script -> signature_script [ style = "dashed" ]; +output0_label -> index [ style = "dashed" ]; +tx0_label -> txid [ style = "dashed", constraint = false ]; + + + +label = "Overview Of Transaction Spending" + +} diff --git a/img/dev/en-tx-overview-spending.png b/img/dev/en-tx-overview-spending.png new file mode 100644 index 00000000..a01168c1 Binary files /dev/null and b/img/dev/en-tx-overview-spending.png differ diff --git a/img/dev/en-tx-overview-spending.svg b/img/dev/en-tx-overview-spending.svg new file mode 100644 index 00000000..3872aee4 --- /dev/null +++ b/img/dev/en-tx-overview-spending.svg @@ -0,0 +1,108 @@ + + + + + + +tx_overview + +Overview Of Transaction Spending +cluster_tx0 + + +cluster_outputs + +Example Output Paying A Pubkey Script + +cluster_tx1 + + +cluster_inputs + +Example Input Spending The Example Output + + +tx1_label +Transaction +1 + + +tx0_label +Transaction +0 + + + +txid + +Transaction +Identifier + + +tx0_label->txid + + + + +tx1_notshown +Not Shown: +Version, Outputs, +Locktime + + +tx0_notshown +Not Shown: +Version, Inputs, +Locktime + + + +pubkey_script + +Pubkey +Script + + +signature_script + +Signature +Script + + +pubkey_script->signature_script + + + + +amount + +Amount +(satoshis) + + +output0_label +Output 0 +(Implied) + + +index + +Output +Index + + +output0_label->index + + + + +sequence + +Sequence +Number + + + diff --git a/img/dev/en-tx-overview.dot b/img/dev/en-tx-overview.dot index 5e623a29..9c3bc9bb 100644 --- a/img/dev/en-tx-overview.dot +++ b/img/dev/en-tx-overview.dot @@ -1,84 +1,54 @@ -digraph blockchain { +digraph tx_overview { size=6.25; splines = "false"; rankdir=LR; -ranksep=0.1; +rankdir=TB; +ranksep=0.001; +nodesep=0.01; //splines=ortho; node [ penwidth=1.75, fontname="Sans", shape = box ]; edge [ penwidth=1.75, fontname="Sans" ]; graph [ penwidth=1.75, fontname="Sans" ]; -//edge [ style = invis, minlen = 1 ]; -//fixedsize -nodesep = 0.25; -//concentrate = true; - -tophelp0 [style = invis, label="", width=0, height=0 ]; -prevout [style = invis, label="", width=0, height=0 ]; -nextout [style = invis, label="", width=0, height=0 ]; - subgraph cluster_tx { - version; - subgraph cluster_input { - sequence; - vout [label="output index"]; - txid; - input [style = invis, label="", width=0, height=0 ]; + Locktime; + Outputs; + Inputs; + Version; + //tx_label1 [ shape = "none", label = "" ]; + tx0_label [ shape = "none", label = "The Main Parts Of\nTransaction 0" ]; - subgraph cluster_scriptsig { - label = "scriptSig" - subgraph cluster_signature { - hashtype; - signature [style = invis, label="", width=0, height=0 ]; - label = "signature" - } - scriptsig [style = invis, label="", width=0, height=0 ]; - } - label = "Input" - } - - left0 [style = invis ]; - left1 [style = invis ]; - left2 [style = invis ]; - middle1 [style = invis, label="", width=0, height=0 ]; - middle2 [style = invis, label="", width=0, height=0 ]; - middle3 [style = invis, label="", width=0, height=1.05 ]; - middle4 [style = invis, label="", width=0, height=0 ]; - middle5 [style = invis, label="", width=0, height=0 ]; - middle6 [style = invis, label="", width=0, height=0 ]; - middle7 [style = invis, label="", width=0, height=0 ]; - middle0 [style = invis, label="", width=0, height=0 ]; - - subgraph cluster_output { - output [style = invis, label="", width=0, height=0 ]; - amount; - script; - label = "Output" - } - - locktime; - label = "A Basic Transaction With One Input & One Output" + labelloc = b + graph [ penwidth=0 ]; } -prevout -> input [ style = "dashed", label = "Each input\nspends\nsatoshis\nfrom a\nprevious\noutput\n(prevout)" ]; -output -> nextout [style="dashed", label = "Each output\nwaits as an\nUnspent\nTx Output\n(UTXO)\nuntil a\nlater input\nspends it"]; -tophelp0 -> version [ style = invis ]; + tx_label [ shape = "none", label = "Each input spends a previous output" ]; + tx_label -> Inputs [ style = "invis" ]; + tx_label -> Outputs [ style = "invis" ]; -txid -> middle1 [ dir = none, label = "Select a previous tx with an\noutput to spend" ]; -vout -> middle2 [ dir = none, label = "Select an output from previous tx" ]; -sequence -> middle3 [ dir = none, label = "Allow override of locktime" ]; -scriptsig -> middle4 [ dir = none, label = "Satisfy prevout script conditions" ]; -signature -> middle5 [ dir = none, label = "Protect tx against modification\nby unauthorized parties" ]; -hashtype -> middle6 [ dir = none, label = "Authorize others to modify tx;\nselect what they can modify" ]; +subgraph cluster_tx1 { + Version1 [ label = "Version" ]; + Inputs1 [ label = "Inputs" ]; + Outputs1 [ label = "Outputs" ]; + Locktime1 [ label = "Locktime" ]; + //tx_label1 [ shape = "none", label = "" ]; + tx1_label [ shape = "none", label = "The Main Parts Of\nTransaction 1" ]; + + labelloc = b + graph [ penwidth=0 ]; +} + +utxos [ shape = "none", label = "Each output waits as an Unspent TX Output (UTXO) until a later input spends it" ]; + +Locktime -> Locktime1 [ style = "invis", weight = 3 ]; +Version -> Version1 [ style = "invis", weight = 3 ]; +Inputs -> Inputs1 [ style = "invis", weight = 3 ]; +Outputs -> Outputs1 [ style = "invis", weight = 3 ]; +Outputs -> Inputs1 [weight = 0 ]; + + +Inputs1 -> utxos [ style = "invis" ]; -version -> middle7 [ dir = none, label = "Indicate what rules this tx follows" ]; -left2 -> locktime [ dir = none, label = "Prevent tx from being added to the\nblock chain before a particular time" ]; - -left0 -> amount [ dir = none, label = "Set amount to spend & pay in fees" ]; -left1 -> script [ dir = none, label = "Describe conditions necessary\nto spend this output" ]; - - -label = "(Metadata not shown: number of inputs/outputs, length in bytes of each script/scriptSig)\n \nThe Parts Of A Transaction" } diff --git a/img/dev/en-tx-overview.png b/img/dev/en-tx-overview.png index f545e708..0f991e1b 100644 Binary files a/img/dev/en-tx-overview.png and b/img/dev/en-tx-overview.png differ diff --git a/img/dev/en-tx-overview.svg b/img/dev/en-tx-overview.svg index 9d6325cf..7bbcfaa2 100644 --- a/img/dev/en-tx-overview.svg +++ b/img/dev/en-tx-overview.svg @@ -3,173 +3,87 @@ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> - - - -blockchain - -(Metadata not shown: number of inputs/outputs, length in bytes of each script/scriptSig) - -The Parts Of A Transaction + + + +tx_overview + cluster_tx - -A Basic Transaction With One Input & One Output + -cluster_input - -Input +cluster_tx1 + -cluster_scriptsig - -scriptSig + +Locktime + +Locktime -cluster_signature - -signature + +Locktime1 + +Locktime -cluster_output - -Output + + +Outputs + +Outputs - - -version - -version + +Inputs1 + +Inputs - - - - -prevout->input - - -Each input -spends -satoshis -from a -previous -output -(prevout) + +Outputs->Inputs1 + + - - - -version->middle7 - -Indicate what rules this tx follows + +Outputs1 + +Outputs - -sequence - -sequence + + +Inputs + +Inputs - - -sequence->middle3 - -Allow override of locktime + + +Version + +Version - -vout - -output index + +Version1 + +Version - - -vout->middle2 - -Select an output from previous tx + + +tx0_label +The Main Parts Of +Transaction 0 - -txid - -txid + +tx_label +Each input spends a previous output - - -txid->middle1 - -Select a previous tx with an -output to spend + + + +utxos +Each output waits as an Unspent TX Output (UTXO) until a later input spends it - -hashtype - -hashtype - - - -hashtype->middle6 - -Authorize others to modify tx; -select what they can modify - - - - -signature->middle5 - -Protect tx against modification -by unauthorized parties - - - - -scriptsig->middle4 - -Satisfy prevout script conditions - - - -amount - -amount - - -left0->amount - -Set amount to spend & pay in fees - - - -script - -script - - -left1->script - -Describe conditions necessary -to spend this output - - - -locktime - -locktime - - -left2->locktime - -Prevent tx from being added to the -block chain before a particular time - - - - -output->nextout - - -Each output -waits as an -Unspent -Tx Output -(UTXO) -until a -later input -spends it + + +tx1_label +The Main Parts Of +Transaction 1