<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.bitcoin.it/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Petertodd</id>
	<title>Bitcoin Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.bitcoin.it/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Petertodd"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/wiki/Special:Contributions/Petertodd"/>
	<updated>2026-05-25T18:56:48Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=User:Petertodd&amp;diff=63593</id>
		<title>User:Petertodd</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=User:Petertodd&amp;diff=63593"/>
		<updated>2017-07-08T00:47:30Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; &amp;lt;nowiki&amp;gt;-----BEGIN PGP SIGNED MESSAGE-----&lt;br /&gt;
Hash: SHA256&lt;br /&gt;
&lt;br /&gt;
As of July 7th 2017, the following user accounts are controlled by myself:&lt;br /&gt;
&lt;br /&gt;
https://en.bitcoin.it/wiki/User:Petertodd&lt;br /&gt;
https://github.com/petertodd&lt;br /&gt;
https://news.ycombinator.com/user?id=petertodd&lt;br /&gt;
https://twitter.com/petertoddbtc&lt;br /&gt;
https://www.reddit.com/user/petertodd&lt;br /&gt;
&lt;br /&gt;
-----BEGIN PGP SIGNATURE-----&lt;br /&gt;
&lt;br /&gt;
iQEcBAEBCAAGBQJZYCtUAAoJECSBQD2l8JH7a38H/RVdhqlurrt4TdgtIRB4izA3&lt;br /&gt;
HbfWkzLEmN//FoKX0G4hVtqpjOqNB1L8oC0vKDW7JnRCfrGqHlAE2nMnlnbMMykg&lt;br /&gt;
EzH5rT+ctx4Yd3mBEP3C4PxVahVcw+ACk0vO6/2gPcVGCvNWZugF5hsOqgf+fGyj&lt;br /&gt;
itUrSAeArLtm8cK7ZpqSg8AyyClo/vguU5o1rPme4W7sAxKfeRSPSqmcQYE663Jf&lt;br /&gt;
79vj5YqBFHi6V5Ze4P1N83IhDqaixCoh9KrjEf83MGLIaEQpGSarh8TDXsr+w0BN&lt;br /&gt;
ZAIzyW1kg/mlXJ+BLlrka3rxZ/R5PuNX+xz/LT7rrCxBRBcMXb0RrWL8sHdwRw4=&lt;br /&gt;
=ZSyX&lt;br /&gt;
-----END PGP SIGNATURE-----&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Segwit_support&amp;diff=63592</id>
		<title>Segwit support</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Segwit_support&amp;diff=63592"/>
		<updated>2017-07-08T00:40:26Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Update my preferences and affiliation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&#039;&#039;&#039;PLEASE NOTE:&#039;&#039;&#039; This list is not yet complete.&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Developers/businesses: Please add a row for yourself in the applicable table to reflect your positions. If for some reason you don&#039;t already have a wiki account that can edit the page, make an account and ask luke-jr for help if you get caught in the anti-spam.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
| {{No}} || doesn&#039;t support (but might or might not go along with it with sufficient community support)&lt;br /&gt;
|-&lt;br /&gt;
| {{Deficient}} || okay with the idea, but considers it to have insufficient community support&lt;br /&gt;
|-&lt;br /&gt;
| {{Evaluating}} || still evaluating the idea&lt;br /&gt;
|-&lt;br /&gt;
| {{AccJuly}} || it is a workable solution, provided it is activated before August 1 (and therefore BIP148-compatible)&lt;br /&gt;
|-&lt;br /&gt;
| {{Wanting}} || positively likes the idea, but considers it to have insufficient community support&lt;br /&gt;
|-&lt;br /&gt;
| {{Weak}} || better than nothing at all&lt;br /&gt;
|-&lt;br /&gt;
| {{Acceptable}} || it is a workable solution&lt;br /&gt;
|-&lt;br /&gt;
| {{Prefer}} || it is what he would choose if it was only up to him and no outside influences&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Developers==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- README: please keep alphabetically ordered by surname! --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note that support for a given proposal does not mean developers support merging it into Core or any other specific codebase.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
! rowspan=2 | Developer&lt;br /&gt;
! rowspan=2 | Aff* &amp;lt;!-- Using one year before the the creation date of this page as the benchmark. Do not list yourself as affiliated with a project that you haven&#039;t made meaningful contributions to since then.  --&amp;gt;&lt;br /&gt;
! Segwit itself&lt;br /&gt;
! colspan=3 | Deployment methods&lt;br /&gt;
! colspan=2 | Hardfork bundles (Silbert agreement)&lt;br /&gt;
|-&lt;br /&gt;
! [https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki BIP 141] !! [https://github.com/bitcoin/bips/blob/master/bip-0148.mediawiki BIP 148] !! [https://github.com/bitcoin/bips/blob/master/bip-0149.mediawiki BIP 149] !! [https://github.com/bitcoin/bips/blob/master/bip-0091.mediawiki BIP 91] || Segwit2x || [https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014445.html COOP]&lt;br /&gt;
|-&lt;br /&gt;
| Karl-Johan Alm || Core || {{Prefer}} || {{Prefer}} || {{Acceptable}} || {{Acceptable}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Bryan Bishop || || {{Prefer}} || {{Wanting}} || {{Acceptable}} || {{Weak}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| ฿tcDrak || Core || {{Prefer}} || {{Acceptable}} || {{Acceptable}} || {{No}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Andrew Chow || Core || {{Prefer}} || {{Prefer}} || {{Acceptable}} || {{Weak}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Wang Chun || [[F2Pool]] || {{Prefer}} || {{Acceptable}} || {{Acceptable}} || {{Acceptable}} || {{AccJuly}} ||&lt;br /&gt;
|-&lt;br /&gt;
| Matt Corallo || Core || {{Prefer}} || {{No}} || || {{Acceptable}} || {{No|LOL}} ||&lt;br /&gt;
|-&lt;br /&gt;
| Johnathan Corgan || Core || {{Prefer}} || {{Prefer}} || {{Acceptable}} || {{No}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Luke Dashjr || Core || {{Prefer}} || {{Prefer}} || {{No}} || {{AccJuly}} || {{No}} || {{Deficient}}&lt;br /&gt;
|-&lt;br /&gt;
| Christian Decker || c-lightning || {{Prefer}} || {{Acceptable}} ||  ||  || || &lt;br /&gt;
|-&lt;br /&gt;
| Nicolas Dorier || Core || {{Prefer}} || {{Deficient}} || {{Acceptable}} || {{AccJuly}} || ||&lt;br /&gt;
|-&lt;br /&gt;
| Thaddeus Dryja || lit || {{Prefer}} || {{No}} || {{Acceptable}} || {{Acceptable}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Marco Falke || Core || {{Prefer}} || {{Deficient}} || {{Prefer}} || {{Deficient}} || ||&lt;br /&gt;
|-&lt;br /&gt;
| Mark Friedenbach || BIP 68/112 || {{Prefer}} || {{Prefer}} || {{No}} || {{AccJuly}} || {{No|LOL}} || {{No|Nope}}&lt;br /&gt;
|-&lt;br /&gt;
| Pavel Janik || Core || {{Prefer}} || {{No}} || {{Acceptable}} || {{No}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Thomas Kerin || Core || {{Prefer}} || {{Wanting}} || {{Prefer}} || {{Weak}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Johnson Lau || Core || {{Prefer}} || {{Wanting}} || {{Acceptable}} || {{Acceptable}} || ||&lt;br /&gt;
|-&lt;br /&gt;
| Eric Lombrozo || || {{Prefer}} || {{Acceptable}} || {{Weak}} || {{AccJuly}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Greg Maxwell || Core || {{Prefer}} || {{Deficient}} || {{Acceptable}} || {{Weak}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Alex Morcos || Core || {{Prefer}} || {{Deficient}} || {{Acceptable}} || {{Weak}} || {{No}} ||&lt;br /&gt;
|-&lt;br /&gt;
| nopara73 || TumbleBit || {{Weak}} || {{Wanting}} || {{Prefer}} || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Laolu &amp;quot;roasbeef&amp;quot; Osuntokun || lnd || {{Prefer}} || || || || {{No}} ||&lt;br /&gt;
|-&lt;br /&gt;
| Jeremy Rubin || Core || {{Prefer}} || {{Deficient}} || {{No}} || {{AccJuly}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Pavol &amp;quot;stick&amp;quot; Rusnak || [[TREZOR]] || {{Prefer}} || {{Wanting}} || {{Acceptable}} || {{AccJuly}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Rusty Russell || c-lightning || {{Prefer}} || {{Prefer}} || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Gregory Sanders || Core || {{Prefer}} || {{Wanting}} || {{Acceptable}} || {{Weak}} || {{No}} ||&lt;br /&gt;
|-&lt;br /&gt;
| Jonas Schnelli || Core || {{Prefer}} || {{Wanting}} || {{Acceptable}} || {{Acceptable}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Patrick Strateman || Core || {{Prefer}} ||  ||  ||  || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Paul Sztorc ||  || {{Prefer}} || {{Deficient}} || {{Wanting}} || {{AccJuly}} || {{Evaluating}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Amir Taaki || libbtc || {{Acceptable}} || {{Prefer}} ||  ||  || {{No}} || {{No}} &lt;br /&gt;
|-&lt;br /&gt;
| Jorge Timon || Core || {{Prefer}} || {{No}} || {{Prefer}} || {{Deficient}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Peter Todd ||  || {{Prefer}} || {{Deficient}} || {{Wanting}} || {{AccJuly}} || {{No|LOL}} ||&lt;br /&gt;
|-&lt;br /&gt;
| Warren Togami || Elements || {{Prefer}} || {{Prefer}} || {{Acceptable}} || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Wladimir van der Laan || Core || {{Prefer}} || {{Prefer}} || {{Acceptable}} || {{Acceptable}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Thomas Voegtlin || Electrum || {{Prefer}} || {{Prefer}} || {{Acceptable}} || {{Acceptable}} || {{No}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Leo Wandersleb || Mycelium || {{Prefer}} || {{Prefer}} || {{Acceptable}} || {{Weak}} || {{AccJuly}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Pieter Wuille || Core || {{Prefer}} || || || || {{No}} ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;affiliation&amp;quot; is an optional field for the company or project the individual is associated with, that most qualifies the person to comment on the matter and is not meant as a company or project endorsement of the individual&#039;s position.&lt;br /&gt;
&lt;br /&gt;
==Businesses==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;When adding companies below, sources for each position MUST be provided.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
! rowspan=2 | Company &lt;br /&gt;
! rowspan=2 | Service&lt;br /&gt;
! Segwit itself&lt;br /&gt;
! colspan=3 | Deployment methods&lt;br /&gt;
! colspan=2 | Hardfork bundles (Silbert agreement)&lt;br /&gt;
|-&lt;br /&gt;
! [https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki BIP 141] !! [https://github.com/bitcoin/bips/blob/master/bip-0148.mediawiki BIP 148] !! [https://github.com/bitcoin/bips/blob/master/bip-0149.mediawiki BIP 149] !! [https://github.com/bitcoin/bips/blob/master/bip-0091.mediawiki BIP 91] || Segwit2x || [https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014445.html COOP]&lt;br /&gt;
|-&lt;br /&gt;
| Abra || wallet || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || {{AccJuly}} || {{AccJuly}}&amp;lt;ref name=&amp;quot;silbert&amp;quot; /&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Bitcoin India || exchange/miner || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| BitcoinReminder.com || service || {{Prefer}}&amp;lt;ref name=&amp;quot;bitcoinreminder_com&amp;quot;&amp;gt;[https://bitcoinreminder.com/informations/poli BitcoinReminder.com&#039;s position on scaling proposals]&amp;lt;/ref&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;bitcoinreminder_com&amp;quot;/&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;bitcoinreminder_com&amp;quot;/&amp;gt; || {{Weak}}&amp;lt;ref name=&amp;quot;bitcoinreminder_com&amp;quot;/&amp;gt; || {{No|LOL}}&amp;lt;ref name=&amp;quot;bitcoinreminder_com&amp;quot;/&amp;gt; || {{No}}&amp;lt;ref name=&amp;quot;bitcoinreminder_com&amp;quot;/&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Bitfinex || exchange || {{Acceptable}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Acceptable}} || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Bitfury || miner || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Acceptable}} || || {{AccJuly}} || {{AccJuly}}&amp;lt;ref name=&amp;quot;silbert&amp;quot; /&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Bitmain || miner || {{AccJuly}}&amp;lt;ref name=&amp;quot;bitmain&amp;quot;&amp;gt;[https://blog.bitmain.com/en/uahf-contingency-plan-uasf-bip148/ Bitmain&#039;s plot against BIP148]&amp;lt;/ref&amp;gt; || {{No}} || || {{AccJuly}} || {{AccJuly}}&amp;lt;ref name=&amp;quot;bitmain&amp;quot; /&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Bitonic/BL3P.eu || exchange || {{Prefer}}&amp;lt;ref name=&amp;quot;bitonic&amp;quot;&amp;gt;[https://bitonic.nl/en/news/138/our-position-on-scaling-proposals Bitonic&#039;s position on scaling proposals]&amp;lt;/ref&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;bitonic&amp;quot;/&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;bitonic&amp;quot;/&amp;gt; || {{Weak}}&amp;lt;ref name=&amp;quot;bitonic&amp;quot;/&amp;gt; || {{No|LOL}}&amp;lt;ref name=&amp;quot;bitonic&amp;quot;/&amp;gt; || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Bitpay || wallet || {{Prefer}}&amp;lt;ref name=&amp;quot;bccore_swadoption&amp;quot;/&amp;gt; || {{No}} || || {{Prefer}} || {{Prefer}}&amp;lt;ref name=&amp;quot;silbert&amp;quot; /&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Bitrated || reputation || {{Acceptable}}&amp;lt;ref name=&amp;quot;bitrated&amp;quot;&amp;gt;[https://twitter.com/bitrated/status/876805892003553281]&amp;lt;/ref&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;bitrated&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;bitrated&amp;quot; /&amp;gt; || {{AccJuly}}&amp;lt;ref name=&amp;quot;bitrated&amp;quot; /&amp;gt; || {{No}}&amp;lt;ref name=&amp;quot;bitrated&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;[https://medium.com/@shesek/why-i-dont-support-the-compromise-efforts-9d73a8cce6be Why I don’t support horse-trading compromises for Bitcoin protocol development]&amp;lt;/ref&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Bitrefill || merchant || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Bitsquare || exchange || {{Prefer}} || {{Prefer}}&amp;lt;ref name=&amp;quot;bitsquare&amp;quot;&amp;gt;[https://forum.bitsquare.io/t/bitsquare-will-support-uasf-bitcoin-not-bitmaincoin/2265 Bitsquare will support UASF Bitcoin not BitMainCoin]&amp;lt;/ref&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;bitsquare&amp;quot;/&amp;gt; || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Bitstamp || exchange || || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Bittylicious || exchange || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref&amp;gt;[https://twitter.com/Bittylicious_/status/867305106668224513 Bittylicious answer on Twitter]&amp;lt;/ref&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Blockchain.info || wallet || {{Acceptable}}&amp;lt;ref name=&amp;quot;bccore_swadoption&amp;quot;/&amp;gt; || || || {{AccJuly}} || {{AccJuly}}&amp;lt;ref name=&amp;quot;silbert&amp;quot; /&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| blockonomics || || {{Prefer}} || {{Prefer}}&amp;lt;ref&amp;gt;[https://twitter.com/blockonomics_co/status/851738251509497856 blockonomics announcement on Twitter]&amp;lt;/ref&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Bustabit|| gambling || {{Prefer}}&amp;lt;ref name=&amp;quot;bustabit&amp;quot;&amp;gt;[https://www.bustabit.com/statement-on-forks Bustabit Statement on Bitcoin Forks]&amp;lt;/ref&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;bustabit&amp;quot;/&amp;gt; || || || {{AccJuly}}&amp;lt;ref name=&amp;quot;bustabit&amp;quot;/&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Bylls || payments / exchange || {{Prefer}}&amp;lt;ref name=&amp;quot;bylls&amp;quot;&amp;gt;[https://twitter.com/myBylls/status/877959773794316288 Bylls supports Segwit softfork but no current HF plan]&amp;lt;/ref&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;bylls&amp;quot;&amp;gt;[https://twitter.com/myBylls/status/877959773794316288 Bylls supports Segwit softfork but no current HF plan]&amp;lt;/ref&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;bylls&amp;quot;&amp;gt;[https://twitter.com/myBylls/status/877965277316730880 Bylls twitter statement]&amp;lt;/ref&amp;gt; || {{AccJuly}}&amp;lt;ref name=&amp;quot;bylls&amp;quot;&amp;gt;[https://twitter.com/myBylls/status/877965277316730880 Bylls twitter statement]&amp;lt;/ref&amp;gt; || {{No}}&amp;lt;ref name=&amp;quot;bylls&amp;quot;&amp;gt;[https://twitter.com/myBylls/status/877965277316730880 Bylls twitter statement]&amp;lt;/ref&amp;gt; || {{No}}&amp;lt;ref name=&amp;quot;bylls&amp;quot;&amp;gt;[https://twitter.com/myBylls/status/877965277316730880 Bylls twitter statement]&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Ciphrex || wallet / dev stack || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Coinbase || wallet || {{Acceptable}}&amp;lt;ref name=&amp;quot;bccore_swadoption&amp;quot;/&amp;gt; || || || {{AccJuly}} || {{AccJuly}}&amp;lt;ref name=&amp;quot;silbert&amp;quot; /&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
| CoinGate || exchange || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| CoinJar || wallet || || {{Evaluating}}&amp;lt;ref&amp;gt;[https://twitter.com/GetCoinJar/status/875581525730787329 CoinJar answer on Twitter]&amp;lt;/ref&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Coinkite || || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| coinomi || wallet || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| DigitalBitbox || wallet(hardware) || {{Prefer}} || {{Acceptable}} || {{Prefer}}|| || ||&lt;br /&gt;
|-&lt;br /&gt;
| Échange de Montréal || exchange || {{Prefer}}&amp;lt;ref name=&amp;quot;echangedemontreal&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;echangedemontreal&amp;quot; /&amp;gt; || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Jaxx || || {{Prefer}}&amp;lt;ref name=&amp;quot;jaxx&amp;quot;&amp;gt;[https://twitter.com/Jaxx_Support/status/882607648457334785 Jaxx tweet]&amp;lt;/ref&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;jaxx&amp;quot;/&amp;gt; || || {{AccJuly}}&amp;lt;ref name=&amp;quot;jaxx&amp;quot;/&amp;gt; || {{AccJuly}}&amp;lt;ref name=&amp;quot;jaxx&amp;quot;/&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Kraken || exchange || || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| LightningASIC || miner || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OneHash || betting || {{Prefer}}&amp;lt;ref&amp;gt;[https://blog.onehash.com/sick-of-presidential-election-3f1a2defbbbf OneHash, &amp;quot;Sick of presidential election ?!&amp;quot;]&amp;lt;/ref&amp;gt; || || || {{AccJuly}} || {{AccJuly}}&amp;lt;ref name=&amp;quot;silbert&amp;quot; /&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Poloniex || exchange || || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
|QUOINE || exchange, trading, financial services || {{Evaluating}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Evaluating}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Evaluating}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Evaluating}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Evaluating}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Evaluating}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| Slushpool || miner || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| TheRockTrading || exchange || || {{Evaluating}}&amp;lt;ref&amp;gt;[https://twitter.com/TheRockTrading/status/872464394034315269 @TheRockTrading message on Twitter]&amp;lt;/ref&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Vaultoro || exchange || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Acceptable}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || {{AccJuly}} || {{AccJuly}}&amp;lt;ref name=&amp;quot;silbert&amp;quot; /&amp;gt; ||&lt;br /&gt;
|-&lt;br /&gt;
| Walltime || exchange || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Xapo || wallet || {{Prefer}}&amp;lt;ref name=&amp;quot;coindance&amp;quot; /&amp;gt; || || || {{AccJuly}}&amp;lt;ref name=&amp;quot;xapo&amp;quot;&amp;gt;[https://twitter.com/tedmrogers/status/883061218545614848 Xapo tweet]&amp;lt;/ref&amp;gt; || {{AccJuly}}&amp;lt;ref name=&amp;quot;xapo&amp;quot;/&amp;gt; || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;bccore_swadoption&amp;quot;&amp;gt;[https://bitcoincore.org/en/segwit_adoption/ Bitcoin Core&#039;s Segwit adoption list]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;coindance&amp;quot;&amp;gt;[https://coin.dance/poli Coin Dance, &amp;quot;Global Bitcoin Political Support &amp;amp; Public Opinion&amp;quot;]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;silbert&amp;quot;&amp;gt;[https://medium.com/@DCGco/bitcoin-scaling-agreement-at-consensus-2017-133521fe9a77 Digital Currency Group, &amp;quot;Bitcoin Scaling Agreement at Consensus 2017&amp;quot;]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;echangedemontreal&amp;quot;&amp;gt;[https://twitter.com/echangedemtl/status/875781093261271040 Échange de Montréal on twitter]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=OP_CHECKSIG&amp;diff=44233</id>
		<title>OP CHECKSIG</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=OP_CHECKSIG&amp;diff=44233"/>
		<updated>2014-02-04T04:15:04Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Procedure for Hashtype SIGHASH_SINGLE */ typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OP_CHECKSIG is [[Script|script]] opcode used to verify that the signature for a tx input is valid. OP_CHECKSIG expects two values to be on the stack, these are, in order of stack depth, the public key and the signature of the script. These two values are normally obtained by running the scriptSig script of the transaction input we are attempting to validate. After the scriptSig script is run the script is deleted but the stack is left as is, and then then scriptPubKey script from the previous transaction output that is now being spent is run, generally concluding in an OP_CHECKSIG. &lt;br /&gt;
&lt;br /&gt;
The standard scriptPubKey checks that the public key (actually a hash of) is a particular value, and that OP_CHECKSIG passes.&lt;br /&gt;
&lt;br /&gt;
For normal transaction inputs if the creator of the current transaction can successfully create a ScriptSig signature that uses the right public key for the ScriptPubKey of the transaction output they are attempting to spend, that transaction input is considered valid. &lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
&lt;br /&gt;
In addition to the script code itself and the stack parameters, to operate OP_CHECKSIG needs to know the current transaction and the index of current transaction input.&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
Firstly always this (the default) procedure is applied:&lt;br /&gt;
[[File:Bitcoin_OpCheckSig_InDetail.png|thumb|right|Signature verification process of the default procedure]]&lt;br /&gt;
# the public key and the signature are popped from the stack, in that order. If the hash-type value is 0, then it is replaced by the last_byte of the signature. Then the last byte of the signature is always deleted.&lt;br /&gt;
# A new subscript is created from the instruction from the most recently parsed OP_CODESEPARATOR (last one in script) to the end of the script. If there is no OP_CODESEPARATOR the entire script becomes the subscript (hereby referred to as subScript)&lt;br /&gt;
# The sig is deleted from subScript.&lt;br /&gt;
# All OP_CODESEPARATORS are removed from subScript&lt;br /&gt;
# The hashtype is removed from the last byte of the sig and stored&lt;br /&gt;
# A copy is made of the current transaction (hereby referred to txCopy)&lt;br /&gt;
# The scripts for all transaction inputs in txCopy are set to empty scripts (exactly 1 byte 0x00)&lt;br /&gt;
# The script for the current transaction input in txCopy is set to subScript (lead in by its length as a var-integer encoded!)&lt;br /&gt;
&lt;br /&gt;
Now depending on the hashtype various things can happen to txCopy, these will be discussed individually.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Hashtype Values (from script.h):&#039;&#039;&#039;&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| SIGHASH_ALL || 0x00000001&lt;br /&gt;
|-&lt;br /&gt;
| SIGHASH_NONE || 0x00000002&lt;br /&gt;
|-&lt;br /&gt;
| SIGHASH_SINGLE || 0x00000003&lt;br /&gt;
|-&lt;br /&gt;
| SIGHASH_ANYONECANPAY || 0x00000080&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; If (hashtype&amp;amp;31) = SIGHASH_NONE then apply the SIGHASH_NONE-procedure&lt;br /&gt;
&amp;lt;li&amp;gt; If (hashtype&amp;amp;31) = SIGHASH_SINGLE then apply the SIGHASH_SINGLE-procedure&lt;br /&gt;
&amp;lt;li&amp;gt; If hashtype &amp;amp; SIGHASH_ANYONECANPAY then apply the SIGHASH_ANYONECANPAY-procedure&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
Hence, hashtype SIGHASH_ANYONECANPAY may be applied also after any other hashtype-procedure&amp;lt;ref&amp;gt;[http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.7.1/bitcoin-0.7.1-linux.tar.gz file src/src/script.cpp in bitcoin-0.7.1]&amp;lt;/ref&amp;gt;. Besides the four listed hashtypes only a hashtype of value 0 appears a few types in the (main) block chain (and is handled like SIGHASH_ALL).&lt;br /&gt;
&lt;br /&gt;
=== Hashtype SIGHASH_ALL (default) ===&lt;br /&gt;
&lt;br /&gt;
No special further handling occurs in the default case.  Think of this as &amp;quot;sign &#039;&#039;&#039;all&#039;&#039;&#039; of the outputs.&amp;quot; Which is already done by the default procedure.&lt;br /&gt;
&lt;br /&gt;
=== Procedure for Hashtype SIGHASH_NONE ===&lt;br /&gt;
&lt;br /&gt;
# The output of txCopy is set to a vector of zero size.&lt;br /&gt;
# All other inputs aside from the current input in txCopy have their nSequence index set to zero&lt;br /&gt;
&lt;br /&gt;
Think of this as &amp;quot;sign &#039;&#039;&#039;none&#039;&#039;&#039; of the outputs-- I don&#039;t care where the bitcoins go.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Procedure for Hashtype SIGHASH_SINGLE ===&lt;br /&gt;
&lt;br /&gt;
# The output of txCopy is resized to the size of the current input index+1.&lt;br /&gt;
# All other txCopy outputs aside from the output that is the same as the current input index are set to a blank script and a value of (long) -1.&lt;br /&gt;
# All other txCopy inputs aside from the current input are set to have an nSequence index of zero.&lt;br /&gt;
&lt;br /&gt;
Think of this as &amp;quot;sign &#039;&#039;&#039;one&#039;&#039;&#039; of the outputs-- I don&#039;t care where the other outputs go&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Note: The transaction that uses SIGHASH_SINGLE type of signature should not have more inputs than outputs.&lt;br /&gt;
However if it does (because of the pre-existing implementation), it shall not be rejected, but instead for every &amp;quot;illegal&amp;quot; input (meaning: an input that has an index bigger than the maximum output index) the node should still verify it, though assuming the hash of 0000000000000000000000000000000000000000000000000000000000000001 [https://bitcointalk.org/index.php?topic=260595.0]&lt;br /&gt;
&lt;br /&gt;
=== Procedure for Hashtype SIGHASH_ANYONECANPAY ===&lt;br /&gt;
&lt;br /&gt;
# The txCopy input vector is resized to a length of one.&lt;br /&gt;
# The subScript (lead in by its length as a var-integer encoded!) is set as the first and only member of this vector.&lt;br /&gt;
&lt;br /&gt;
Think of this as &amp;quot;Let other people add inputs to this transaction, I don&#039;t care where the rest of the bitcoins come from.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Final signature check===&lt;br /&gt;
&lt;br /&gt;
An array of bytes is constructed from the serialized txCopy appended by four bytes for the hash type. This array is sha256 hashed twice, then the public key is used to check the supplied signature against the hash.&lt;br /&gt;
The secp256k1 elliptic curve is used for the verification with the given public key.&lt;br /&gt;
&lt;br /&gt;
== Return values ==&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG will push true to the stack if the check passed, false otherwise.&lt;br /&gt;
OP_CHECKSIG_VERIFY leaves nothing on the stack but will cause the script eval to fail immediately if the check does not pass.&lt;br /&gt;
&lt;br /&gt;
== Code samples and raw dumps ==&lt;br /&gt;
&lt;br /&gt;
Taking the first transaction in Bitcoin which is in block number 170, we would get after serialising the transaction but before we hash+sign (or verify) it:&lt;br /&gt;
&lt;br /&gt;
* http://blockexplorer.com/block/00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee&lt;br /&gt;
* http://blockexplorer.com/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16&lt;br /&gt;
&lt;br /&gt;
See also [https://gitorious.org/libbitcoin/libbitcoin libbitcoin] for code samples.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
01 00 00 00              version&lt;br /&gt;
01                       number of inputs (var_uint)&lt;br /&gt;
&lt;br /&gt;
input 0:&lt;br /&gt;
c9 97 a5 e5 6e 10 41 02  input address hash&lt;br /&gt;
fa 20 9c 6a 85 2d d9 06 &lt;br /&gt;
60 a2 0b 2d 9c 35 24 23 &lt;br /&gt;
ed ce 25 85 7f cd 37 04&lt;br /&gt;
00 00 00 00              input index&lt;br /&gt;
&lt;br /&gt;
48                       size of script (var_uint)&lt;br /&gt;
47                       push 71 bytes to stack&lt;br /&gt;
30 44 02 20 4e 45 e1 69&lt;br /&gt;
32 b8 af 51 49 61 a1 d3&lt;br /&gt;
a1 a2 5f df 3f 4f 77 32&lt;br /&gt;
e9 d6 24 c6 c6 15 48 ab&lt;br /&gt;
5f b8 cd 41 02 20 18 15&lt;br /&gt;
22 ec 8e ca 07 de 48 60&lt;br /&gt;
a4 ac dd 12 90 9d 83 1c&lt;br /&gt;
c5 6c bb ac 46 22 08 22&lt;br /&gt;
21 a8 76 8d 1d 09 01&lt;br /&gt;
ff ff ff ff              sequence&lt;br /&gt;
&lt;br /&gt;
02                       number of outputs (var_uint)&lt;br /&gt;
&lt;br /&gt;
output 0:&lt;br /&gt;
00 ca 9a 3b 00 00 00 00  amount = 10.00000000&lt;br /&gt;
43                       size of script (var_uint)&lt;br /&gt;
script for output 0:&lt;br /&gt;
41                       push 65 bytes to stack&lt;br /&gt;
04 ae 1a 62 fe 09 c5 f5 &lt;br /&gt;
1b 13 90 5f 07 f0 6b 99 &lt;br /&gt;
a2 f7 15 9b 22 25 f3 74 &lt;br /&gt;
cd 37 8d 71 30 2f a2 84 &lt;br /&gt;
14 e7 aa b3 73 97 f5 54 &lt;br /&gt;
a7 df 5f 14 2c 21 c1 b7 &lt;br /&gt;
30 3b 8a 06 26 f1 ba de &lt;br /&gt;
d5 c7 2a 70 4f 7e 6c d8 &lt;br /&gt;
4c &lt;br /&gt;
ac                       OP_CHECKSIG&lt;br /&gt;
&lt;br /&gt;
output 1:&lt;br /&gt;
00 28 6b ee 00 00 00 00  amount = 40.00000000&lt;br /&gt;
43                       size of script (var_uint)&lt;br /&gt;
script for output 1:&lt;br /&gt;
41                       push 65 bytes to stack&lt;br /&gt;
04 11 db 93 e1 dc db 8a  &lt;br /&gt;
01 6b 49 84 0f 8c 53 bc &lt;br /&gt;
1e b6 8a 38 2e 97 b1 48 &lt;br /&gt;
2e ca d7 b1 48 a6 90 9a&lt;br /&gt;
5c b2 e0 ea dd fb 84 cc &lt;br /&gt;
f9 74 44 64 f8 2e 16 0b &lt;br /&gt;
fa 9b 8b 64 f9 d4 c0 3f &lt;br /&gt;
99 9b 86 43 f6 56 b4 12 &lt;br /&gt;
a3                       &lt;br /&gt;
ac                       OP_CHECKSIG&lt;br /&gt;
&lt;br /&gt;
00 00 00 00              locktime&lt;br /&gt;
01 00 00 00              hash_code_type (added on)&lt;br /&gt;
&lt;br /&gt;
result =&lt;br /&gt;
01 00 00 00 01 c9 97 a5 e5 6e 10 41 02 fa 20 9c 6a 85 2d d9 06 60 a2 0b 2d 9c 35 &lt;br /&gt;
24 23 ed ce 25 85 7f cd 37 04 00 00 00 00 43 41 04 11 db 93 e1 dc db 8a 01 6b 49 &lt;br /&gt;
84 0f 8c 53 bc 1e b6 8a 38 2e 97 b1 48 2e ca d7 b1 48 a6 90 9a 5c b2 e0 ea dd fb &lt;br /&gt;
84 cc f9 74 44 64 f8 2e 16 0b fa 9b 8b 64 f9 d4 c0 3f 99 9b 86 43 f6 56 b4 12 a3 &lt;br /&gt;
ac ff ff ff ff 02 00 ca 9a 3b 00 00 00 00 43 41 04 ae 1a 62 fe 09 c5 f5 1b 13 90 &lt;br /&gt;
5f 07 f0 6b 99 a2 f7 15 9b 22 25 f3 74 cd 37 8d 71 30 2f a2 84 14 e7 aa b3 73 97 &lt;br /&gt;
f5 54 a7 df 5f 14 2c 21 c1 b7 30 3b 8a 06 26 f1 ba de d5 c7 2a 70 4f 7e 6c d8 4c &lt;br /&gt;
ac 00 28 6b ee 00 00 00 00 43 41 04 11 db 93 e1 dc db 8a 01 6b 49 84 0f 8c 53 bc &lt;br /&gt;
1e b6 8a 38 2e 97 b1 48 2e ca d7 b1 48 a6 90 9a 5c b2 e0 ea dd fb 84 cc f9 74 44 &lt;br /&gt;
64 f8 2e 16 0b fa 9b 8b 64 f9 d4 c0 3f 99 9b 86 43 f6 56 b4 12 a3 ac 00 00 00 00 &lt;br /&gt;
01 00 00 00 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To understand where that raw dump has come from, it may be useful to examine tests/ec-key.cpp in [https://gitorious.org/libbitcoin/libbitcoin libbitcoin],&lt;br /&gt;
&lt;br /&gt;
[https://gitorious.org/libbitcoin/libbitcoin libbitcoin] has a unit test under tests/ec-key.cpp (make ec-key &amp;amp;&amp;amp; ./bin/tests/ec-key). There is also a working OP_CHECKSIG implementation in src/script.cpp under script::op_checksig(). See also the unit test: tests/script-test.cpp&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;iomanip&amp;gt;&lt;br /&gt;
#include &amp;lt;bitcoin/util/serializer.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;bitcoin/util/elliptic_curve_key.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;bitcoin/util/sha256.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;bitcoin/util/assert.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;bitcoin/util/logger.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;bitcoin/types.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;openssl/ecdsa.h&amp;gt;&lt;br /&gt;
#include &amp;lt;openssl/obj_mac.h&amp;gt;&lt;br /&gt;
using libbitcoin::elliptic_curve_key;&lt;br /&gt;
using libbitcoin::serializer;&lt;br /&gt;
using libbitcoin::hash_digest;&lt;br /&gt;
using libbitcoin::data_chunk;&lt;br /&gt;
using libbitcoin::log_info;&lt;br /&gt;
using libbitcoin::log_fatal;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    serializer ss;&lt;br /&gt;
    // blk number 170, tx 1, input 0&lt;br /&gt;
    // version = 1&lt;br /&gt;
    ss.write_4_bytes(1);&lt;br /&gt;
    // 1 inputs&lt;br /&gt;
    ss.write_var_uint(1);&lt;br /&gt;
&lt;br /&gt;
    // input 0&lt;br /&gt;
    // prevout hash&lt;br /&gt;
    ss.write_hash(hash_digest{0x04, 0x37, 0xcd, 0x7f, 0x85, 0x25, 0xce, 0xed, 0x23, 0x24, 0x35, 0x9c, 0x2d, 0x0b, 0xa2, 0x60, 0x06, 0xd9, 0x2d, 0x85, 0x6a, 0x9c, 0x20, 0xfa, 0x02, 0x41, 0x10, 0x6e, 0xe5, 0xa5, 0x97, 0xc9});&lt;br /&gt;
    // prevout index &lt;br /&gt;
    ss.write_4_bytes(0);&lt;br /&gt;
&lt;br /&gt;
    // input script after running OP_CHECKSIG for this tx is a single&lt;br /&gt;
    // OP_CHECKSIG opcode&lt;br /&gt;
    data_chunk raw_data;&lt;br /&gt;
    raw_data = {0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x2e, 0x97, 0xb1, 0x48, 0x2e, 0xca, 0xd7, 0xb1, 0x48, 0xa6, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3};&lt;br /&gt;
    data_chunk raw_script;&lt;br /&gt;
    raw_script = data_chunk();&lt;br /&gt;
    raw_script.push_back(raw_data.size());&lt;br /&gt;
    libbitcoin::extend_data(raw_script, raw_data);&lt;br /&gt;
    raw_script.push_back(172);&lt;br /&gt;
    ss.write_var_uint(raw_script.size());&lt;br /&gt;
    ss.write_data(raw_script);&lt;br /&gt;
    // sequence&lt;br /&gt;
    ss.write_4_bytes(0xffffffff);&lt;br /&gt;
&lt;br /&gt;
    // 2 outputs for this tx&lt;br /&gt;
    ss.write_var_uint(2);&lt;br /&gt;
&lt;br /&gt;
    // output 0&lt;br /&gt;
    ss.write_8_bytes(1000000000);&lt;br /&gt;
    // script for output 0&lt;br /&gt;
    raw_data = {0x04, 0xae, 0x1a, 0x62, 0xfe, 0x09, 0xc5, 0xf5, 0x1b, 0x13, 0x90, 0x5f, 0x07, 0xf0, 0x6b, 0x99, 0xa2, 0xf7, 0x15, 0x9b, 0x22, 0x25, 0xf3, 0x74, 0xcd, 0x37, 0x8d, 0x71, 0x30, 0x2f, 0xa2, 0x84, 0x14, 0xe7, 0xaa, 0xb3, 0x73, 0x97, 0xf5, 0x54, 0xa7, 0xdf, 0x5f, 0x14, 0x2c, 0x21, 0xc1, 0xb7, 0x30, 0x3b, 0x8a, 0x06, 0x26, 0xf1, 0xba, 0xde, 0xd5, 0xc7, 0x2a, 0x70, 0x4f, 0x7e, 0x6c, 0xd8, 0x4c};&lt;br /&gt;
    // when data &amp;lt; 75, we can just write it&#039;s length as a single byte (&#039;special&#039;&lt;br /&gt;
    // opcodes)&lt;br /&gt;
    raw_script = data_chunk();&lt;br /&gt;
    raw_script.push_back(raw_data.size());&lt;br /&gt;
    libbitcoin::extend_data(raw_script, raw_data);&lt;br /&gt;
    // OP_CHECKSIG&lt;br /&gt;
    raw_script.push_back(172);&lt;br /&gt;
    // now actually write the script&lt;br /&gt;
    ss.write_var_uint(raw_script.size());&lt;br /&gt;
    ss.write_data(raw_script);&lt;br /&gt;
&lt;br /&gt;
    // output 1&lt;br /&gt;
    ss.write_8_bytes(4000000000);&lt;br /&gt;
    // script for output 0&lt;br /&gt;
    raw_data = {0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x2e, 0x97, 0xb1, 0x48, 0x2e, 0xca, 0xd7, 0xb1, 0x48, 0xa6, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3};&lt;br /&gt;
    // when data &amp;lt; 75, we can just write it&#039;s length as a single byte (&#039;special&#039;&lt;br /&gt;
    raw_script.push_back(raw_data.size());&lt;br /&gt;
    libbitcoin::extend_data(raw_script, raw_data);&lt;br /&gt;
    // OP_CHECKSIG&lt;br /&gt;
    raw_script.push_back(172);&lt;br /&gt;
    // now actually write the script&lt;br /&gt;
    ss.write_var_uint(raw_script.size());&lt;br /&gt;
    ss.write_data(raw_script);&lt;br /&gt;
&lt;br /&gt;
    // End of 2 outputs&lt;br /&gt;
&lt;br /&gt;
    // locktime&lt;br /&gt;
    ss.write_4_bytes(0);&lt;br /&gt;
&lt;br /&gt;
    // write hash_type_code&lt;br /&gt;
    ss.write_4_bytes(1);&lt;br /&gt;
&lt;br /&gt;
    // Dump hex to screen&lt;br /&gt;
    log_info() &amp;lt;&amp;lt; &amp;quot;hashing:&amp;quot;;&lt;br /&gt;
    {&lt;br /&gt;
        auto log_obj = log_info();&lt;br /&gt;
        log_obj &amp;lt;&amp;lt; std::hex;&lt;br /&gt;
        for (int val: ss.get_data())&lt;br /&gt;
            log_obj &amp;lt;&amp;lt; std::setfill(&#039;0&#039;) &amp;lt;&amp;lt; std::setw(2) &amp;lt;&amp;lt; val &amp;lt;&amp;lt; &#039; &#039;;&lt;br /&gt;
    }&lt;br /&gt;
    log_info();&lt;br /&gt;
&lt;br /&gt;
    data_chunk raw_tx = {0x01, 0x00, 0x00, 0x00, 0x01, 0xc9, 0x97, 0xa5, 0xe5, 0x6e, 0x10, 0x41, 0x02, 0xfa, 0x20, 0x9c, 0x6a, 0x85, 0x2d, 0xd9, 0x06, 0x60, 0xa2, 0x0b, 0x2d, 0x9c, 0x35, 0x24, 0x23, 0xed, 0xce, 0x25, 0x85, 0x7f, 0xcd, 0x37, 0x04, 0x00, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x2e, 0x97, 0xb1, 0x48, 0x2e, 0xca, 0xd7, 0xb1, 0x48, 0xa6, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3, 0xac, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0xca, 0x9a, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, 0xae, 0x1a, 0x62, 0xfe, 0x09, 0xc5, 0xf5, 0x1b, 0x13, 0x90, 0x5f, 0x07, 0xf0, 0x6b, 0x99, 0xa2, 0xf7, 0x15, 0x9b, 0x22, 0x25, 0xf3, 0x74, 0xcd, 0x37, 0x8d, 0x71, 0x30, 0x2f, 0xa2, 0x84, 0x14, 0xe7, 0xaa, 0xb3, 0x73, 0x97, 0xf5, 0x54, 0xa7, 0xdf, 0x5f, 0x14, 0x2c, 0x21, 0xc1, 0xb7, 0x30, 0x3b, 0x8a, 0x06, 0x26, 0xf1, 0xba, 0xde, 0xd5, 0xc7, 0x2a, 0x70, 0x4f, 0x7e, 0x6c, 0xd8, 0x4c, 0xac, 0x00, 0x28, 0x6b, 0xee, 0x00, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x2e, 0x97, 0xb1, 0x48, 0x2e, 0xca, 0xd7, 0xb1, 0x48, 0xa6, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3, 0xac, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};&lt;br /&gt;
    BITCOIN_ASSERT(raw_tx == ss.get_data());&lt;br /&gt;
&lt;br /&gt;
    hash_digest tx_hash = libbitcoin::generate_sha256_hash(ss.get_data());&lt;br /&gt;
&lt;br /&gt;
    data_chunk pubkey{0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x2e, 0x97, 0xb1, 0x48, 0x2e, 0xca, 0xd7, 0xb1, 0x48, 0xa6, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3};&lt;br /&gt;
    // Leave out last byte since that&#039;s the hash_type_code (SIGHASH_ALL in this&lt;br /&gt;
    // case)&lt;br /&gt;
    data_chunk signature{0x30, 0x44, 0x02, 0x20, 0x4e, 0x45, 0xe1, 0x69, 0x32, 0xb8, 0xaf, 0x51, 0x49, 0x61, 0xa1, 0xd3, 0xa1, 0xa2, 0x5f, 0xdf, 0x3f, 0x4f, 0x77, 0x32, 0xe9, 0xd6, 0x24, 0xc6, 0xc6, 0x15, 0x48, 0xab, 0x5f, 0xb8, 0xcd, 0x41, 0x02, 0x20, 0x18, 0x15, 0x22, 0xec, 0x8e, 0xca, 0x07, 0xde, 0x48, 0x60, 0xa4, 0xac, 0xdd, 0x12, 0x90, 0x9d, 0x83, 0x1c, 0xc5, 0x6c, 0xbb, 0xac, 0x46, 0x22, 0x08, 0x22, 0x21, 0xa8, 0x76, 0x8d, 0x1d, 0x09};&lt;br /&gt;
    BITCOIN_ASSERT(signature.size() == 70);&lt;br /&gt;
&lt;br /&gt;
    elliptic_curve_key key;&lt;br /&gt;
    if (!key.set_public_key(pubkey))&lt;br /&gt;
    {&lt;br /&gt;
        log_fatal() &amp;lt;&amp;lt; &amp;quot;unable to set EC public key&amp;quot;;&lt;br /&gt;
        return -1;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    log_info() &amp;lt;&amp;lt; &amp;quot;checksig returns: &amp;quot; &amp;lt;&amp;lt; (key.verify(tx_hash, signature) ? &amp;quot;true&amp;quot; : &amp;quot;false&amp;quot;);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Contract&amp;diff=43732</id>
		<title>Contract</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Contract&amp;diff=43732"/>
		<updated>2014-01-14T10:23:16Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: add warning about tx replacement&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;&#039;distributed contract&#039;&#039;&#039; is a method of using Bitcoin to form agreements with people via the block chain. Contracts don&#039;t make anything possible that was previously impossible, but rather, they allow you to solve common problems in a way that minimizes trust. Minimal trust often makes things more convenient by allowing human judgements to be taken out of the loop, thus allowing complete automation.&lt;br /&gt;
&lt;br /&gt;
By building low trust protocols that interact with Bitcoin, entirely new products can be created:&lt;br /&gt;
&lt;br /&gt;
* [[Smart Property|Smart property]] is property that can be atomically traded and loaned via the block chain.&lt;br /&gt;
* [[Transferable virtual property]] are digital items that can be traded but not duplicated.&lt;br /&gt;
* [[Agents]] are autonomous programs that maintain their own wallet, which they use to buy server time. Money is obtained by the agent selling services. If demand exceeds supply the agents can spawn children that either survive or die depending on whether they can get enough business.&lt;br /&gt;
* [[Distributed markets]] are a way to implement peer to peer bond and stock trading, allowing Bitcoin to be evolve into a full competitor to the international financial system.&lt;br /&gt;
* The [[Ripple currency exchange]] is a way to implement a distributed currency exchange based on social networks.&lt;br /&gt;
&lt;br /&gt;
This page also lists some smaller examples.&lt;br /&gt;
&lt;br /&gt;
Many of the ideas underlying Bitcoin contracts were first described by Nick Szabó in his seminal paper, &lt;br /&gt;
[http://szabo.best.vwh.net/formalize.html Formalizing and Securing Relationships on Public Networks]. These pages were written by [mailto:mike@plan99.net Mike Hearn]. Contact him if you have an idea for a new type of contract. You can watch &#039;&#039;&#039;[https://www.youtube.com/watch?feature=player_embedded&amp;amp;v=mD4L7xDNCmA a video of a talk on contracts]&#039;&#039;&#039; that was presented at the Bitcoin 2012 conference in London.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==A warning about the mempool transaction replacement mechanism==&lt;br /&gt;
&lt;br /&gt;
This page repeatedly refers to the obsolete and insecure nSequence-based transaction mempool replacement mechanism. This mechanism existed in very early versions of the Bitcoin sourcecode, but was not tested and did not work. It was disabled in [https://github.com/bitcoin/bitcoin/commit/401926283a200994ecd7df8eae8ced8e0b067c46 2010], and more recently the code has been [https://github.com/bitcoin/bitcoin/commit/98c7c8fd1d3712e02be0e9f2eeca7e02aa54d197 removed completely]. Mempool transaction replacement is a form of zero-conf transaction and is vulnerable to double-spending like any other zero-conf transaction is. The replacement mechanism is also trivially vulnerable to DoS attacks. Mike Hearn&#039;s views that replacement is a viable mechanism are not shared by other Bitcoin developers. Implementors should take this into account and create contract mechanisms that do not rely on mempool replacement if they wish to have their implementations work in the forseeable future. Finally, note that the nLockTime mechanism &#039;&#039;is&#039;&#039; supported in Bitcoin, and nLockTime-using transactions are accepted into the mempool and mined when the lock expires and then become final, and sequence numbers are still signed as described below by signatures, and nLockTime is disabled if all sequence numbers are equal to UINT_MAX.&lt;br /&gt;
&lt;br /&gt;
==Theory==&lt;br /&gt;
&lt;br /&gt;
Every [[transaction]] in Bitcoin has one or more inputs and outputs. Each input/output has a small, pure function associated with it called a [[script]]. Scripts can contain signatures over simplified forms of the transaction itself.&lt;br /&gt;
&lt;br /&gt;
Every transaction can have a lock time associated with it. This allows the transaction to be pending and replaceable until an agreed-upon future time, specified either as a block index or as a timestamp (the same field is used for both, but values less than 500 million are interpreted as a block index). If a transaction&#039;s lock time has been reached, we say it is final.&lt;br /&gt;
&lt;br /&gt;
Each transaction input has a sequence number. In a normal transaction that just moves value around, the sequence numbers are all UINT_MAX and the lock time is zero. If the lock time has not yet been reached, but all the sequence numbers are UINT_MAX, the transaction is also considered final. Sequence numbers can be used to issue new versions of a transaction without invalidating other inputs signatures, e.g., in the case where each input on a transaction comes from a different party, each input may start with a sequence number of zero, and those numbers can be incremented independently.&lt;br /&gt;
&lt;br /&gt;
Signature checking is flexible because the form of transaction that is signed can be controlled through the use of SIGHASH flags, which are stuck on the end of a signature. In this way, contracts can be constructed in which each party signs only a part of it, allowing other parts to be changed without their involvement.  The SIGHASH flags have two parts, a mode and the ANYONECANPAY modifier:&lt;br /&gt;
&lt;br /&gt;
# SIGHASH_ALL: This is the default. It indicates that everything about the transaction is signed, except for the input scripts. Signing the input scripts as well would obviously make it impossible to construct a transaction, so they are always blanked out. Note, though, that other properties of the input, like the connected output and sequence numbers, &#039;&#039;are&#039;&#039; signed; it&#039;s only the scripts that are not. Intuitively, it means &amp;quot;I agree to put my money in, if everyone puts their money in and the outputs are this&amp;quot;.&lt;br /&gt;
# SIGHASH_NONE: The outputs are not signed and can be anything. Use this to indicate &amp;quot;I agree to put my money in, as long as everyone puts their money in, but I don&#039;t care what&#039;s done with the output&amp;quot;. This mode allows others to update the transaction by changing their inputs sequence numbers.&lt;br /&gt;
# SIGHASH_SINGLE: Like SIGHASH_NONE, the inputs are signed, but the sequence numbers are blanked, so others can create new versions of the transaction. However, the only output that is signed is the one at the same position as the input. Use this to indicate &amp;quot;I agree, as long as my output is what I want; I don&#039;t care about the others&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The SIGHASH_ANYONECANPAY modifier can be combined with the above three modes. When set, only that input is signed and the other inputs can be anything.&lt;br /&gt;
&lt;br /&gt;
Scripts can contain the CHECKMULTISIG opcode. This opcode provides n-of-m checking: you provide multiple public keys, and specify the number of valid signatures that must be present. The number of signatures can be less than the number of public keys. An output can require two signatures to be spent by setting it to something like this:&lt;br /&gt;
&lt;br /&gt;
 2 &amp;lt;pubkey1&amp;gt; &amp;lt;pubkey2&amp;gt; 2 CHECKMULTISIGVERIFY&lt;br /&gt;
&lt;br /&gt;
There are two general patterns for safely creating contracts:&lt;br /&gt;
&lt;br /&gt;
# Transactions are passed around outside of the P2P network, in partially-complete or invalid forms.&lt;br /&gt;
# Two transactions are used: one (the contract) is created and signed but not broadcast right away. Instead, the other transaction (the payment) is broadcast after the contract is agreed to lock in the money, and then the contract is broadcast.&lt;br /&gt;
&lt;br /&gt;
This is to ensure that people always know what they are agreeing to.&lt;br /&gt;
&lt;br /&gt;
Together, these features let us build interesting new financial tools on top of the block chain.&lt;br /&gt;
&lt;br /&gt;
==Example 1: Providing a deposit==&lt;br /&gt;
&lt;br /&gt;
Imagine that you open an account on a website (eg, a forum or wiki) and wish to establish your trustworthiness with the operators, but you don&#039;t have any pre-existing reputation to leverage. One solution is to buy trust by paying the website some money. But if at some point you close your account, you&#039;d probably like that money back. You may not trust the site enough to give them a deposit that they are tempted to spend. Another risk is that the site might just disappear one day. &lt;br /&gt;
&lt;br /&gt;
The goal is to prove that you made a sacrifice of some kind so the site knows you&#039;re not a spambot, but you don&#039;t want them to be able to spend the money. And if the operators disappear, you&#039;d eventually like the coins back without needing anything from them.&lt;br /&gt;
&lt;br /&gt;
We can solve this problem with a contract:&lt;br /&gt;
&lt;br /&gt;
# The user and website send each other a newly-generated public key.&lt;br /&gt;
# The user creates transaction Tx1 (the payment) putting 10 BTC into an output that requires both user and website to sign, but does not broadcast it. They use the key from the previous step for the site.&lt;br /&gt;
# User sends the hash of Tx1 to the website.&lt;br /&gt;
# The website creates a transaction Tx2 (the contract).  Tx2 spends Tx1 and pays it back to the user via the address he provided in the first step. Note that Tx1 requires two signatures, so this transaction can&#039;t be complete. nLockTime is set to some date in the future (eg, six months). The sequence number on the input is set to zero.&lt;br /&gt;
# Finally, the incomplete (half-signed) transaction is sent back to the user. The user checks that the contract is as expected - that the coins will eventually come back to him - but, unless things are changed, only after six months. Because the sequence number is zero, the contract can be amended in future if both parties agree. The script in the input isn&#039;t finished though; there are only zeros where the user&#039;s signature should be. He fixes that by signing the contract and putting the new signature in the appropriate spot.&lt;br /&gt;
# The user broadcasts Tx1, then broadcasts Tx2.&lt;br /&gt;
&lt;br /&gt;
At this stage, the 10 BTC are in a state where neither the user nor the website can spend them independently. After six months, the contract will complete and the user will get the coins back, even if the website disappears.&lt;br /&gt;
&lt;br /&gt;
What if the user wishes to close his account early? The website creates a new version of Tx2 with nLockTime set to zero and the input sequence number set to UINT_MAX, then he re-signs it. The site hands the tx back to the user, who signs it as well. The user then broadcasts the transaction, terminating the contract early and releasing the coins.&lt;br /&gt;
&lt;br /&gt;
What if the six months is nearly up and the user wishes to keep his account? The same thing applies: the contract can be resigned with a newer nLockTime, a sequence number 1 higher than the previous and rebroadcast 2^32 times. No matter what happens, both parties must agree for the contract to change.&lt;br /&gt;
&lt;br /&gt;
Obviously, if the user turns out to be abusive (i.e., a spammer), the website will not allow an early close of the contract. If too much abuse is getting through, the size of the deposit can be raised or the length of the contract can be increased.&lt;br /&gt;
&lt;br /&gt;
==Example 2: Escrow and dispute mediation==&lt;br /&gt;
&lt;br /&gt;
A buyer wants to trade with somebody he doesn&#039;t know or trust. In the common case where the transaction goes well, the client doesn&#039;t want any third parties involved. If something goes wrong though, he&#039;d like a third party to decide who gets the money - perhaps a professional dispute mediation service. Note that this concept can apply to either buyer or seller. The mediator might request proof of postage from the merchant, for example.&lt;br /&gt;
&lt;br /&gt;
In other words, one wants to lock up some coins so a third party has to agree in order for them to be spent:&lt;br /&gt;
&lt;br /&gt;
# Agree with the merchant on a dispute mediator (e.g., ClearCoin).&lt;br /&gt;
# Ask the merchant for a public key (K1). Ask the mediator for a public key (K2). Create a new key for yourself (K3).&lt;br /&gt;
# Send the merchant K2. The merchant challenges the mediator with a random nonce. The mediator signs the nonce with the private form of K2, thus proving it really belongs to merchant.&lt;br /&gt;
# Create a transaction (Tx1) with an output script as follows and broadcast it:&lt;br /&gt;
&lt;br /&gt;
 2 &amp;lt;K1&amp;gt; &amp;lt;K2&amp;gt; &amp;lt;K3&amp;gt; 3 CHECKMULTISIGVERIFY&lt;br /&gt;
&lt;br /&gt;
Now the coins are locked in such a way that they can only be spent by the following methods:&lt;br /&gt;
&lt;br /&gt;
# Client and the merchant agree (either a successful trade, or merchant agrees to reimburse client without mediation)&lt;br /&gt;
# Client and the mediator agree (failed trade, mediator sides with client, like a charge-back)&lt;br /&gt;
# The mediator and the merchant agree (goods delivered, merchant gets client&#039;s coins despite the dispute)&lt;br /&gt;
&lt;br /&gt;
When signing an input, the contents are set to the connected output. Thus, to redeem this transaction, the client creates a scriptSig containing zeros where the other signature should be, signs it, and then sets one of the slots to his new signature. The partially-complete transaction can then be sent to the merchant or mediator for the second signature.&lt;br /&gt;
&lt;br /&gt;
==Example 3: Assurance contracts==&lt;br /&gt;
&lt;br /&gt;
An [http://en.wikipedia.org/wiki/Assurance_contract assurance contract] is a way of funding the creation of a [http://www.auburn.edu/~johnspm/gloss/public_goods public good], that is, a good that, once created, anyone can benefit from for free. The standard example is a lighthouse: whilst everyone may agree that one should be built, it’s too expensive for an individual sailor to justify building one, given that it will also benefit all his competitors. &lt;br /&gt;
&lt;br /&gt;
One solution is for everyone to pledge money towards the creation of the public good, such that the pledges are only committed if the total value of all pledges is above the cost of creation. If not enough people contribute, nobody has to pay anything.&lt;br /&gt;
&lt;br /&gt;
Examples where Bitcoin is superior to traditional payment methods for assurance contract fundraising include applications where frequent, small pledges need to be made automatically, for instance internet radio station funding and [https://bitcointalk.org/index.php?topic=67255.msg788110#msg788110 web page translation]. Consider a browser extension that you send a bit of money to. It detects the current language of the page and broadcasts a pledge for a translation into your language to be prepared. If enough users with the extension land on the same page at the same time (eg, it was linked to from somewhere high traffic), then enough pledges are broadcast to trigger a payment to a company who prepares a high quality translation. When complete it automatically loads in your browser.&lt;br /&gt;
&lt;br /&gt;
We can model this in Bitcoin as follows:&lt;br /&gt;
&lt;br /&gt;
# An entrepreneur creates a new address and announces that the good will be created if at least 1000 BTC is raised. Anyone can contribute.&lt;br /&gt;
# Each party wishing to pledge creates a new transaction spending some of their coins to the announced address, but they do not broadcast it. The transaction is similar to a regular transaction except for three differences: Firstly, there cannot be any change. If you don’t have any outputs of the right size, you must create one first by spending to one of your own addresses. Secondly, the input script signature is signed with SIGHASH_ALL | SIGHASH_ANYONECANPAY. Finally, the output value is set to 1000 BTC. Note that this is not a valid transaction because the output value is larger than the input value.&lt;br /&gt;
# The transaction is uploaded to the entrepreneur&#039;s server, which saves it to disk and updates its count of how many coins have been pledged.&lt;br /&gt;
# Once the server has enough coins, it merges the separate transactions together into a new transaction. The new transaction has a single output that simply spends to the announced address - it is the same as the outputs on each contributed transaction. The inputs to the transaction are collected from the contributed pledges.&lt;br /&gt;
# The finished transaction is broadcast, sending the pledged coins to the announced address.&lt;br /&gt;
&lt;br /&gt;
This scheme relies on several aspects of the protocol. The first is the SIGHASH flags used. SIGHASH_ALL is the default and means the entire contents of the transaction are signed, except for the input scripts. SIGHASH_ANYONECANPAY is an additional modifier that means the signature only covers the input it’s found in - the other inputs are not signed and thus can be anything.&lt;br /&gt;
&lt;br /&gt;
By combining these flags together, we are able to create a signature that is valid even when other inputs are added, but breaks if the outputs or other properties of the transaction are changed.&lt;br /&gt;
&lt;br /&gt;
The second aspect we exploit is the fact that a transaction in which the output values are larger than the input values is invalid (for obvious reasons). This means it’s safe to send the entrepreneur a transaction that spends such coins - it’s impossible for him to claim the coins unless he has other inputs that sum to the output value or more.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to create assurance contracts without using SIGHASH_ANYONECANPAY. Instead, a two step process is used in which pledges are collected without transactions, and once the total value is reached, a transaction with an input for each pledger is created and passed around until all signatures are collected. However, using SIGHASH_ANYONECANPAY and then merging is probably more convenient.&lt;br /&gt;
&lt;br /&gt;
An assurance contract can be prepared for &#039;&#039;&#039;[[Funding network security|funding network security]]&#039;&#039;&#039; for the next block. In this way, mining can be funded even if block space is not scarce.&lt;br /&gt;
&lt;br /&gt;
An elaboration of this concept is described by Tabarrok in his paper, [http://mason.gmu.edu/~atabarro/PrivateProvision.pdf “The private provision of public goods via dominant assurance contracts”]. In a dominant assurance contract, if a contract fails (not enough pledges within a set time window) the entrepreneur pays a fee to those who pledged so far. This type of contract attempts to arrange incentives such that taking part is always the right strategy. [[Dominant Assurance Contracts|A scheme for dominant assurance contracts]] in Bitcoin has been proposed.&lt;br /&gt;
&lt;br /&gt;
==Example 4: Using external state==&lt;br /&gt;
&lt;br /&gt;
Scripts are, by design, pure functions. They cannot poll external servers or import any state that may change as it would allow an attacker to outrun the block chain. What&#039;s more, the scripting language is extremely limited in what it can do. Fortunately, we can make transactions connected to the world in other ways.&lt;br /&gt;
&lt;br /&gt;
Consider the example of an old man who wishes to give an inheritance to his grandson, either on the grandson&#039;s 18th birthday or when the man dies, whichever comes first. &lt;br /&gt;
&lt;br /&gt;
To solve this, the man first sends the amount of the inheritance to himself so there is a single output of the right amount. Then he creates a transaction with a lock time of the grandson&#039;s 18th birthday that pays the coins to another key owned by the grandson, signs it, and gives it to him - but does not broadcast it. This takes care of the 18th birthday condition. If the date passes, the grandson broadcasts the transaction and claims the coins. He could do it before then, but it doesn&#039;t let him get the coins any earlier, and some nodes may choose to drop transactions in the memory pool with lock times far in the future.&lt;br /&gt;
&lt;br /&gt;
The death condition is harder. As Bitcoin nodes cannot measure arbitrary conditions, we must rely on an &#039;&#039;oracle&#039;&#039;. An oracle is a server that has a keypair, and signs transactions on request when a user-provided expression evaluates to true.&lt;br /&gt;
&lt;br /&gt;
Here is an example. The man creates a transaction spending his output, and sets the output to:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;hash&amp;gt; OP_DROP 2 &amp;lt;sons pubkey&amp;gt; &amp;lt;oracle pubkey&amp;gt; CHECKMULTISIG&lt;br /&gt;
&lt;br /&gt;
This is the oracle script. It has an unusual form - it pushes data to the stack then immediately deletes it again. The pubkey is published on the oracle&#039;s website and is well-known. The hash is set to be the hash of the user-provided expression stating that he has died, written in a form the oracle knows how to evaluate. For example, it could be the hash of the string:&lt;br /&gt;
&lt;br /&gt;
 if (has_died(&#039;john smith&#039;, born_on=1950/01/02)) return (10.0, 1JxgRXEHBi86zYzHN2U4KMyRCg4LvwNUrp);&lt;br /&gt;
&lt;br /&gt;
This little language is hypothetical, it&#039;d be defined by the oracle and could be anything. The return value is an output: an amount of value and an address owned by the grandson.&lt;br /&gt;
&lt;br /&gt;
Once more, the man creates this transaction but gives it directly to his grandson instead of broadcasting it. He also provides the expression that is hashed into the transaction and the name of the oracle that can unlock it.&lt;br /&gt;
&lt;br /&gt;
It is used in the following algorithm:&lt;br /&gt;
&lt;br /&gt;
# The oracle accepts a measurement request. The request contains the user-provided expression, a copy of the output script, and a partially complete transaction provided by the user. Everything in this transaction is finished except for the scriptSig, which contains just one signature (the grandson&#039;s) - not enough to unlock the output.&lt;br /&gt;
# The oracle checks the user-provided expression hashes to the value in the provided output script. If it doesn&#039;t, it returns an error.&lt;br /&gt;
# The oracle evaluates the expression. If the result is not the destination address of the output, it returns an error.&lt;br /&gt;
# Otherwise the oracle signs the transaction and returns the signature to the user. Note that when signing a Bitcoin transaction, the input script is set to the connected output script. The reason is that when OP_CHECKSIG runs, the script containing the opcode is put in the input being evaluated, _not_ the script containing the signature itself. The oracle has never seen the full output it is being asked to sign, but it doesn&#039;t have to. It knows the output script, its own public key, and the hash of the user-provided expression, which is everything it needs to check the output script and finish the transaction.&lt;br /&gt;
# The user accepts the new signature, inserts it into the scriptSig and broadcasts the transaction.&lt;br /&gt;
&lt;br /&gt;
If, and only if, the oracle agrees that the man is dead, the grandson can broadcast the two transactions (the contract and the claim) and take the coins.&lt;br /&gt;
&lt;br /&gt;
Oracles can potentially evaluate anything, yet the output script form in the block chain can always be the same. Consider the following possibilities:&lt;br /&gt;
&lt;br /&gt;
 today() == 2011/09/25 &amp;amp;&amp;amp; exchange_rate(mtgoxUSD) &amp;gt;= 12.5 &amp;amp;&amp;amp; exchange_rate(mtgoxUSD) &amp;lt;= 13.5&lt;br /&gt;
 Require exchange rate to be between two values on a given date&lt;br /&gt;
 &lt;br /&gt;
 google_results_count(site:www.google.com/hostednews &#039;Mike Hearn&#039; olympic gold medal) &amp;gt; 0&lt;br /&gt;
 A bet on me doing something that I will never actually do&lt;br /&gt;
 &lt;br /&gt;
 // Choose between one of two winners of a bet on the outcome of the Eurovision song contest.&lt;br /&gt;
 if (eurovision_winner() == &#039;Azerbaijan&#039;) &lt;br /&gt;
   return 1Lj9udBVDwptFffGSJSC2sohCfudQgSTPD; &lt;br /&gt;
 else &lt;br /&gt;
   return 1JxgRXEHBi86zYzHN2U4KMyRCg4LvwNUrp;&lt;br /&gt;
&lt;br /&gt;
The conditions that control whether the oracle signs can be arbitrarily complex, but the block chain never needs to contain more than a single hash.&lt;br /&gt;
&lt;br /&gt;
===Trust minimization: challenges===&lt;br /&gt;
&lt;br /&gt;
There are various ways to reduce the level of required trust in the oracle.&lt;br /&gt;
&lt;br /&gt;
Going back to our first example, the oracle has not seen the transaction the grandson is trying to unlock, as it was never broadcast, thus, it cannot hold the grandson to ransom because it does not know whether the transaction it&#039;s signing for even exists. People can, and should, regularly &#039;&#039;&#039;challenge&#039;&#039;&#039; the oracle in an automated fashion to ensure it always outputs what is expected. The challenges can be done without spending any coins because the tx to be signed can be invalid (ie, connected to transactions that don&#039;t exist). The oracle has no way to know whether a request to be signed is random or real. How to challenge the oracle with conditions that are not yet true is however an open research question. &lt;br /&gt;
&lt;br /&gt;
===Trust minimization: multiple independent oracles===&lt;br /&gt;
&lt;br /&gt;
The number of keys in the CHECKMULTISIG can be increased to allow for &#039;&#039;&#039;n-of-m&#039;&#039;&#039; oracles if need be.  Of course, it is vital to check that the oracles really are independent and not in collusion.&lt;br /&gt;
&lt;br /&gt;
===Trust minimization: trusted hardware===&lt;br /&gt;
&lt;br /&gt;
Using commodity hardware, you can use &#039;&#039;&#039;trusted computing&#039;&#039;&#039; in the form of Intel TXT or the AMD equivalent (SKINIT) to set up a sealed hardware environment and then use the TPM chip to attest that fact to a third party. That third party can verify the hardware was in the required state. Defeating this requires someone to be able to interfere with the execution of a program that may run entirely on the CPU, even in extreme cases without any data traversing the memory bus (you can run entirely using on-die cache if the program is small enough).&lt;br /&gt;
&lt;br /&gt;
===Trust minimization: Amazon AWS oracles===&lt;br /&gt;
&lt;br /&gt;
Finally, perhaps the most practical approach currently is to use Amazon Web Services. As of November 2013, the closest we have to a working oracle is [https://bitcointalk.org/index.php?topic=301538.0 this recipe for creating a trusted computing environment using AWS], built in support of [https://bitcointalk.org/index.php?topic=173220.0 this project for doing selective SSL logging and decryption]. The idea is that an oracle, which can be proven trustworthy using the Amazon APIs with Amazon as the root of trust, records encrypted SSL sessions to an online banking interface in such a way that later if there is a dispute about a person-to-person exchange, the logs can be decrypted and the dispute settled.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Example 5: Trading across chains==&lt;br /&gt;
&lt;br /&gt;
The Bitcoin technology can be adapted to create [[Alternative chain|multiple, independent currencies]]. NameCoin is an example of one such currency that operates under a slightly different set of rules, and can also be used to rent names in a namespace. Currencies that implement the same ideas as Bitcoin can be traded freely against each other with limited trust. &lt;br /&gt;
&lt;br /&gt;
For example, imagine a consortium of companies that issue EURcoins, a crypto-currency that is backed 1:1 by deposits in the consortium&#039;s bank accounts. Such a currency would have a different set of tradeoffs to Bitcoin: more centralized, but without FX risk. People might wish to trade Bitcoins for EURcoins back and forth, with the companies only getting involved when cashing in/out of the regular banking system.&lt;br /&gt;
&lt;br /&gt;
To implement this, a [https://bitcointalk.org/index.php?topic=193281.msg2224949#msg2224949 protocol proposed by TierNolan] can be used:&lt;br /&gt;
&lt;br /&gt;
# Party &#039;A&#039; generates some random data, x (the secret).&lt;br /&gt;
# Party &#039;A&#039; generates Tx1 (the payment) containing an output with the chain-trade script in it. See below for this script and a discussion of it. It allows coin release either by signing with the two keys (key &#039;A&#039; and key &#039;B&#039;) or with (secret &#039;x&#039;, key &#039;B&#039;). This transaction is not broadcast. The chain release script contains hashes, not the actual secrets themselves.&lt;br /&gt;
# Party &#039;A&#039; generates Tx2 (the contract), which spends Tx1 and has an output going back to key &#039;A&#039;. It has a lock time in the future and the input has a sequence number of zero, so it can be replaced. &#039;A&#039; signs Tx2 and sends it to &#039;B&#039;, who also signs it and sends it back.&lt;br /&gt;
# &#039;A&#039; broadcasts Tx1 and Tx2. Party &#039;B&#039; can now see the coins but cannot spend them because it does not have an output going to him, and the tx is not finalized anyway.&lt;br /&gt;
# &#039;B&#039; performs the same scheme in reverse on the alternative chain. The lock time for &#039;B&#039; should be much larger than the lock time for &#039;A&#039;. Both sides of the trade are now pending but incomplete.&lt;br /&gt;
# Since &#039;A&#039; knows the secret, &#039;A&#039; can claim his coins immediately. However, &#039;A&#039;, in the process of claiming his coin, reveals the secret &#039;x&#039; to &#039;B&#039;, who then uses it to finish the other side of the trade with (&#039;x&#039;, key &#039;B&#039;).&lt;br /&gt;
&lt;br /&gt;
This protocol makes it feasible to do trades automatically in an entirely peer-to-peer manner, which should ensure good liquidity.&lt;br /&gt;
&lt;br /&gt;
The chain-trade script could look like this:&lt;br /&gt;
&lt;br /&gt;
 IF &lt;br /&gt;
   2 &amp;lt;key A&amp;gt; &amp;lt;key B&amp;gt; 2 CHECKMULTISIGVERIFY&lt;br /&gt;
 ELSE&lt;br /&gt;
   &amp;lt;key B&amp;gt; CHECKSIGVERIFY SHA256 &amp;lt;hash of secret x&amp;gt; EQUALVERIFY&lt;br /&gt;
 ENDIF&lt;br /&gt;
&lt;br /&gt;
The contract input script looks like either:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;sig A&amp;gt; &amp;lt;sig B&amp;gt; 1&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;secret x&amp;gt; &amp;lt;sig B&amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
i.e., the first data element selects which phase is being used.&lt;br /&gt;
&lt;br /&gt;
See [[Atomic cross-chain trading]] for details.&lt;br /&gt;
&lt;br /&gt;
Note that whilst EURcoins is a natural idea, there are other ways to implement peer-to-peer currency exchange (Bitcoin to fiat and vice versa), see the [[Ripple currency exchange]] article for more information.&lt;br /&gt;
&lt;br /&gt;
Sergio Demian-Lerner proposed [https://bitcointalk.org/index.php?topic=91843.0 P2PTradeX], a solution requiring the validation rules for one blockchain to be effectively encoded into the validation rules for the other.&lt;br /&gt;
&lt;br /&gt;
==Example 6: Pay-for-proof contracts: buying a solution to any pure function==&lt;br /&gt;
&lt;br /&gt;
In example 4, we saw how to make payments conditional on the output of some arbitrary program. Those programs are very powerful and can do anything a regular program can do, like fetching web pages. The downside is that a third party is required (an oracle). Although there are techniques that can help reduce the trust needed in the oracle, none can reduce it to zero.&lt;br /&gt;
&lt;br /&gt;
For a restricted class of programs, pure functions, new cryptographic techniques are starting to become available that can actually reduce the trust needed all the way to zero with no third parties. These programs cannot perform any I/O, but in many cases this restriction turns out to be unimportant or can be worked around in other ways, like by giving the program a signed/timestamped document as an input instead of having the program download it.&lt;br /&gt;
&lt;br /&gt;
Read an explanation of the protocol here: [[User:Gmaxwell/why_hash_locked]]&lt;br /&gt;
&lt;br /&gt;
==Example 7: Rapidly-adjusted (micro)payments to a pre-determined party==&lt;br /&gt;
&lt;br /&gt;
Bitcoin transactions are very cheap relative to traditional payment systems, but still have a cost due to the need for it to be mined and stored. There are some cases in which you want to rapidly and cheaply adjust the amount of money sent to a particular recipient without incurring the cost of a broadcast transaction.&lt;br /&gt;
&lt;br /&gt;
For example, consider an untrusted internet access point, like a WiFi hotspot in a cafe you never visited before. You&#039;d like to pay 0.001 BTC per 10 kilobytes of usage, without opening an account with the cafe. A zero-trust solution means it could be fully automatic, so you could just pre-allocate a budget on your phone&#039;s mobile wallet at the start of the month, and then your device automatically negotiates and pays for internet access on demand. The cafe also wants to allow anyone to pay them without the fear of being ripped off.&lt;br /&gt;
&lt;br /&gt;
To do this, the following protocol can be used. This protocol relies upon a &#039;&#039;&#039;different&#039;&#039;&#039; behavior of nLockTime to the original design. Starting around 2013 time-locked transactions were made non standard and no longer enter the memory pool, thus cannot be broadcast before the timelock expires. When the behaviour of nLockTime is restored to the original design from Satoshi, a variant of this protocol is required which is discussed below.&lt;br /&gt;
&lt;br /&gt;
We define the client to be the party sending value, and the server to be the party receiving it. This is written from the clients perspective.&lt;br /&gt;
&lt;br /&gt;
# Create a public key (K1). Request a public key from the server (K2). &lt;br /&gt;
# Create and sign but do not broadcast a transaction (T1) that sets up a payment of (for example) 10 BTC to an output requiring both the server&#039;s public key and one of your own to be used. A good way to do this is use OP_CHECKMULTISIG. The value to be used is chosen as an efficiency tradeoff.&lt;br /&gt;
# Create a refund transaction (T2) that is connected to the output of T1 which sends all the money back to yourself. It has a time lock set for some time in the future, for instance a few hours. Don&#039;t sign it, and provide the unsigned transaction to the server. By convention, the output script is &amp;quot;2 K1 K2 2 CHECKMULTISIG&amp;quot;&lt;br /&gt;
# The server signs T2 using its public key K2 and returns the signature to the client. Note that it has not seen T1 at this point, just the hash (which is in the unsigned T2).&lt;br /&gt;
# The client verifies the servers signature is correct and aborts if not.&lt;br /&gt;
# The client signs T1 and passes the signature to the server, which now broadcasts the transaction (either party can do this if they both have connectivity). This locks in the money.&lt;br /&gt;
# The client then creates a new transaction, T3, which connects to T1 like the refund transaction does and has two outputs. One goes to K1 and the other goes to K2. It starts out with all value allocated to the first output (K1), ie, it does the same thing as the refund transaction but is not time locked. The client signs T3 and provides the transaction and signature to the server.&lt;br /&gt;
# The server verifies the output to itself is of the expected size and verifies the client&#039;s provided signature is correct.&lt;br /&gt;
# When the client wishes to pay the server, it adjusts its copy of T3 to allocate more value to the server&#039;s output and less to its ow. It then re-signs the new T3 and sends the signature to the server. It does not have to send the whole transaction, just the signature and the amount to increment by is sufficient. The server adjusts its copy of T3 to match the new amounts, verifies the signature and continues.&lt;br /&gt;
&lt;br /&gt;
This continues until the session ends, or the 1-day period is getting close to expiry. The AP then signs and broadcasts the last transaction it saw, allocating the final amount to itself. The refund transaction is needed to handle the case where the server disappears or halts at any point, leaving the allocated value in limbo. If this happens then once the time lock has expired the client can broadcast the refund transaction and get back all the money.&lt;br /&gt;
&lt;br /&gt;
This protocol has [https://code.google.com/p/bitcoinj/wiki/WorkingWithMicropayments been implemented in bitcoinj].&lt;br /&gt;
&lt;br /&gt;
When nLockTime&#039;d transactions are able to enter the memory pool (once more) and transaction replacement has been re-enabled, a variant on the protocol must be used. In this case, no refund transaction is used. Instead each T3 has a sequence number one higher than the previous and all T3&#039;s have a time lock set to the same period as above. Each time a payment is made the sequence number is incremented, ensuring that the last version will take precedence. If the channel protocol is not closed cleanly, this means the value transfer won&#039;t commit until the time lock expires. To avoid this both parties can cooperate by signing a T3 that has a sequence number of 0xFFFFFFFF resulting in immediate confirmation regardless of the value of nLockTime.&lt;br /&gt;
&lt;br /&gt;
The lock time and sequence numbers avoid an attack in which the AP provides connectivity, and then the user [[double-spending|double-spends]] the output back to themselves using the first version of TX2, thus preventing the cafe from claiming the bill. If the user does try this, the TX won&#039;t be included right away, giving the access point a window of time in which it can observe the TX broadcast, and then broadcast the last version it saw, overriding the user&#039;s attempted double-spend.&lt;br /&gt;
&lt;br /&gt;
The latter protocol that relies on transaction replacement is more flexible because it allows the value allocated to go down as well as up during the lifetime of the channel as long as the client receives signatures from the server, but for many use cases this functionality is not required. Replacement also allows for more complex configurations of channels that involve more than two parties. Elaboration on such use cases is a left as an exercise for the reader.&lt;br /&gt;
&lt;br /&gt;
==Example 8: Multi-party decentralised lotteries==&lt;br /&gt;
&lt;br /&gt;
Using some of the techniques from example 6 and some very advanced scripting, it becomes possible to build a multi-party lottery with no operator. The exact protocol used is explained in the paper [http://eprint.iacr.org/2013/784 &amp;quot;Secure multiparty computations on Bitcoin&amp;quot;]. A shorter explanation of how it works may be added to this wiki at some point in the future.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Script]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=39785</id>
		<title>Fidelity bonds</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=39785"/>
		<updated>2013-07-25T18:05:02Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Financial Services */ history&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A fidelity bond is a proposed mechanism where Bitcoins are deliberately sacrificed to make a cryptographic identity expensive to obtain. The sacrifice is done in a way that can be proven to a third party. By making the identity expensive it can be trusted not to commit unwanted acts, such as spamming message boards, or committing fraud, because upon detection of the unwanted acts the identity becomes useless, requiring the owner of the identity to purchase another one.&lt;br /&gt;
&lt;br /&gt;
== Mechanism ==&lt;br /&gt;
&lt;br /&gt;
The core of the fidelity bond is the sacrifice - the mechanism by which Bitcoins are provably taken from their original owner. The Bitcoins may be given to someone else or destroyed, but regardless it must not be possible for their original owner to regain control of them.&lt;br /&gt;
&lt;br /&gt;
An effective form of sacrifice is to simply create a transaction assigning the coins to an unspendable output, either an address known to not have a corresponding secret key, or to a scriptPubKey that is [[Script#Provably_Unspendable.2FPrunable_Outputs|provably unspendable]]. The Bitcoins are removed from circulation forever, a criticism of this mechanism.&lt;br /&gt;
&lt;br /&gt;
The Bitcoins can also be donated to a third party, such as a charity, however such donations can be controversial, allow the charity itself (or anyone with access to their funds) to purchase bonds at little or no cost, pose the problem of verifying the bonds validity in the future should the chosen charity(s) change, and finally, pose the problem of coming to a consensus on the charities themselves.&lt;br /&gt;
&lt;br /&gt;
In the context of Bitcoin, miners have been proposed as a third party whom any Bitcoin user can agree should receive funds, as miners act to secure the network from attack for everyone. The value is sacrificed to miners in the form of transaction fees.&lt;br /&gt;
&lt;br /&gt;
=== Single/Consecutive Block Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
The sacrifice can be done with transactions that pay abnormally high fees, either single such transactions, or groups of multiple ones in a row, latter intended to prevent miners themselves from creating the sacrifices and mining them in their own blocks. Problems with consecutive transaction sacrifices include the potential for gaps, as well as the large size of the proofs of the sacrifices.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.msg1498806#msg1498806]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Announce/Commit Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
To ensure that the miner collecting the sacrificed Bitcoin is picked at random the announce/commit sacrifice was proposed.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=134827.0 Purchasing fidelity bonds by provably throwing away bitcoins]&amp;lt;/ref&amp;gt; First a sacrifice transaction is prepared that either sacrifices value to transaction fees, or spends coins to an [[Script#Anyone-Can-Spend_Outputs|Anyone-Can-Spend Output]]. With [[nLockTime]] the transaction is made invalid until some time in the future.&lt;br /&gt;
&lt;br /&gt;
The second step is the announcement. The transaction is enclosed in another transaction as data, for instance by using a [[Script#Provably_Unspendable.2FPrunable_Outputs|prunable output]]. The announcement is then broadcast and is included in the blockchain, proving that anyone could have seen the inner transaction prior to it becoming valid.&lt;br /&gt;
&lt;br /&gt;
Finally the inner transaction becomes valid when the [[nLockTime]] is reached. Because mining is a random process, any miner can collect the value sacrified, and the purchaser of the fidelity bond has no control over where that value goes.&lt;br /&gt;
&lt;br /&gt;
The proof of the sacrifice is then two transactions: the proof the announcement transaction exists in the chain, and the proof that the inner sacrifice exists in the chain. (possibly with proof of the inner sacrifice inputs to prove what fees were actually paid)&lt;br /&gt;
&lt;br /&gt;
=== Coinbase TxOut Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
Coinbase transactions are unique in that they can&#039;t be spent for 100 blocks, thus solving the problem of proving a transaction output was made public prior to it being possible to spend that output in a single transaction. In addition coinbase transactions can be created anonymously without linking the transaction to any other transaction provided that the creator has the ability to mine anonymously. (or have someone else do so on their behalf)&lt;br /&gt;
&lt;br /&gt;
A proof for a coinbase txout is particularly short if the txout is the last txout and the script is meant to be unspendable. SHA256 midstate compression can then be used to prove the committed digest, and that the last opcode was OP_RETURN; it is not possible for a script to return true unless without the last opcode being executed. Fortunately the anyone-can-spend version can-not be proven so easily - consider the following txout fragment:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;SHA256 midstate&amp;gt; &amp;lt;scriptPubKey length&amp;gt; &amp;lt;digest&amp;gt; &amp;lt;nLockTime&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The problem is the fragment could actually be part of this scriptPubkey:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pubkey&amp;gt; OP_CHECKSIGVERIFY OP_PUSHDATA (&amp;lt;scriptPubKey length&amp;gt; &amp;lt;digest&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
In reality this isn&#039;t a true sacrifice. The only way around this problem is if the proven data is greater than the maximum pushdata length allowed, 520 bytes, which undesirably depends on a constant whose value may be changed in a future hard-fork.&lt;br /&gt;
&lt;br /&gt;
== Passports ==&lt;br /&gt;
&lt;br /&gt;
This wiki combats spam, while still allowing for users to sign up anonymously, by requiring users to pay a small amount of Bitcoins to the wiki before editing privileges are granted. Creating large numbers of &amp;quot;sock-puppets&amp;quot; to add spam content to articles is thus made expensive. The fee approach can be generalized with the concept of a Passport, first proposed by Mike Hearn,&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.0 Creating Bitcoin passports using sacrifices]&amp;lt;/ref&amp;gt; tied to the users identity. Wikis, forums, webmail and other services can then create blacklists of users who violate the rules of the services, with those blacklists tied to passports.&lt;br /&gt;
&lt;br /&gt;
The advantage of fidelity bonds in that application over simply charging fees is re-usability of an identity across multiple services, as well as the neutrality: if the value required to create the passport provably does not go to the person adding the passport to a blacklist, there is no incentive to do so to collect new sign-up fees.&lt;br /&gt;
&lt;br /&gt;
== Financial Services ==&lt;br /&gt;
&lt;br /&gt;
Fidelity bonds can be used to make financial fraud unprofitable. For instance the original fidelity bond proposal&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=29185108 Trusted identities]&amp;lt;/ref&amp;gt; - called &amp;quot;Trusted identities&amp;quot; at that time - included the idea of using fidelity bonds to create decentralized [[Green address|green addresses]]. Someone wishing for their transactions to be accepted without confirmations would first purchase a fidelity bond of some value tied to their identity. Someone determining if they should accept a payment without confirmations can check that the bond was sufficiently expensive to make it unprofitable for the sender to commit fraud. If the sender does commit fraud by double-spending the payment, the recipient can prove that fraud to the world by providing both transactions spending the same inputs. This proof is added to some sort of blacklist, centralized or decentralized, which later recipients can consult to determine if the fidelity bond is now invalidated.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=39784</id>
		<title>Fidelity bonds</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=39784"/>
		<updated>2013-07-25T18:03:02Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Financial Services */  spelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A fidelity bond is a proposed mechanism where Bitcoins are deliberately sacrificed to make a cryptographic identity expensive to obtain. The sacrifice is done in a way that can be proven to a third party. By making the identity expensive it can be trusted not to commit unwanted acts, such as spamming message boards, or committing fraud, because upon detection of the unwanted acts the identity becomes useless, requiring the owner of the identity to purchase another one.&lt;br /&gt;
&lt;br /&gt;
== Mechanism ==&lt;br /&gt;
&lt;br /&gt;
The core of the fidelity bond is the sacrifice - the mechanism by which Bitcoins are provably taken from their original owner. The Bitcoins may be given to someone else or destroyed, but regardless it must not be possible for their original owner to regain control of them.&lt;br /&gt;
&lt;br /&gt;
An effective form of sacrifice is to simply create a transaction assigning the coins to an unspendable output, either an address known to not have a corresponding secret key, or to a scriptPubKey that is [[Script#Provably_Unspendable.2FPrunable_Outputs|provably unspendable]]. The Bitcoins are removed from circulation forever, a criticism of this mechanism.&lt;br /&gt;
&lt;br /&gt;
The Bitcoins can also be donated to a third party, such as a charity, however such donations can be controversial, allow the charity itself (or anyone with access to their funds) to purchase bonds at little or no cost, pose the problem of verifying the bonds validity in the future should the chosen charity(s) change, and finally, pose the problem of coming to a consensus on the charities themselves.&lt;br /&gt;
&lt;br /&gt;
In the context of Bitcoin, miners have been proposed as a third party whom any Bitcoin user can agree should receive funds, as miners act to secure the network from attack for everyone. The value is sacrificed to miners in the form of transaction fees.&lt;br /&gt;
&lt;br /&gt;
=== Single/Consecutive Block Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
The sacrifice can be done with transactions that pay abnormally high fees, either single such transactions, or groups of multiple ones in a row, latter intended to prevent miners themselves from creating the sacrifices and mining them in their own blocks. Problems with consecutive transaction sacrifices include the potential for gaps, as well as the large size of the proofs of the sacrifices.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.msg1498806#msg1498806]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Announce/Commit Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
To ensure that the miner collecting the sacrificed Bitcoin is picked at random the announce/commit sacrifice was proposed.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=134827.0 Purchasing fidelity bonds by provably throwing away bitcoins]&amp;lt;/ref&amp;gt; First a sacrifice transaction is prepared that either sacrifices value to transaction fees, or spends coins to an [[Script#Anyone-Can-Spend_Outputs|Anyone-Can-Spend Output]]. With [[nLockTime]] the transaction is made invalid until some time in the future.&lt;br /&gt;
&lt;br /&gt;
The second step is the announcement. The transaction is enclosed in another transaction as data, for instance by using a [[Script#Provably_Unspendable.2FPrunable_Outputs|prunable output]]. The announcement is then broadcast and is included in the blockchain, proving that anyone could have seen the inner transaction prior to it becoming valid.&lt;br /&gt;
&lt;br /&gt;
Finally the inner transaction becomes valid when the [[nLockTime]] is reached. Because mining is a random process, any miner can collect the value sacrified, and the purchaser of the fidelity bond has no control over where that value goes.&lt;br /&gt;
&lt;br /&gt;
The proof of the sacrifice is then two transactions: the proof the announcement transaction exists in the chain, and the proof that the inner sacrifice exists in the chain. (possibly with proof of the inner sacrifice inputs to prove what fees were actually paid)&lt;br /&gt;
&lt;br /&gt;
=== Coinbase TxOut Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
Coinbase transactions are unique in that they can&#039;t be spent for 100 blocks, thus solving the problem of proving a transaction output was made public prior to it being possible to spend that output in a single transaction. In addition coinbase transactions can be created anonymously without linking the transaction to any other transaction provided that the creator has the ability to mine anonymously. (or have someone else do so on their behalf)&lt;br /&gt;
&lt;br /&gt;
A proof for a coinbase txout is particularly short if the txout is the last txout and the script is meant to be unspendable. SHA256 midstate compression can then be used to prove the committed digest, and that the last opcode was OP_RETURN; it is not possible for a script to return true unless without the last opcode being executed. Fortunately the anyone-can-spend version can-not be proven so easily - consider the following txout fragment:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;SHA256 midstate&amp;gt; &amp;lt;scriptPubKey length&amp;gt; &amp;lt;digest&amp;gt; &amp;lt;nLockTime&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The problem is the fragment could actually be part of this scriptPubkey:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pubkey&amp;gt; OP_CHECKSIGVERIFY OP_PUSHDATA (&amp;lt;scriptPubKey length&amp;gt; &amp;lt;digest&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
In reality this isn&#039;t a true sacrifice. The only way around this problem is if the proven data is greater than the maximum pushdata length allowed, 520 bytes, which undesirably depends on a constant whose value may be changed in a future hard-fork.&lt;br /&gt;
&lt;br /&gt;
== Passports ==&lt;br /&gt;
&lt;br /&gt;
This wiki combats spam, while still allowing for users to sign up anonymously, by requiring users to pay a small amount of Bitcoins to the wiki before editing privileges are granted. Creating large numbers of &amp;quot;sock-puppets&amp;quot; to add spam content to articles is thus made expensive. The fee approach can be generalized with the concept of a Passport, first proposed by Mike Hearn,&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.0 Creating Bitcoin passports using sacrifices]&amp;lt;/ref&amp;gt; tied to the users identity. Wikis, forums, webmail and other services can then create blacklists of users who violate the rules of the services, with those blacklists tied to passports.&lt;br /&gt;
&lt;br /&gt;
The advantage of fidelity bonds in that application over simply charging fees is re-usability of an identity across multiple services, as well as the neutrality: if the value required to create the passport provably does not go to the person adding the passport to a blacklist, there is no incentive to do so to collect new sign-up fees.&lt;br /&gt;
&lt;br /&gt;
== Financial Services ==&lt;br /&gt;
&lt;br /&gt;
Fidelity bonds can be used to make financial fraud unprofitable. For instance one early proposal&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=29185108 Trusted identities]&amp;lt;/ref&amp;gt; was to use fidelity bonds - called &amp;quot;Trusted identities&amp;quot; by the proposal&#039;s author - to create decentralized [[Green address|green addresses]]. Someone wishing for their transactions to be accepted without confirmations would first purchase a fidelity bond of some value tied to their identity. Someone determining if they should accept a payment without confirmations can check that the bond was sufficiently expensive to make it unprofitable for the sender to commit fraud. If the sender does commit fraud by double-spending the payment, the recipient can prove that fraud to the world by providing both transactions spending the same inputs. This proof is added to some sort of blacklist, centralized or decentralized, which later recipients can consult to determine if the fidelity bond is now invalidated.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=39783</id>
		<title>Fidelity bonds</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=39783"/>
		<updated>2013-07-25T17:46:10Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Coinbase TxOut Sacrifices */  note problems with midstate compression&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A fidelity bond is a proposed mechanism where Bitcoins are deliberately sacrificed to make a cryptographic identity expensive to obtain. The sacrifice is done in a way that can be proven to a third party. By making the identity expensive it can be trusted not to commit unwanted acts, such as spamming message boards, or committing fraud, because upon detection of the unwanted acts the identity becomes useless, requiring the owner of the identity to purchase another one.&lt;br /&gt;
&lt;br /&gt;
== Mechanism ==&lt;br /&gt;
&lt;br /&gt;
The core of the fidelity bond is the sacrifice - the mechanism by which Bitcoins are provably taken from their original owner. The Bitcoins may be given to someone else or destroyed, but regardless it must not be possible for their original owner to regain control of them.&lt;br /&gt;
&lt;br /&gt;
An effective form of sacrifice is to simply create a transaction assigning the coins to an unspendable output, either an address known to not have a corresponding secret key, or to a scriptPubKey that is [[Script#Provably_Unspendable.2FPrunable_Outputs|provably unspendable]]. The Bitcoins are removed from circulation forever, a criticism of this mechanism.&lt;br /&gt;
&lt;br /&gt;
The Bitcoins can also be donated to a third party, such as a charity, however such donations can be controversial, allow the charity itself (or anyone with access to their funds) to purchase bonds at little or no cost, pose the problem of verifying the bonds validity in the future should the chosen charity(s) change, and finally, pose the problem of coming to a consensus on the charities themselves.&lt;br /&gt;
&lt;br /&gt;
In the context of Bitcoin, miners have been proposed as a third party whom any Bitcoin user can agree should receive funds, as miners act to secure the network from attack for everyone. The value is sacrificed to miners in the form of transaction fees.&lt;br /&gt;
&lt;br /&gt;
=== Single/Consecutive Block Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
The sacrifice can be done with transactions that pay abnormally high fees, either single such transactions, or groups of multiple ones in a row, latter intended to prevent miners themselves from creating the sacrifices and mining them in their own blocks. Problems with consecutive transaction sacrifices include the potential for gaps, as well as the large size of the proofs of the sacrifices.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.msg1498806#msg1498806]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Announce/Commit Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
To ensure that the miner collecting the sacrificed Bitcoin is picked at random the announce/commit sacrifice was proposed.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=134827.0 Purchasing fidelity bonds by provably throwing away bitcoins]&amp;lt;/ref&amp;gt; First a sacrifice transaction is prepared that either sacrifices value to transaction fees, or spends coins to an [[Script#Anyone-Can-Spend_Outputs|Anyone-Can-Spend Output]]. With [[nLockTime]] the transaction is made invalid until some time in the future.&lt;br /&gt;
&lt;br /&gt;
The second step is the announcement. The transaction is enclosed in another transaction as data, for instance by using a [[Script#Provably_Unspendable.2FPrunable_Outputs|prunable output]]. The announcement is then broadcast and is included in the blockchain, proving that anyone could have seen the inner transaction prior to it becoming valid.&lt;br /&gt;
&lt;br /&gt;
Finally the inner transaction becomes valid when the [[nLockTime]] is reached. Because mining is a random process, any miner can collect the value sacrified, and the purchaser of the fidelity bond has no control over where that value goes.&lt;br /&gt;
&lt;br /&gt;
The proof of the sacrifice is then two transactions: the proof the announcement transaction exists in the chain, and the proof that the inner sacrifice exists in the chain. (possibly with proof of the inner sacrifice inputs to prove what fees were actually paid)&lt;br /&gt;
&lt;br /&gt;
=== Coinbase TxOut Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
Coinbase transactions are unique in that they can&#039;t be spent for 100 blocks, thus solving the problem of proving a transaction output was made public prior to it being possible to spend that output in a single transaction. In addition coinbase transactions can be created anonymously without linking the transaction to any other transaction provided that the creator has the ability to mine anonymously. (or have someone else do so on their behalf)&lt;br /&gt;
&lt;br /&gt;
A proof for a coinbase txout is particularly short if the txout is the last txout and the script is meant to be unspendable. SHA256 midstate compression can then be used to prove the committed digest, and that the last opcode was OP_RETURN; it is not possible for a script to return true unless without the last opcode being executed. Fortunately the anyone-can-spend version can-not be proven so easily - consider the following txout fragment:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;SHA256 midstate&amp;gt; &amp;lt;scriptPubKey length&amp;gt; &amp;lt;digest&amp;gt; &amp;lt;nLockTime&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The problem is the fragment could actually be part of this scriptPubkey:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pubkey&amp;gt; OP_CHECKSIGVERIFY OP_PUSHDATA (&amp;lt;scriptPubKey length&amp;gt; &amp;lt;digest&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
In reality this isn&#039;t a true sacrifice. The only way around this problem is if the proven data is greater than the maximum pushdata length allowed, 520 bytes, which undesirably depends on a constant whose value may be changed in a future hard-fork.&lt;br /&gt;
&lt;br /&gt;
== Passports ==&lt;br /&gt;
&lt;br /&gt;
This wiki combats spam, while still allowing for users to sign up anonymously, by requiring users to pay a small amount of Bitcoins to the wiki before editing privileges are granted. Creating large numbers of &amp;quot;sock-puppets&amp;quot; to add spam content to articles is thus made expensive. The fee approach can be generalized with the concept of a Passport, first proposed by Mike Hearn,&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.0 Creating Bitcoin passports using sacrifices]&amp;lt;/ref&amp;gt; tied to the users identity. Wikis, forums, webmail and other services can then create blacklists of users who violate the rules of the services, with those blacklists tied to passports.&lt;br /&gt;
&lt;br /&gt;
The advantage of fidelity bonds in that application over simply charging fees is re-usability of an identity across multiple services, as well as the neutrality: if the value required to create the passport provably does not go to the person adding the passport to a blacklist, there is no incentive to do so to collect new sign-up fees.&lt;br /&gt;
&lt;br /&gt;
== Financial Services ==&lt;br /&gt;
&lt;br /&gt;
Fidelity bonds can be used to make financial fraud unprofitable. For instance one early proposal&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=29185108 Trusted identities]&amp;lt;/ref&amp;gt; was to use fidelity bonds - called &amp;quot;Trusted identities&amp;quot; by the proposal&#039;s author - to create decentralized [[Green address|green addresses]]. Someone wishing for their transactions to be accepted without confirmations would first purchase a fidelity bond of some value tied to their identity. Someone determining if they should accept a payment without confirmations can check that the bond was sufficiently expensive to make it unprofitable for the sender to commit fraud. If the sender does commit fraud by double-spending the payment, the recipient can prove that fraud to the world by providing both transactions spending the same inputs. This proof is added to some sort of blacklisted, centralized or decentralized, which later recipients can consult to determine if the fidelity bond is now invalidated.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=39781</id>
		<title>Fidelity bonds</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=39781"/>
		<updated>2013-07-25T17:11:06Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Add Coinbase TxOut Sacrifice&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A fidelity bond is a proposed mechanism where Bitcoins are deliberately sacrificed to make a cryptographic identity expensive to obtain. The sacrifice is done in a way that can be proven to a third party. By making the identity expensive it can be trusted not to commit unwanted acts, such as spamming message boards, or committing fraud, because upon detection of the unwanted acts the identity becomes useless, requiring the owner of the identity to purchase another one.&lt;br /&gt;
&lt;br /&gt;
== Mechanism ==&lt;br /&gt;
&lt;br /&gt;
The core of the fidelity bond is the sacrifice - the mechanism by which Bitcoins are provably taken from their original owner. The Bitcoins may be given to someone else or destroyed, but regardless it must not be possible for their original owner to regain control of them.&lt;br /&gt;
&lt;br /&gt;
An effective form of sacrifice is to simply create a transaction assigning the coins to an unspendable output, either an address known to not have a corresponding secret key, or to a scriptPubKey that is [[Script#Provably_Unspendable.2FPrunable_Outputs|provably unspendable]]. The Bitcoins are removed from circulation forever, a criticism of this mechanism.&lt;br /&gt;
&lt;br /&gt;
The Bitcoins can also be donated to a third party, such as a charity, however such donations can be controversial, allow the charity itself (or anyone with access to their funds) to purchase bonds at little or no cost, pose the problem of verifying the bonds validity in the future should the chosen charity(s) change, and finally, pose the problem of coming to a consensus on the charities themselves.&lt;br /&gt;
&lt;br /&gt;
In the context of Bitcoin, miners have been proposed as a third party whom any Bitcoin user can agree should receive funds, as miners act to secure the network from attack for everyone. The value is sacrificed to miners in the form of transaction fees.&lt;br /&gt;
&lt;br /&gt;
=== Single/Consecutive Block Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
The sacrifice can be done with transactions that pay abnormally high fees, either single such transactions, or groups of multiple ones in a row, latter intended to prevent miners themselves from creating the sacrifices and mining them in their own blocks. Problems with consecutive transaction sacrifices include the potential for gaps, as well as the large size of the proofs of the sacrifices.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.msg1498806#msg1498806]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Announce/Commit Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
To ensure that the miner collecting the sacrificed Bitcoin is picked at random the announce/commit sacrifice was proposed.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=134827.0 Purchasing fidelity bonds by provably throwing away bitcoins]&amp;lt;/ref&amp;gt; First a sacrifice transaction is prepared that either sacrifices value to transaction fees, or spends coins to an [[Script#Anyone-Can-Spend_Outputs|Anyone-Can-Spend Output]]. With [[nLockTime]] the transaction is made invalid until some time in the future.&lt;br /&gt;
&lt;br /&gt;
The second step is the announcement. The transaction is enclosed in another transaction as data, for instance by using a [[Script#Provably_Unspendable.2FPrunable_Outputs|prunable output]]. The announcement is then broadcast and is included in the blockchain, proving that anyone could have seen the inner transaction prior to it becoming valid.&lt;br /&gt;
&lt;br /&gt;
Finally the inner transaction becomes valid when the [[nLockTime]] is reached. Because mining is a random process, any miner can collect the value sacrified, and the purchaser of the fidelity bond has no control over where that value goes.&lt;br /&gt;
&lt;br /&gt;
The proof of the sacrifice is then two transactions: the proof the announcement transaction exists in the chain, and the proof that the inner sacrifice exists in the chain. (possibly with proof of the inner sacrifice inputs to prove what fees were actually paid)&lt;br /&gt;
&lt;br /&gt;
=== Coinbase TxOut Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
Coinbase transactions are unique in that they can&#039;t be spent for 100 blocks, thus solving the problem of proving a transaction output was made public prior to it being possible to spend that output in a single transaction. In addition coinbase transactions can be created anonymously without linking the transaction to any other transaction provided that the creator has the ability to mine anonymously. (or have someone else do so on their behalf)&lt;br /&gt;
&lt;br /&gt;
== Passports ==&lt;br /&gt;
&lt;br /&gt;
This wiki combats spam, while still allowing for users to sign up anonymously, by requiring users to pay a small amount of Bitcoins to the wiki before editing privileges are granted. Creating large numbers of &amp;quot;sock-puppets&amp;quot; to add spam content to articles is thus made expensive. The fee approach can be generalized with the concept of a Passport, first proposed by Mike Hearn,&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.0 Creating Bitcoin passports using sacrifices]&amp;lt;/ref&amp;gt; tied to the users identity. Wikis, forums, webmail and other services can then create blacklists of users who violate the rules of the services, with those blacklists tied to passports.&lt;br /&gt;
&lt;br /&gt;
The advantage of fidelity bonds in that application over simply charging fees is re-usability of an identity across multiple services, as well as the neutrality: if the value required to create the passport provably does not go to the person adding the passport to a blacklist, there is no incentive to do so to collect new sign-up fees.&lt;br /&gt;
&lt;br /&gt;
== Financial Services ==&lt;br /&gt;
&lt;br /&gt;
Fidelity bonds can be used to make financial fraud unprofitable. For instance one early proposal&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=29185108 Trusted identities]&amp;lt;/ref&amp;gt; was to use fidelity bonds - called &amp;quot;Trusted identities&amp;quot; by the proposal&#039;s author - to create decentralized [[Green address|green addresses]]. Someone wishing for their transactions to be accepted without confirmations would first purchase a fidelity bond of some value tied to their identity. Someone determining if they should accept a payment without confirmations can check that the bond was sufficiently expensive to make it unprofitable for the sender to commit fraud. If the sender does commit fraud by double-spending the payment, the recipient can prove that fraud to the world by providing both transactions spending the same inputs. This proof is added to some sort of blacklisted, centralized or decentralized, which later recipients can consult to determine if the fidelity bond is now invalidated.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Script&amp;diff=39735</id>
		<title>Talk:Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Script&amp;diff=39735"/>
		<updated>2013-07-23T02:51:13Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Provably Unspendable/Prunable Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;xOP_IFDUP	115	0x73	x	x / x x	If the input is true or false, duplicate it.&lt;br /&gt;
&lt;br /&gt;
Shouldn&#039;t it be: &amp;quot;If the input is true, duplicate it.&amp;quot;?&lt;br /&gt;
--[[User:ThePiachu|ThePiachu]] 11:37, 20 December 2011 (GMT)&lt;br /&gt;
&lt;br /&gt;
The byte vectors in the stack are specified as being signed integers of variable-length. Then there&#039;s an explanation that these integers are considered false if they are either zero or negative zero, which is 0x80. For this to be the case, the elements should be represented in an old binary format called sign-magnitude, which is important to state explicitly, since today virtually all computers use two&#039;s complement as representation, and there&#039;s no such thing as a negative zero. There&#039;s even another representation, one&#039;s complement, where negative zero looks like 0xff.&lt;br /&gt;
&lt;br /&gt;
Reading the source code of the application, I see that arithmetic operations expect unsigned integers, for example, operations OP_2MUL and OP_2DIV are implemented as byte-shifting, which wouldn&#039;t work with signed representations.&lt;br /&gt;
&lt;br /&gt;
It seems to me that, at best, variable-length sign-magnitued integer format is only used for testing for truth, although I haven&#039;t read all the code yet.&lt;br /&gt;
&lt;br /&gt;
--[[User:Jpierre|Jean-Pierre Rupp]] 10:43, 4 March 2012 (GMT)&lt;br /&gt;
&lt;br /&gt;
== Provably Unspendable/Prunable Outputs ==&lt;br /&gt;
&lt;br /&gt;
If im not mistaken this kind of transaction would not result in donating the output to the miner. It would instead make the output unusable by anyone forever. In my opinion the best and easiest way to donate to miner is just transfer BTC between your own addresses and set a high fee. [[User:Norill|Norill]] ([[User talk:Norill|talk]]) 22:32, 14 April 2013 (GMT)&lt;br /&gt;
&lt;br /&gt;
normill: Fixed wording for OP_RETURN; it is mining fee in the example because the output value is zero, not 0.125BTC as I think you thought. Sorry about that.&lt;br /&gt;
[[User:Petertodd|Peter Todd]] ([[User talk:Petertodd|talk]]) 02:51, 23 July 2013 (GMT)&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Script&amp;diff=39734</id>
		<title>Talk:Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Script&amp;diff=39734"/>
		<updated>2013-07-23T02:50:36Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;xOP_IFDUP	115	0x73	x	x / x x	If the input is true or false, duplicate it.&lt;br /&gt;
&lt;br /&gt;
Shouldn&#039;t it be: &amp;quot;If the input is true, duplicate it.&amp;quot;?&lt;br /&gt;
--[[User:ThePiachu|ThePiachu]] 11:37, 20 December 2011 (GMT)&lt;br /&gt;
&lt;br /&gt;
The byte vectors in the stack are specified as being signed integers of variable-length. Then there&#039;s an explanation that these integers are considered false if they are either zero or negative zero, which is 0x80. For this to be the case, the elements should be represented in an old binary format called sign-magnitude, which is important to state explicitly, since today virtually all computers use two&#039;s complement as representation, and there&#039;s no such thing as a negative zero. There&#039;s even another representation, one&#039;s complement, where negative zero looks like 0xff.&lt;br /&gt;
&lt;br /&gt;
Reading the source code of the application, I see that arithmetic operations expect unsigned integers, for example, operations OP_2MUL and OP_2DIV are implemented as byte-shifting, which wouldn&#039;t work with signed representations.&lt;br /&gt;
&lt;br /&gt;
It seems to me that, at best, variable-length sign-magnitued integer format is only used for testing for truth, although I haven&#039;t read all the code yet.&lt;br /&gt;
&lt;br /&gt;
--[[User:Jpierre|Jean-Pierre Rupp]] 10:43, 4 March 2012 (GMT)&lt;br /&gt;
&lt;br /&gt;
== Provably Unspendable/Prunable Outputs ==&lt;br /&gt;
&lt;br /&gt;
If im not mistaken this kind of transaction would not result in donating the output to the miner. It would instead make the output unusable by anyone forever. In my opinion the best and easiest way to donate to miner is just transfer BTC between your own addresses and set a high fee. [[User:Norill|Norill]] ([[User talk:Norill|talk]]) 22:32, 14 April 2013 (GMT)&lt;br /&gt;
&lt;br /&gt;
normill: Fixed wording for OP_RETURN; it is mining fee in the example because the output value is zero, not 0.125BTC as I think you thought. Sorry about that.&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39733</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39733"/>
		<updated>2013-07-23T02:41:28Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Provably Unspendable/Prunable Outputs */ wording changes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some of the more complicated opcodes are disabled out of concern that the client might have a bug in their implementation; if a transaction using such an opcode were to be included in the chain any fix would risk forking the chain. &lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
If any input value for any of these commands is longer than 4 bytes, the script should abort and fail. &lt;br /&gt;
If any opcode marked as &#039;&#039;Currently disabled&#039;&#039; is present in a script - it should also abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address (pay-to-script-hash) ===&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;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&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;
=== Standard Generation Transaction (pay-to-pubkey) ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key. By default the reference implementation uses this form for coinbase payment, and scriptPubKeys of this transaction form are recognized as payments to user. The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&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;
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; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&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;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 is an example: it has a single output of zero value, thus giving the full 0.125BTC fee to the miner who mined the transaction without adding an entry to the UTXO set. You can also use OP_RETURN to add data to a transaction without the data ever appearing in the UTXO set, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc; [[P2Pool]] does this with the share chain hash txout in the coinbase of blocks it creates.&lt;br /&gt;
&lt;br /&gt;
Note that this mechanism is not yet a standard transaction type, and thus will not be relayed by nodes on mainnet.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&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;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39732</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39732"/>
		<updated>2013-07-23T02:39:48Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Provably Unspendable/Prunable Outputs */ make OP_RETURN functionality in the example more clear&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some of the more complicated opcodes are disabled out of concern that the client might have a bug in their implementation; if a transaction using such an opcode were to be included in the chain any fix would risk forking the chain. &lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
If any input value for any of these commands is longer than 4 bytes, the script should abort and fail. &lt;br /&gt;
If any opcode marked as &#039;&#039;Currently disabled&#039;&#039; is present in a script - it should also abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address (pay-to-script-hash) ===&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;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&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;
=== Standard Generation Transaction (pay-to-pubkey) ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key. By default the reference implementation uses this form for coinbase payment, and scriptPubKeys of this transaction form are recognized as payments to user. The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&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;
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; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&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;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 is an example: it has a single output of zero value, thus giving the full 0.125BTC fee to the miner who mined the transaction without adding an entry to the UTXO set. Another use is to add data to a transaction, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc. [[P2Pool]] uses OP_RETURN so that their share chain hash txout in the coinbase of blocks it creates does not clutter the UTXO space.&lt;br /&gt;
&lt;br /&gt;
Note that this mechanism is not yet a standard transaction type, and thus will not be relayed by nodes on mainnet.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&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;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39731</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39731"/>
		<updated>2013-07-23T02:38:35Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Undo revision 39730 by Norill (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some of the more complicated opcodes are disabled out of concern that the client might have a bug in their implementation; if a transaction using such an opcode were to be included in the chain any fix would risk forking the chain. &lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
If any input value for any of these commands is longer than 4 bytes, the script should abort and fail. &lt;br /&gt;
If any opcode marked as &#039;&#039;Currently disabled&#039;&#039; is present in a script - it should also abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address (pay-to-script-hash) ===&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;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&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;
=== Standard Generation Transaction (pay-to-pubkey) ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key. By default the reference implementation uses this form for coinbase payment, and scriptPubKeys of this transaction form are recognized as payments to user. The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&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;
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; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&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;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 is an example, and acts to donate 0.125BTC to the miner who mined the transaction. Another use is to add data to a transaction, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc. [[P2Pool]] uses OP_RETURN so that their share chain hash txout in the coinbase of blocks it creates does not clutter the UTXO space.&lt;br /&gt;
&lt;br /&gt;
Note that this mechanism is not yet a standard transaction type, and thus will not be relayed by nodes on mainnet.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&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;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39692</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39692"/>
		<updated>2013-07-20T06:38:51Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Standard Generation Transaction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some of the more complicated opcodes are disabled out of concern that the client might have a bug in their implementation; if a transaction using such an opcode were to be included in the chain any fix would risk forking the chain. &lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
If any input value for any of these commands is longer than 4 bytes, the script should abort and fail. &lt;br /&gt;
If any opcode marked as &#039;&#039;Currently disabled&#039;&#039; is present in a script - it should also abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address (pay-to-script-hash) ===&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;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&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;
=== Standard Generation Transaction (pay-to-pubkey) ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key. By default the reference implementation uses this form for coinbase payment, and scriptPubKeys of this transaction form are recognized as payments to user. The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&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;
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; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&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;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 is an example, and acts to donate 0.125BTC to the miner who mined the transaction. Another use is to add data to a transaction, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc. [[P2Pool]] uses OP_RETURN so that their share chain hash txout in the coinbase of blocks it creates does not clutter the UTXO space.&lt;br /&gt;
&lt;br /&gt;
Note that this mechanism is not yet a standard transaction type, and thus will not be relayed by nodes on mainnet.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&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;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39691</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39691"/>
		<updated>2013-07-20T06:38:41Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Standard Transaction to Bitcoin address */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some of the more complicated opcodes are disabled out of concern that the client might have a bug in their implementation; if a transaction using such an opcode were to be included in the chain any fix would risk forking the chain. &lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
If any input value for any of these commands is longer than 4 bytes, the script should abort and fail. &lt;br /&gt;
If any opcode marked as &#039;&#039;Currently disabled&#039;&#039; is present in a script - it should also abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address (pay-to-script-hash) ===&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;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&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;
=== Standard Generation Transaction ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key. By default the reference implementation uses this form for coinbase payment, and scriptPubKeys of this transaction form are recognized as payments to user. The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&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;
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; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&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;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 is an example, and acts to donate 0.125BTC to the miner who mined the transaction. Another use is to add data to a transaction, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc. [[P2Pool]] uses OP_RETURN so that their share chain hash txout in the coinbase of blocks it creates does not clutter the UTXO space.&lt;br /&gt;
&lt;br /&gt;
Note that this mechanism is not yet a standard transaction type, and thus will not be relayed by nodes on mainnet.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&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;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39690</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39690"/>
		<updated>2013-07-20T06:37:36Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Provably Unspendable/Prunable Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some of the more complicated opcodes are disabled out of concern that the client might have a bug in their implementation; if a transaction using such an opcode were to be included in the chain any fix would risk forking the chain. &lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
If any input value for any of these commands is longer than 4 bytes, the script should abort and fail. &lt;br /&gt;
If any opcode marked as &#039;&#039;Currently disabled&#039;&#039; is present in a script - it should also abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address ===&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;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&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;
=== Standard Generation Transaction ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key. By default the reference implementation uses this form for coinbase payment, and scriptPubKeys of this transaction form are recognized as payments to user. The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&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;
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; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&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;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 is an example, and acts to donate 0.125BTC to the miner who mined the transaction. Another use is to add data to a transaction, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc. [[P2Pool]] uses OP_RETURN so that their share chain hash txout in the coinbase of blocks it creates does not clutter the UTXO space.&lt;br /&gt;
&lt;br /&gt;
Note that this mechanism is not yet a standard transaction type, and thus will not be relayed by nodes on mainnet.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&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;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39689</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=39689"/>
		<updated>2013-07-20T06:35:34Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Transaction with a message */ Transaction with a message gives people the wrong impression&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some of the more complicated opcodes are disabled out of concern that the client might have a bug in their implementation; if a transaction using such an opcode were to be included in the chain any fix would risk forking the chain. &lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as Currently disabled is present in a script, it should abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
If any input value for any of these commands is longer than 4 bytes, the script should abort and fail. &lt;br /&gt;
If any opcode marked as &#039;&#039;Currently disabled&#039;&#039; is present in a script - it should also abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address ===&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;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&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;
=== Standard Generation Transaction ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key. By default the reference implementation uses this form for coinbase payment, and scriptPubKeys of this transaction form are recognized as payments to user. The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&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;
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; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&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;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 is an example, and acts to donate 0.125BTC to the miner who mined the transaction. Another use is to add data to a transaction, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc&lt;br /&gt;
&lt;br /&gt;
Note that this mechanism is not yet a standard transaction type, and thus will not be relayed by nodes on mainnet.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&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;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=39015</id>
		<title>Identity protocol v1</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=39015"/>
		<updated>2013-06-29T23:08:14Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Creating a SIN */ testnet is just &amp;quot;testnet&amp;quot; - reboot version shouldn&amp;#039;t be specified&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Design goals==&lt;br /&gt;
&lt;br /&gt;
Fully decentralized, anonymous, secure identity.&lt;br /&gt;
&lt;br /&gt;
A SIN (&amp;quot;System Identification Number&amp;quot;) is the unique record identifier by which this identity will be known.&lt;br /&gt;
&lt;br /&gt;
Attributes:&lt;br /&gt;
* Has some creation cost, deterring spam.&lt;br /&gt;
* Sacrifice may be digitally proven, bootstrapping root of trust from blockchain data&lt;br /&gt;
* Start as anonymous; opt out of anonymity by attaching identifying key-value pairs (real.name = &amp;quot;John Smith&amp;quot;, gov.us.ssn = &amp;quot;123-45-6789&amp;quot;).&lt;br /&gt;
* Third parties may offer digital attestions:  Identity Verification, Inc. digitally signs a SIN as passing their Not A Criminal/Level-1 check.&lt;br /&gt;
* All key-value pair updates digitally signed by SIN owner (key holder)&lt;br /&gt;
&lt;br /&gt;
==Creating sacrifice transactions==&lt;br /&gt;
&lt;br /&gt;
Creation cost is attached to decentralized identity by means of sacrificing a small amount of value.&lt;br /&gt;
&lt;br /&gt;
An implementation of [https://en.bitcoin.it/wiki/Fidelity_bonds#Announce.2FCommit_Sacrifices Announce/Commit Sacrifices].  That author&#039;s feedback on this protocol was very helpful.&lt;br /&gt;
&lt;br /&gt;
# MPK = master public key&lt;br /&gt;
# BH = current block height&lt;br /&gt;
# Create and sign transaction T2. Broadcast if desired.&lt;br /&gt;
## must include Hash160(MPK) OP_TRUE anyone-can-spend output with value &amp;gt;= 0.001BTC&lt;br /&gt;
## nlocktime = BH + 144 blocks&lt;br /&gt;
## no more than 1000 bytes in size&lt;br /&gt;
# Create, sign and broadcast transaction T1&lt;br /&gt;
## must include OP_RETURN serialized(T2) output as last txout&lt;br /&gt;
&lt;br /&gt;
==Creating a SIN==&lt;br /&gt;
&lt;br /&gt;
# Prefix = 0x18 (mainnet) or 0x19 (testnet)&lt;br /&gt;
# SIN_Version = 0x01, similar to how a [http://en.wikipedia.org/wiki/Universally_unique_identifier UUID&#039;s] form is dictated by a UUID&#039;s self-identified version&lt;br /&gt;
# MD = Hash160(MPK)&lt;br /&gt;
# SIN = base58_encode_check( Prefix + SIN_Version + MD )&lt;br /&gt;
# Hyphenate SIN for easier human reading&lt;br /&gt;
&lt;br /&gt;
==Validating the root identity information==&lt;br /&gt;
&lt;br /&gt;
# B1 = block w/ T1&lt;br /&gt;
# B2 = block w/ T2&lt;br /&gt;
# Verify B2 height - 144 &amp;gt;= B1 height.&lt;br /&gt;
# Verify announced T2 is valid&lt;br /&gt;
# Verify mined T2 spends same inputs as announced T2 (not equal to account for [[Transaction Malleability]])&lt;br /&gt;
# Fail and waste sacrifice if not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus a minimal root record is MPK and is provably&lt;br /&gt;
* linked to the sacrifices&lt;br /&gt;
* MPK starts a new chain of digital signature trust, for further record updates&lt;br /&gt;
&lt;br /&gt;
==Future work==&lt;br /&gt;
&lt;br /&gt;
After creation, the root identity and key-value pairs must be stored $somewhere.&lt;br /&gt;
&lt;br /&gt;
After that root identity is created, additional key-value pairs may be associated with the root record via updates verified by MPK, stored in an alt-blockchain or DHT somewhere.  That is outside the scope of this minimal document, at this time.&lt;br /&gt;
&lt;br /&gt;
Key attributes of this system, like price and transaction size, are hardcoded.  It is presumed that version 2+ will improve upon this, once field experience is gained and lessons are learned.&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=39004</id>
		<title>Identity protocol v1</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=39004"/>
		<updated>2013-06-28T08:40:57Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Creating a SIN */ remove &amp;quot;space&amp;quot; option for SIN to ensure double-click selection works&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Design goals==&lt;br /&gt;
&lt;br /&gt;
Decentralized identity.&lt;br /&gt;
&lt;br /&gt;
A SIN (&amp;quot;System Identification Number&amp;quot;) is the unique record identifier by which this identity will be known.&lt;br /&gt;
&lt;br /&gt;
Attributes:&lt;br /&gt;
* Has some creation cost, deterring spam.&lt;br /&gt;
* Sacrifice may be digitally proven, bootstrapping root of trust from blockchain data&lt;br /&gt;
* Start as anonymous; opt out of anonymity by attaching identifying key-value pairs (real.name = &amp;quot;John Smith&amp;quot;, gov.us.ssn = &amp;quot;123-45-6789&amp;quot;).&lt;br /&gt;
* Third parties may offer digital attestions:  Identity Verification, Inc. digitally signs a SIN as passing their Not A Criminal/Level-1 check.&lt;br /&gt;
* All key-value pair updates digitally signed by SIN owner (key holder)&lt;br /&gt;
&lt;br /&gt;
==Creating sacrifice transactions==&lt;br /&gt;
&lt;br /&gt;
Creation cost is attached to decentralized identity by means of sacrificing a small amount of value.&lt;br /&gt;
&lt;br /&gt;
An implementation of [https://en.bitcoin.it/wiki/Fidelity_bonds#Announce.2FCommit_Sacrifices Announce/Commit Sacrifices].  That author&#039;s feedback on this protocol was very helpful.&lt;br /&gt;
&lt;br /&gt;
# MPK = master public key&lt;br /&gt;
# BH = current block height&lt;br /&gt;
# Create and sign transaction T2. Broadcast if desired.&lt;br /&gt;
## must include Hash160(MPK) OP_TRUE anyone-can-spend output with value &amp;gt;= 0.001BTC&lt;br /&gt;
## nlocktime = BH + 144 blocks&lt;br /&gt;
## no more than 1000 bytes in size&lt;br /&gt;
# Create, sign and broadcast transaction T1&lt;br /&gt;
## must include OP_RETURN serialized(T2) output as last txout&lt;br /&gt;
&lt;br /&gt;
==Creating a SIN==&lt;br /&gt;
&lt;br /&gt;
# Prefix = 0x18&lt;br /&gt;
# SIN_Version = 0x01, similar to how a [http://en.wikipedia.org/wiki/Universally_unique_identifier UUID&#039;s] form is dictated by a UUID&#039;s self-identified version&lt;br /&gt;
# MD = Hash160(MPK)&lt;br /&gt;
# SIN = base58_encode_check( Prefix + SIN_Version + MD )&lt;br /&gt;
# Hyphenate SIN for easier human reading&lt;br /&gt;
&lt;br /&gt;
==Validating the root identity information==&lt;br /&gt;
&lt;br /&gt;
# B1 = block w/ T1&lt;br /&gt;
# B2 = block w/ T2&lt;br /&gt;
# Verify B2 height - 144 &amp;gt;= B1 height.&lt;br /&gt;
# Verify announced T2 is valid&lt;br /&gt;
# Verify mined T2 spends same inputs as announced T2 (not equal to account for [[Transaction Malleability]])&lt;br /&gt;
# Fail and waste sacrifice if not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus a minimal root record is MPK and is provably&lt;br /&gt;
* linked to the sacrifices&lt;br /&gt;
* MPK starts a new chain of digital signature trust, for further record updates&lt;br /&gt;
&lt;br /&gt;
==Future work==&lt;br /&gt;
&lt;br /&gt;
After creation, the root identity and key-value pairs must be stored $somewhere.&lt;br /&gt;
&lt;br /&gt;
After that root identity is created, additional key-value pairs may be associated with the root record via updates verified by MPK, stored in an alt-blockchain or DHT somewhere.  That is outside the scope of this minimal document, at this time.&lt;br /&gt;
&lt;br /&gt;
Key attributes of this system, like price and transaction size, are hardcoded.  It is presumed that version 2+ will improve upon this, once field experience is gained and lessons are learned.&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=38985</id>
		<title>Identity protocol v1</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=38985"/>
		<updated>2013-06-28T05:21:28Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Creating sacrifice transactions */ change to anyone-can-spend&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Design goals==&lt;br /&gt;
&lt;br /&gt;
Decentralized identity.&lt;br /&gt;
* Has some creation cost&lt;br /&gt;
* Sacrifice may be digitally proven, bootstrapping root of trust from blockchain data&lt;br /&gt;
* Start as anonymous; opt out of anonymity by attaching identifying key-value pairs (real.name = &amp;quot;John Smith&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Creating sacrifice transactions==&lt;br /&gt;
&lt;br /&gt;
An implementation of [https://en.bitcoin.it/wiki/Fidelity_bonds#Announce.2FCommit_Sacrifices Announce/Commit Sacrifices].  That author&#039;s feedback on this protocol was very helpful.&lt;br /&gt;
&lt;br /&gt;
# MPK = master public key&lt;br /&gt;
# TM = current block height&lt;br /&gt;
# Create and sign transaction T2. Broadcast if desired.&lt;br /&gt;
## must include Hash160(MPK) OP_TRUE output with value &amp;gt;= 0.001BTC&lt;br /&gt;
## nlocktime = TM + 144 blocks&lt;br /&gt;
## no more than 1000 bytes in size&lt;br /&gt;
# Create, sign and broadcast transaction T1&lt;br /&gt;
## must include OP_RETURN serialized(T2) output as last txout&lt;br /&gt;
&lt;br /&gt;
==Creating a SIN==&lt;br /&gt;
&lt;br /&gt;
A SIN (&amp;quot;System Identification Number&amp;quot;) is the unique record identifier by which this identity will be known.&lt;br /&gt;
&lt;br /&gt;
# Prefix = 0x18&lt;br /&gt;
# SIN_Version = 0x01&lt;br /&gt;
# MD = Hash160(MPK)&lt;br /&gt;
# SIN = base58_encode_check( Prefix + SIN_Version + MD )&lt;br /&gt;
# Hyphenate or space SIN for easier human reading&lt;br /&gt;
&lt;br /&gt;
==Validating the root identity information==&lt;br /&gt;
&lt;br /&gt;
# B1 = block w/ T1, B2 = block w/ T2&lt;br /&gt;
# Verify B2 height - 144 &amp;gt;= B1 height.&lt;br /&gt;
# Verify announced T2 is valid&lt;br /&gt;
# Verify mined T2 spends same inputs as announced T2 (not equal to account for [[Transaction Malleability]])&lt;br /&gt;
# Fail and waste sacrifice if not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus a minimal root record is MPK and is provably&lt;br /&gt;
* linked to the sacrifices&lt;br /&gt;
* MPK starts a new chain of digital signature trust, for further record updates&lt;br /&gt;
&lt;br /&gt;
After that, additional key-value pairs may be associated with the root record via updates verified by PPK, stored in an alt-blockchain or DHT somewhere.  That is outside the scope of this minimal document.&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=38984</id>
		<title>Identity protocol v1</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=38984"/>
		<updated>2013-06-28T05:18:00Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Validating the root identity information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Design goals==&lt;br /&gt;
&lt;br /&gt;
Decentralized identity.&lt;br /&gt;
* Has some creation cost&lt;br /&gt;
* Sacrifice may be digitally proven, bootstrapping root of trust from blockchain data&lt;br /&gt;
* Start as anonymous; opt out of anonymity by attaching identifying key-value pairs (real.name = &amp;quot;John Smith&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Creating sacrifice transactions==&lt;br /&gt;
&lt;br /&gt;
An implementation of [https://en.bitcoin.it/wiki/Fidelity_bonds#Announce.2FCommit_Sacrifices Announce/Commit Sacrifices].  That author&#039;s feedback on this protocol was very helpful.&lt;br /&gt;
&lt;br /&gt;
# MPK = master public key&lt;br /&gt;
# TM = current block height&lt;br /&gt;
# Create and sign transaction T2. Broadcast if desired.&lt;br /&gt;
## must include OP_RETURN Hash160(MPK) output with value &amp;gt;= 0.001BTC&lt;br /&gt;
## nlocktime = TM + 144 blocks&lt;br /&gt;
## no more than 1000 bytes in size&lt;br /&gt;
# Create, sign and broadcast transaction T1&lt;br /&gt;
## must include OP_RETURN serialized(T2) output as last txout&lt;br /&gt;
&lt;br /&gt;
==Creating a SIN==&lt;br /&gt;
&lt;br /&gt;
A SIN (&amp;quot;System Identification Number&amp;quot;) is the unique record identifier by which this identity will be known.&lt;br /&gt;
&lt;br /&gt;
# Prefix = 0x18&lt;br /&gt;
# SIN_Version = 0x01&lt;br /&gt;
# MD = Hash160(MPK)&lt;br /&gt;
# SIN = base58_encode_check( Prefix + SIN_Version + MD )&lt;br /&gt;
# Hyphenate or space SIN for easier human reading&lt;br /&gt;
&lt;br /&gt;
==Validating the root identity information==&lt;br /&gt;
&lt;br /&gt;
# B1 = block w/ T1, B2 = block w/ T2&lt;br /&gt;
# Verify B2 height - 144 &amp;gt;= B1 height.&lt;br /&gt;
# Verify announced T2 is valid&lt;br /&gt;
# Verify mined T2 spends same inputs as announced T2 (not equal to account for [[Transaction Malleability]])&lt;br /&gt;
# Fail and waste sacrifice if not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus a minimal root record is MPK and is provably&lt;br /&gt;
* linked to the sacrifices&lt;br /&gt;
* MPK starts a new chain of digital signature trust, for further record updates&lt;br /&gt;
&lt;br /&gt;
After that, additional key-value pairs may be associated with the root record via updates verified by PPK, stored in an alt-blockchain or DHT somewhere.  That is outside the scope of this minimal document.&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=38983</id>
		<title>Identity protocol v1</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=38983"/>
		<updated>2013-06-28T05:14:08Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Creating sacrifice transactions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Design goals==&lt;br /&gt;
&lt;br /&gt;
Decentralized identity.&lt;br /&gt;
* Has some creation cost&lt;br /&gt;
* Sacrifice may be digitally proven, bootstrapping root of trust from blockchain data&lt;br /&gt;
* Start as anonymous; opt out of anonymity by attaching identifying key-value pairs (real.name = &amp;quot;John Smith&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Creating sacrifice transactions==&lt;br /&gt;
&lt;br /&gt;
An implementation of [https://en.bitcoin.it/wiki/Fidelity_bonds#Announce.2FCommit_Sacrifices Announce/Commit Sacrifices].  That author&#039;s feedback on this protocol was very helpful.&lt;br /&gt;
&lt;br /&gt;
# MPK = master public key&lt;br /&gt;
# TM = current block height&lt;br /&gt;
# Create and sign transaction T2. Broadcast if desired.&lt;br /&gt;
## must include OP_RETURN Hash160(MPK) output with value &amp;gt;= 0.001BTC&lt;br /&gt;
## nlocktime = TM + 144 blocks&lt;br /&gt;
## no more than 1000 bytes in size&lt;br /&gt;
# Create, sign and broadcast transaction T1&lt;br /&gt;
## must include OP_RETURN serialized(T2) output as last txout&lt;br /&gt;
&lt;br /&gt;
==Creating a SIN==&lt;br /&gt;
&lt;br /&gt;
A SIN (&amp;quot;System Identification Number&amp;quot;) is the unique record identifier by which this identity will be known.&lt;br /&gt;
&lt;br /&gt;
# Prefix = 0x18&lt;br /&gt;
# SIN_Version = 0x01&lt;br /&gt;
# MD = Hash160(MPK)&lt;br /&gt;
# SIN = base58_encode_check( Prefix + SIN_Version + MD )&lt;br /&gt;
# Hyphenate or space SIN for easier human reading&lt;br /&gt;
&lt;br /&gt;
==Validating the root identity information==&lt;br /&gt;
&lt;br /&gt;
# B1 = block w/ T1, B2 = block w/ T2&lt;br /&gt;
# Verify B2 height - 144 &amp;gt;= B1 height.&lt;br /&gt;
# Verify mined T2 == announced T2&lt;br /&gt;
# Fail and waste sacrifice if not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus a minimal root record is MPK and is provably&lt;br /&gt;
* linked to the sacrifices&lt;br /&gt;
* MPK starts a new chain of digital signature trust, for further record updates&lt;br /&gt;
&lt;br /&gt;
After that, additional key-value pairs may be associated with the root record via updates verified by PPK, stored in an alt-blockchain or DHT somewhere.  That is outside the scope of this minimal document.&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=38982</id>
		<title>Identity protocol v1</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Identity_protocol_v1&amp;diff=38982"/>
		<updated>2013-06-28T05:12:49Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Specify the usual Bitcoin Hash160(d)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Design goals==&lt;br /&gt;
&lt;br /&gt;
Decentralized identity.&lt;br /&gt;
* Has some creation cost&lt;br /&gt;
* Sacrifice may be digitally proven, bootstrapping root of trust from blockchain data&lt;br /&gt;
* Start as anonymous; opt out of anonymity by attaching identifying key-value pairs (real.name = &amp;quot;John Smith&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Creating sacrifice transactions==&lt;br /&gt;
&lt;br /&gt;
An implementation of [https://en.bitcoin.it/wiki/Fidelity_bonds#Announce.2FCommit_Sacrifices Announce/Commit Sacrifices].  That author&#039;s feedback on this protocol was very helpful.&lt;br /&gt;
&lt;br /&gt;
# MPK = master public key&lt;br /&gt;
# TM = current block height&lt;br /&gt;
# Create and sign transaction T2. Broadcast if desired.&lt;br /&gt;
## must include OP_RETURN Hash160(MPK) output&lt;br /&gt;
## nlocktime = TM + 144 blocks&lt;br /&gt;
## no more than 1000 bytes in size&lt;br /&gt;
## must include &amp;gt;= 0.001 BTC fee&lt;br /&gt;
# Create, sign and broadcast transaction T1&lt;br /&gt;
## must include OP_RETURN serialized(T2) output&lt;br /&gt;
&lt;br /&gt;
==Creating a SIN==&lt;br /&gt;
&lt;br /&gt;
A SIN (&amp;quot;System Identification Number&amp;quot;) is the unique record identifier by which this identity will be known.&lt;br /&gt;
&lt;br /&gt;
# Prefix = 0x18&lt;br /&gt;
# SIN_Version = 0x01&lt;br /&gt;
# MD = Hash160(MPK)&lt;br /&gt;
# SIN = base58_encode_check( Prefix + SIN_Version + MD )&lt;br /&gt;
# Hyphenate or space SIN for easier human reading&lt;br /&gt;
&lt;br /&gt;
==Validating the root identity information==&lt;br /&gt;
&lt;br /&gt;
# B1 = block w/ T1, B2 = block w/ T2&lt;br /&gt;
# Verify B2 height - 144 &amp;gt;= B1 height.&lt;br /&gt;
# Verify mined T2 == announced T2&lt;br /&gt;
# Fail and waste sacrifice if not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus a minimal root record is MPK and is provably&lt;br /&gt;
* linked to the sacrifices&lt;br /&gt;
* MPK starts a new chain of digital signature trust, for further record updates&lt;br /&gt;
&lt;br /&gt;
After that, additional key-value pairs may be associated with the root record via updates verified by PPK, stored in an alt-blockchain or DHT somewhere.  That is outside the scope of this minimal document.&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Forums&amp;diff=37065</id>
		<title>Talk:Forums</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Forums&amp;diff=37065"/>
		<updated>2013-04-15T22:03:02Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Revert spam&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37063</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37063"/>
		<updated>2013-04-15T13:50:41Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: make &amp;quot;what is security&amp;quot; section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you have followed a link to this page from reddit or elsewhere discussing Mike Hearn&#039;s assurance contracts proposal to fund network security, please see [https://bitcointalk.org/index.php?topic=157141.msg1665332#msg1665332 the discussion on bitcointalk] for the original document. Below is a general discussion of how network security is funded now and could be in the future, including Mike&#039;s proposal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
== What is security? ==&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example - what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is or will be.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use an [[Off-Chain Transactions|off-chain payment system]] to move the funds instead, either one denominated in Bitcoins, or in a different currency entirely. The availability of off-chain transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37062</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37062"/>
		<updated>2013-04-15T13:49:27Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: grammar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you have followed a link to this page from reddit or elsewhere discussing Mike Hearn&#039;s assurance contracts proposal to fund network security, please see [https://bitcointalk.org/index.php?topic=157141.msg1665332#msg1665332 the discussion on bitcointalk] for the original document. Below is a general discussion of how network security is funded now and could be in the future, including Mike&#039;s proposal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example - what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is or will be.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use an [[Off-Chain Transactions|off-chain payment system]] to move the funds instead, either one denominated in Bitcoins, or in a different currency entirely. The availability of off-chain transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37061</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37061"/>
		<updated>2013-04-15T13:48:38Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: fix link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you have followed a link to this page from reddit or elsewhere discussing Mike Hearn&#039;s assurance contracts proposal to fund network security, please see [https://bitcointalk.org/index.php?topic=157141.msg1665332#msg1665332 the discussion on bitcointalk] for the original document. Below is a general discussion of how network security is funded now and could be in the future, including Mike&#039;s proposal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example; what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is or will be.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use an [[Off-Chain Transactions|off-chain payment system]] to move the funds instead, either one denominated in Bitcoins, or in a different currency entirely. The availability of off-chain transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37060</id>
		<title>Off-chain transactions</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37060"/>
		<updated>2013-04-15T13:00:19Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Proving Fraud */  grammar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An off-chain transaction is the movement of value outside of the [[block chain]]. While an [[Transactions|on-chain transaction]] - usually referred to as simply &#039;a transaction&#039; - modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction. Like on-chain transactions all parties must agree to accept the particular method by which the transaction occurs, the question then being, how can those parties be convinced that the movement of value has actually happened, will not be reversed, and can be exchanged in the future for something of value?&lt;br /&gt;
&lt;br /&gt;
With an on-chain transaction those questions are answered by the parties faith in the Bitcoin system as a whole. For instance a transaction (after some number of [[Confirmation|confirmations]]) can only be reversed if a majority of hashing power agrees to reverse the transaction. The parties to the transaction are trusting that the majority of hashing power in existence is controlled by &amp;quot;honest&amp;quot; parties who will not attempt to reverse the transaction.&lt;br /&gt;
&lt;br /&gt;
== Rational ==&lt;br /&gt;
&lt;br /&gt;
On-chain transactions have disadvantages that make them unsuitable for some applications:&lt;br /&gt;
&lt;br /&gt;
=== Speed ===&lt;br /&gt;
&lt;br /&gt;
On-chain transactions take some time to accumulate enough [[Confirmation|confirmations]] to ensure that they can-not be reversed; accepting a transaction [[Zero-Conf Transactions|without any confirmations]] is potentially risky. Confirmations take time and the time they take to accumulate is random. Off-chain transaction systems can record that a transaction has happened immediately, and, subject to the guarantees of the system itself, immediately guarantee it won&#039;t be reversed.&lt;br /&gt;
&lt;br /&gt;
=== Privacy/Anonymity ===&lt;br /&gt;
&lt;br /&gt;
All on-chain transactions are recorded publicly on the block chain; Bitcoin transactions are not inherently [[Anonymity|anonymous]]. It may be possible for a third-party to use the block chain transaction data to determine the source and/or destination of a transaction if they can gather enough information linking addresses to identities. Because off-chain transactions do not happen on the block chain they need not be public. Using cryptographic techniques such as [http://en.wikipedia.org/wiki/Blind_signature chaum tokens] it can be made impossible for even the operators of the system itself to determine who participated in a transaction.&lt;br /&gt;
&lt;br /&gt;
=== Cost/Scalability ===&lt;br /&gt;
&lt;br /&gt;
Miners usually charge [[Transaction fees|fees]] to confirm a transaction. While currently the demand for transactions is sufficiently low that fees are relatively small, and transactions can often be confirmed for free, for many applications even paying a few cents per transaction is unaffordable.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=156334.0 How to send BitCoins with LOW TX FEE (Not No TX Fee)]&amp;lt;/ref&amp;gt; In addition Bitcoin currently has a limit of 7 transactions per second, the [[blocksize limit]]. This limit is related to the [[Scalability|scalability]] of the system as a whole, and one option to achieve higher transaction volumes is to keep the blocksize limit as is and use off-chain transactions for lower-value transactions; with higher volumes fees for transactions done on-chain will rise due to supply and demand.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The most simple example of an off-chain transaction is perhaps two friends who agree on a debt between them. The &amp;quot;transaction&amp;quot; happens by the act of agreeing that the debt exists, and the validity of it is based solely on the trust that one friend has in the other. Further transactions can be agreed upon, possibly in exchange for something of value such one friend buying the other a meal. Multiple mutually trusting parties can participate, creating a network of value owed from one to the other. As an example the [http://en.wikipedia.org/wiki/Ripple_monetary_system Ripple monetary system] takes this concept, and adds to it an automated ledger to record all the mutual debts between participating parties. However actually acting upon those debts is still a matter of trust between the parties; the system only records debts and can-not by itself cause Bitcoins or some other object of value to change hands.&lt;br /&gt;
&lt;br /&gt;
=== Trusted Third Parties ===&lt;br /&gt;
&lt;br /&gt;
If the sender and recipient do not trust each other, or would simply prefer someone else record and guarantee the transaction, they can use a [http://en.wikipedia.org/wiki/Trusted_third_party trusted third party] to record and guarantee the transaction. The vast majority of conventional banking and electronic payment systems work this way. For instance in the PayPal system, PayPal is trusted to keep an accurate record of all transactions, including within the PayPal system, as well as transactions that move funds to and from PayPal. Within Bitcoin [[Redeemable_code|redeemable code]] systems exist where a third party, such as Mt. Gox, records codes issued and promise to redeem them for either new codes, balances within the system, or Bitcoins via on-chain transactions. In addition [[E-Wallet]] services such as [[Easywallet.org]] often allow users to transfer funds between addresses within the system without creating an on-chain transaction.&lt;br /&gt;
&lt;br /&gt;
The difficulty with third-parties is achieving that trust. Outside of Bitcoin PayPal has been criticized&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/PayPal#Criticism PayPal - Criticism]&amp;lt;/ref&amp;gt; for arbitrarily freezing accounts. Within Bitcoin multiple E-Wallet services such as [[MyBitcoin]] and [[Instawallet]] have failed due to hacks as well as technical mistakes resulting in the loss of some or all funds held on behalf of their customers.&lt;br /&gt;
&lt;br /&gt;
=== Auditing ===&lt;br /&gt;
&lt;br /&gt;
In addition to hacks, currently no trusted third party payment systems in Bitcoin provide any way for users to determine if the services actually hold the Bitcoins they claim to hold. Conventionally banks and payment processors are [http://en.wikipedia.org/wiki/Financial_audit audited] regularly by third-parties - because Bitcoin is based on cryptography auditing can be done in a cryptographically provable way.&lt;br /&gt;
&lt;br /&gt;
Gregory Maxwell has proposed&amp;lt;ref&amp;gt;private communication on IRC (gmaxwell: do you have a writeup somewhere?)&amp;lt;/ref&amp;gt; to use [[merkle-sum trees]] of accounts to audit funds held by third parties. Each account with the service is assigned a number, such as a SHA256 digest, and those digests are formed into a merkle tree. Additionally for every node in the tree the sum of the account balances on both leaves is computed, and that sum becomes part of the data hashed by the parent node. The tip of the tree is then the sum of all balances for all accounts.&lt;br /&gt;
&lt;br /&gt;
The service proves they control the Bitcoins they claim to by signing statements with the private keys capable of spending transaction outputs present on the blockchain, and in addition regularly sign statements attesting what is the current tip of the account merkle-sum tree.&lt;br /&gt;
&lt;br /&gt;
Clients check that their account is included in that tree by regularly demanding proof, in the form of a merkle path, that their account leads to the claimed tip. Any discrepancy is evidence of fraud on by the service, or at least poor record-keeping.&lt;br /&gt;
&lt;br /&gt;
=== Proving Fraud ===&lt;br /&gt;
&lt;br /&gt;
If the communication protocol between client and service is designed correctly fraud by the service can be proven to others. For instance if the service cryptographically signs all communications an inconsistency between the claimed merkle-tip of the accounts held by the service and the merkle-path from a particular account to that tip can be proven by providing the signed tip, and the signed merkle-path. This fraud proof can be self-authenticating, and thus anyone who comes in possession of such a proof can broadcast it to their peers. With appropriate software all participating clients of the service can be informed of any fraud immediately taking &amp;quot;advantage of the nature of information being easy to spread but hard to stifle&amp;quot; - a core concept underlying the security of Bitcoin itself.&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=30482839 Satoshi]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37059</id>
		<title>Off-chain transactions</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37059"/>
		<updated>2013-04-15T12:59:44Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Methods */ grammar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An off-chain transaction is the movement of value outside of the [[block chain]]. While an [[Transactions|on-chain transaction]] - usually referred to as simply &#039;a transaction&#039; - modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction. Like on-chain transactions all parties must agree to accept the particular method by which the transaction occurs, the question then being, how can those parties be convinced that the movement of value has actually happened, will not be reversed, and can be exchanged in the future for something of value?&lt;br /&gt;
&lt;br /&gt;
With an on-chain transaction those questions are answered by the parties faith in the Bitcoin system as a whole. For instance a transaction (after some number of [[Confirmation|confirmations]]) can only be reversed if a majority of hashing power agrees to reverse the transaction. The parties to the transaction are trusting that the majority of hashing power in existence is controlled by &amp;quot;honest&amp;quot; parties who will not attempt to reverse the transaction.&lt;br /&gt;
&lt;br /&gt;
== Rational ==&lt;br /&gt;
&lt;br /&gt;
On-chain transactions have disadvantages that make them unsuitable for some applications:&lt;br /&gt;
&lt;br /&gt;
=== Speed ===&lt;br /&gt;
&lt;br /&gt;
On-chain transactions take some time to accumulate enough [[Confirmation|confirmations]] to ensure that they can-not be reversed; accepting a transaction [[Zero-Conf Transactions|without any confirmations]] is potentially risky. Confirmations take time and the time they take to accumulate is random. Off-chain transaction systems can record that a transaction has happened immediately, and, subject to the guarantees of the system itself, immediately guarantee it won&#039;t be reversed.&lt;br /&gt;
&lt;br /&gt;
=== Privacy/Anonymity ===&lt;br /&gt;
&lt;br /&gt;
All on-chain transactions are recorded publicly on the block chain; Bitcoin transactions are not inherently [[Anonymity|anonymous]]. It may be possible for a third-party to use the block chain transaction data to determine the source and/or destination of a transaction if they can gather enough information linking addresses to identities. Because off-chain transactions do not happen on the block chain they need not be public. Using cryptographic techniques such as [http://en.wikipedia.org/wiki/Blind_signature chaum tokens] it can be made impossible for even the operators of the system itself to determine who participated in a transaction.&lt;br /&gt;
&lt;br /&gt;
=== Cost/Scalability ===&lt;br /&gt;
&lt;br /&gt;
Miners usually charge [[Transaction fees|fees]] to confirm a transaction. While currently the demand for transactions is sufficiently low that fees are relatively small, and transactions can often be confirmed for free, for many applications even paying a few cents per transaction is unaffordable.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=156334.0 How to send BitCoins with LOW TX FEE (Not No TX Fee)]&amp;lt;/ref&amp;gt; In addition Bitcoin currently has a limit of 7 transactions per second, the [[blocksize limit]]. This limit is related to the [[Scalability|scalability]] of the system as a whole, and one option to achieve higher transaction volumes is to keep the blocksize limit as is and use off-chain transactions for lower-value transactions; with higher volumes fees for transactions done on-chain will rise due to supply and demand.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The most simple example of an off-chain transaction is perhaps two friends who agree on a debt between them. The &amp;quot;transaction&amp;quot; happens by the act of agreeing that the debt exists, and the validity of it is based solely on the trust that one friend has in the other. Further transactions can be agreed upon, possibly in exchange for something of value such one friend buying the other a meal. Multiple mutually trusting parties can participate, creating a network of value owed from one to the other. As an example the [http://en.wikipedia.org/wiki/Ripple_monetary_system Ripple monetary system] takes this concept, and adds to it an automated ledger to record all the mutual debts between participating parties. However actually acting upon those debts is still a matter of trust between the parties; the system only records debts and can-not by itself cause Bitcoins or some other object of value to change hands.&lt;br /&gt;
&lt;br /&gt;
=== Trusted Third Parties ===&lt;br /&gt;
&lt;br /&gt;
If the sender and recipient do not trust each other, or would simply prefer someone else record and guarantee the transaction, they can use a [http://en.wikipedia.org/wiki/Trusted_third_party trusted third party] to record and guarantee the transaction. The vast majority of conventional banking and electronic payment systems work this way. For instance in the PayPal system, PayPal is trusted to keep an accurate record of all transactions, including within the PayPal system, as well as transactions that move funds to and from PayPal. Within Bitcoin [[Redeemable_code|redeemable code]] systems exist where a third party, such as Mt. Gox, records codes issued and promise to redeem them for either new codes, balances within the system, or Bitcoins via on-chain transactions. In addition [[E-Wallet]] services such as [[Easywallet.org]] often allow users to transfer funds between addresses within the system without creating an on-chain transaction.&lt;br /&gt;
&lt;br /&gt;
The difficulty with third-parties is achieving that trust. Outside of Bitcoin PayPal has been criticized&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/PayPal#Criticism PayPal - Criticism]&amp;lt;/ref&amp;gt; for arbitrarily freezing accounts. Within Bitcoin multiple E-Wallet services such as [[MyBitcoin]] and [[Instawallet]] have failed due to hacks as well as technical mistakes resulting in the loss of some or all funds held on behalf of their customers.&lt;br /&gt;
&lt;br /&gt;
=== Auditing ===&lt;br /&gt;
&lt;br /&gt;
In addition to hacks, currently no trusted third party payment systems in Bitcoin provide any way for users to determine if the services actually hold the Bitcoins they claim to hold. Conventionally banks and payment processors are [http://en.wikipedia.org/wiki/Financial_audit audited] regularly by third-parties - because Bitcoin is based on cryptography auditing can be done in a cryptographically provable way.&lt;br /&gt;
&lt;br /&gt;
Gregory Maxwell has proposed&amp;lt;ref&amp;gt;private communication on IRC (gmaxwell: do you have a writeup somewhere?)&amp;lt;/ref&amp;gt; to use [[merkle-sum trees]] of accounts to audit funds held by third parties. Each account with the service is assigned a number, such as a SHA256 digest, and those digests are formed into a merkle tree. Additionally for every node in the tree the sum of the account balances on both leaves is computed, and that sum becomes part of the data hashed by the parent node. The tip of the tree is then the sum of all balances for all accounts.&lt;br /&gt;
&lt;br /&gt;
The service proves they control the Bitcoins they claim to by signing statements with the private keys capable of spending transaction outputs present on the blockchain, and in addition regularly sign statements attesting what is the current tip of the account merkle-sum tree.&lt;br /&gt;
&lt;br /&gt;
Clients check that their account is included in that tree by regularly demanding proof, in the form of a merkle path, that their account leads to the claimed tip. Any discrepancy is evidence of fraud on by the service, or at least poor record-keeping.&lt;br /&gt;
&lt;br /&gt;
=== Proving Fraud ===&lt;br /&gt;
&lt;br /&gt;
If the communication protocol between client and service is designed correctly fraud by the service can be proven to others. For instance if the service cryptographically signs all communications an inconsistency between the claimed merkle-tip of the accounts held by the service and the merkle-path from a particular account to that tip can be proven by providing the signed tip, and the signed merkle-path. This fraud proof can be self-authenticating, and thus anyone who comes in possession of such a proof can broadcast it to their peers. With appropriate software all participating clients of the service can be informed of any fraud immediately taking &amp;quot;advantage of the nature of information being easy to spread but hard to stifle&amp;quot;, a core concept underlying the security of Bitcoin itself.&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=30482839 Satoshi]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37058</id>
		<title>Off-chain transactions</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37058"/>
		<updated>2013-04-15T12:57:16Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An off-chain transaction is the movement of value outside of the [[block chain]]. While an [[Transactions|on-chain transaction]] - usually referred to as simply &#039;a transaction&#039; - modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction. Like on-chain transactions all parties must agree to accept the particular method by which the transaction occurs, the question then being, how can those parties be convinced that the movement of value has actually happened, will not be reversed, and can be exchanged in the future for something of value?&lt;br /&gt;
&lt;br /&gt;
With an on-chain transaction those questions are answered by the parties faith in the Bitcoin system as a whole. For instance a transaction (after some number of [[Confirmation|confirmations]]) can only be reversed if a majority of hashing power agrees to reverse the transaction. The parties to the transaction are trusting that the majority of hashing power in existence is controlled by &amp;quot;honest&amp;quot; parties who will not attempt to reverse the transaction.&lt;br /&gt;
&lt;br /&gt;
== Rational ==&lt;br /&gt;
&lt;br /&gt;
On-chain transactions have disadvantages that make them unsuitable for some applications:&lt;br /&gt;
&lt;br /&gt;
=== Speed ===&lt;br /&gt;
&lt;br /&gt;
On-chain transactions take some time to accumulate enough [[Confirmation|confirmations]] to ensure that they can-not be reversed; accepting a transaction [[Zero-Conf Transactions|without any confirmations]] is potentially risky. Confirmations take time and the time they take to accumulate is random. Off-chain transaction systems can record that a transaction has happened immediately, and, subject to the guarantees of the system itself, immediately guarantee it won&#039;t be reversed.&lt;br /&gt;
&lt;br /&gt;
=== Privacy/Anonymity ===&lt;br /&gt;
&lt;br /&gt;
All on-chain transactions are recorded publicly on the block chain; Bitcoin transactions are not inherently [[Anonymity|anonymous]]. It may be possible for a third-party to use the block chain transaction data to determine the source and/or destination of a transaction if they can gather enough information linking addresses to identities. Because off-chain transactions do not happen on the block chain they need not be public. Using cryptographic techniques such as [http://en.wikipedia.org/wiki/Blind_signature chaum tokens] it can be made impossible for even the operators of the system itself to determine who participated in a transaction.&lt;br /&gt;
&lt;br /&gt;
=== Cost/Scalability ===&lt;br /&gt;
&lt;br /&gt;
Miners usually charge [[Transaction fees|fees]] to confirm a transaction. While currently the demand for transactions is sufficiently low that fees are relatively small, and transactions can often be confirmed for free, for many applications even paying a few cents per transaction is unaffordable.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=156334.0 How to send BitCoins with LOW TX FEE (Not No TX Fee)]&amp;lt;/ref&amp;gt; In addition Bitcoin currently has a limit of 7 transactions per second, the [[blocksize limit]]. This limit is related to the [[Scalability|scalability]] of the system as a whole, and one option to achieve higher transaction volumes is to keep the blocksize limit as is and use off-chain transactions for lower-value transactions; with higher volumes fees for transactions done on-chain will rise due to supply and demand.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The most simple example of an off-chain transaction is perhaps two friends who agree on a debt between them. The &amp;quot;transaction&amp;quot; happens by the act of agreeing that the debt exists, and the validity of it is based solely on the trust that one friend has in the other. Further transactions can be agreed upon, possibly in exchange for something of value such one friend buying the other a meal. Multiple mutually trusting parties can participate, creating a network of value owed from one to the other. As an example the [http://en.wikipedia.org/wiki/Ripple_monetary_system Ripple monetary system] takes this concept, and adds to it an automated ledger to record all the mutual debts between participating parties. However actually acting upon those debts is still a matter of trust between the parties, the system only records and can-not by itself cause Bitcoins or some other object of value to change hands.&lt;br /&gt;
&lt;br /&gt;
=== Trusted Third Parties ===&lt;br /&gt;
&lt;br /&gt;
If the sender and recipient do not trust each other, or would simply prefer someone else record and guarantee the transaction, they can use a [http://en.wikipedia.org/wiki/Trusted_third_party trusted third party] to record and guarantee the transaction. The vast majority of conventional banking and electronic payment systems work this way. For instance in the PayPal system, PayPal is trusted to keep an accurate record of all transactions, including within the PayPal system, as well as transactions that move funds to and from PayPal. Within Bitcoin [[Redeemable_code|redeemable code]] systems exist where a third party, such as Mt. Gox, records codes issued and promise to redeem them for either new codes, balances within the system, or Bitcoins via on-chain transactions. In addition [[E-Wallet]] services such as [[Easywallet.org]] often allow users to transfer funds between addresses within the system without creating an on-chain transaction.&lt;br /&gt;
&lt;br /&gt;
The difficulty with third-parties is achieving that trust. Outside of Bitcoin PayPal has been criticized&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/PayPal#Criticism PayPal - Criticism]&amp;lt;/ref&amp;gt; for arbitrarily freezing accounts. Within Bitcoin multiple E-Wallet services such as [[MyBitcoin]] and [[Instawallet]] have failed due to hacks as well as technical mistakes resulting in the loss of some or all funds held on behalf of their customers.&lt;br /&gt;
&lt;br /&gt;
=== Auditing ===&lt;br /&gt;
&lt;br /&gt;
In addition to hacks, currently no trusted third party payment systems in Bitcoin provide any way for users to determine if the services actually hold the Bitcoins they claim to hold. Conventionally banks and payment processors are [http://en.wikipedia.org/wiki/Financial_audit audited] regularly by third-parties - because Bitcoin is based on cryptography auditing can be done in a cryptographically provable way.&lt;br /&gt;
&lt;br /&gt;
Gregory Maxwell has proposed&amp;lt;ref&amp;gt;private communication on IRC (gmaxwell: do you have a writeup somewhere?)&amp;lt;/ref&amp;gt; to use [[merkle-sum trees]] of accounts to audit funds held by third parties. Each account with the service is assigned a number, such as a SHA256 digest, and those digests are formed into a merkle tree. Additionally for every node in the tree the sum of the account balances on both leaves is computed, and that sum becomes part of the data hashed by the parent node. The tip of the tree is then the sum of all balances for all accounts.&lt;br /&gt;
&lt;br /&gt;
The service proves they control the Bitcoins they claim to by signing statements with the private keys capable of spending transaction outputs present on the blockchain, and in addition regularly sign statements attesting what is the current tip of the account merkle-sum tree.&lt;br /&gt;
&lt;br /&gt;
Clients check that their account is included in that tree by regularly demanding proof, in the form of a merkle path, that their account leads to the claimed tip. Any discrepancy is evidence of fraud on by the service, or at least poor record-keeping.&lt;br /&gt;
&lt;br /&gt;
=== Proving Fraud ===&lt;br /&gt;
&lt;br /&gt;
If the communication protocol between client and service is designed correctly fraud by the service can be proven to others. For instance if the service cryptographically signs all communications an inconsistency between the claimed merkle-tip of the accounts held by the service and the merkle-path from a particular account to that tip can be proven by providing the signed tip, and the signed merkle-path. This fraud proof can be self-authenticating, and thus anyone who comes in possession of such a proof can broadcast it to their peers. With appropriate software all participating clients of the service can be informed of any fraud immediately taking &amp;quot;advantage of the nature of information being easy to spread but hard to stifle&amp;quot;, a core concept underlying the security of Bitcoin itself.&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=30482839 Satoshi]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37057</id>
		<title>Off-chain transactions</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37057"/>
		<updated>2013-04-15T12:54:53Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Proving Fraud */ expand&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An off-chain transaction is the movement of value outside of the [[block chain]]. While an [[Transactions|on-chain transaction]] - usually referred to as simply &#039;a transaction&#039; - modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction. Like on-chain transactions all parties must agree to accept the particular method by which the transaction occurs, the question then being, how can those parties be convinced that the movement of value has actually happened, will not be reversed, and can be exchanged in the future for something of value?&lt;br /&gt;
&lt;br /&gt;
With an on-chain transaction those questions are answered by the parties faith in the Bitcoin system as a whole. For instance a transaction (after some number of confirmations) can only be reversed if a majority of hashing power agrees to reverse the transaction. The parties to the transaction are trusting that the majority of hashing power in existence is controlled by &amp;quot;honest&amp;quot; parties who will not attempt to reverse the transaction.&lt;br /&gt;
&lt;br /&gt;
== Rational ==&lt;br /&gt;
&lt;br /&gt;
On-chain transactions have disadvantages that make them unsuitable for some applications:&lt;br /&gt;
&lt;br /&gt;
=== Speed ===&lt;br /&gt;
&lt;br /&gt;
On-chain transactions take some time to accumulate enough [[Confirmation|confirmations]] to ensure that they can-not be reversed; accepting a transaction [[Zero-Conf Transactions|without any confirmations]] is potentially risky. Confirmations take time and the time they take to accumulate is random. Off-chain transaction systems can record that a transaction has happened immediately, and, subject to the guarantees of the system itself, immediately guarantee it won&#039;t be reversed.&lt;br /&gt;
&lt;br /&gt;
=== Privacy/Anonymity ===&lt;br /&gt;
&lt;br /&gt;
All on-chain transactions are recorded publicly on the block chain; Bitcoin transactions are not inherently [[Anonymity|anonymous]]. It may be possible for a third-party to use the block chain transaction data to determine the source and/or destination of a transaction if they can gather enough information linking addresses to identities. Because off-chain transactions do not happen on the block chain they need not be public. Using cryptographic techniques such as [http://en.wikipedia.org/wiki/Blind_signature chaum tokens] it can be made impossible for even the operators of the system itself to determine who participated in a transaction.&lt;br /&gt;
&lt;br /&gt;
=== Cost/Scalability ===&lt;br /&gt;
&lt;br /&gt;
Miners usually charge [[Transaction fees|fees]] to confirm a transaction. While currently the demand for transactions is sufficiently low that fees are relatively small, and transactions can often be confirmed for free, for many applications even paying a few cents per transaction is unaffordable.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=156334.0 How to send BitCoins with LOW TX FEE (Not No TX Fee)]&amp;lt;/ref&amp;gt; In addition Bitcoin currently has a limit of 7 transactions per second, the [[blocksize limit]]. This limit is related to the [[Scalability|scalability]] of the system as a whole, and one option to achieve higher transaction volumes is to keep the blocksize limit as is and use off-chain transactions for lower-value transactions; with higher volumes fees for transactions done on-chain will rise due to supply and demand.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The most simple example of an off-chain transaction is perhaps two friends who agree on a debt between them. The &amp;quot;transaction&amp;quot; happens by the act of agreeing that the debt exists, and the validity of it is based solely on the trust that one friend has in the other. Further transactions can be agreed upon, possibly in exchange for something of value such one friend buying the other a meal. Multiple mutually trusting parties can participate, creating a network of value owed from one to the other. As an example the [http://en.wikipedia.org/wiki/Ripple_monetary_system Ripple monetary system] takes this concept, and adds to it an automated ledger to record all the mutual debts between participating parties. However actually acting upon those debts is still a matter of trust between the parties, the system only records and can-not by itself cause Bitcoins or some other object of value to change hands.&lt;br /&gt;
&lt;br /&gt;
=== Trusted Third Parties ===&lt;br /&gt;
&lt;br /&gt;
If the sender and recipient do not trust each other, or would simply prefer someone else record and guarantee the transaction, they can use a [http://en.wikipedia.org/wiki/Trusted_third_party trusted third party] to record and guarantee the transaction. The vast majority of conventional banking and electronic payment systems work this way. For instance in the PayPal system, PayPal is trusted to keep an accurate record of all transactions, including within the PayPal system, as well as transactions that move funds to and from PayPal. Within Bitcoin [[Redeemable_code|redeemable code]] systems exist where a third party, such as Mt. Gox, records codes issued and promise to redeem them for either new codes, balances within the system, or Bitcoins via on-chain transactions. In addition [[E-Wallet]] services such as [[Easywallet.org]] often allow users to transfer funds between addresses within the system without creating an on-chain transaction.&lt;br /&gt;
&lt;br /&gt;
The difficulty with third-parties is achieving that trust. Outside of Bitcoin PayPal has been criticized&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/PayPal#Criticism PayPal - Criticism]&amp;lt;/ref&amp;gt; for arbitrarily freezing accounts. Within Bitcoin multiple E-Wallet services such as [[MyBitcoin]] and [[Instawallet]] have failed due to hacks as well as technical mistakes resulting in the loss of some or all funds held on behalf of their customers.&lt;br /&gt;
&lt;br /&gt;
=== Auditing ===&lt;br /&gt;
&lt;br /&gt;
In addition to hacks, currently no trusted third party payment systems in Bitcoin provide any way for users to determine if the services actually hold the Bitcoins they claim to hold. Conventionally banks and payment processors are [http://en.wikipedia.org/wiki/Financial_audit audited] regularly by third-parties - because Bitcoin is based on cryptography auditing can be done in a cryptographically provable way.&lt;br /&gt;
&lt;br /&gt;
Gregory Maxwell has proposed&amp;lt;ref&amp;gt;private communication on IRC (gmaxwell: do you have a writeup somewhere?)&amp;lt;/ref&amp;gt; to use [[merkle-sum trees]] of accounts to audit funds held by third parties. Each account with the service is assigned a number, such as a SHA256 digest, and those digests are formed into a merkle tree. Additionally for every node in the tree the sum of the account balances on both leaves is computed, and that sum becomes part of the data hashed by the parent node. The tip of the tree is then the sum of all balances for all accounts.&lt;br /&gt;
&lt;br /&gt;
The service proves they control the Bitcoins they claim to by signing statements with the private keys capable of spending transaction outputs present on the blockchain, and in addition regularly sign statements attesting what is the current tip of the account merkle-sum tree.&lt;br /&gt;
&lt;br /&gt;
Clients check that their account is included in that tree by regularly demanding proof, in the form of a merkle path, that their account leads to the claimed tip. Any discrepancy is evidence of fraud on by the service, or at least poor record-keeping.&lt;br /&gt;
&lt;br /&gt;
=== Proving Fraud ===&lt;br /&gt;
&lt;br /&gt;
If the communication protocol between client and service is designed correctly fraud by the service can be proven to others. For instance if the service cryptographically signs all communications an inconsistency between the claimed merkle-tip of the accounts held by the service and the merkle-path from a particular account to that tip can be proven by providing the signed tip, and the signed merkle-path. This fraud proof can be self-authenticating, and thus anyone who comes in possession of such a proof can broadcast it to their peers. With appropriate software all participating clients of the service can be informed of any fraud immediately taking &amp;quot;advantage of the nature of information being easy to spread but hard to stifle&amp;quot;, a core concept underlying the security of Bitcoin itself.&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=30482839 Satoshi]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37056</id>
		<title>Off-chain transactions</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37056"/>
		<updated>2013-04-15T12:54:01Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Auditing Third Parties */ proving fraud&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An off-chain transaction is the movement of value outside of the [[block chain]]. While an [[Transactions|on-chain transaction]] - usually referred to as simply &#039;a transaction&#039; - modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction. Like on-chain transactions all parties must agree to accept the particular method by which the transaction occurs, the question then being, how can those parties be convinced that the movement of value has actually happened, will not be reversed, and can be exchanged in the future for something of value?&lt;br /&gt;
&lt;br /&gt;
With an on-chain transaction those questions are answered by the parties faith in the Bitcoin system as a whole. For instance a transaction (after some number of confirmations) can only be reversed if a majority of hashing power agrees to reverse the transaction. The parties to the transaction are trusting that the majority of hashing power in existence is controlled by &amp;quot;honest&amp;quot; parties who will not attempt to reverse the transaction.&lt;br /&gt;
&lt;br /&gt;
== Rational ==&lt;br /&gt;
&lt;br /&gt;
On-chain transactions have disadvantages that make them unsuitable for some applications:&lt;br /&gt;
&lt;br /&gt;
=== Speed ===&lt;br /&gt;
&lt;br /&gt;
On-chain transactions take some time to accumulate enough [[Confirmation|confirmations]] to ensure that they can-not be reversed; accepting a transaction [[Zero-Conf Transactions|without any confirmations]] is potentially risky. Confirmations take time and the time they take to accumulate is random. Off-chain transaction systems can record that a transaction has happened immediately, and, subject to the guarantees of the system itself, immediately guarantee it won&#039;t be reversed.&lt;br /&gt;
&lt;br /&gt;
=== Privacy/Anonymity ===&lt;br /&gt;
&lt;br /&gt;
All on-chain transactions are recorded publicly on the block chain; Bitcoin transactions are not inherently [[Anonymity|anonymous]]. It may be possible for a third-party to use the block chain transaction data to determine the source and/or destination of a transaction if they can gather enough information linking addresses to identities. Because off-chain transactions do not happen on the block chain they need not be public. Using cryptographic techniques such as [http://en.wikipedia.org/wiki/Blind_signature chaum tokens] it can be made impossible for even the operators of the system itself to determine who participated in a transaction.&lt;br /&gt;
&lt;br /&gt;
=== Cost/Scalability ===&lt;br /&gt;
&lt;br /&gt;
Miners usually charge [[Transaction fees|fees]] to confirm a transaction. While currently the demand for transactions is sufficiently low that fees are relatively small, and transactions can often be confirmed for free, for many applications even paying a few cents per transaction is unaffordable.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=156334.0 How to send BitCoins with LOW TX FEE (Not No TX Fee)]&amp;lt;/ref&amp;gt; In addition Bitcoin currently has a limit of 7 transactions per second, the [[blocksize limit]]. This limit is related to the [[Scalability|scalability]] of the system as a whole, and one option to achieve higher transaction volumes is to keep the blocksize limit as is and use off-chain transactions for lower-value transactions; with higher volumes fees for transactions done on-chain will rise due to supply and demand.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The most simple example of an off-chain transaction is perhaps two friends who agree on a debt between them. The &amp;quot;transaction&amp;quot; happens by the act of agreeing that the debt exists, and the validity of it is based solely on the trust that one friend has in the other. Further transactions can be agreed upon, possibly in exchange for something of value such one friend buying the other a meal. Multiple mutually trusting parties can participate, creating a network of value owed from one to the other. As an example the [http://en.wikipedia.org/wiki/Ripple_monetary_system Ripple monetary system] takes this concept, and adds to it an automated ledger to record all the mutual debts between participating parties. However actually acting upon those debts is still a matter of trust between the parties, the system only records and can-not by itself cause Bitcoins or some other object of value to change hands.&lt;br /&gt;
&lt;br /&gt;
=== Trusted Third Parties ===&lt;br /&gt;
&lt;br /&gt;
If the sender and recipient do not trust each other, or would simply prefer someone else record and guarantee the transaction, they can use a [http://en.wikipedia.org/wiki/Trusted_third_party trusted third party] to record and guarantee the transaction. The vast majority of conventional banking and electronic payment systems work this way. For instance in the PayPal system, PayPal is trusted to keep an accurate record of all transactions, including within the PayPal system, as well as transactions that move funds to and from PayPal. Within Bitcoin [[Redeemable_code|redeemable code]] systems exist where a third party, such as Mt. Gox, records codes issued and promise to redeem them for either new codes, balances within the system, or Bitcoins via on-chain transactions. In addition [[E-Wallet]] services such as [[Easywallet.org]] often allow users to transfer funds between addresses within the system without creating an on-chain transaction.&lt;br /&gt;
&lt;br /&gt;
The difficulty with third-parties is achieving that trust. Outside of Bitcoin PayPal has been criticized&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/PayPal#Criticism PayPal - Criticism]&amp;lt;/ref&amp;gt; for arbitrarily freezing accounts. Within Bitcoin multiple E-Wallet services such as [[MyBitcoin]] and [[Instawallet]] have failed due to hacks as well as technical mistakes resulting in the loss of some or all funds held on behalf of their customers.&lt;br /&gt;
&lt;br /&gt;
=== Auditing ===&lt;br /&gt;
&lt;br /&gt;
In addition to hacks, currently no trusted third party payment systems in Bitcoin provide any way for users to determine if the services actually hold the Bitcoins they claim to hold. Conventionally banks and payment processors are [http://en.wikipedia.org/wiki/Financial_audit audited] regularly by third-parties - because Bitcoin is based on cryptography auditing can be done in a cryptographically provable way.&lt;br /&gt;
&lt;br /&gt;
Gregory Maxwell has proposed&amp;lt;ref&amp;gt;private communication on IRC (gmaxwell: do you have a writeup somewhere?)&amp;lt;/ref&amp;gt; to use [[merkle-sum trees]] of accounts to audit funds held by third parties. Each account with the service is assigned a number, such as a SHA256 digest, and those digests are formed into a merkle tree. Additionally for every node in the tree the sum of the account balances on both leaves is computed, and that sum becomes part of the data hashed by the parent node. The tip of the tree is then the sum of all balances for all accounts.&lt;br /&gt;
&lt;br /&gt;
The service proves they control the Bitcoins they claim to by signing statements with the private keys capable of spending transaction outputs present on the blockchain, and in addition regularly sign statements attesting what is the current tip of the account merkle-sum tree.&lt;br /&gt;
&lt;br /&gt;
Clients check that their account is included in that tree by regularly demanding proof, in the form of a merkle path, that their account leads to the claimed tip. Any discrepancy is evidence of fraud on by the service, or at least poor record-keeping.&lt;br /&gt;
&lt;br /&gt;
=== Proving Fraud ===&lt;br /&gt;
&lt;br /&gt;
If the communication protocol between client and service is designed correctly fraud by the service can be proven to others. For instance if the service cryptographically signs all communications an inconsistency between the claimed merkle-tip of the accounts held by the service and the merkle-path from a particular account to that tip can be proven by providing the signed tip, and the signed merkle-path. This fraud proof can be self-authenticating, and thus anyone who comes in possession of such a proof can broadcast it to their peers. With appropriate software all participating clients of the service can be informed of any fraud immediately, taking &amp;quot;advantage of the nature of information being easy to spread but hard to stifle.&amp;quot;&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=30482839 Satoshi]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37055</id>
		<title>Off-chain transactions</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37055"/>
		<updated>2013-04-15T12:39:16Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Rational */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An off-chain transaction is the movement of value outside of the [[block chain]]. While an [[Transactions|on-chain transaction]] - usually referred to as simply &#039;a transaction&#039; - modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction. Like on-chain transactions all parties must agree to accept the particular method by which the transaction occurs, the question then being, how can those parties be convinced that the movement of value has actually happened, will not be reversed, and can be exchanged in the future for something of value?&lt;br /&gt;
&lt;br /&gt;
With an on-chain transaction those questions are answered by the parties faith in the Bitcoin system as a whole. For instance a transaction (after some number of confirmations) can only be reversed if a majority of hashing power agrees to reverse the transaction. The parties to the transaction are trusting that the majority of hashing power in existence is controlled by &amp;quot;honest&amp;quot; parties who will not attempt to reverse the transaction.&lt;br /&gt;
&lt;br /&gt;
== Rational ==&lt;br /&gt;
&lt;br /&gt;
On-chain transactions have disadvantages that make them unsuitable for some applications:&lt;br /&gt;
&lt;br /&gt;
=== Speed ===&lt;br /&gt;
&lt;br /&gt;
On-chain transactions take some time to accumulate enough [[Confirmation|confirmations]] to ensure that they can-not be reversed; accepting a transaction [[Zero-Conf Transactions|without any confirmations]] is potentially risky. Confirmations take time and the time they take to accumulate is random. Off-chain transaction systems can record that a transaction has happened immediately, and, subject to the guarantees of the system itself, immediately guarantee it won&#039;t be reversed.&lt;br /&gt;
&lt;br /&gt;
=== Privacy/Anonymity ===&lt;br /&gt;
&lt;br /&gt;
All on-chain transactions are recorded publicly on the block chain; Bitcoin transactions are not inherently [[Anonymity|anonymous]]. It may be possible for a third-party to use the block chain transaction data to determine the source and/or destination of a transaction if they can gather enough information linking addresses to identities. Because off-chain transactions do not happen on the block chain they need not be public. Using cryptographic techniques such as [http://en.wikipedia.org/wiki/Blind_signature chaum tokens] it can be made impossible for even the operators of the system itself to determine who participated in a transaction.&lt;br /&gt;
&lt;br /&gt;
=== Cost/Scalability ===&lt;br /&gt;
&lt;br /&gt;
Miners usually charge [[Transaction fees|fees]] to confirm a transaction. While currently the demand for transactions is sufficiently low that fees are relatively small, and transactions can often be confirmed for free, for many applications even paying a few cents per transaction is unaffordable.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=156334.0 How to send BitCoins with LOW TX FEE (Not No TX Fee)]&amp;lt;/ref&amp;gt; In addition Bitcoin currently has a limit of 7 transactions per second, the [[blocksize limit]]. This limit is related to the [[Scalability|scalability]] of the system as a whole, and one option to achieve higher transaction volumes is to keep the blocksize limit as is and use off-chain transactions for lower-value transactions; with higher volumes fees for transactions done on-chain will rise due to supply and demand.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
The most simple example of an off-chain transaction is perhaps two friends who agree on a debt between them. The &amp;quot;transaction&amp;quot; happens by the act of agreeing that the debt exists, and the validity of it is based solely on the trust that one friend has in the other. Further transactions can be agreed upon, possibly in exchange for something of value such one friend buying the other a meal. Multiple mutually trusting parties can participate, creating a network of value owed from one to the other. As an example the [http://en.wikipedia.org/wiki/Ripple_monetary_system Ripple monetary system] takes this concept, and adds to it an automated ledger to record all the mutual debts between participating parties. However actually acting upon those debts is still a matter of trust between the parties, the system only records and can-not by itself cause Bitcoins or some other object of value to change hands.&lt;br /&gt;
&lt;br /&gt;
=== Trusted Third Parties ===&lt;br /&gt;
&lt;br /&gt;
If the sender and recipient do not trust each other, or would simply prefer someone else record and guarantee the transaction, they can use a [http://en.wikipedia.org/wiki/Trusted_third_party trusted third party] to record and guarantee the transaction. The vast majority of conventional banking and electronic payment systems work this way. For instance in the PayPal system, PayPal is trusted to keep an accurate record of all transactions, including within the PayPal system, as well as transactions that move funds to and from PayPal. Within Bitcoin [[Redeemable_code|redeemable code]] systems exist where a third party, such as Mt. Gox, records codes issued and promise to redeem them for either new codes, balances within the system, or Bitcoins via on-chain transactions. In addition [[E-Wallet]] services such as [[Easywallet.org]] often allow users to transfer funds between addresses within the system without creating an on-chain transaction.&lt;br /&gt;
&lt;br /&gt;
The difficulty with third-parties is achieving that trust. Outside of Bitcoin PayPal has been criticized&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/PayPal#Criticism PayPal - Criticism]&amp;lt;/ref&amp;gt; for arbitrarily freezing accounts. Within Bitcoin multiple E-Wallet services such as [[MyBitcoin]] and [[Instawallet]] have failed due to hacks as well as technical mistakes resulting in the loss of some or all funds held on behalf of their customers.&lt;br /&gt;
&lt;br /&gt;
=== Auditing Third Parties ===&lt;br /&gt;
&lt;br /&gt;
In addition to hacks, currently no trusted third party payment systems in Bitcoin provide any way for users to determine if the services actually hold the Bitcoins they claim to hold. Conventionally banks and payment processors are [http://en.wikipedia.org/wiki/Financial_audit audited] regularly by third-parties - because Bitcoin is based on cryptography auditing can be done in a cryptographically provable way.&lt;br /&gt;
&lt;br /&gt;
Gregory Maxwell has proposed&amp;lt;ref&amp;gt;private communication on IRC (gmaxwell: do you have a writeup somewhere?)&amp;lt;/ref&amp;gt; to use [[merkle-sum trees]] of accounts to audit funds held by third parties. Each account with the service is assigned a number, such as a SHA256 digest, and those digests are formed into a merkle tree. Additionally for every node in the tree the sum of the account balances on both leaves is computed, and that sum becomes part of the data hashed by the parent node. The tip of the tree is then the sum of all balances for all accounts.&lt;br /&gt;
&lt;br /&gt;
The service proves they control the Bitcoins they claim to by signing statements with the private keys capable of spending transaction outputs present on the blockchain, and in addition regularly sign statements attesting what is the current tip of the account merkle-sum tree.&lt;br /&gt;
&lt;br /&gt;
Clients check that their account is included in that tree by regularly demanding proof, in the form of a merkle path, that their account leads to the claimed tip. Any discrepancy is evidence of fraud on by the service, or at least poor record-keeping.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37054</id>
		<title>Off-chain transactions</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37054"/>
		<updated>2013-04-15T11:55:00Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: grammar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An off-chain transaction is the movement of value outside of the [[block chain]]. While an [[Transactions|on-chain transaction]] - usually referred to as simply &#039;a transaction&#039; - modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction. Like on-chain transactions all parties must agree to accept the particular method by which the transaction occurs, the question then being, how can those parties be convinced that the movement of value has actually happened, will not be reversed, and can be exchanged in the future for something of value?&lt;br /&gt;
&lt;br /&gt;
With an on-chain transaction those questions are answered by the parties faith in the Bitcoin system as a whole. For instance a transaction (after some number of confirmations) can only be reversed if a majority of hashing power agrees to reverse the transaction. The parties to the transaction are trusting that the majority of hashing power in existence is controlled by &amp;quot;honest&amp;quot; parties who will not attempt to reverse the transaction.&lt;br /&gt;
&lt;br /&gt;
== Rational ==&lt;br /&gt;
&lt;br /&gt;
On-chain transactions have disadvantages that make them unsuitable for some applications:&lt;br /&gt;
&lt;br /&gt;
=== Speed ===&lt;br /&gt;
&lt;br /&gt;
On-chain transactions take some time to accumulate enough [[Confirmation|confirmations]] to ensure that they can-not be reversed; accepting a transaction [[Zero-Conf Transactions|without any confirmations]] is potentially risky. Confirmations take time and the time they take to accumulate is random. Off-chain transaction systems can record that a transaction has happened immediately, and, subject to the guarantees of the system itself, immediately guarantee it won&#039;t be reversed.&lt;br /&gt;
&lt;br /&gt;
=== Privacy/Anonymity ===&lt;br /&gt;
&lt;br /&gt;
All on-chain transactions are recorded publicly on the block chain; Bitcoin transactions are not inherently [[Anonymity|anonymous]]. It may be possible for a third-party to use the block chain transaction data to determine the source and/or destination of a transaction if they can gather enough information linking addresses to identities. Because off-chain transactions do not happen on the block chain they need not be public. Using cryptographic techniques such as [http://en.wikipedia.org/wiki/Blind_signature chaum tokens] it can be made impossible for even the operators of the system itself to determine who participated in a transaction.&lt;br /&gt;
&lt;br /&gt;
=== Cost/Scalability ===&lt;br /&gt;
&lt;br /&gt;
Miners usually charge [[Transaction fees|fees]] to confirm a transaction. While currently the demand for transactions is sufficiently low that fees are relatively small, and transactions can often be confirmed for free, for many applications even paying a few cents per transaction is unaffordable.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=156334.0 How to send BitCoins with LOW TX FEE (Not No TX Fee)]&amp;lt;/ref&amp;gt; In addition Bitcoin currently has a limit of 7 transactions per second, the [[blocksize limit]]. This limit is related to the [[Scalability|scalability]] of the system as a whole, and one option to achieve higher transaction volumes is to keep the blocksize limit as is and use off-chain transactions for lower-value transactions; with higher volumes fees for transactions done on-chain will rise due to supply and demand.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37053</id>
		<title>Off-chain transactions</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Off-chain_transactions&amp;diff=37053"/>
		<updated>2013-04-15T11:54:21Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: First version&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An off-chain transaction is the movement of value outside of the [[block chain]]. While an [[Transactions|on-chain transaction]] - usually referred to as simply &#039;a transaction&#039; - modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction. Like on-chain transactions all parties must agree to accept the particular method by which the transaction occurs, the question then being, how can those parties be convinced that the movement of value has actually happened, will not be reversed, and can be exchanged in the future for something of value?&lt;br /&gt;
&lt;br /&gt;
With an on-chain transaction those question are answered by the parties faith in the Bitcoin system as a whole. For instance a transaction (after some number of confirmations) can only be reversed if a majority of hashing power agrees to reverse the transaction. The parties to the transaction are trusting that the majority of hashing power in existence is controlled by &amp;quot;honest&amp;quot; parties who will not attempt to reverse the transaction.&lt;br /&gt;
&lt;br /&gt;
== Rational ==&lt;br /&gt;
&lt;br /&gt;
On-chain transactions have disadvantages that make them unsuitable for some applications:&lt;br /&gt;
&lt;br /&gt;
=== Speed ===&lt;br /&gt;
&lt;br /&gt;
On-chain transactions take some time to accumulate enough [[Confirmation|confirmations]] to ensure that they can-not be reversed; accepting a transaction [[Zero-Conf Transactions|without any confirmations]] is potentially risky. Confirmations take time and the time they take to accumulate is random. Off-chain transaction systems can record that a transaction has happened immediately, and, subject to the guarantees of the system itself, immediately guarantee it won&#039;t be reversed.&lt;br /&gt;
&lt;br /&gt;
=== Privacy/Anonymity ===&lt;br /&gt;
&lt;br /&gt;
All on-chain transactions are recorded publicly on the block chain; Bitcoin transactions are not inherently [[Anonymity|anonymous]]. It may be possible for a third-party to use the block chain transaction data to determine the source and/or destination of a transaction if they can gather enough information linking addresses to identities. Because off-chain transactions do not happen on the block chain they need not be public. Using cryptographic techniques such as [http://en.wikipedia.org/wiki/Blind_signature chaum tokens] it can be made impossible for even the operators of the system itself to determine who participated in a transaction.&lt;br /&gt;
&lt;br /&gt;
=== Cost/Scalability ===&lt;br /&gt;
&lt;br /&gt;
Miners usually charge [[Transaction fees|fees]] to confirm a transaction. While currently the demand for transactions is sufficiently low that fees are relatively small, and transactions can often be confirmed for free, for many applications even paying a few cents per transaction is unaffordable.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=156334.0 How to send BitCoins with LOW TX FEE (Not No TX Fee)]&amp;lt;/ref&amp;gt; In addition Bitcoin currently has a limit of 7 transactions per second, the [[blocksize limit]]. This limit is related to the [[Scalability|scalability]] of the system as a whole, and one option to achieve higher transaction volumes is to keep the blocksize limit as is and use off-chain transactions for lower-value transactions; with higher volumes fees for transactions done on-chain will rise due to supply and demand.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37052</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37052"/>
		<updated>2013-04-15T11:06:22Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Off-chain Transactions */ grammerz&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you have followed a link to this page from reddit or elsewhere discussing Mike Hearn&#039;s assurance contracts proposal to fund network security, please see [https://bitcointalk.org/index.php?topic=157141.msg1665332#msg1665332|the discussion on bitcointalk] for the original document. Below is a general discussion of how network security is funded now and could be in the future, including Mike&#039;s proposal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example; what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is or will be.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use an [[Off-Chain Transactions|off-chain payment system]] to move the funds instead, either one denominated in Bitcoins, or in a different currency entirely. The availability of off-chain transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37051</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37051"/>
		<updated>2013-04-15T11:06:01Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Off-chain Transactions */ add link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you have followed a link to this page from reddit or elsewhere discussing Mike Hearn&#039;s assurance contracts proposal to fund network security, please see [https://bitcointalk.org/index.php?topic=157141.msg1665332#msg1665332|the discussion on bitcointalk] for the original document. Below is a general discussion of how network security is funded now and could be in the future, including Mike&#039;s proposal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example; what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is or will be.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use an [[Off-Chain Transactions|off-chain payment system]] to move the funds instead, either one denominated in Bitcoins, or in a different currency entirely; the availability of off-chain transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=37050</id>
		<title>Fidelity bonds</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=37050"/>
		<updated>2013-04-15T11:03:46Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Financial Services */  grammerz&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A fidelity bond is a proposed mechanism where Bitcoins are deliberately sacrificed to make a cryptographic identity expensive to obtain. The sacrifice is done in a way that can be proven to a third party. By making the identity expensive it can be trusted not to commit unwanted acts, such as spamming message boards, or committing fraud, because upon detection of the unwanted acts the identity becomes useless, requiring the owner of the identity to purchase another one.&lt;br /&gt;
&lt;br /&gt;
== Mechanism ==&lt;br /&gt;
&lt;br /&gt;
The core of the fidelity bond is the sacrifice - the mechanism by which Bitcoins are provably taken from their original owner. The Bitcoins may be given to someone else or destroyed, but regardless it must not be possible for their original owner to regain control of them.&lt;br /&gt;
&lt;br /&gt;
An effective form of sacrifice is to simply create a transaction assigning the coins to an unspendable output, either an address known to not have a corresponding secret key, or to a scriptPubKey that is [[Script#Provably_Unspendable.2FPrunable_Outputs|provably unspendable]]. The Bitcoins are removed from circulation forever, a criticism of this mechanism.&lt;br /&gt;
&lt;br /&gt;
The Bitcoins can also be donated to a third party, such as a charity, however such donations can be controversial, allow the charity itself (or anyone with access to their funds) to purchase bonds at little or no cost, pose the problem of verifying the bonds validity in the future should the chosen charity(s) change, and finally, pose the problem of coming to a consensus on the charities themselves.&lt;br /&gt;
&lt;br /&gt;
In the context of Bitcoin, miners have been proposed as a third party whom any Bitcoin user can agree should receive funds, as miners act to secure the network from attack for everyone. The value is sacrificed to miners in the form of transaction fees.&lt;br /&gt;
&lt;br /&gt;
=== Single/Consecutive Block Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
The sacrifice can be done with transactions that pay abnormally high fees, either single such transactions, or groups of multiple ones in a row, latter intended to prevent miners themselves from creating the sacrifices and mining them in their own blocks. Problems with consecutive transaction sacrifices include the potential for gaps, as well as the large size of the proofs of the sacrifices.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.msg1498806#msg1498806]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Announce/Commit Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
To ensure that the miner collecting the sacrificed Bitcoin is picked at random the announce/commit sacrifice was proposed.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=134827.0 Purchasing fidelity bonds by provably throwing away bitcoins]&amp;lt;/ref&amp;gt; First a sacrifice transaction is prepared that either sacrifices value to transaction fees, or spends coins to an [[Script#Anyone-Can-Spend_Outputs|Anyone-Can-Spend Output]]. With [[nLockTime]] the transaction is made invalid until some time in the future.&lt;br /&gt;
&lt;br /&gt;
The second step is the announcement. The transaction is enclosed in another transaction as data, for instance by using a [[Script#Provably_Unspendable.2FPrunable_Outputs|prunable output]]. The announcement is then broadcast and is included in the blockchain, proving that anyone could have seen the inner transaction prior to it becoming valid.&lt;br /&gt;
&lt;br /&gt;
Finally the inner transaction becomes valid when the [[nLockTime]] is reached. Because mining is a random process, any miner can collect the value sacrified, and the purchaser of the fidelity bond has no control over where that value goes.&lt;br /&gt;
&lt;br /&gt;
The proof of the sacrifice is then two transactions: the proof the announcement transaction exists in the chain, and the proof that the inner sacrifice exists in the chain. (possibly with proof of the inner sacrifice inputs to prove what fees were actually paid)&lt;br /&gt;
&lt;br /&gt;
== Passports ==&lt;br /&gt;
&lt;br /&gt;
This wiki combats spam, while still allowing for users to sign up anonymously, by requiring users to pay a small amount of Bitcoins to the wiki before editing privileges are granted. Creating large numbers of &amp;quot;sock-puppets&amp;quot; to add spam content to articles is thus made expensive. The fee approach can be generalized with the concept of a Passport, first proposed by Mike Hearn,&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.0 Creating Bitcoin passports using sacrifices]&amp;lt;/ref&amp;gt; tied to the users identity. Wikis, forums, webmail and other services can then create blacklists of users who violate the rules of the services, with those blacklists tied to passports.&lt;br /&gt;
&lt;br /&gt;
The advantage of fidelity bonds in that application over simply charging fees is re-usability of an identity across multiple services, as well as the neutrality: if the value required to create the passport provably does not go to the person adding the passport to a blacklist, there is no incentive to do so to collect new sign-up fees.&lt;br /&gt;
&lt;br /&gt;
== Financial Services ==&lt;br /&gt;
&lt;br /&gt;
Fidelity bonds can be used to make financial fraud unprofitable. For instance one early proposal&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=29185108 Trusted identities]&amp;lt;/ref&amp;gt; was to use fidelity bonds - called &amp;quot;Trusted identities&amp;quot; by the proposal&#039;s author - to create decentralized [[Green address|green addresses]]. Someone wishing for their transactions to be accepted without confirmations would first purchase a fidelity bond of some value tied to their identity. Someone determining if they should accept a payment without confirmations can check that the bond was sufficiently expensive to make it unprofitable for the sender to commit fraud. If the sender does commit fraud by double-spending the payment, the recipient can prove that fraud to the world by providing both transactions spending the same inputs. This proof is added to some sort of blacklisted, centralized or decentralized, which later recipients can consult to determine if the fidelity bond is now invalidated.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=37049</id>
		<title>Fidelity bonds</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Fidelity_bonds&amp;diff=37049"/>
		<updated>2013-04-15T11:03:11Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: First version&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A fidelity bond is a proposed mechanism where Bitcoins are deliberately sacrificed to make a cryptographic identity expensive to obtain. The sacrifice is done in a way that can be proven to a third party. By making the identity expensive it can be trusted not to commit unwanted acts, such as spamming message boards, or committing fraud, because upon detection of the unwanted acts the identity becomes useless, requiring the owner of the identity to purchase another one.&lt;br /&gt;
&lt;br /&gt;
== Mechanism ==&lt;br /&gt;
&lt;br /&gt;
The core of the fidelity bond is the sacrifice - the mechanism by which Bitcoins are provably taken from their original owner. The Bitcoins may be given to someone else or destroyed, but regardless it must not be possible for their original owner to regain control of them.&lt;br /&gt;
&lt;br /&gt;
An effective form of sacrifice is to simply create a transaction assigning the coins to an unspendable output, either an address known to not have a corresponding secret key, or to a scriptPubKey that is [[Script#Provably_Unspendable.2FPrunable_Outputs|provably unspendable]]. The Bitcoins are removed from circulation forever, a criticism of this mechanism.&lt;br /&gt;
&lt;br /&gt;
The Bitcoins can also be donated to a third party, such as a charity, however such donations can be controversial, allow the charity itself (or anyone with access to their funds) to purchase bonds at little or no cost, pose the problem of verifying the bonds validity in the future should the chosen charity(s) change, and finally, pose the problem of coming to a consensus on the charities themselves.&lt;br /&gt;
&lt;br /&gt;
In the context of Bitcoin, miners have been proposed as a third party whom any Bitcoin user can agree should receive funds, as miners act to secure the network from attack for everyone. The value is sacrificed to miners in the form of transaction fees.&lt;br /&gt;
&lt;br /&gt;
=== Single/Consecutive Block Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
The sacrifice can be done with transactions that pay abnormally high fees, either single such transactions, or groups of multiple ones in a row, latter intended to prevent miners themselves from creating the sacrifices and mining them in their own blocks. Problems with consecutive transaction sacrifices include the potential for gaps, as well as the large size of the proofs of the sacrifices.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.msg1498806#msg1498806]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Announce/Commit Sacrifices ===&lt;br /&gt;
&lt;br /&gt;
To ensure that the miner collecting the sacrificed Bitcoin is picked at random the announce/commit sacrifice was proposed.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=134827.0 Purchasing fidelity bonds by provably throwing away bitcoins]&amp;lt;/ref&amp;gt; First a sacrifice transaction is prepared that either sacrifices value to transaction fees, or spends coins to an [[Script#Anyone-Can-Spend_Outputs|Anyone-Can-Spend Output]]. With [[nLockTime]] the transaction is made invalid until some time in the future.&lt;br /&gt;
&lt;br /&gt;
The second step is the announcement. The transaction is enclosed in another transaction as data, for instance by using a [[Script#Provably_Unspendable.2FPrunable_Outputs|prunable output]]. The announcement is then broadcast and is included in the blockchain, proving that anyone could have seen the inner transaction prior to it becoming valid.&lt;br /&gt;
&lt;br /&gt;
Finally the inner transaction becomes valid when the [[nLockTime]] is reached. Because mining is a random process, any miner can collect the value sacrified, and the purchaser of the fidelity bond has no control over where that value goes.&lt;br /&gt;
&lt;br /&gt;
The proof of the sacrifice is then two transactions: the proof the announcement transaction exists in the chain, and the proof that the inner sacrifice exists in the chain. (possibly with proof of the inner sacrifice inputs to prove what fees were actually paid)&lt;br /&gt;
&lt;br /&gt;
== Passports ==&lt;br /&gt;
&lt;br /&gt;
This wiki combats spam, while still allowing for users to sign up anonymously, by requiring users to pay a small amount of Bitcoins to the wiki before editing privileges are granted. Creating large numbers of &amp;quot;sock-puppets&amp;quot; to add spam content to articles is thus made expensive. The fee approach can be generalized with the concept of a Passport, first proposed by Mike Hearn,&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=140711.0 Creating Bitcoin passports using sacrifices]&amp;lt;/ref&amp;gt; tied to the users identity. Wikis, forums, webmail and other services can then create blacklists of users who violate the rules of the services, with those blacklists tied to passports.&lt;br /&gt;
&lt;br /&gt;
The advantage of fidelity bonds in that application over simply charging fees is re-usability of an identity across multiple services, as well as the neutrality: if the value required to create the passport provably does not go to the person adding the passport to a blacklist, there is no incentive to do so to collect new sign-up fees.&lt;br /&gt;
&lt;br /&gt;
== Financial Services ==&lt;br /&gt;
&lt;br /&gt;
Fidelity bonds can be used to make financial fraud unprofitable. For instance one early proposal&amp;lt;ref&amp;gt;[http://sourceforge.net/mailarchive/message.php?msg_id=29185108 Trusted identities]&amp;lt;/ref&amp;gt; was to use fidelity bonds - called &amp;quot;Trusted identities&amp;quot; by the proposals author - to create decentralized [[Green address|green addresses]]. Someone wishing for their transactions to be accepted without confirmations would first purchase a fidelity bond of some value tied to their identity. Someone determining if they should accept a payment without confirmations can check that the bond was sufficiently expensive to make it unprofitable for the sender to commit fraud. If the sender does commit fraud by double-spending the payment, the recipient can prove that fraud to the world by providing both transactions spending the same inputs. This proof is added to some sort of blacklisted, centralized or decentralized, which later recipients can consult to determine if the fidelity bond is now invalidated.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=37047</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=37047"/>
		<updated>2013-04-15T10:08:28Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Anyone-Can-Spend Outputs */ add detail&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some of the more complicated opcodes are disabled out of concern that the client might have a bug in their implementation; if a transaction using such an opcode were to be included in the chain any fix would risk forking the chain. &lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address ===&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;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&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;
=== Standard Generation Transaction ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key. By default the reference implementation uses this form for coinbase payment, and scriptPubKeys of this transaction form are recognized as payments to user. The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&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;
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; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&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;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 is an example, and acts to donate 0.125BTC to the miner who mined the transaction. Another use is to add data to a transaction, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc&lt;br /&gt;
&lt;br /&gt;
Note that this mechanism is not yet a standard transaction type, and thus will not be relayed by nodes on mainnet.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction with a message ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to add arbitrary data to any transaction by just adding some data along with OP_DROP. Scripts are limited to 10,000 bytes and 201 instructions, and each individual instruction/value is limited to 520 bytes.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&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;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt;&lt;br /&gt;
|OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|The message has been put.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|Top stack item has been removed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
|Checking signature against the public key.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Stack holds the value of signature check now.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&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;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=User:Petertodd&amp;diff=37044</id>
		<title>User:Petertodd</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=User:Petertodd&amp;diff=37044"/>
		<updated>2013-04-15T08:36:25Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; &amp;lt;nowiki&amp;gt;-----BEGIN PGP SIGNED MESSAGE-----&lt;br /&gt;
Hash: SHA1&lt;br /&gt;
&lt;br /&gt;
https://en.bitcoin.it/wiki/User:Petertodd is the bitcoin.it wiki page of&lt;br /&gt;
Peter Todd, AKA retep on bitcointalk&lt;br /&gt;
&lt;br /&gt;
https://github.com/petertodd&lt;br /&gt;
-----BEGIN PGP SIGNATURE-----&lt;br /&gt;
Version: GnuPG v1.4.11 (GNU/Linux)&lt;br /&gt;
&lt;br /&gt;
iQEcBAEBAgAGBQJRa7vzAAoJEH+rEUJn5PoExOIIAJgkrxVkMwTAl1pEbRmSwIJt&lt;br /&gt;
PAoafHdVUaKieM/L/LhRIA1Uw+87oJXNVwuNsCUSpiY0x4GfQyZdbIz7Yd8nViU8&lt;br /&gt;
KVyI/tswBwtq+hPtiS5LROwqeeiLtcZJrr8sOXTkucDA/mFLB+D+efEPaW10uEJJ&lt;br /&gt;
PP0C0/cwS/s01msXjLOqYUVLK3bknkWCKnEgs8+QssRwZqWHjKSwhr23+ywv1jjM&lt;br /&gt;
q9IL74F3fS2NvY7oV0c3y0GH3xMVBXYWEllYfHs6IZNWIX65HX8YKTyEgpDdmi0O&lt;br /&gt;
cN3P6RLgTa1kk97/3+S+CaaeE1eOaDq8UVHKEFOtvCKzn94itlG3qrZPhbaG+4s=&lt;br /&gt;
=K/Lo&lt;br /&gt;
-----END PGP SIGNATURE-----&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=User:Petertodd&amp;diff=37043</id>
		<title>User:Petertodd</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=User:Petertodd&amp;diff=37043"/>
		<updated>2013-04-15T08:35:35Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Update with actual URL to prevent copying&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; &amp;lt;nowiki&amp;gt;-----BEGIN PGP SIGNED MESSAGE-----&lt;br /&gt;
Hash: SHA1&lt;br /&gt;
&lt;br /&gt;
https://en.bitcoin.it/wiki/User:Petertodd is the bitcoin.it wiki page of Peter Todd, AKA retep on bitcointalk&lt;br /&gt;
&lt;br /&gt;
https://github.com/petertodd&lt;br /&gt;
-----BEGIN PGP SIGNATURE-----&lt;br /&gt;
Version: GnuPG v1.4.11 (GNU/Linux)&lt;br /&gt;
&lt;br /&gt;
iQEcBAEBAgAGBQJRa7usAAoJEH+rEUJn5PoE8pUH/jug1qtKIa5uacU2DbgQlrtE&lt;br /&gt;
xG1uONAIHrAA2bnMh9b7M19YlFoB1RsdoOQjm9ptg9EfBtNG27gACyNSHqlP9TTu&lt;br /&gt;
a7eqk6+55xpuXAbhEUbEWeGfzZ7nRDNN2vzdmKwwSR7e44j1zv20CdMOWlDzGHjP&lt;br /&gt;
ETNBUEjiVtqiXBZZQtVI5ViBG5atiQVuiaWQ+4qecH64hrTgi6e9lkT8TgvIPUwL&lt;br /&gt;
6SGp9fmygdynAO0TABxR4uYQxDupqbGCiex726AFbhDMpHtszTovnFyvndE7wRtB&lt;br /&gt;
yuTY47FaaO6U274CxLMO3J+S2am013TOreiFWs/k9/k9UtoFw9xFLMriSX6afYk=&lt;br /&gt;
=qC0E&lt;br /&gt;
-----END PGP SIGNATURE-----&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37005</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=37005"/>
		<updated>2013-04-14T21:53:43Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Merge content with &amp;#039;original proposal&amp;#039; link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you have followed a link to this page from reddit or elsewhere discussing Mike Hearn&#039;s assurance contracts proposal to fund network security, please see [https://bitcointalk.org/index.php?topic=157141.msg1665332#msg1665332|the discussion on bitcointalk] for the original document. Below is a general discussion of how network security is funded now and could be in the future, including Mike&#039;s proposal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example; what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is or will be.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use&lt;br /&gt;
an off-chain payment system to move the funds instead, either one denominated&lt;br /&gt;
in Bitcoins, or in a different currency entirely; the availability of off-chain&lt;br /&gt;
transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=36986</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=36986"/>
		<updated>2013-04-14T12:09:38Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Inflation Subsidy */ wording&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example; what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is or will be.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use&lt;br /&gt;
an off-chain payment system to move the funds instead, either one denominated&lt;br /&gt;
in Bitcoins, or in a different currency entirely; the availability of off-chain&lt;br /&gt;
transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=36985</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=36985"/>
		<updated>2013-04-14T12:02:39Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Mike: The wiki needs a general page on funding network security; create a specific page for your specific assurance contract stuff if you want. Mike (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example; what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use&lt;br /&gt;
an off-chain payment system to move the funds instead, either one denominated&lt;br /&gt;
in Bitcoins, or in a different currency entirely; the availability of off-chain&lt;br /&gt;
transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Maximum_transaction_rate&amp;diff=36983</id>
		<title>Maximum transaction rate</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Maximum_transaction_rate&amp;diff=36983"/>
		<updated>2013-04-14T11:13:16Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Trust-free Combining */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The maximum transaction rate is the block size limit divided by the average transaction size. The block size limit is well known, 1MB, however the average transaction size isn&#039;t. Here we&#039;ll look at what influences that size.&lt;br /&gt;
&lt;br /&gt;
The minimum sized transaction type&amp;lt;ref name=&amp;quot;mintxsize&amp;quot;&amp;gt;Even smaller transactions can be made by using empty scriptPubKeys, however such transactions are not secure because anyone can spend them.&amp;lt;/ref&amp;gt; is the [[Script#Standard_Generation_Transaction|OP_CHECKSIG transaction]]:&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;33 byte compressed pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;72 byte signature&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each transaction input requires at least 41 bytes for the previous transaction reference and other headers and each transaction output requires an additional 9 bytes of headers. Finally every transaction has a header at least 10 bytes long. Added up we get 166 bytes for the minimum-sized Bitcoin transaction. For 1MB (1,000,000 byte) blocks this implies a theoretical maximum rate of 10tx/s.&lt;br /&gt;
&lt;br /&gt;
However [[Change|change]] complicates the situation. It isn&#039;t always possible for a client to find a transaction input of the size required. Thus client software will included additional outputs to themselves for the change, and similarly they will include additional inputs to collect change outputs together when no one output is large enough.&lt;br /&gt;
&lt;br /&gt;
Users with large wallets, in particular [[eWallets]] such as Instawallet or large exchanges like Mt. Gox are most likely to be able to find transaction outputs of a suitable size for any given payment. It&#039;s conceivable that if transaction fees are high enough in the future users who trust each other may get together to use each others wallets to make payments as a way to avoid transaction fees, with the balances settled periodically by some other means.&lt;br /&gt;
&lt;br /&gt;
== Trust-free Combining ==&lt;br /&gt;
&lt;br /&gt;
Users can also combine their transactions to make them slightly smaller, and possibly improve privacy. A transaction is invalid until every transaction input is signed for, thus multiple users can create a joint transaction with no risk of their funds being stolen. This reduces average transaction size by 10 bytes, the size of the per-transaction header. Using this technique aggressively results in 156 byte average transactions, or 10.7tx/s.&lt;br /&gt;
&lt;br /&gt;
== Lower-bound transaction rate ==&lt;br /&gt;
&lt;br /&gt;
A reasonable, conservative, assumption is to assume that every transaction requires two outputs, including change, and two inputs, consuming change. Assuming that trust-free combining is not used gives us 322 byte transactions, or 5.2tx/s.&lt;br /&gt;
&lt;br /&gt;
Actual real-world rates will likely be somewhere between those numbers, although equally rates may be less as well if multi-signature transactions are become popular; the figure 7tx/s is commonly quoted as a &#039;ball-park&#039; approximation in discussions of the [[Scalability|blocksize limit]].&lt;br /&gt;
&lt;br /&gt;
== Footnotes ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Maximum_transaction_rate&amp;diff=36982</id>
		<title>Maximum transaction rate</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Maximum_transaction_rate&amp;diff=36982"/>
		<updated>2013-04-14T11:12:52Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Lower-bound transaction rate */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The maximum transaction rate is the block size limit divided by the average transaction size. The block size limit is well known, 1MB, however the average transaction size isn&#039;t. Here we&#039;ll look at what influences that size.&lt;br /&gt;
&lt;br /&gt;
The minimum sized transaction type&amp;lt;ref name=&amp;quot;mintxsize&amp;quot;&amp;gt;Even smaller transactions can be made by using empty scriptPubKeys, however such transactions are not secure because anyone can spend them.&amp;lt;/ref&amp;gt; is the [[Script#Standard_Generation_Transaction|OP_CHECKSIG transaction]]:&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;33 byte compressed pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;72 byte signature&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each transaction input requires at least 41 bytes for the previous transaction reference and other headers and each transaction output requires an additional 9 bytes of headers. Finally every transaction has a header at least 10 bytes long. Added up we get 166 bytes for the minimum-sized Bitcoin transaction. For 1MB (1,000,000 byte) blocks this implies a theoretical maximum rate of 10tx/s.&lt;br /&gt;
&lt;br /&gt;
However [[Change|change]] complicates the situation. It isn&#039;t always possible for a client to find a transaction input of the size required. Thus client software will included additional outputs to themselves for the change, and similarly they will include additional inputs to collect change outputs together when no one output is large enough.&lt;br /&gt;
&lt;br /&gt;
Users with large wallets, in particular [[eWallets]] such as Instawallet or large exchanges like Mt. Gox are most likely to be able to find transaction outputs of a suitable size for any given payment. It&#039;s conceivable that if transaction fees are high enough in the future users who trust each other may get together to use each others wallets to make payments as a way to avoid transaction fees, with the balances settled periodically by some other means.&lt;br /&gt;
&lt;br /&gt;
== Trust-free Combining ==&lt;br /&gt;
&lt;br /&gt;
Users can also combine their transactions to make them slightly smaller, and possibly improve privacy. A transaction is invalid until every transaction input is signed for, thus multiple users can create a joint transaction with no risk of their funds being stolen. This reduces average transaction size by 10 bytes; the size of the per-transaction header. Using this technique aggressively results in 156 byte average transactions, or 10.7tx/s.&lt;br /&gt;
&lt;br /&gt;
== Lower-bound transaction rate ==&lt;br /&gt;
&lt;br /&gt;
A reasonable, conservative, assumption is to assume that every transaction requires two outputs, including change, and two inputs, consuming change. Assuming that trust-free combining is not used gives us 322 byte transactions, or 5.2tx/s.&lt;br /&gt;
&lt;br /&gt;
Actual real-world rates will likely be somewhere between those numbers, although equally rates may be less as well if multi-signature transactions are become popular; the figure 7tx/s is commonly quoted as a &#039;ball-park&#039; approximation in discussions of the [[Scalability|blocksize limit]].&lt;br /&gt;
&lt;br /&gt;
== Footnotes ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Maximum_transaction_rate&amp;diff=36981</id>
		<title>Maximum transaction rate</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Maximum_transaction_rate&amp;diff=36981"/>
		<updated>2013-04-14T11:11:55Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Add ball-park figure&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The maximum transaction rate is the block size limit divided by the average transaction size. The block size limit is well known, 1MB, however the average transaction size isn&#039;t. Here we&#039;ll look at what influences that size.&lt;br /&gt;
&lt;br /&gt;
The minimum sized transaction type&amp;lt;ref name=&amp;quot;mintxsize&amp;quot;&amp;gt;Even smaller transactions can be made by using empty scriptPubKeys, however such transactions are not secure because anyone can spend them.&amp;lt;/ref&amp;gt; is the [[Script#Standard_Generation_Transaction|OP_CHECKSIG transaction]]:&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;33 byte compressed pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;72 byte signature&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each transaction input requires at least 41 bytes for the previous transaction reference and other headers and each transaction output requires an additional 9 bytes of headers. Finally every transaction has a header at least 10 bytes long. Added up we get 166 bytes for the minimum-sized Bitcoin transaction. For 1MB (1,000,000 byte) blocks this implies a theoretical maximum rate of 10tx/s.&lt;br /&gt;
&lt;br /&gt;
However [[Change|change]] complicates the situation. It isn&#039;t always possible for a client to find a transaction input of the size required. Thus client software will included additional outputs to themselves for the change, and similarly they will include additional inputs to collect change outputs together when no one output is large enough.&lt;br /&gt;
&lt;br /&gt;
Users with large wallets, in particular [[eWallets]] such as Instawallet or large exchanges like Mt. Gox are most likely to be able to find transaction outputs of a suitable size for any given payment. It&#039;s conceivable that if transaction fees are high enough in the future users who trust each other may get together to use each others wallets to make payments as a way to avoid transaction fees, with the balances settled periodically by some other means.&lt;br /&gt;
&lt;br /&gt;
== Trust-free Combining ==&lt;br /&gt;
&lt;br /&gt;
Users can also combine their transactions to make them slightly smaller, and possibly improve privacy. A transaction is invalid until every transaction input is signed for, thus multiple users can create a joint transaction with no risk of their funds being stolen. This reduces average transaction size by 10 bytes; the size of the per-transaction header. Using this technique aggressively results in 156 byte average transactions, or 10.7tx/s.&lt;br /&gt;
&lt;br /&gt;
== Lower-bound transaction rate ==&lt;br /&gt;
&lt;br /&gt;
A reasonable, conservative, assumption is to assume that every transaction requires two outputs, including change, and two inputs, consuming change. Assuming that trust-free combining is not used gives us 322 byte transactions, or 5.2tx/s.&lt;br /&gt;
&lt;br /&gt;
Actual real-world rates will likely be somewhere between those numbers, although equally rates may be less as well if multi-signature transactions are become popular; the figure 7tx/s is commonly quoted as a &#039;ball-park&#039; approximation in discussions of the [[blocksize limit]].&lt;br /&gt;
&lt;br /&gt;
== Footnotes ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=36980</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=36980"/>
		<updated>2013-04-14T10:59:28Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: /* Inflation Subsidy */ Add ref&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example; what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine, an activity that can be seen as an attack.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=69423.0 Miners that refuse to include transactions are becoming a problem]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use&lt;br /&gt;
an off-chain payment system to move the funds instead, either one denominated&lt;br /&gt;
in Bitcoins, or in a different currency entirely; the availability of off-chain&lt;br /&gt;
transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=36979</id>
		<title>Funding network security</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Funding_network_security&amp;diff=36979"/>
		<updated>2013-04-14T10:58:00Z</updated>

		<summary type="html">&lt;p&gt;Petertodd: Wording&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What Bitcoin provides is a means to determine what is the consensus version&lt;br /&gt;
of the transaction history, with the consensus determined by what a majority of&lt;br /&gt;
hashing power applied to the proof of work problem by miners accepts as the&lt;br /&gt;
true history. Since those who own Bitcoins, and who have access to hashing&lt;br /&gt;
power, are not necessarily the same group there needs to be a mechanism for the&lt;br /&gt;
former to fund the latter. The risk is that mechanism failing, and the majority&lt;br /&gt;
of hashing power acting in a way that is against the wishes of the majority of&lt;br /&gt;
economic interests.&lt;br /&gt;
&lt;br /&gt;
An attacker with a majority of hashing power can either publish blocks they&lt;br /&gt;
mine as they mine them, or withhold them. The former simply makes it impossible&lt;br /&gt;
to get transactions confirmed that the attacker does not wish to be confirmed.&lt;br /&gt;
The latter however can be used to rewrite the blockchain after the fact,&lt;br /&gt;
causing transactions that appeared to be confirmed to become unconfirmed and&lt;br /&gt;
vulnerable to reversal. In addition the attacker can exploit [[Transaction Malleability]] to make it impossible for those transactions to ever be included&lt;br /&gt;
in the blockchain again.&lt;br /&gt;
&lt;br /&gt;
The hashing power majority does not need to constitute a single individual or&lt;br /&gt;
coherent group. For instance the economic majority may see [[fungibility]] as&lt;br /&gt;
important, and thus want to ensure transaction outputs can not be blacklisted&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157130.0 Decentralised crime fighting using private set intersection protocols]&amp;lt;/ref&amp;gt; to prevent transactions spending them from being confirmed,&lt;br /&gt;
even if those outputs are known to be involved with illegal activity such as theft or fraud.&lt;br /&gt;
However the actions of mining pools are usually public knowledge; which blocks&lt;br /&gt;
they mine is usually published on the pool website. If mining a transaction&lt;br /&gt;
output known to be involved in illegal activity is made illegal, mining pools&lt;br /&gt;
may independently seek out sources of information on transaction outputs known&lt;br /&gt;
to be involved in illegal activity, and prohibit transactions spending those&lt;br /&gt;
outputs from the blocks they mine, as well as delibrately trying to mine blocks&lt;br /&gt;
that would [[Orphan Block|orphan blocks]] with such transactions.&lt;br /&gt;
&lt;br /&gt;
Similarly it could be made illegal to mine a transaction if the identity of the&lt;br /&gt;
person making the transaction is not known, in conjunction with ways for&lt;br /&gt;
transactions to make that identity public. Again, even if the economic majority&lt;br /&gt;
would prefer to be able to make anonymous transactions, the hashing power&lt;br /&gt;
majority may not want to take that risk.&lt;br /&gt;
&lt;br /&gt;
Conversely the opposite may be true in either example; what &amp;quot;security&amp;quot; is may not always be obvious or easily agreed upon.&lt;br /&gt;
&lt;br /&gt;
== Inflation Subsidy ==&lt;br /&gt;
&lt;br /&gt;
Currently each block [[Controlled_Currency_Supply|creates 25 BTC]] as the block&lt;br /&gt;
reward; as of April 2013 that inflates the currency supply by about 11% per&lt;br /&gt;
year, in effect transferring 11% of the value of all the Bitcoins in existence&lt;br /&gt;
to miners to pay for the security they provide. However, every four years the&lt;br /&gt;
block reward is decreased by half, thus halving the overall inflation subsidy&lt;br /&gt;
that pays miners.&lt;br /&gt;
&lt;br /&gt;
The inflation subsidy pays miners directly from Bitcoin as a whole; in effect&lt;br /&gt;
everyone holding Bitcoins is paying for security directly. However at some&lt;br /&gt;
point it will become small enough that Bitcoin could be attacked by someone&lt;br /&gt;
with very little resources. In addition a miner can still collect the inflation&lt;br /&gt;
subsidy without including any transactions at all in the blocks they mine.&lt;br /&gt;
&lt;br /&gt;
It is predicted that the inflation subsidy will reach less than 1% of the&lt;br /&gt;
Bitcoin nominal market cap sometime in 2033. However that figure is subject to&lt;br /&gt;
the amount of [[lost coins]] from the early days of Bitcoin; it is unknown what&lt;br /&gt;
the market cap of coins with owners able to spend them actually is.&lt;br /&gt;
&lt;br /&gt;
== Transaction Fees ==&lt;br /&gt;
&lt;br /&gt;
Transactions may include [[transaction_fees|fees]] which are given to the miner&lt;br /&gt;
who included the transaction in a block. These fees can range from 0% to 100%&lt;br /&gt;
of the transaction inputs technically speaking, although what is economically&lt;br /&gt;
practical is a subset of that.&lt;br /&gt;
&lt;br /&gt;
Fees can align the economic interests of Bitcoin users with the interests of&lt;br /&gt;
miners. For instance in the above example of anonymous transactions fees can&lt;br /&gt;
encourage miners to mine anonymous transactions regardless of the legal risk,&lt;br /&gt;
or to take (possibly expensive) measures to reduce that risk.&lt;br /&gt;
&lt;br /&gt;
=== The Blocksize Limit ===&lt;br /&gt;
&lt;br /&gt;
Currently blocks are limited to 1MB in size, and further limited by &amp;quot;gentlemans&lt;br /&gt;
agreement&amp;quot; in the form of a 500KB default maximum. While miners can choose to&lt;br /&gt;
mine blocks exceeding the 500KB limit, the 1MB limit is fixed and any block&lt;br /&gt;
larger than it is invalid; block space is a scarce resource. Provided that the&lt;br /&gt;
demand for transactions is greater than about [[Maximum transaction rate|seven&lt;br /&gt;
per second]] we can expect transaction fees to be greater than the marginal&lt;br /&gt;
costs required to accept a transaction, thus creating a profit that can be used&lt;br /&gt;
to fund the operation of hashing power.&lt;br /&gt;
&lt;br /&gt;
=== Off-chain Transactions ===&lt;br /&gt;
&lt;br /&gt;
If making a transaction becomes too expensive it can become worthwhile to use&lt;br /&gt;
an off-chain payment system to move the funds instead, either one denominated&lt;br /&gt;
in Bitcoins, or in a different currency entirely; the availability of off-chain&lt;br /&gt;
transactions limits the maximum fees that miners can charge, in turn limiting the value of transactions as a way to fund security.&lt;br /&gt;
&lt;br /&gt;
== Alternatives ==&lt;br /&gt;
&lt;br /&gt;
If transaction fees and the inflation subsidy do not pay for adequate security&lt;br /&gt;
alternatives exist. In particular users who own Bitcoins, yet do not perform&lt;br /&gt;
transactions, possibly because they are holding onto their Bitcoins as an&lt;br /&gt;
investment and/or use off-chain transactions, only pay for security through the&lt;br /&gt;
inflation subsidy.&lt;br /&gt;
&lt;br /&gt;
In addition one approach to the [[scalability|scalability problem]] posed by&lt;br /&gt;
the current 1MB blocksize limit is to remove or increase that limit. Without&lt;br /&gt;
the blocksize limit it is expected that transaction fees will fall to the&lt;br /&gt;
[[marginal costs of a transaction]], which means that fees will not pay for any&lt;br /&gt;
security at all.&lt;br /&gt;
&lt;br /&gt;
=== Individual ===&lt;br /&gt;
&lt;br /&gt;
As individuals Bitcoin owners can fund network security in a variety of ways,&lt;br /&gt;
including artifical fee-paying transactions, paying abnormally high fees,&lt;br /&gt;
donating directly to known miners, and operating their own mining equipment.&lt;br /&gt;
The latter two methods have the advantage that the donator has control over the&lt;br /&gt;
policy followed by the miner being funded.&lt;br /&gt;
&lt;br /&gt;
However mining is a public good: any individual can also simply hope that&lt;br /&gt;
others will fund security for them, also known as the&lt;br /&gt;
[http://en.wikipedia.org/wiki/Free_rider_problem free rider problem].&lt;br /&gt;
&lt;br /&gt;
=== Assurance Contracts ===&lt;br /&gt;
&lt;br /&gt;
An assurance contract, also known as a provision point mechanism, is a game&lt;br /&gt;
theoretic mechanism and a financial technology that facilitates the voluntary&lt;br /&gt;
creation of public goods and club goods in the face of the free rider&lt;br /&gt;
problem.&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Assurance_contract&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The free rider problem is that there may be actions that would benefit a large&lt;br /&gt;
group of people, but once the action is taken, there is no way to exclude those&lt;br /&gt;
who did not pay for the action from the benefits. In Bitcoin the problem is&lt;br /&gt;
that mining is costly and benefits everyone who owns Bitcoins and/or performs&lt;br /&gt;
transactions. A mining assurance contract needs to be constructed in such a way&lt;br /&gt;
that participants agree that if some large amount of funds are commited, those&lt;br /&gt;
funds will go to mining in some way, with the amount set to be large enough for&lt;br /&gt;
a sufficiently high percentage of the economic activity of Bitcoin must have&lt;br /&gt;
participated to avoid the free rider problem.&lt;br /&gt;
&lt;br /&gt;
Bitcoin already supports assurance contracts as a transaction&lt;br /&gt;
type&amp;lt;ref&amp;gt;[[Contracts#Example_3:_Assurance_contracts]]&amp;lt;/ref&amp;gt; - for a&lt;br /&gt;
mining assurance contract the transaction output would be set to either an&lt;br /&gt;
[[Script#Anyone-Can-Spend_Outputs|anyone can spend]] output, or an address owned&lt;br /&gt;
by a specific miner. However as-is they have a serious problem: a miner can&lt;br /&gt;
always collect the funds pledged to date by simply adding a sufficient amount&lt;br /&gt;
of their own funds to the outstanding contract, and mining that transaction&lt;br /&gt;
themselves, thus turning the contract into a simple&lt;br /&gt;
donation.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1821770#msg1821770]&amp;lt;/ref&amp;gt;&lt;br /&gt;
(modulo the small chance of the block being orphaned; if the chance is large, the assurance contract is not encouraging orderly mining) The problem can be mitigated somewhat by forcing donators to reveal their identity in a provable way, but then high participation is difficult to achieve.&lt;br /&gt;
&lt;br /&gt;
With [[nLockTime]] a transaction can be created where the miner who will&lt;br /&gt;
actually collect it is unknown in advance. As the deadline approaches, if the&lt;br /&gt;
contract is not fully funded, participants double-spend their pledged&lt;br /&gt;
transaction outputs to invalidate the contract. However this mechanism has the&lt;br /&gt;
problem that anyone can make the contract fail, even if it is fully funded.&lt;br /&gt;
That problem can be solved if Bitcoin&#039;s scripting language is extended to allow&lt;br /&gt;
for transaction outputs that can only be spent by transactions following&lt;br /&gt;
certain forms - the outputs would be locked to the contract until some time&lt;br /&gt;
after the contract&lt;br /&gt;
expires.&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=157141.msg1822138#msg1822138]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=157141.0 Bitcointalk thread]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Petertodd</name></author>
	</entry>
</feed>