<?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=Jhyslop</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=Jhyslop"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/wiki/Special:Contributions/Jhyslop"/>
	<updated>2026-04-06T00:21:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Help:FAQ&amp;diff=7093</id>
		<title>Help:FAQ</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Help:FAQ&amp;diff=7093"/>
		<updated>2011-04-10T18:38:40Z</updated>

		<summary type="html">&lt;p&gt;Jhyslop: /* General - added question about lost bitcoins */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you will find answers to the most commonly asked questions.&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
=== What are bitcoins? ===&lt;br /&gt;
Bitcoins are the unit of currency of the Bitcoin system. A commonly used shorthand for this is “BTC” to refer to a price or amount (eg: “100 BTC”)&lt;br /&gt;
A Bitcoin isn&#039;t actually a &#039;thing&#039; you can point at. It is just a number associated with a [[Address|Bitcoin Address]]. See also an [[Introduction|easy intro]] to bitcoin.&lt;br /&gt;
&lt;br /&gt;
=== How are new Bitcoins created? ===&lt;br /&gt;
&lt;br /&gt;
[[File:total_bitcoins_over_time_graph.png|thumb|Number of bitcoins over time, assuming a perfect 10-minute interval.]]&lt;br /&gt;
New coins are generated by a network node each time it finds the solution to a certain mathematical problem (i.e. creates a new [[block]]), which is difficult to perform and can demonstrate a [[proof of work]].  The reward for solving a block is [[controlled inflation|automatically adjusted]] so that in the first 4 years of the Bitcoin network, 10,500,000 BTC will be created. The amount is halved each 4 years, so it will be 5,250,000 over years 4-8, 2,625,000 over years 8-12 and so on. Thus the total number of coins will approach 21,000,000 BTC over time.&lt;br /&gt;
&lt;br /&gt;
In addition, built into the network is a system that attempts to allocate new coins in blocks about every 10 minutes, on average, somewhere on the network.  As the number of people who attempt to generate these new coins changes, the difficulty of creating new coins changes.  This happens in a manner that is agreed upon by the network as a whole, based upon the time taken to generate the previous 2016 blocks.  The difficulty is therefore related to the average computing resources devoted to generate these new coins over the time it took to create these previous blocks.  The likelihood of somebody &amp;quot;discovering&amp;quot; one of these blocks is based on the computer they are using compared to all of the computers also generating blocks on the network.&lt;br /&gt;
&lt;br /&gt;
=== What&#039;s the current total amount of Bitcoins in existence?  ===&lt;br /&gt;
&lt;br /&gt;
[http://blockexplorer.com/q/totalbc Current count]&lt;br /&gt;
&lt;br /&gt;
The number of blocks times the coin value of a block is the number of coins in existence. The coin value of a block is 50 BTC for each of the first 210,000 blocks, 25 BTC for the next 210,000 blocks, then 12.5 BTC, 6.25 BTC and so on.&lt;br /&gt;
&lt;br /&gt;
=== How divisible are Bitcoins?  ===&lt;br /&gt;
&lt;br /&gt;
Technically, a Bitcoin can be divided down to 8 decimals using existing data structures, so 0.00000001 BTC is the smallest amount currently possible.  Discussions about and ideas for ways to provide for even smaller quantities of Bitcoins may be created in the future if the need for them ever arises. For convenience, the program currently accepts only 2 decimal places as quantities smaller than 0.01 BTC are considered of trivial value and are usually used only to attack the network.&lt;br /&gt;
&lt;br /&gt;
=== How does the halving work when the number gets really small? ===&lt;br /&gt;
&lt;br /&gt;
The reward will go from 0.00000001 BTC to 0. Then no more coins will likely be created.  &lt;br /&gt;
&lt;br /&gt;
The calculation is done as a right bitwise shift of a 64-bit signed integer, which means it is divided by 2 and rounded down. The integer is equal to the value in BTC * 100,000,000. This is how all Bitcoin balances/values are stored internally.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that using current rules this will take nearly 100 years before it becomes an issue and Bitcoins may change considerably before that happens.&lt;br /&gt;
&lt;br /&gt;
=== How long will it take to generate all the coins? ===&lt;br /&gt;
&lt;br /&gt;
The last block that will generate coins will be block #6,929,999. This should be generated around year 2140. Then the total number of coins in circulation will remain static at 20,999,999.9769 BTC.&lt;br /&gt;
&lt;br /&gt;
Even if the allowed precision is expanded from the current 8 decimals, the total BTC in circulation will always be slightly below 21 million (assuming everything else stays the same). For example, with 16 decimals of precision, the end total would be 20999999.999999999496 BTC.&lt;br /&gt;
&lt;br /&gt;
=== If no more coins are going to be generated, will more blocks be created? ===&lt;br /&gt;
&lt;br /&gt;
Absolutely!  Even before the creation of coins ends, the use of [[transaction fee|transaction fees]] will likely make creating new blocks more valuable from the fees than the new coins being created.  When coin generation ends, what will sustain the ability to use bitcoins will be these fees entirely.  There will be blocks generated after block #6,929,999, assuming that people are still using Bitcoins at that time.&lt;br /&gt;
&lt;br /&gt;
=== But if no more coins are generated, what happens when Bitcoins are lost? Won&#039;t that be a problem? ===&lt;br /&gt;
&lt;br /&gt;
Not at all. Because of the law of supply and demand, when fewer Bitcoins are available the ones that are left will be in higher demand, and therefore will have a higher value. So when Bitcoins are lost, the the remaining Bitcoins will increase in value to compensate. As the value of Bitcoins increase, the number of Bitcoins required to purchase an item &#039;&#039;&#039;de&#039;&#039;&#039;creases. This is known as a [[Deflationary spiral|deflationary economic model]]. Eventually, if and when it gets to the point where the largest transaction is less that 1BTC, then it&#039;s a simple matter of shifting the decimal place to the right a few places, and the system continues.&lt;br /&gt;
&lt;br /&gt;
==Economy==&lt;br /&gt;
=== Where does the value of Bitcoin stem from? What backs up Bitcoin? ===&lt;br /&gt;
Bitcoins have value because they are accepted as payment by many. See the [[Trade|list of Bitcoin-accepting sites]].&lt;br /&gt;
&lt;br /&gt;
When we say that a currency is backed up by gold, we mean that there&#039;s a promise in place that you can exchange the currency for gold. In a sense, you could say that Bitcoin is &amp;quot;backed up&amp;quot; by the price tags of merchants – a price tag is a promise to exchange goods for a specified amount of currency.&lt;br /&gt;
&lt;br /&gt;
It&#039;s a common misconception that Bitcoins gain their value from the cost of electricity required to generate them. Cost doesn&#039;t equal value – hiring 1,000 men to shovel a big hole in the ground may be costly, but not valuable. Also, even though scarcity is a critical requirement for a useful currency, it alone doesn&#039;t make anything valuable. For example, your fingerprints are scarce, but that doesn&#039;t mean they have any exchange value.&lt;br /&gt;
&lt;br /&gt;
=== What if someone bought up all the existing Bitcoins? ===&lt;br /&gt;
What if somebody bought up all the gold in the world? Well, by attempting to buy it all, the buyer would just drive the prices up until he runs out of money.&lt;br /&gt;
&lt;br /&gt;
=== Bitcoin&#039;s monetary policy causes a deflationary spiral ===&lt;br /&gt;
See the article [[Deflationary spiral]].&lt;br /&gt;
&lt;br /&gt;
==Networking==&lt;br /&gt;
=== Do I need to configure my firewall to run bitcoin? ===&lt;br /&gt;
&lt;br /&gt;
Bitcoin will connect to other nodes, usually on tcp port 8333. You will need to allow outgoing TCP connections to port 8333 if you want to allow your bitcoin client to connect to many nodes. Bitcoin will also try to connect to IRC (tcp port 6667) to meet other nodes to connect to.&lt;br /&gt;
&lt;br /&gt;
If you want to restrict your firewall rules to a few ips and/or don&#039;t want to allow IRC connection, you can find stable nodes in the [[Fallback Nodes|fallback nodes list]].  If your provider blocks the common IRC ports, note that lfnet also listens on port 7777.  Connecting to this alternate port currently requires either recompiling Bitcoin, or changing routing rules.  For example, on Linux you can evade a port 6667 block by doing something like this:&lt;br /&gt;
&lt;br /&gt;
 echo 173.246.103.92 irc.lfnet.org &amp;gt;&amp;gt; /etc/hosts&lt;br /&gt;
 iptables -t nat -A OUTPUT -p tcp --dest 173.246.103.92 --dport 6667 -j DNAT --to-destination :7777 -m comment --comment &amp;quot;bitcoind irc connection&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== How does the peer finding mechanism work? ===&lt;br /&gt;
Bitcoin finds peers primarily by connecting to an IRC server (channel #bitcoin on irc.lfnet.org). If a connection to the IRC server cannot be established (like when connecting through TOR), an in-built node list will be used and the nodes will be queried for more node addresses.&lt;br /&gt;
&lt;br /&gt;
==Help==&lt;br /&gt;
===I&#039;d like to learn more.  Where can I get help?===&lt;br /&gt;
&lt;br /&gt;
* Read the [[Introduction|introduction to bitcoin]] &lt;br /&gt;
* See the videos, podcasts, and blog posts from the [[Press]]&lt;br /&gt;
* Read and post on the [[Bitcoin:Community_portal#Bitcoin_Community_Forums|forums]]&lt;br /&gt;
* Chat on one of the [[Bitcoin:Community_portal#IRC_Chat|Bitcoin IRC]] channels&lt;br /&gt;
* Listen to [http://omegataupodcast.net/2011/03/59-bitcoin-a-digital-decentralized-currency/ this podcast], which goes into the details of how bitcoin works&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Man page]]&lt;br /&gt;
&lt;br /&gt;
[[zh-cn:FAQ]]&lt;br /&gt;
[[fr:FAQ]]&lt;br /&gt;
{{fromold|bitcoins}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Jhyslop</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Protocol_rules&amp;diff=5539</id>
		<title>Protocol rules</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Protocol_rules&amp;diff=5539"/>
		<updated>2011-03-17T01:02:32Z</updated>

		<summary type="html">&lt;p&gt;Jhyslop: /* Removed redundant step (old step 9) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Rules&#039;&#039;&#039; for [[:Category:Clients|clients]].&lt;br /&gt;
&lt;br /&gt;
The wiki substantially documents the [[Protocol_specification|Bitcoin protocol]], but equally important are the rules used by the client to process messages. It&#039;s crucial that clients follow certain rules in order to maintain consistency across the network, and to protect the Bitcoin security guarantees.&lt;br /&gt;
&lt;br /&gt;
Here, the focus is on handling tx and block messages, because that is the tricky logic. This will skip over the method of requesting and forwarding these messages for now, and describe what to do when they are received. Also, this will describe the minimal data structures in rather abstract terms, ignoring the client&#039;s various indexes, maps and hash tables used for efficiency. This will be a conceptual description. This is all based on a fairly literal reading of the source code.&lt;br /&gt;
&lt;br /&gt;
Mining (block generation) rules are not yet presented.&lt;br /&gt;
&lt;br /&gt;
== Data structures ==&lt;br /&gt;
&lt;br /&gt;
The main data structures are [[transactions]] and [[blocks]]. Blocks are composed of the &#039;&#039;block header&#039;&#039; followed by transactions in the block. Transactions are identified by their hash; blocks by the hash of their header. Blocks have prev pointers that link them into a graph.&lt;br /&gt;
&lt;br /&gt;
Conceptually, the client has the following data structures:&lt;br /&gt;
&lt;br /&gt;
=== Transactions ===&lt;br /&gt;
&lt;br /&gt;
There are two collections of transactions:&lt;br /&gt;
&lt;br /&gt;
;transaction pool&lt;br /&gt;
: an unordered collection of transactions that are not in blocks in the main chain, but for which we have input transactions&lt;br /&gt;
&lt;br /&gt;
;orphan transactions&lt;br /&gt;
: transactions that can&#039;t go into the pool due to one or more missing input transactions&lt;br /&gt;
&lt;br /&gt;
=== Blocks ===&lt;br /&gt;
&lt;br /&gt;
There are 3 categories of blocks:&lt;br /&gt;
&lt;br /&gt;
;blocks in the main branch&lt;br /&gt;
: the transactions in these blocks are considered at least tentatively confirmed&lt;br /&gt;
&lt;br /&gt;
;blocks on side branches off the main branch&lt;br /&gt;
: these blocks have at least tentatively lost the race to be in the main branch&lt;br /&gt;
&lt;br /&gt;
;orphan blocks&lt;br /&gt;
: these are blocks which don&#039;t link into the main branch, normally because of a missing predecessor or nth-level predecessor&lt;br /&gt;
&lt;br /&gt;
Blocks in the first two categories form a tree rooted at the genesis block, linked by the prev pointer, which points toward the root. (It is a very linear tree with few and short branches off the main branch.) The main branch is defined as the branch with highest total difficulty, summing the difficulties for each block in the branch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== [[Protocol_specification#tx|&amp;quot;tx&amp;quot;]] messages ==&lt;br /&gt;
&lt;br /&gt;
These messages hold a single transaction.&lt;br /&gt;
&lt;br /&gt;
# Check syntactic correctness&lt;br /&gt;
# Make sure neither in or out lists are empty&lt;br /&gt;
# Size in bytes &amp;lt; MAX_BLOCK_SIZE&lt;br /&gt;
# Each output value, as well as the total, must be in legal money range&lt;br /&gt;
# Make sure none of the inputs have hash=0, n=-1 (&#039;&#039;coinbase&#039;&#039; transactions)&lt;br /&gt;
# Check that nLockTime &amp;lt;= INT_MAX&amp;lt;ref&amp;gt;nLockTime must not exceed 32 bites, as some clients will interpret it incorrectly&amp;lt;/ref&amp;gt;, size in bytes &amp;gt;= 100&amp;lt;ref&amp;gt;A valid transaction requires at least 100 bytes. If it&#039;s any less, the transaction is not valid&amp;lt;/ref&amp;gt;, and sig opcount &amp;lt;= 2&amp;lt;ref&amp;gt;The number of signature operands in the signature (no, that is not redundant) for standard transactions will never exceed two&amp;lt;/ref&amp;gt;&lt;br /&gt;
# Reject &amp;quot;nonstandard&amp;quot; transactions: scriptSig doing anything other than pushing numbers on the stack, or scriptPubkey not matching the two usual forms&amp;lt;ref&amp;gt;Note that this is not a hard requirement on clients.&amp;lt;/ref&amp;gt;&lt;br /&gt;
# Reject if we already have matching tx in the pool, or in a block in the main branch&lt;br /&gt;
# Reject if any other tx in the pool uses the same transaction output as one used by this tx.&amp;lt;ref&amp;gt;This is the protection against double-spending&amp;lt;/ref&amp;gt;&lt;br /&gt;
# For each input, look in the main branch and the transaction pool to find the referenced output transaction. If the output transaction is missing for any input, this will be an orphan transaction. Add to the orphan transactions, if a matching transaction is not in there already.&lt;br /&gt;
# For each input, if we are using the &#039;&#039;n&#039;&#039;th output of the earlier transaction, but it has fewer than n+1 outputs, reject this transaction&lt;br /&gt;
# For each input, if the referenced output transaction is coinbase (i.e. only 1 input, with hash=0, n=-1), it must have at least COINBASE_MATURITY confirmations; else reject this transaction&lt;br /&gt;
# Verify crypto signatures for each input; reject if any are bad&lt;br /&gt;
# For each input, if the referenced output has already been spent by a transaction in the main branch, reject this transaction&lt;br /&gt;
# Using the referenced output transactions to get input values, check that each input value, as well as the sum, are in legal money range&lt;br /&gt;
# Reject if the sum of input values &amp;lt; sum of output values&lt;br /&gt;
# Reject if transaction fee (defined as sum of input values minus sum of output values) would be too low to get into an empty block&lt;br /&gt;
# Add to transaction pool&amp;lt;ref&amp;gt;Note that when the transaction is accepted into the memory pool, an additional check is made to ensure that the coinbase value does not exceed the transaction fees plus the expected BTC value (50BTC as of this writing).&amp;lt;/ref&amp;gt;&lt;br /&gt;
# &amp;quot;Add to wallet if mine&amp;quot;&lt;br /&gt;
# Relay transaction to peers&lt;br /&gt;
# For each orphan transaction that uses this one as one of its inputs, run all these steps (including this one) recursively on that orphan&lt;br /&gt;
&lt;br /&gt;
===Explanation of Some Rules===&lt;br /&gt;
Most rules are self-explanatory. This section explains why some of the less obvious rules are in place.&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [[Protocol_specification#block|&amp;quot;block&amp;quot;]] messages ==&lt;br /&gt;
&lt;br /&gt;
These messages hold a single block.&lt;br /&gt;
&lt;br /&gt;
# Check syntactic correctness&lt;br /&gt;
# Reject if duplicate of block we have in any of the three categories&lt;br /&gt;
# Transaction list must be non-empty&lt;br /&gt;
# Block hash must satisfy claimed &#039;&#039;nBits&#039;&#039; proof of work&lt;br /&gt;
# Block timestamp must not be more than two hours in the future&lt;br /&gt;
# First transaction must be coinbase (i.e. only 1 input, with hash=0, n=-1), the rest must not be&lt;br /&gt;
# For each transaction, apply &amp;quot;tx&amp;quot; checks 2-4&lt;br /&gt;
# For the coinbase (first) transaction, scriptSig length must be 2-100&lt;br /&gt;
# Reject if sum of transaction sig opcounts &amp;gt; MAX_BLOCK_SIGOPS&lt;br /&gt;
# Verify Merkle hash&lt;br /&gt;
# Check if prev block (matching &#039;&#039;prev&#039;&#039; hash) is in main branch or side branches. If not, add this to orphan blocks, then query peer we got this from for 1st missing orphan block in &#039;&#039;prev&#039;&#039; chain; done with block&lt;br /&gt;
# Check that &#039;&#039;nBits&#039;&#039; value matches the difficulty rules&lt;br /&gt;
# Reject if timestamp is before prev block (for a complicated definition of &amp;quot;before&amp;quot;)&lt;br /&gt;
# For certain old blocks (i.e. on initial block download) check that hash matches known values&lt;br /&gt;
# Add block into the tree. There are three cases: 1. block further extends the main branch; 2. block extends a side branch but does not add enough difficulty to make it become the new main branch; 3. block extends a side branch and makes it the new main branch.&lt;br /&gt;
# For case 1, adding to main branch:&lt;br /&gt;
## For all but the coinbase transaction, apply the following:&lt;br /&gt;
### For each input, look in the main branch to find the referenced output transaction. Reject if the output transaction is missing for any input.&lt;br /&gt;
### For each input, if we are using the &#039;&#039;n&#039;&#039;th output of the earlier transaction, but it has fewer than n+1 outputs, reject.&lt;br /&gt;
### For each input, if the referenced output transaction is coinbase (i.e. only 1 input, with hash=0, n=-1), it must have at least COINBASE_MATURITY confirmations; else reject.&lt;br /&gt;
### Verify crypto signatures for each input; reject if any are bad&lt;br /&gt;
### For each input, if the referenced output has already been spent by a transaction in the main branch, reject&lt;br /&gt;
### Using the referenced output transactions to get input values, check that each input value, as well as the sum, are in legal money range&lt;br /&gt;
### Reject if the sum of input values &amp;lt; sum of output values&lt;br /&gt;
## Reject if coinbase value &amp;gt; sum of block creation fee and transaction fees&lt;br /&gt;
## (If we have not rejected):&lt;br /&gt;
## For each transaction, &amp;quot;Add to wallet if mine&amp;quot;&lt;br /&gt;
## For each transaction in the block, delete any matching transaction from the transaction pool&lt;br /&gt;
## Relay block to our peers&lt;br /&gt;
## If we rejected, the block is not counted as part of the main branch&lt;br /&gt;
# For case 2, adding to a side branch, we don&#039;t do anything.&lt;br /&gt;
# For case 3, a side branch becoming the main branch:&lt;br /&gt;
## Find the &#039;&#039;fork&#039;&#039; block on the main branch which this side branch forks off of&lt;br /&gt;
## Redefine the main branch to only go up to this &#039;&#039;fork&#039;&#039; block&lt;br /&gt;
## For each block on the side branch, from the child of the &#039;&#039;fork&#039;&#039; block to the leaf, add to the main branch:&lt;br /&gt;
### Do &amp;quot;branch&amp;quot; checks 3-11&lt;br /&gt;
### For all but the coinbase transaction, apply the following:&lt;br /&gt;
#### For each input, look in the main branch to find the referenced output transaction. Reject if the output transaction is missing for any input.&lt;br /&gt;
#### For each input, if we are using the &#039;&#039;n&#039;&#039;th output of the earlier transaction, but it has fewer than n+1 outputs, reject.&lt;br /&gt;
#### For each input, if the referenced output transaction is coinbase (i.e. only 1 input, with hash=0, n=-1), it must have at least COINBASE_MATURITY confirmations; else reject.&lt;br /&gt;
#### Verify crypto signatures for each input; reject if any are bad&lt;br /&gt;
#### For each input, if the referenced output has already been spent by a transaction in the main branch, reject&lt;br /&gt;
#### Using the referenced output transactions to get input values, check that each input value, as well as the sum, are in legal money range&lt;br /&gt;
#### Reject if the sum of input values &amp;lt; sum of output values&lt;br /&gt;
### Reject if coinbase value &amp;gt; sum of block creation fee and transaction fees&lt;br /&gt;
### (If we have not rejected):&lt;br /&gt;
### For each transaction, &amp;quot;Add to wallet if mine&amp;quot;&lt;br /&gt;
## If we reject at any point, leave the main branch as what it was originally, done with block&lt;br /&gt;
## For each block in the old main branch, from the leaf down to the child of the &#039;&#039;fork&#039;&#039; block:&lt;br /&gt;
### For each non-coinbase transaction in the block:&lt;br /&gt;
#### Apply &amp;quot;tx&amp;quot; checks 2-9, except in step 8, only look in the transaction pool for duplicates, not the main branch&lt;br /&gt;
#### Add to transaction pool if accepted, else go on to next transaction&lt;br /&gt;
## For each block in the new main branch, from the child of the &#039;&#039;fork&#039;&#039; node to the leaf:&lt;br /&gt;
### For each transaction in the block, delete any matching transaction from the transaction pool&lt;br /&gt;
## Relay block to our peers&lt;br /&gt;
# For each orphan block for which this block is its &#039;&#039;prev&#039;&#039;, run all these steps (including this one) recursively on that orphan&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Protocol specification]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]][[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Jhyslop</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Protocol_rules&amp;diff=5537</id>
		<title>Protocol rules</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Protocol_rules&amp;diff=5537"/>
		<updated>2011-03-17T00:57:57Z</updated>

		<summary type="html">&lt;p&gt;Jhyslop: /* Add explanation of why some rules exist */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Rules&#039;&#039;&#039; for [[:Category:Clients|clients]].&lt;br /&gt;
&lt;br /&gt;
The wiki substantially documents the [[Protocol_specification|Bitcoin protocol]], but equally important are the rules used by the client to process messages. It&#039;s crucial that clients follow certain rules in order to maintain consistency across the network, and to protect the Bitcoin security guarantees.&lt;br /&gt;
&lt;br /&gt;
Here, the focus is on handling tx and block messages, because that is the tricky logic. This will skip over the method of requesting and forwarding these messages for now, and describe what to do when they are received. Also, this will describe the minimal data structures in rather abstract terms, ignoring the client&#039;s various indexes, maps and hash tables used for efficiency. This will be a conceptual description. This is all based on a fairly literal reading of the source code.&lt;br /&gt;
&lt;br /&gt;
Mining (block generation) rules are not yet presented.&lt;br /&gt;
&lt;br /&gt;
== Data structures ==&lt;br /&gt;
&lt;br /&gt;
The main data structures are [[transactions]] and [[blocks]]. Blocks are composed of the &#039;&#039;block header&#039;&#039; followed by transactions in the block. Transactions are identified by their hash; blocks by the hash of their header. Blocks have prev pointers that link them into a graph.&lt;br /&gt;
&lt;br /&gt;
Conceptually, the client has the following data structures:&lt;br /&gt;
&lt;br /&gt;
=== Transactions ===&lt;br /&gt;
&lt;br /&gt;
There are two collections of transactions:&lt;br /&gt;
&lt;br /&gt;
;transaction pool&lt;br /&gt;
: an unordered collection of transactions that are not in blocks in the main chain, but for which we have input transactions&lt;br /&gt;
&lt;br /&gt;
;orphan transactions&lt;br /&gt;
: transactions that can&#039;t go into the pool due to one or more missing input transactions&lt;br /&gt;
&lt;br /&gt;
=== Blocks ===&lt;br /&gt;
&lt;br /&gt;
There are 3 categories of blocks:&lt;br /&gt;
&lt;br /&gt;
;blocks in the main branch&lt;br /&gt;
: the transactions in these blocks are considered at least tentatively confirmed&lt;br /&gt;
&lt;br /&gt;
;blocks on side branches off the main branch&lt;br /&gt;
: these blocks have at least tentatively lost the race to be in the main branch&lt;br /&gt;
&lt;br /&gt;
;orphan blocks&lt;br /&gt;
: these are blocks which don&#039;t link into the main branch, normally because of a missing predecessor or nth-level predecessor&lt;br /&gt;
&lt;br /&gt;
Blocks in the first two categories form a tree rooted at the genesis block, linked by the prev pointer, which points toward the root. (It is a very linear tree with few and short branches off the main branch.) The main branch is defined as the branch with highest total difficulty, summing the difficulties for each block in the branch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== [[Protocol_specification#tx|&amp;quot;tx&amp;quot;]] messages ==&lt;br /&gt;
&lt;br /&gt;
These messages hold a single transaction.&lt;br /&gt;
&lt;br /&gt;
# Check syntactic correctness&lt;br /&gt;
# Make sure neither in or out lists are empty&lt;br /&gt;
# Size in bytes &amp;lt; MAX_BLOCK_SIZE&lt;br /&gt;
# Each output value, as well as the total, must be in legal money range&lt;br /&gt;
# Make sure none of the inputs have hash=0, n=-1 (&#039;&#039;coinbase&#039;&#039; transactions)&lt;br /&gt;
# Check that nLockTime &amp;lt;= INT_MAX&amp;lt;ref&amp;gt;nLockTime must not exceed 32 bites, as some clients will interpret it incorrectly&amp;lt;/ref&amp;gt;, size in bytes &amp;gt;= 100&amp;lt;ref&amp;gt;A valid transaction requires at least 100 bytes. If it&#039;s any less, the transaction is not valid&amp;lt;/ref&amp;gt;, and sig opcount &amp;lt;= 2&amp;lt;ref&amp;gt;The number of signature operands in the signature (no, that is not redundant) for standard transactions will never exceed two&amp;lt;/ref&amp;gt;&lt;br /&gt;
# Reject &amp;quot;nonstandard&amp;quot; transactions: scriptSig doing anything other than pushing numbers on the stack, or scriptPubkey not matching the two usual forms&amp;lt;ref&amp;gt;Note that this is not a hard requirement on clients.&amp;lt;/ref&amp;gt;&lt;br /&gt;
# Reject if we already have matching tx in the pool, or in a block in the main branch&lt;br /&gt;
# Reject if any other tx in the pool uses the same transaction output as one used by this tx.&amp;lt;ref&amp;gt;This is the protection against double-spending&amp;lt;/ref&amp;gt;&lt;br /&gt;
# For each input, look in the main branch and the transaction pool to find the referenced output transaction. If the output transaction is missing for any input, this will be an orphan transaction. Add to the orphan transactions, if a matching transaction is not in there already.&lt;br /&gt;
# For each input, if we are using the &#039;&#039;n&#039;&#039;th output of the earlier transaction, but it has fewer than n+1 outputs, reject this transaction&lt;br /&gt;
# For each input, if the referenced output transaction is coinbase (i.e. only 1 input, with hash=0, n=-1), it must have at least COINBASE_MATURITY confirmations; else reject this transaction&lt;br /&gt;
# Verify crypto signatures for each input; reject if any are bad&lt;br /&gt;
# For each input, if the referenced output has already been spent by a transaction in the main branch, reject this transaction&lt;br /&gt;
# Using the referenced output transactions to get input values, check that each input value, as well as the sum, are in legal money range&lt;br /&gt;
# Reject if the sum of input values &amp;lt; sum of output values&lt;br /&gt;
# Reject if transaction fee (defined as sum of input values minus sum of output values) would be too low to get into an empty block&lt;br /&gt;
# Add to transaction pool&amp;lt;ref&amp;gt;Note that when the transaction is accepted into the memory pool, an additional check is made to ensure that the coinbase value does not exceed the transaction fees plus the expected BTC value (50BTC as of this writing).&amp;lt;/ref&amp;gt;&lt;br /&gt;
# &amp;quot;Add to wallet if mine&amp;quot;&lt;br /&gt;
# Relay transaction to peers&lt;br /&gt;
# For each orphan transaction that uses this one as one of its inputs, run all these steps (including this one) recursively on that orphan&lt;br /&gt;
&lt;br /&gt;
===Explanation of Some Rules===&lt;br /&gt;
Most rules are self-explanatory. This section explains why some of the less obvious rules are in place.&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [[Protocol_specification#block|&amp;quot;block&amp;quot;]] messages ==&lt;br /&gt;
&lt;br /&gt;
These messages hold a single block.&lt;br /&gt;
&lt;br /&gt;
# Check syntactic correctness&lt;br /&gt;
# Reject if duplicate of block we have in any of the three categories&lt;br /&gt;
# Transaction list must be non-empty&lt;br /&gt;
# Block hash must satisfy claimed &#039;&#039;nBits&#039;&#039; proof of work&lt;br /&gt;
# Block timestamp must not be more than two hours in the future&lt;br /&gt;
# First transaction must be coinbase (i.e. only 1 input, with hash=0, n=-1), the rest must not be&lt;br /&gt;
# For each transaction, apply &amp;quot;tx&amp;quot; checks 2-4&lt;br /&gt;
# For the coinbase (first) transaction, scriptSig length must be 2-100&lt;br /&gt;
# For the other transactions, reject if any input has hash=0, n=-1&lt;br /&gt;
# Reject if sum of transaction sig opcounts &amp;gt; MAX_BLOCK_SIGOPS&lt;br /&gt;
# Verify Merkle hash&lt;br /&gt;
# Check if prev block (matching &#039;&#039;prev&#039;&#039; hash) is in main branch or side branches. If not, add this to orphan blocks, then query peer we got this from for 1st missing orphan block in &#039;&#039;prev&#039;&#039; chain; done with block&lt;br /&gt;
# Check that &#039;&#039;nBits&#039;&#039; value matches the difficulty rules&lt;br /&gt;
# Reject if timestamp is before prev block (for a complicated definition of &amp;quot;before&amp;quot;)&lt;br /&gt;
# For certain old blocks (i.e. on initial block download) check that hash matches known values&lt;br /&gt;
# Add block into the tree. There are three cases: 1. block further extends the main branch; 2. block extends a side branch but does not add enough difficulty to make it become the new main branch; 3. block extends a side branch and makes it the new main branch.&lt;br /&gt;
# For case 1, adding to main branch:&lt;br /&gt;
## For all but the coinbase transaction, apply the following:&lt;br /&gt;
### For each input, look in the main branch to find the referenced output transaction. Reject if the output transaction is missing for any input.&lt;br /&gt;
### For each input, if we are using the &#039;&#039;n&#039;&#039;th output of the earlier transaction, but it has fewer than n+1 outputs, reject.&lt;br /&gt;
### For each input, if the referenced output transaction is coinbase (i.e. only 1 input, with hash=0, n=-1), it must have at least COINBASE_MATURITY confirmations; else reject.&lt;br /&gt;
### Verify crypto signatures for each input; reject if any are bad&lt;br /&gt;
### For each input, if the referenced output has already been spent by a transaction in the main branch, reject&lt;br /&gt;
### Using the referenced output transactions to get input values, check that each input value, as well as the sum, are in legal money range&lt;br /&gt;
### Reject if the sum of input values &amp;lt; sum of output values&lt;br /&gt;
## Reject if coinbase value &amp;gt; sum of block creation fee and transaction fees&lt;br /&gt;
## (If we have not rejected):&lt;br /&gt;
## For each transaction, &amp;quot;Add to wallet if mine&amp;quot;&lt;br /&gt;
## For each transaction in the block, delete any matching transaction from the transaction pool&lt;br /&gt;
## Relay block to our peers&lt;br /&gt;
## If we rejected, the block is not counted as part of the main branch&lt;br /&gt;
# For case 2, adding to a side branch, we don&#039;t do anything.&lt;br /&gt;
# For case 3, a side branch becoming the main branch:&lt;br /&gt;
## Find the &#039;&#039;fork&#039;&#039; block on the main branch which this side branch forks off of&lt;br /&gt;
## Redefine the main branch to only go up to this &#039;&#039;fork&#039;&#039; block&lt;br /&gt;
## For each block on the side branch, from the child of the &#039;&#039;fork&#039;&#039; block to the leaf, add to the main branch:&lt;br /&gt;
### Do &amp;quot;branch&amp;quot; checks 3-11&lt;br /&gt;
### For all but the coinbase transaction, apply the following:&lt;br /&gt;
#### For each input, look in the main branch to find the referenced output transaction. Reject if the output transaction is missing for any input.&lt;br /&gt;
#### For each input, if we are using the &#039;&#039;n&#039;&#039;th output of the earlier transaction, but it has fewer than n+1 outputs, reject.&lt;br /&gt;
#### For each input, if the referenced output transaction is coinbase (i.e. only 1 input, with hash=0, n=-1), it must have at least COINBASE_MATURITY confirmations; else reject.&lt;br /&gt;
#### Verify crypto signatures for each input; reject if any are bad&lt;br /&gt;
#### For each input, if the referenced output has already been spent by a transaction in the main branch, reject&lt;br /&gt;
#### Using the referenced output transactions to get input values, check that each input value, as well as the sum, are in legal money range&lt;br /&gt;
#### Reject if the sum of input values &amp;lt; sum of output values&lt;br /&gt;
### Reject if coinbase value &amp;gt; sum of block creation fee and transaction fees&lt;br /&gt;
### (If we have not rejected):&lt;br /&gt;
### For each transaction, &amp;quot;Add to wallet if mine&amp;quot;&lt;br /&gt;
## If we reject at any point, leave the main branch as what it was originally, done with block&lt;br /&gt;
## For each block in the old main branch, from the leaf down to the child of the &#039;&#039;fork&#039;&#039; block:&lt;br /&gt;
### For each non-coinbase transaction in the block:&lt;br /&gt;
#### Apply &amp;quot;tx&amp;quot; checks 2-9, except in step 8, only look in the transaction pool for duplicates, not the main branch&lt;br /&gt;
#### Add to transaction pool if accepted, else go on to next transaction&lt;br /&gt;
## For each block in the new main branch, from the child of the &#039;&#039;fork&#039;&#039; node to the leaf:&lt;br /&gt;
### For each transaction in the block, delete any matching transaction from the transaction pool&lt;br /&gt;
## Relay block to our peers&lt;br /&gt;
# For each orphan block for which this block is its &#039;&#039;prev&#039;&#039;, run all these steps (including this one) recursively on that orphan&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Protocol specification]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]][[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Jhyslop</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Privacy&amp;diff=4856</id>
		<title>Talk:Privacy</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Privacy&amp;diff=4856"/>
		<updated>2011-03-04T06:14:33Z</updated>

		<summary type="html">&lt;p&gt;Jhyslop: Created page with &amp;quot;I have been looking at the algorithm Bitcoin uses to choose coins. The algorithm does not lend itself to obscuring the trail of coin transfers. In fact, I think it makes it easie...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I have been looking at the algorithm Bitcoin uses to choose coins. The algorithm does not lend itself to obscuring the trail of coin transfers. In fact, I think it makes it easier for someone analyzing the transactions to figure out things.&lt;br /&gt;
&lt;br /&gt;
Suppose, for example, there is a transaction with two coins in and two coins out (one for the payment, one for the change). The source code randomizes which output is the payment, and which is the change, but in most cases it is trivial to look at the transaction and figure it out. For example, suppose there&#039;s a transaction with two inputs, 50 coins and 20 coins; and two outputs, 65 coins and 5 coins. It&#039;s pretty clear that the payment is 65 coins, and the change - &#039;&#039;which goes back to the owner&#039;&#039; - is 5 coins. You have now linked two coin transactions to a single person (whether or not you can identify that person is another matter).&lt;br /&gt;
&lt;br /&gt;
Or, suppose Bitcoin creates a transaction with several (or even many) coins on the input side. If an analyst links just one of those coins to you, that person now knows for certain that all the other coins in that transaction also belonged to you. So, for anonymity sake, the fewer the coins on the &#039;in&#039; side, the better.&lt;br /&gt;
&lt;br /&gt;
And, of course, if a transaction has one input and one output, it&#039;s a no-brainer to figure it out.&lt;br /&gt;
&lt;br /&gt;
The program uses what I call a &amp;quot;best fit&amp;quot; algorithm - i.e. it chooses one or more coins that come as close as possible to the exact value requested, giving preference to selecting a single coin with the exact payment value. So you will likely find many transactions that have multiple coins coming in, and one or two transactions out - the payment, and a small amount of change, or with exactly one input and one output. In either case, it&#039;s pretty easy to figure out what&#039;s going on.&lt;br /&gt;
&lt;br /&gt;
Fortunately, the default behaviour of the program is to choose a new key each time you receive a payment, so that&#039;s a plus at least.&lt;br /&gt;
&lt;br /&gt;
I don&#039;t know if this is the correct place to make these suggestions, but I would suggest modifying the standard Bitcoin program as follows:&lt;br /&gt;
&lt;br /&gt;
# Eliminate the transaction logging in the wallet. Your wallet should contain only the coins you haven&#039;t spent (after having been confirmed, of course). &lt;br /&gt;
# Accounting entries should never be linked to specific coins or addresses used to create that entry.&lt;br /&gt;
# Automatically &amp;quot;shuffle&amp;quot; the coins. By &amp;quot;shuffling&amp;quot; I mean generating transactions within your own wallet - take one or two coins, and pay them to a Bitcoin address - NOT an IP address - under your control. (Note that for this to work, transaction logging MUST be removed.) This helps strengthen the plausible deniability mentioned in the article: since the program automatically generates these transactions, if someone questions where a particular payment went to you can legitimately say you don&#039;t know. Transactions would created at random intervals (but ideally not more frequently than once every 10 minutes or so, to keep them on separate blocks), using coins selected at random, and the transaction would be chosen at random from the following list:&lt;br /&gt;
## Combine two coins into a single coin.&lt;br /&gt;
## split a single coin into two coins&lt;br /&gt;
## Rearrange two coins into two coins of different values, for example 5+2 in, 1+6 out. In order for this to be indistinguishable from an actual transaction, one output must be larger than the larger of the two inputs. In this example, the larger input is 5, so one output must be &amp;gt; 5. If not, then it will be obvious that this is a shuffling transaction. For example, if the outputs are 3+4, then you could obviously have paid with just the 5 BTC coin and there&#039;s no reason to include the 2BTC coin.&lt;br /&gt;
# Modify the coin selection routine to randomly choose one of the following algorithms:&lt;br /&gt;
## Select two coins, the value of each coin being greater than the value of the payment. For example, payment amount is 5. Choose 50+20 in, giving 65+5 out. In this case, the payment is 5 and the change is 65. Randomize which is the payment and which is the change.&lt;br /&gt;
## Select two coins, the value of each coin being smaller than the value of the payment. For example, payment amount is 65. Choose 50+20 in, 65+5 out. Randomize which is the payment and which is the change.&lt;br /&gt;
## Select two coins which equal exactly the payment amount (this matches the &amp;quot;combine two coins into a single coin&amp;quot; shuffle operation above).&lt;br /&gt;
## Select a single coin for payment, with a value much greater than the value of the payment (for some definition of &amp;quot;much greater&amp;quot;). About 2x the payment value is good, because then the payment and the change are about the same, and a snooper won&#039;t be able to tell which is which.&lt;br /&gt;
## Choose multiple coins such that the value of the payment is greater than the value of the smallest coin, but less than the value of the largest coin. For example, your payment is 7 BTC. Choose coins valued at 5, 8, and 10, giving a payment of 7 and change of 16.&lt;br /&gt;
## The existing &amp;quot;best fit&amp;quot; algorithm, modified so that it only selects a single coin with the exact value as a last resort.&lt;/div&gt;</summary>
		<author><name>Jhyslop</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Scalability&amp;diff=4833</id>
		<title>Talk:Scalability</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Scalability&amp;diff=4833"/>
		<updated>2011-03-03T23:51:07Z</updated>

		<summary type="html">&lt;p&gt;Jhyslop: Created page with &amp;quot;There is one major point that the page overlooks: the limitation on block creation.  Block creation is limited to an average of one block every ten minutes. Furthermore, block si...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There is one major point that the page overlooks: the limitation on block&lt;br /&gt;
creation.&lt;br /&gt;
&lt;br /&gt;
Block creation is limited to an average of one block every ten minutes.&lt;br /&gt;
Furthermore, block size (which includes the transactions in the block) is limited to 1,000,000 bytes.&lt;br /&gt;
&lt;br /&gt;
Each transaction requires 10 bytes, plus approximately 106 bytes for every&lt;br /&gt;
input and approximately 69 bytes for every output. The exact size depends&lt;br /&gt;
on the size of the public key, which I have not been able to confirm, but&lt;br /&gt;
the keys in my wallet.dat seem to be about 65 bytes each.&lt;br /&gt;
&lt;br /&gt;
If we assume that transactions average two inputs and two outputs, then&lt;br /&gt;
the average transaction size will be about 350 bytes &#039;&#039;(note that the main page assumes an average of 1KB per transaction)&#039;&#039;. If we further assume&lt;br /&gt;
that the block size will, in practice, be limited to 500,000 bytes because&lt;br /&gt;
the transaction fees increase as the block size increases, then that means&lt;br /&gt;
there will be, on average, approximately 1430 transactions per block. That&lt;br /&gt;
works out to an average of 2.5 transactions per second - &#039;&#039;&#039;well&#039;&#039;&#039; below&lt;br /&gt;
the stated goal of at least 4,000 transactions per second.&lt;br /&gt;
&lt;br /&gt;
Even if we assume only one input and one output per transaction, and that&lt;br /&gt;
each block will contain the full 1,000,000 bytes, that still works out to only 5,405&lt;br /&gt;
transactions per block, or 9 transactions per second.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, this is &#039;&#039;&#039;not&#039;&#039;&#039; a limitation that can be overcome by&lt;br /&gt;
simply increasing memory, or switching to a different ISP with more&lt;br /&gt;
bandwidth. It is a built-in limitation, designed to &#039;&#039;&#039;deliberately&#039;&#039;&#039;&lt;br /&gt;
slow down block creation. One solution is to somehow allow blocks to be freely created, while still keeping the rate of coin creation constant.&lt;br /&gt;
&lt;br /&gt;
The bottom line is that, &#039;&#039;as it sits&#039;&#039;, this system is not scalable.&lt;/div&gt;</summary>
		<author><name>Jhyslop</name></author>
	</entry>
</feed>