<?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=Simapple</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=Simapple"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/wiki/Special:Contributions/Simapple"/>
	<updated>2026-04-25T21:38:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Genesis_block&amp;diff=9254</id>
		<title>Genesis block</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Genesis_block&amp;diff=9254"/>
		<updated>2011-05-30T07:16:04Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;genesis block&#039;&#039;&#039; is the first block of a [[block chain]]. Modern versions of Bitcoin assign it block number 0, though older versions gave it number 1.&lt;br /&gt;
&lt;br /&gt;
== Main network genesis block ==&lt;br /&gt;
[http://blockexplorer.com/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f The block on Bitcoin Block Explorer]&lt;br /&gt;
&lt;br /&gt;
Here is a representation of the genesis block as it appeared in a comment in an old version of Bitcoin ([http://bitcoin.svn.sourceforge.net/viewvc/bitcoin/trunk/main.cpp?revision=133&amp;amp;view=markup&amp;amp;pathrev=170 line 1613]). The first section defines exactly all of the variables necessary to recreate the block. The second section is the block in standard printblock format, which contains shortened versions of the data in the first section.&lt;br /&gt;
&lt;br /&gt;
 GetHash()      = 0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f&lt;br /&gt;
 hashMerkleRoot = 0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b&lt;br /&gt;
 txNew.vin[0].scriptSig     = 486604799 4 0x736B6E616220726F662074756F6C69616220646E6F63657320666F206B6E697262206E6F20726F6C6C65636E61684320393030322F6E614A2F33302073656D695420656854&lt;br /&gt;
 txNew.vout[0].nValue       = 5000000000&lt;br /&gt;
 txNew.vout[0].scriptPubKey = 0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704 OP_CHECKSIG&lt;br /&gt;
 block.nVersion = 1&lt;br /&gt;
 block.nTime    = 1231006505&lt;br /&gt;
 block.nBits    = 0x1d00ffff&lt;br /&gt;
 block.nNonce   = 2083236893&lt;br /&gt;
 &lt;br /&gt;
 CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)&lt;br /&gt;
   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)&lt;br /&gt;
     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)&lt;br /&gt;
     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)&lt;br /&gt;
   vMerkleTree: 4a5e1e&lt;br /&gt;
&lt;br /&gt;
The coinbase parameter (seen above in hex) contains, along with the normal data, the following text&amp;lt;ref&amp;gt;[http://uk.reuters.com/article/idUKPTIP32510920090103 Reuters&#039; reference on The Financial Times article]&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 The Times 03/Jan/2009 Chancellor on brink of second bailout for banks&lt;br /&gt;
&lt;br /&gt;
This was probably intended as proof that the block was created on or after January 3rd, 2009, as well as a comment on the instability caused by fractional-reserve banking.&lt;br /&gt;
&lt;br /&gt;
The first 50BTC block reward went to [[address]] [http://blockexplorer.com/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa] and has yet to be spent (2011-03-04).&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[zh-cn:创世block]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Genesis_block&amp;diff=9253</id>
		<title>Genesis block</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Genesis_block&amp;diff=9253"/>
		<updated>2011-05-30T07:14:24Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;genesis block&#039;&#039;&#039; is the first block of a [[block chain]]. Modern versions of Bitcoin assign it block number 0, though older versions gave it number 1.&lt;br /&gt;
&lt;br /&gt;
== Main network genesis block ==&lt;br /&gt;
[http://blockexplorer.com/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f The block on Bitcoin Block Explorer]&lt;br /&gt;
&lt;br /&gt;
Here is a representation of the genesis block as it appeared in a comment in an old version of Bitcoin ([http://bitcoin.svn.sourceforge.net/viewvc/bitcoin/trunk/main.cpp?revision=133&amp;amp;view=markup&amp;amp;pathrev=170 line 1613]). The first section defines exactly all of the variables necessary to recreate the block. The second section is the block in standard printblock format, which contains shortened versions of the data in the first section.&lt;br /&gt;
&lt;br /&gt;
 GetHash()      = 0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f&lt;br /&gt;
 hashMerkleRoot = 0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b&lt;br /&gt;
 txNew.vin[0].scriptSig     = 486604799 4 0x736B6E616220726F662074756F6C69616220646E6F63657320666F206B6E697262206E6F20726F6C6C65636E61684320393030322F6E614A2F33302073656D695420656854&lt;br /&gt;
 txNew.vout[0].nValue       = 5000000000&lt;br /&gt;
 txNew.vout[0].scriptPubKey = 0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704 OP_CHECKSIG&lt;br /&gt;
 block.nVersion = 1&lt;br /&gt;
 block.nTime    = 1231006505&lt;br /&gt;
 block.nBits    = 0x1d00ffff&lt;br /&gt;
 block.nNonce   = 2083236893&lt;br /&gt;
 &lt;br /&gt;
[[zh-cn:创世block]]&lt;br /&gt;
 CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)&lt;br /&gt;
   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)&lt;br /&gt;
     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)&lt;br /&gt;
     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)&lt;br /&gt;
   vMerkleTree: 4a5e1e&lt;br /&gt;
&lt;br /&gt;
The coinbase parameter (seen above in hex) contains, along with the normal data, the following text&amp;lt;ref&amp;gt;[http://uk.reuters.com/article/idUKPTIP32510920090103 Reuters&#039; reference on The Financial Times article]&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 The Times 03/Jan/2009 Chancellor on brink of second bailout for banks&lt;br /&gt;
&lt;br /&gt;
This was probably intended as proof that the block was created on or after January 3rd, 2009, as well as a comment on the instability caused by fractional-reserve banking.&lt;br /&gt;
&lt;br /&gt;
The first 50BTC block reward went to [[address]] [http://blockexplorer.com/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa] and has yet to be spent (2011-03-04).&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Block&amp;diff=9248</id>
		<title>Block</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Block&amp;diff=9248"/>
		<updated>2011-05-30T06:41:52Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Data is permanently recorded in the Bitcoin network through &#039;&#039;&#039;blocks&#039;&#039;&#039;. Each block contains all recent [[transactions]], a [[nonce]] (random number), and the [[hash]] of the previous block. A block is &amp;quot;solved&amp;quot; (published and considered valid by peers) when the SHA-256 hash of the entire block is below the current [[target]]. This is very unlikely to occur after being hashed only once, so the nonce must be incremented and the block re-hashed millions of times until it does. &lt;br /&gt;
&lt;br /&gt;
Bitcoin transactions are broadcast to the [[network]] by the sender, and all peers generating coins collect them and add them to the block they&#039;re working on. If the transaction is much larger than the average transaction size, a small [[transaction fee]] may be charged.&lt;br /&gt;
&lt;br /&gt;
The first transaction in the block is special: it creates new [[Bitcoins]] for the person who generated it. Other peers will only accept the block if this transaction is of the correct amount. The number of [[Bitcoins]] generated per block starts at 50 and is halved every 210,000 blocks (about four years).&lt;br /&gt;
&lt;br /&gt;
The network tries to create 6 blocks per hour. Every 2016 blocks (about two weeks), all Bitcoin clients compare the actual number created with this goal and modify the target by the percentage that it varied. This increases (or decreases) the difficulty of generating blocks.&lt;br /&gt;
&lt;br /&gt;
The client accepts the &#039;longest&#039; chain of blocks as valid. The &#039;length&#039; of the entire [[block chain]] refers to the chain with the most combined difficulty, not the one with the most blocks. This prevents someone from forking the chain and creating a large number of low-difficulty blocks, and having it accepted by the network as &#039;longest&#039;. &lt;br /&gt;
&lt;br /&gt;
== Common Questions about Blocks ==&lt;br /&gt;
&lt;br /&gt;
=== How many blocks are there? ===&lt;br /&gt;
[http://blockexplorer.com/q/getblockcount Current block count]&lt;br /&gt;
&lt;br /&gt;
=== What is the maximum number of blocks? ===&lt;br /&gt;
There is no maximum number, blocks just keep getting added to the end of the chain at an average rate of one every 10 minutes.&lt;br /&gt;
&lt;br /&gt;
==== Even when all 21 million coins have been generated? ====&lt;br /&gt;
Yes. The blocks are for proving that transactions existed at a particular time. Transactions will still occur once all the coins have been generated, so blocks will still be created as long as people are trading Bitcoins.&lt;br /&gt;
&lt;br /&gt;
=== How long will it take me to generate a block? ===&lt;br /&gt;
No-one can say exactly. There is a [[Generation Calculator|generation calculator]] that will tell you how long it &#039;&#039;&#039;might&#039;&#039;&#039; take.&lt;br /&gt;
&lt;br /&gt;
=== What if I&#039;m 1% towards calculating a block and...? ===&lt;br /&gt;
There&#039;s no such thing as being 1% towards solving a block.  You don&#039;t make progress towards solving it.  After working on it for 24 hours, your chances of solving it are equal to what your chances were at the start or at any moment.&lt;br /&gt;
&lt;br /&gt;
It&#039;s like trying to flip 37 coins at once and have them all come up heads.  Each time you try, your chances of success are the same.&lt;br /&gt;
&lt;br /&gt;
=== Where can I find more technical detail? ===&lt;br /&gt;
There is more technical detail on the [[block hashing algorithm]] page.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.bitcoin.it/wiki/File:Total_bitcoins_over_time_graph.png Total Bitcoins Over Time]&lt;br /&gt;
&lt;br /&gt;
{{fromold|block}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Blocs]][[zh-cn:Block]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Category:Mining&amp;diff=9247</id>
		<title>Category:Mining</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Category:Mining&amp;diff=9247"/>
		<updated>2011-05-30T06:39:08Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Reprinted from the [[How_bitcoin_works#Bitcoin_mining|How Bitcoin works]] page:&lt;br /&gt;
&lt;br /&gt;
== High Level Description ==&lt;br /&gt;
&#039;&#039;&#039;Mining&#039;&#039;&#039; bitcoins is the process of generating [[blocks]] for the [[block chain]], which is a way of processing and verifying [[transactions]]. Adding a block to the block chain is difficult, requiring time and processing power to accomplish. So what incentive does anyone have to spend the effort to produce a block, if it takes up all these resources? The answer is that the person who manages to produce a block gets a reward. This reward is two-fold. First, the block producer gets a bounty of some number of bitcoins, which is agreed-upon by the network. (Currently this bounty is 50 bitcoins; this value will halve every 210,000 blocks.) Second, any transaction fees that may be present in the transactions included in the block, get claimed by the block producer.&lt;br /&gt;
&lt;br /&gt;
This gives rise to the activity known as &amp;quot;bitcoin mining&amp;quot; - using processing power to try to produce a valid block, and as a result &#039;mine&#039; some bitcoins. The network rules are such that the difficulty is adjusted to keep block production to approximately 1 block per 10 minutes. Thus, the more miners engage in the mining activity, the more difficult it becomes for each individual miner to produce a block. The higher the total difficulty, the harder it is for an attacker to overwrite the tip of the block chain with his own blocks (which enables him to double-spend his coins. See the [[weaknesses]] page for more details).&lt;br /&gt;
&lt;br /&gt;
Besides being important for maintaining the transaction database, mining is also the mechanism by which bitcoins get created and distributed among the people in the bitcoin economy. The network rules are such that over the next hundred years, give or take a few decades, a total of 21 million bitcoins will be created. Rather than dropping money out of a helicopter, the bitcoins are awarded to those who contribute to the network by creating blocks in the block chain.&lt;br /&gt;
[[zh-cn:Category:开采]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=User:Simapple&amp;diff=9214</id>
		<title>User:Simapple</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=User:Simapple&amp;diff=9214"/>
		<updated>2011-05-29T11:01:25Z</updated>

		<summary type="html">&lt;p&gt;Simapple: Created page with &amp;quot;bitcoin: 1CLPyRuKK8wLDsG9C2Avuerc54fjYjfWbi zh-cn:User:Simapple&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;bitcoin: 1CLPyRuKK8wLDsG9C2Avuerc54fjYjfWbi&lt;br /&gt;
[[zh-cn:User:Simapple]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=API_reference_(JSON-RPC)&amp;diff=9213</id>
		<title>API reference (JSON-RPC)</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=API_reference_(JSON-RPC)&amp;diff=9213"/>
		<updated>2011-05-29T10:37:01Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Controlling Bitcoin ==&lt;br /&gt;
&lt;br /&gt;
Run &#039;&#039;bitcoind&#039;&#039; or &#039;&#039;bitcoin -server&#039;&#039;. You can control it via the command-line or by [http://json-rpc.org/wiki/specification| HTTP JSON-RPC] commands.&lt;br /&gt;
&lt;br /&gt;
You must create a bitcoin.conf configuration file setting an rpcuser and rpcpassword; see [[Running Bitcoin]] for details.&lt;br /&gt;
&lt;br /&gt;
Now run:&lt;br /&gt;
  $ ./bitcoind&lt;br /&gt;
  bitcoin server starting&lt;br /&gt;
  $ ./bitcoind help&lt;br /&gt;
  # shows the help text&lt;br /&gt;
&lt;br /&gt;
A [[Original Bitcoin client/API Calls list|list of RPC calls]] will be shown.&lt;br /&gt;
&lt;br /&gt;
  $ ./bitcoind getbalance&lt;br /&gt;
  2000.00000&lt;br /&gt;
&lt;br /&gt;
== JSON-RPC ==&lt;br /&gt;
&lt;br /&gt;
Running Bitcoin with the -server argument (or running bitcoind) tells it to function as a [http://json-rpc.org/wiki/specification| HTTP JSON-RPC] server, but &lt;br /&gt;
[http://en.wikipedia.org/wiki/Basic_access_authentication Basic access authentication] must be used when communicating with it, and, for security, by default, the server only accepts connections from other processes on the same machine.  If your HTTP or JSON library requires you to specify which &#039;realm&#039; is authenticated, use &#039;jsonrpc&#039;.&lt;br /&gt;
&lt;br /&gt;
Bitcoin supports SSL (https) JSON-RPC connections beginning with version 0.3.14.  See the [[Enabling SSL on original client daemon|rpcssl wiki page]] for setup instructions and a list of all bitcoin.conf configuration options.&lt;br /&gt;
&lt;br /&gt;
To access the server you should find a [http://json-rpc.org/wiki/implementations|suitable library] for your language.&lt;br /&gt;
&lt;br /&gt;
== Proper money handling ==&lt;br /&gt;
&lt;br /&gt;
See the [[Proper Money Handling (JSON-RPC)|proper money handling page]] for notes on avoiding rounding errors when handling bitcoin values.&lt;br /&gt;
&lt;br /&gt;
== Python ==&lt;br /&gt;
&lt;br /&gt;
[http://json-rpc.org/wiki/python-json-rpc python-jsonrpc] is the official JSON-RPC implementation for Python.&lt;br /&gt;
It automatically generates Python methods for RPC calls.&lt;br /&gt;
However, due to its design for supporting old versions of Python, it is also rather inefficient.&lt;br /&gt;
[[User:jgarzik|jgarzik]] has forked it as [https://github.com/jgarzik/python-bitcoinrpc Python-BitcoinRPC] and optimized it for current versions (at least Python 2.6+, though not 3.x).&lt;br /&gt;
Generally, this version is recommended.&lt;br /&gt;
&lt;br /&gt;
While BitcoinRPC lacks a few obscure features from jsonrpc, software using only the ServiceProxy class can be written the same to work with either version the user might choose to install:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
  from jsonrpc import ServiceProxy&lt;br /&gt;
  &lt;br /&gt;
  access = ServiceProxy(&amp;quot;http://user:password@127.0.0.1:8332&amp;quot;)&lt;br /&gt;
  access.getinfo()&lt;br /&gt;
  access.listreceivedbyaddress(6)&lt;br /&gt;
  #access.sendtoaddress(&amp;quot;11yEmxiMso2RsFVfBcCa616npBvGgxiBX&amp;quot;, 10)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ruby ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
=begin&lt;br /&gt;
Make sure to do:&lt;br /&gt;
    gem install rest-client&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
    h = ServiceProxy.new(&#039;http://user:password@127.0.0.1:8332&#039;)&lt;br /&gt;
    puts h.getinfo.call&lt;br /&gt;
    puts h.getbalance.call &#039;accname&#039;&lt;br /&gt;
=end&lt;br /&gt;
require &#039;json&#039;&lt;br /&gt;
require &#039;rest_client&#039;&lt;br /&gt;
&lt;br /&gt;
class JSONRPCException &amp;lt; RuntimeError&lt;br /&gt;
    def initialize()&lt;br /&gt;
        super()&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class ServiceProxy&lt;br /&gt;
    def initialize(service_url, service_name=nil)&lt;br /&gt;
        @service_url = service_url&lt;br /&gt;
        @service_name = service_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def method_missing(name, *args, &amp;amp;block)&lt;br /&gt;
        if @service_name != nil&lt;br /&gt;
            name = &amp;quot;%s.%s&amp;quot; % [@service_name, name]&lt;br /&gt;
        end&lt;br /&gt;
        return ServiceProxy.new(@service_url, name)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def respond_to?(sym)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def call(*args)&lt;br /&gt;
        postdata = {&amp;quot;method&amp;quot; =&amp;gt; @service_name, &amp;quot;params&amp;quot; =&amp;gt; args, &amp;quot;id&amp;quot; =&amp;gt; &amp;quot;jsonrpc&amp;quot;}.to_json&lt;br /&gt;
        respdata = RestClient.post @service_url, postdata&lt;br /&gt;
        resp = JSON.parse respdata&lt;br /&gt;
        if resp[&amp;quot;error&amp;quot;] != nil&lt;br /&gt;
            raise JSONRPCException.new, resp[&#039;error&#039;]&lt;br /&gt;
        end&lt;br /&gt;
        return resp[&#039;result&#039;]&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== PHP ==&lt;br /&gt;
&lt;br /&gt;
The [http://jsonrpcphp.org/ JSON-RPC PHP] library also makes it very easy to connect to Bitcoin.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  require_once &#039;jsonRPCClient.php&#039;;&lt;br /&gt;
  &lt;br /&gt;
  $bitcoin = new jsonRPCClient(&#039;http://user:password@127.0.0.1:8332/&#039;);&lt;br /&gt;
   &lt;br /&gt;
  echo &amp;quot;&amp;lt;pre&amp;gt;\n&amp;quot;;&lt;br /&gt;
  print_r($bitcoin-&amp;gt;getinfo()); echo &amp;quot;\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;Received: &amp;quot;.$bitcoin-&amp;gt;getreceivedbylabel(&amp;quot;Your Address&amp;quot;).&amp;quot;\n&amp;quot;;&lt;br /&gt;
  echo &amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Java ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to tell Java to use HTTP Basic authentication is to set a default Authenticator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  final String rpcuser =&amp;quot;...&amp;quot;;&lt;br /&gt;
  final String rpcpassword =&amp;quot;...&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  Authenticator.setDefault(new Authenticator() {&lt;br /&gt;
      protected PasswordAuthentication getPasswordAuthentication() {&lt;br /&gt;
          return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());&lt;br /&gt;
      }&lt;br /&gt;
  });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once that is done, any JSON-RPC library for Java (or ordinary URL POSTs) may be used to communicate with the Bitcoin server.&lt;br /&gt;
&lt;br /&gt;
== Perl ==&lt;br /&gt;
&lt;br /&gt;
The JSON::RPC package from CPAN can be used to communicate with Bitcoin.  You must set the client&#039;s credentials; for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
  use JSON::RPC::Client;&lt;br /&gt;
  use Data::Dumper;&lt;br /&gt;
   &lt;br /&gt;
  my $client = new JSON::RPC::Client;&lt;br /&gt;
  &lt;br /&gt;
  $client-&amp;gt;ua-&amp;gt;credentials(&lt;br /&gt;
     &#039;localhost:8332&#039;, &#039;jsonrpc&#039;, &#039;user&#039; =&amp;gt; &#039;password&#039;  # REPLACE WITH YOUR bitcoin.conf rpcuser/rpcpassword&lt;br /&gt;
      );&lt;br /&gt;
  &lt;br /&gt;
  my $uri = &#039;http://localhost:8332/&#039;;&lt;br /&gt;
  my $obj = {&lt;br /&gt;
      method  =&amp;gt; &#039;getinfo&#039;,&lt;br /&gt;
      params  =&amp;gt; [],&lt;br /&gt;
   };&lt;br /&gt;
   &lt;br /&gt;
  my $res = $client-&amp;gt;call( $uri, $obj );&lt;br /&gt;
   &lt;br /&gt;
  if ($res){&lt;br /&gt;
      if ($res-&amp;gt;is_error) { print &amp;quot;Error : &amp;quot;, $res-&amp;gt;error_message; }&lt;br /&gt;
      else { print Dumper($res-&amp;gt;result); }&lt;br /&gt;
  } else {&lt;br /&gt;
      print $client-&amp;gt;status_line;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== .NET (C#) ==&lt;br /&gt;
The communication with rpc service can be achieved using the standard httprequest/response objects.&lt;br /&gt;
A library for serialising and deserialising Json will make your life a lot easier:&lt;br /&gt;
&lt;br /&gt;
* JayRock for .NET 4.0&lt;br /&gt;
* Json.Net for .NET 2.0 and above &lt;br /&gt;
&lt;br /&gt;
The following example uses Json.Net:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(&amp;quot;http://localhost.:8332&amp;quot;);&lt;br /&gt;
 webRequest.Credentials = new NetworkCredential(&amp;quot;user&amp;quot;, &amp;quot;pwd&amp;quot;);&lt;br /&gt;
 /// important, otherwise the service can&#039;t desirialse your request properly&lt;br /&gt;
 webRequest.ContentType = &amp;quot;application/json-rpc&amp;quot;;&lt;br /&gt;
 webRequest.Method = &amp;quot;POST&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
 JObject joe = new JObject();&lt;br /&gt;
 joe.Add(new JProperty(&amp;quot;jsonrpc&amp;quot;, &amp;quot;1.0&amp;quot;));&lt;br /&gt;
 joe.Add(new JProperty(&amp;quot;id&amp;quot;, &amp;quot;1&amp;quot;));&lt;br /&gt;
 joe.Add(new JProperty(&amp;quot;method&amp;quot;, Method));&lt;br /&gt;
 // params is a collection values which the method requires..&lt;br /&gt;
 if (Params.Keys.Count == 0)&lt;br /&gt;
 {&lt;br /&gt;
  joe.Add(new JProperty(&amp;quot;params&amp;quot;, new JArray()));&lt;br /&gt;
 }&lt;br /&gt;
 else&lt;br /&gt;
 {&lt;br /&gt;
     JArray props = new JArray();&lt;br /&gt;
     // add the props in the reverse order!&lt;br /&gt;
     for (int i = Params.Keys.Count - 1; i &amp;gt;= 0; i--)&lt;br /&gt;
     {&lt;br /&gt;
        .... // add the params&lt;br /&gt;
     }&lt;br /&gt;
     joe.Add(new JProperty(&amp;quot;params&amp;quot;, props));&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     // serialize json for the request&lt;br /&gt;
     string s = JsonConvert.SerializeObject(joe);&lt;br /&gt;
     byte[] byteArray = Encoding.UTF8.GetBytes(s);&lt;br /&gt;
     webRequest.ContentLength = byteArray.Length;&lt;br /&gt;
     Stream dataStream = webRequest.GetRequestStream();&lt;br /&gt;
     dataStream.Write(byteArray, 0, byteArray.Length);&lt;br /&gt;
     dataStream.Close();&lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
     WebResponse webResponse = webRequest.GetResponse();&lt;br /&gt;
     &lt;br /&gt;
     ... // deserialze the response&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Command line (cURL) ==&lt;br /&gt;
&lt;br /&gt;
You can also send commands and see results using [http://curl.haxx.se/ cURL] or some other command-line HTTP-fetching utility; for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
  curl --user user --data-binary &#039;{&amp;quot;jsonrpc&amp;quot;: &amp;quot;1.0&amp;quot;, &amp;quot;id&amp;quot;:&amp;quot;curltest&amp;quot;, &amp;quot;method&amp;quot;: &amp;quot;getinfo&amp;quot;, &amp;quot;params&amp;quot;: [] }&#039; &lt;br /&gt;
    -H &#039;content-type: text/plain;&#039; http://127.0.0.1:8332/&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for your rpcpassword, and then will see something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  {&amp;quot;result&amp;quot;:{&amp;quot;balance&amp;quot;:0.000000000000000,&amp;quot;blocks&amp;quot;:59952,&amp;quot;connections&amp;quot;:48,&amp;quot;proxy&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;generate&amp;quot;:false,&lt;br /&gt;
     &amp;quot;genproclimit&amp;quot;:-1,&amp;quot;difficulty&amp;quot;:16.61907875185736,&amp;quot;error&amp;quot;:null,&amp;quot;id&amp;quot;:&amp;quot;curltest&amp;quot;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Original_Bitcoin_client/API_Calls_list|API calls list]]&lt;br /&gt;
* [[Running Bitcoin]]&lt;br /&gt;
* [[Lazy API]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Articles using content from the old wiki]]&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[zh-cn:API_reference_(JSON-RPC)]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Securing_your_wallet&amp;diff=9212</id>
		<title>Securing your wallet</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Securing_your_wallet&amp;diff=9212"/>
		<updated>2011-05-29T10:35:05Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Wallet security can be broken down into two independent goals:&lt;br /&gt;
# Protecting your wallet against loss.&lt;br /&gt;
# Protecting your wallet against theft.&lt;br /&gt;
&lt;br /&gt;
In the case that your current wallet hasn&#039;t been protected adequately (e.g. put online with a weaker password):&lt;br /&gt;
# Making a new secure wallet, using appropriate long-term protection.&lt;br /&gt;
&lt;br /&gt;
==Technical Background==&lt;br /&gt;
&lt;br /&gt;
Bitcoin transactions send Bitcoins to a specific public key. A Bitcoin address is an encoded hash of a public key. In order to use received Bitcoins, you need to have the private key matching the public key you received with. This is sort of like a super long password associated with an account (public key). Your Bitcoin wallet contains all of the private keys necessary for spending your received transactions. If you delete your wallet without a backup, then you no longer have the authorization information necessary to claim your coins, and the coins associated with those keys are lost forever.&lt;br /&gt;
&lt;br /&gt;
The wallet contains a pool of queued keys. By default there are 100 keys in the [[key pool]].  The size of the pool is configurable using the &amp;quot;-keypool&amp;quot; command line argument.  When you need an address for whatever reason (send, “new address”, generation, etc.), the key is not actually generated freshly, but taken from this pool. A brand new address is generated to fill the pool back to 100. So when a backup is first created, it has all of your old keys plus 100 unused keys. After sending a transaction, it has 99 unused keys. After a total of 100 new-key actions, you will start using keys that are not in your backup. Since the backup does not have the private keys necessary for authorizing spends of these coins, restoring from the old backup will cause you to lose Bitcoins.&lt;br /&gt;
&lt;br /&gt;
Creating a new address generates a new pair of public and private keys, which are added to your wallet. Each keypair is mostly random numbers, so they cannot be known prior to generation. If you backup your wallet and then create more than 100 new addresses, the keypair associated with the newest addresses will not be in the old wallet because the new keypairs are only known after creating them. Any coins received at these addresses will be lost if you restore from the backup.&lt;br /&gt;
&lt;br /&gt;
The situation is made somewhat more confusing because the receiving addresses shown in the UI are not the only keys in your wallet. Each Bitcoin generation is given a new public key, and, more importantly, each sent transaction also sends some number of Bitcoins back to yourself at a new key. When sending Bitcoins to anyone, you generate a new keypair for yourself and simultaneously send Bitcoins to your new public key and the actual recipient&#039;s public key. This is an anonymity feature – it makes tracking Bitcoin transactions much more difficult.&lt;br /&gt;
&lt;br /&gt;
So if you create a backup, do more than 100 things that cause a new key to be used, and then restore from the backup, some Bitcoins will be lost. Bitcoin has not deleted any keys (keys are never deleted) – it has created a new key that is not in your old backup and then sent Bitcoins to it.&lt;br /&gt;
&lt;br /&gt;
== Making a new wallet ==&lt;br /&gt;
&lt;br /&gt;
In the case that a wallet has been distributed, or stored, in a (real or potential) compromised state, it is wise to create a new wallet and transfer the full balance of Bitcoins to an address contained only in the newly created wallet.&lt;br /&gt;
&lt;br /&gt;
For example, this will be necessary if one created a wallet with a password of 12 characters, as suggested. However a few years have passed and the wallet is now more easily compromised.  Just re-encrypting isn&#039;t secure.  One needs to make a new wallet and make the old wallet worthless (spending the funds to the new wallet).&lt;br /&gt;
&lt;br /&gt;
==Making a secure workspace==&lt;br /&gt;
&lt;br /&gt;
===Linux===&lt;br /&gt;
&lt;br /&gt;
The first step is to make a [http://www.howtogeek.com/howto/ubuntu/add-a-user-on-ubuntu-server/ new user,] so type:&lt;br /&gt;
&lt;br /&gt;
sudo adduser new_user_name&lt;br /&gt;
&lt;br /&gt;
when you get to the prompt &#039;Enter the new value, or press ENTER for the default&#039;, just keep hitting ENTER.&lt;br /&gt;
&lt;br /&gt;
Then switch user to the new user.  To get to the new user you can use the switch user icon for your system, which on Ubuntu is in the &#039;System/Quit&#039; screen, or if there is no switch icon on your system you can log out and log back in as the new user.  Then click on a folder in the new user to display the file browser, then keep going up folders until you see the new user home directory, then right click to bring up the Properties dialog, then click on the Permissions tab, then in the Others section, set the folder access to None.&lt;br /&gt;
&lt;br /&gt;
For secure browsing, open Firefox, and then go into the Edit menu and click Preferences.  Starting from the left, click on the General tab, and in the &#039;Startup/When Firefox starts&#039; pop up menu, choose &#039;Show a Blank Page&#039;.  Then click on the Content tab, and deselect &#039;Load images automatically&#039; and deselect &#039;Enable Javascript&#039;.  Then click on the Privacy tab, and in the &#039;History/Firefox will&#039; pop up menu, choose &#039;Never remember history&#039;.  Then click on the Security tab, and in the Passwords section, deselect &#039;Remember passwords for sites&#039; and deselect &#039;Use a master password&#039;.  Then click on the Advanced tab, then click on the Update tab, and then in the &#039;Automatically check for updates to&#039; section, deselect &#039;Add-ons&#039; and &#039;Search Engines&#039;.&lt;br /&gt;
&lt;br /&gt;
When javascript is disabled, the [http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.19/bitcoin-0.3.19-linux.tar.gz/download linux download page] will not download automatically, so you&#039;ll have to click on the &#039;direct link&#039; part of the &amp;quot;Problems with the download? Please use this &#039;direct link&#039; or try another mirror.&amp;quot; line.&lt;br /&gt;
&lt;br /&gt;
After you&#039;ve made your secure new user, to maintain security you should use it only for bitcoin.&lt;br /&gt;
&lt;br /&gt;
===Mac===&lt;br /&gt;
&lt;br /&gt;
You can keep your wallet file on an encrypted disk image. Open Disk Utility, click New Image, choose small size (eg. 100MB), 128-bit or 256-bit (faster or more secure) encryption and single partition. Save it somewhere you won&#039;t lose it (like your Dropbox, Strongspace or whatever), choose a safe password and there you have it. Move everything from ~/Library/Application Support/Bitcoin/ to the image and symlink it back so the app would be able to use it, eg.&lt;br /&gt;
&lt;br /&gt;
ln -s /Volumes/Bitcoin ~/Library/Application Support/Bitcoin&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to mount your image before using Bitcoin and unmount after quitting it.&lt;br /&gt;
&lt;br /&gt;
== Locating BitCoin&#039;s data directory ==&lt;br /&gt;
&lt;br /&gt;
The [[data directory]] is the location where Bitcoin&#039;s data files are stored, including the wallet data file.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
Go to Start -&amp;gt; Run (or press WinKey+R) and run this:&lt;br /&gt;
&lt;br /&gt;
 explorer %APPDATA%\BitCoin&lt;br /&gt;
&lt;br /&gt;
BitCoin&#039;s data folder will open. For most users, this is the following locations:&lt;br /&gt;
&lt;br /&gt;
 C:\Documents and Settings\YourUserName\Application data\BitCoin (XP)&lt;br /&gt;
 &lt;br /&gt;
 C:\Users\YourUserName\Appdata\Roaming\BitCoin (Vista and 7)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;AppData&amp;quot; and &amp;quot;Application data&amp;quot; are hidden by default.&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
&lt;br /&gt;
By default BitCoin will put its data here:&lt;br /&gt;
&lt;br /&gt;
 ~/.bitcoin/&lt;br /&gt;
&lt;br /&gt;
You need to do a &amp;quot;ls -a&amp;quot; to see directories that start with a dot.&lt;br /&gt;
&lt;br /&gt;
If that&#039;s not it, you can do a search like this:&lt;br /&gt;
&lt;br /&gt;
 find / -name wallet.dat -print 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
=== Mac ===&lt;br /&gt;
&lt;br /&gt;
By default BitCoin will put its data here:&lt;br /&gt;
&lt;br /&gt;
 ~/Library/Application Support/Bitcoin/&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
The only file you need to back up is &amp;quot;wallet.dat&amp;quot;. Ensure that BitCoin is closed, copy this file somewhere else, encrypt it, and put it somewhere safe. Ideally, you would put this file in two places: one nearby, and one 100+ miles away.&lt;br /&gt;
&lt;br /&gt;
You can use the [[api|backupwallet]] JSON-RPC command to back up without shutting down Bitcoin.&lt;br /&gt;
&lt;br /&gt;
=== General Solutions ===&lt;br /&gt;
&lt;br /&gt;
Your wallet.dat file is not encrypted by BitCoin. Anyone who can access it can easily steal all of your coins. Use one of these encryption programs if there is any chance someone might stumble upon your wallet.&lt;br /&gt;
* [http://www.7-zip.org/ 7-zip] - Supports strongly-encrypted archives.&lt;br /&gt;
* [http://www.axantum.com/axcrypt/ AxCrypt]&lt;br /&gt;
* [http://www.truecrypt.org/ TrueCrypt] - Volume-based on-the-fly encryption (for advanced users)&lt;br /&gt;
* [http://www.rarlab.com/ WinRar] - Commonly used archive software that supports verification records and encryption.&lt;br /&gt;
&lt;br /&gt;
There is also a list of [[OpenSourceEncryptionSoftware|open source encryption software.]]&lt;br /&gt;
&lt;br /&gt;
==== Password Strength ====&lt;br /&gt;
Brute-force password cracking has come a long distance, a previously thought secure password of random [a-Z] [0-9] [!-~] of 8 characters long can be trivially solved now (using appropriate hardware)... The recommended length is &#039;&#039;&#039;at least&#039;&#039;&#039; 12 characters long.&lt;br /&gt;
&lt;br /&gt;
If you use keyfiles in addition to a password, it is unlikely that your encrypted file can ever be cracked using brute force methods, even 10 years from now when even a 12 character password might be too short.&lt;br /&gt;
&lt;br /&gt;
Assume that any encrypted files you store online (eg. gmail, Dropbox) will be stored somewhere forever and can never be erased.&lt;br /&gt;
&lt;br /&gt;
==== Storage of Archive ====&lt;br /&gt;
One of the most simple methods for storing a appropriately &#039;&#039;&#039;encrypted&#039;&#039;&#039; archive of your wallet.dat file is to send the archive as an email attachment to your own e-mail address.  Services like gmail.com use very comprehensive distributed networks that make the loss of data very unlikely.  One can even obfuscate the name of the files within the archive, and name the archive something less inviting, such as: &#039;personal notes&#039; or &#039;car insurance&#039;.&lt;br /&gt;
&lt;br /&gt;
Another solution is to use a file storage service like [http://www.wuala.com/bitcoin Wuala] ( encrypted, [http://www.bitcoin.org/smf/index.php?topic=5817.0 instructions]), [http://www.dropbox.com Dropbox] and [http://en.wikipedia.org/wiki/Comparison_of_online_backup_services others], including the more secure [http://www.spideroak.com SpiderOak].&lt;br /&gt;
&lt;br /&gt;
=== Linux solution ===&lt;br /&gt;
&lt;br /&gt;
Linux users can setup cron by running &#039;crontab -e&#039; and adding this line:&lt;br /&gt;
&lt;br /&gt;
  01 */1 * * * /usr/local/bin/backupwallet.sh&lt;br /&gt;
&lt;br /&gt;
This cron line runs backupwallet.sh at the 01 minute of every hour. Remember to add a newline after the last line of the crontab file, or else the last line won&#039;t run.&lt;br /&gt;
&lt;br /&gt;
backupwallet.sh:&lt;br /&gt;
&lt;br /&gt;
  #!/bin/bash&lt;br /&gt;
  &lt;br /&gt;
  TS=$(date &amp;quot;+%Y%m%d-%H-%M&amp;quot;)&lt;br /&gt;
  WALLET=/tmp/wallet${TS}&lt;br /&gt;
  WALLET_E=/tmp/wallet${TS}.crypt&lt;br /&gt;
  &lt;br /&gt;
  if&lt;br /&gt;
    echo -n making backup...&lt;br /&gt;
    bitcoind backupwallet $WALLET &lt;br /&gt;
    &amp;lt;nowiki&amp;gt;[[ ! -s &amp;quot;$WALLET&amp;quot; ]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  then echo failed&lt;br /&gt;
  elif&lt;br /&gt;
    echo done&lt;br /&gt;
    echo -n encrypting....&lt;br /&gt;
    ! gpg -r myusername --output $WALLET_E --encrypt $WALLET&lt;br /&gt;
  then echo failed&lt;br /&gt;
  elif&lt;br /&gt;
    echo done&lt;br /&gt;
    echo -n copying to distant server...&lt;br /&gt;
    ! scp $WALLET_E user@myserver.org:~/wallets/&lt;br /&gt;
  then echo failed&lt;br /&gt;
  else echo done&lt;br /&gt;
  fi&lt;br /&gt;
  &lt;br /&gt;
  rm -f $WALLET $WALLET_E&lt;br /&gt;
&lt;br /&gt;
The shell script:&lt;br /&gt;
&lt;br /&gt;
* Calls bitcoind backupwallet to create a time/date-stamped wallet.&lt;br /&gt;
* GPG encrypts the wallet with your public key.&lt;br /&gt;
* Copies the result to a backup location.&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
&lt;br /&gt;
==Restore==&lt;br /&gt;
&lt;br /&gt;
Assuming your backup is recent enough that you haven&#039;t used up all of your key pool... restoring a wallet to a new (or old) location and rescanning the block chain should leave you with all your coins. Just follow these steps:&lt;br /&gt;
* Quit bitcoin(d).&lt;br /&gt;
* Copy your backed up wallet.dat into your bitcoin profile directory.&lt;br /&gt;
* If copying into existing profile, delete file &#039;&#039;blkindex.dat&#039;&#039;, to make the client rescan the block chain.&lt;br /&gt;
And you&#039;ll be good as new.&lt;br /&gt;
&lt;br /&gt;
==Erasing Plain Text Wallets==&lt;br /&gt;
&lt;br /&gt;
A good practice is to keep at least two wallets, one as a &amp;quot;current account&amp;quot; for everyday transactions and one as a &amp;quot;savings account&amp;quot; where you store the majority of your Bitcoins.  &lt;br /&gt;
&lt;br /&gt;
The &amp;quot;savings account&amp;quot; wallet should be backed up in encrypted form only and all plaintext copies of this wallet should be erased. In case someone gains unauthorised access to your computer (either by physically stealing it or by exploiting a system vulnerability via the internet), they will only be able to spend the coins in your &amp;quot;current account&amp;quot; wallet.&lt;br /&gt;
&lt;br /&gt;
In most operating systems, including Windows, Linux, and Mac OS X, simply deleting a wallet.dat file will &#039;&#039;not&#039;&#039; generally destroy it. It is likely that advanced tools can still be used to recover the wallet.dat file, even after it has been deleted.&lt;br /&gt;
&lt;br /&gt;
The Linux &#039;&#039;&#039;shred&#039;&#039;&#039; command can be used to overwrite the wallet file with random data prior to deleting; this particular copy of the file will then be practically impossible to recover.  Using shred (and similar tools on Windows) however does not guarantee that still other copies don&#039;t exist somewhere hidden on your HD. That will depend on your system configuration and what packages you have installed. Some system restore and backup tools, for instance, create periodic snapshots of your  filesystem, duplicating your wallet.dat.&lt;br /&gt;
&lt;br /&gt;
In Mac OS, clicking &amp;quot;Secure Empty Trash&amp;quot; in the Finder menu will shred the contents of the trash can. As with any OS this doesn&#039;t guarantee that there are not other copies elsewhere on your system.&lt;br /&gt;
&lt;br /&gt;
For Windows, the built-in command &#039;&#039;cipher /W&#039;&#039; will shred all previously-deleted files. [http://www.cylog.org/utilities/cybershredder.jsp CyberShredder] can securely deleted individual files.&lt;br /&gt;
&lt;br /&gt;
==eWallet==&lt;br /&gt;
&lt;br /&gt;
Storing bitcoins with an [[eWallet]] provider incurs risks as well.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Data directory]]&lt;br /&gt;
&lt;br /&gt;
[[de:Sichere deine Geldbörse]]&lt;br /&gt;
[[zh-cn:保护你的钱包]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Help:Installing_Bitcoin_Core&amp;diff=9211</id>
		<title>Help:Installing Bitcoin Core</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Help:Installing_Bitcoin_Core&amp;diff=9211"/>
		<updated>2011-05-29T10:33:42Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An account can effortlessly be created using an [[eWallet]] service. eWallet services provide an online wallet to hold your bitcoins.&lt;br /&gt;
&lt;br /&gt;
This guide covers installing Bitcoin without needing a third party wallet service.&lt;br /&gt;
&lt;br /&gt;
== For Windows computers ==&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
[http://sourceforge.net/projects/bitcoin/ Download] and install Bitcoin.&lt;br /&gt;
&lt;br /&gt;
[[File:Install fin.png|frame|none|Complete installation wizard]]&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
The first time you run Bitcoin, it needs to download all the blocks to setup. You already have your bitcoin address at this point, but you won&#039;t see any transactions before the initialisation is complete (it can take from half to a few hours).&lt;br /&gt;
&lt;br /&gt;
[[File:First time run fin.png|frame|none|Bitcoin is initialising by establishing a connection to other clients and downloading the blocks.]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bitcoin all blocks fin.png|frame|none|Completed download of block-chain.]]&lt;br /&gt;
&lt;br /&gt;
Your address (you can have as many as you want) is at the top. Below is your balance which will be zero. The list below shows your transactions.&lt;br /&gt;
&lt;br /&gt;
== For Mac computers ==&lt;br /&gt;
&lt;br /&gt;
Download the [http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.3.19/bitcoin-0.3.19-macosx.zip/download OS X version] of Bitcoin and expand the archive.&lt;br /&gt;
&lt;br /&gt;
[[File:BcOSX.png|thumb|none|Contents of the Bitcoin archive after expansion]]&lt;br /&gt;
&lt;br /&gt;
Drag the Bitcoin icon to the desired install location, and double-click or Cmd-O (⌘O) to run the application. The Bitcoin window will open and connections will start up in minutes. The blocks will begin downloading. Your address and balance are at the top of the window. Click &amp;quot;Copy to Clipboard&amp;quot; to copy your address. Transactions are displayed in the main window.&lt;br /&gt;
&lt;br /&gt;
[[File:BcOSXrunning.png|thumb|none|Main window]]&lt;br /&gt;
&lt;br /&gt;
As Bitcoin currently does not support hiding with Cmd-H (⌘H), it is recommended that users tick the &amp;quot;Minimize on close&amp;quot; option in the Preferences menu to prevent accidental program exits.&lt;br /&gt;
&lt;br /&gt;
[[File:BcOSXPreferences.png|thumb|none|Preferences window on OS X]]&lt;br /&gt;
&lt;br /&gt;
== Getting my first coins ==&lt;br /&gt;
&lt;br /&gt;
The  [[Bitcoin Faucet]] [https://freebitcoins.appspot.com/ website] currently hands out 0.02 BTC to new bitcoin users. Fill in the form with your bitcoin address.  When you wish to add more, view [[Buying bitcoins]].&lt;br /&gt;
&lt;br /&gt;
[[File:Get some btc.png|frame|none|Getting free coins from the Faucet]]&lt;br /&gt;
&lt;br /&gt;
A new entry should appear in Bitcoin. The network hasn&#039;t yet confirmed it, but you know it&#039;s being processed. After about one hour it should get 6 confirmations. You are able to spend the coins when there is only one confirmation.&lt;br /&gt;
&lt;br /&gt;
The confirmation counter (like the block counter) will increase by one roughly every 10 minutes. Six confirmations are considered as 100% sure a transfer has been processed.&lt;br /&gt;
&lt;br /&gt;
[[File:First btc recv.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
[[File:Six confirms bitcoin client.png|frame|none]]&lt;br /&gt;
&lt;br /&gt;
* Play games and enter your first raffle at http://bitgames.jhfire.net!&lt;br /&gt;
* Create an account on witcoin and post something (cost 0.01 BTC): &amp;lt;br /&amp;gt;http://www.witcoin.com  (click &amp;quot;get wit it&amp;quot; to create an account)&amp;lt;br /&amp;gt;If your post is any good, you can earn when it gets replies and votes.&lt;br /&gt;
* Give a tip to a deserving artist, writer, etc. on YouTipIt.org.&amp;lt;br /&amp;gt;For instance, this video creation is worth 0.05 BTC, no?:&amp;lt;br /&amp;gt; http://www.youtipit.org/t/2652&lt;br /&gt;
* Give lady luck a shot?&amp;lt;br /&amp;gt; Double Trouble (49% chance of doubling your money)&amp;lt;br /&amp;gt; http://doubletrouble.bitcoinbet.com&lt;br /&gt;
* Give to any of the charities on Bitcoin Trade page:&amp;lt;br /&amp;gt; http://en.bitcoin.it/wiki/Trade#Donation-accepting_organizations_and_projects&lt;br /&gt;
&lt;br /&gt;
== Points to remember ==&lt;br /&gt;
&lt;br /&gt;
* You don&#039;t need to be online to receive BTC.&lt;br /&gt;
* You can create as many new addresses as you like. Using a different address each time helps keep you [[Anonymity|anonymous]].&lt;br /&gt;
* You can be [[Anonymity|anonymous]] with adequate precautions.&lt;br /&gt;
* You cannot send BTC to an invalid address. Typos are not a worry as the payment will refuse to send.&lt;br /&gt;
* The wallet file holds the keys that allow spending and thus the computer should be [[Securing_your_wallet|protected]] from the risk of loss and theft.&lt;br /&gt;
* Leaving Bitcoin open improves connectivity for the network and ensures that you don&#039;t fall behind on the block chain. Also see [[FAQ#Do_I_need_to_configure_my_firewall_to_run_bitcoin?|the FAQ about port forwarding]]&lt;br /&gt;
&lt;br /&gt;
Proceed to the [[Introduction|introduction]]&lt;br /&gt;
&lt;br /&gt;
== Technical ==&lt;br /&gt;
=== Block chain ===&lt;br /&gt;
The [[block chain]] is a neverending story of every transaction throughout the network from day 1 (genesis). The first time you run Bitcoin, it is downloaded and verified on your computer. Every new transaction is added to the end of this chain and verified by the network to be valid.&lt;br /&gt;
&lt;br /&gt;
=== Addresses ===&lt;br /&gt;
Whenever you send a coin, you are actually sending a cryptographically signed message, associating your coin with the recipient&#039;s address. This effectively transfers ownership to to the recipient. Once they own the coin, they are free to transfer it to another person.&lt;br /&gt;
&lt;br /&gt;
A wallet is a collection of addresses. You can create as many new addresses as you wish; having more addresses makes you more anonymous, because then people cannot see how much BTC you received. Your wallet contains the secret keys used for spending that money, and must be [[Securing your wallet|backed-up regularly]]. If you lose the wallet then you no longer possess the money.&lt;br /&gt;
&lt;br /&gt;
=== Generating ===&lt;br /&gt;
New coins are minted through generating hashes. These generators are rewarded with a small fee for the computationally intensive task of incorporating your transactions into the block-chain.  This fee halves each time 210000 blocks are added to the block chain, or approximately every 4 years.  The fee will keep halving until it effectively reaches zero, at which point 21 million coins will be in circulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Introduction]]&lt;br /&gt;
&lt;br /&gt;
[[de:Erste Schritte]]&lt;br /&gt;
[[zh-cn:入门]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Secure_Trading&amp;diff=9210</id>
		<title>Secure Trading</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Secure_Trading&amp;diff=9210"/>
		<updated>2011-05-29T10:32:43Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;Secure Trading Online&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This topic is a guide in how to set up your online identity and best practices for trading with others in the Bitcoin community.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Within the Bitcoin community, many are very careful with their security and identity.   This is because of two main reasons:&lt;br /&gt;
# There is no violent body to cover your back for you.  Or more simply there is no courts to seek assistance from if your transaction sours.&lt;br /&gt;
# One’s reputation is the most important thing that any user has; traders will take very little risk with new users who have not proven themselves.  (as they could just be last week’s scammer with a new identity)&lt;br /&gt;
The bitcoin community uses a few tools to help protect their privacy, and thus identity.   The first and most important is a [[Securing Your Computer|Secure Computer]].&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Before proceeding please make sure you have completed the [[Securing Your Computer]] guide, this guide assumes that your computer is secure both physically and in software.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Creating a secure Identity==&lt;br /&gt;
The first step is to create a cryptographically secure public-private key-pair.  This will be used as the basis of keeping both your wallet secure (see [[Securing your wallet]]), and your identity secure.&lt;br /&gt;
&lt;br /&gt;
===Creating your first PGP key-pair===&lt;br /&gt;
A PGP key-pair does two very important functions.&lt;br /&gt;
# Sign information with an unforgeable signature&lt;br /&gt;
# Decrypt things that other people encrypt for you&lt;br /&gt;
&lt;br /&gt;
This allows you to both conduct business privately (encryption), and give out promises that you cannot deny making (signature).&lt;br /&gt;
&lt;br /&gt;
==== Microsoft Windows:====&lt;br /&gt;
* Install GPG4Win: http://www.gpg4win.org/&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This contains all the key management and generation tools for Microsoft Windows.&lt;br /&gt;
&lt;br /&gt;
====All:====&lt;br /&gt;
# Install Thunderbird: https://www.mozillamessaging.com/en-GB/ &lt;br /&gt;
# Setup your email account with Thunderbird.&lt;br /&gt;
# Install the Enigmail plugin for Thunderbird: https://addons.mozilla.org/en-US/thunderbird/addon/enigmail/&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon loading Enigmail, Thunderbird will ask you to make a new ‘identity,’ follow this wizard and you will have created your identity.&amp;lt;br /&amp;gt;&lt;br /&gt;
You should backup your private key in a secure place.  Secondary, you should create a revocation certificate and store that in a different secure place (maybe print it out and store it in your fire safe).&lt;br /&gt;
&lt;br /&gt;
===Register with [#bitcoin-otc]===&lt;br /&gt;
Follow the guide here: http://wiki.bitcoin-otc.com/wiki/Using_bitcoin-otc&lt;br /&gt;
&lt;br /&gt;
===Register the same username at the popular places:===&lt;br /&gt;
* [[Bitcoin Forum]]&lt;br /&gt;
* [[Bitcoin.it_Wiki|Bitcoin Wiki]]&lt;br /&gt;
* [[Bitcoin:Community_portal#IRC_Chat|Freenode IRC]]&lt;br /&gt;
Use a strong and different password for each of these places, keeping your passwords in a secure place.  This will allow other people in the community to track you across the different Bitcoin related sites.  Also making identity theft online more challenging.&lt;br /&gt;
&lt;br /&gt;
==Best Practices with trading==&lt;br /&gt;
===Use Bitcoin-OTC===&lt;br /&gt;
* Always require the user to become registered with #bitcoin-otc.&lt;br /&gt;
* Require a signed message from the fingerprint quoted at: http://bitcoin-otc.com/viewgpg.php&lt;br /&gt;
* Follow additional [http://wiki.bitcoin-otc.com/wiki/Using_bitcoin-otc#Risk_of_fraud recommendations] for avoiding fraud.&lt;br /&gt;
&lt;br /&gt;
===Make sure both parties agree to the terms of the trade with signed messages===&lt;br /&gt;
* Get a PGP signed quote, and check the signature.&lt;br /&gt;
* Send a PGP signed receipt.&lt;br /&gt;
This allows either party to go public if the trade has become sour and stops your trading partner from claiming the details of the agreement were somehow different.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Search the Bitcoin Forum for the username of the person that you are trading with. Check if the user has provided constructive and useful advice to other parties.  And, most importantly, check for any claims that the user has scammed.&lt;br /&gt;
&lt;br /&gt;
===Use an escrow===&lt;br /&gt;
Trading might benefit from an escrow such that bitcoins are disbursed only after contract terms have been met.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A popular online escrow is [[ClearCoin]].&lt;br /&gt;
&lt;br /&gt;
Found in Bitcoin&#039;s community are trusted individuals willing to act as independent, third-party escrow brokers.&lt;br /&gt;
&lt;br /&gt;
[[de:Sicheres_Handeln]]&lt;br /&gt;
[[zh-cn:交易安全]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Protocol_documentation&amp;diff=9209</id>
		<title>Protocol documentation</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Protocol_documentation&amp;diff=9209"/>
		<updated>2011-05-29T10:20:00Z</updated>

		<summary type="html">&lt;p&gt;Simapple: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sources:&lt;br /&gt;
* [[Original Bitcoin client]] source&lt;br /&gt;
* [http://www.bitcoin.org/wiki/doku.php?id=bitcoins_draft_spec_0_0_1 Draft spec on bitcoin wiki]&lt;br /&gt;
&lt;br /&gt;
Type names used in this documentation are from the C99 standard.&lt;br /&gt;
&lt;br /&gt;
==Common standards==&lt;br /&gt;
&lt;br /&gt;
=== Hashes ===&lt;br /&gt;
&lt;br /&gt;
Usually, when a hash is computed within bitcoin, it is computed twice. Most of the time [http://en.wikipedia.org/wiki/SHA-2 SHA-256] hashes are used, however [http://en.wikipedia.org/wiki/RIPEMD RIPEMD-160] is also used when a shorter hash is desirable (for example when creating a bitcoin address).&lt;br /&gt;
&lt;br /&gt;
Example of double-SHA-256 encoding of string &amp;quot;hello&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 hello&lt;br /&gt;
 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (first round of sha-256)&lt;br /&gt;
 9595c9df90075148eb06860365df33584b75bff782a510c6cd4883a419833d50 (second round of sha-256)&lt;br /&gt;
&lt;br /&gt;
For bitcoin addresses (RIPEMD-160) this would give:&lt;br /&gt;
&lt;br /&gt;
 hello&lt;br /&gt;
 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (first round is sha-256)&lt;br /&gt;
 b6a9c8c230722b7c748331a8b450f05566dc7d0f (with ripemd-160)&lt;br /&gt;
&lt;br /&gt;
=== Merkle Trees ===&lt;br /&gt;
&lt;br /&gt;
Merkle trees are binary trees of hashes. Merkle trees in bitcoin use SHA-256, and are built up as so:&lt;br /&gt;
&lt;br /&gt;
 sha256(a) sha256(b) sha256(c)&lt;br /&gt;
 sha256(sha256(a)+sha256(b)) sha256(sha256(c)+sha256(c))&lt;br /&gt;
 sha256(sha256(sha256(a)+sha256(b))+sha256(sha256(c)+sha256(c)))&lt;br /&gt;
&lt;br /&gt;
They are paired up, with the last element being _duplicated_.&lt;br /&gt;
&lt;br /&gt;
=== Signatures ===&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses [http://en.wikipedia.org/wiki/Elliptic_curve_cryptography Elliptic Curve] [http://en.wikipedia.org/wiki/Digital_Signature_Algorithm Digital Signature Algorithm] (ECDSA) to sign transactions. &lt;br /&gt;
&lt;br /&gt;
For ECDSA the secp256k1 curve from http://www.secg.org/collateral/sec2_final.pdf is used.&lt;br /&gt;
&lt;br /&gt;
Public keys (in scripts) are given as 04 &amp;lt;x&amp;gt; &amp;lt;y&amp;gt; where x and y are 32 byte strings representing the coordinates of a point on the curve. Signatures use [http://en.wikipedia.org/wiki/Distinguished_Encoding_Rules DER encoding] to pack the r and s components into a single byte stream (because this is what OpenSSL produces by default).&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
{{See also|OP_CHECKSIG}}&lt;br /&gt;
&lt;br /&gt;
The first transaction of a block is usually the generating transaction, which do not include any &amp;quot;in&amp;quot; transaction, and generate bitcoins (from fees for example) usually received by whoever solved the block containing this transaction.&lt;br /&gt;
Such transactions are called a &amp;quot;coinbase transaction&amp;quot; and are accepted by bitcoin clients without any need to execute scripts, provided there is only one per block.&lt;br /&gt;
&lt;br /&gt;
If a transaction is not a coinbase, it references previous transaction hashes as input, and the index of the other transaction&#039;s output used as input for this transaction.&lt;br /&gt;
The script from the in part of this transaction is executed.&lt;br /&gt;
Then the script from the out part of the referenced transaction is executed.&lt;br /&gt;
It is considered valid if the top element of the stack is true.&lt;br /&gt;
&lt;br /&gt;
=== Addresses ===&lt;br /&gt;
&lt;br /&gt;
A bitcoin address is in fact the hash of a ECDSA public key, computed this way:&lt;br /&gt;
&lt;br /&gt;
 Version = 1 byte of 0 (zero); on the test network, this is 1 byte of 111&lt;br /&gt;
 Key hash = Version concatenated with RIPEMD-160(SHA-256(public key))&lt;br /&gt;
 Checksum = 1st 4 bytes of SHA-256(SHA-256(Key hash))&lt;br /&gt;
 Bitcoin Address = Base58Encode(Key hash concatenated with Checksum)&lt;br /&gt;
&lt;br /&gt;
The Base58 encoding used is home made, and has some differences. Especially, leading zeroes are kept as single zeroes when conversion happens.&lt;br /&gt;
&lt;br /&gt;
== Common structures ==&lt;br /&gt;
&lt;br /&gt;
Almost all integers are encoded in little endian. Only IP or port number are encoded big endian.&lt;br /&gt;
&lt;br /&gt;
=== Message structure ===&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || magic || uint32_t || Magic value indicating message origin network, and used to seek to next message when stream state is unknown&lt;br /&gt;
|-&lt;br /&gt;
| 12 || command || char[12] || ASCII string identifying the packet content, NULL padded (non-NULL padding results in packet rejected)&lt;br /&gt;
|-&lt;br /&gt;
| 4 || length || uint32_t || Length of payload in number of bytes&lt;br /&gt;
|-&lt;br /&gt;
| 4 || checksum || uint32_t || First 4 bytes of sha256(sha256(payload)) (not included in version or verack)&lt;br /&gt;
|-&lt;br /&gt;
| ? || payload || uchar[] || The actual data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The version and verack messages do not have a checksum, the payload starts 4 bytes earlier.&lt;br /&gt;
&lt;br /&gt;
Known magic values:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Network !! Magic value&lt;br /&gt;
|-&lt;br /&gt;
| main || F9BEB4D9&lt;br /&gt;
|-&lt;br /&gt;
| testnet || FABFB5DA&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Variable length integer ===&lt;br /&gt;
&lt;br /&gt;
Integer can be encoded depending on the represented value to save space.  Variable length integers always precede an array/vector of a type of data that may vary in length.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Storage length !! Format&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 0xfd || 1 || uint8_t&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;= 0xffff || 3 || 0xfd + uint16_t&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;= 0xffffffff || 5 || 0xfe + uint32_t&lt;br /&gt;
|-&lt;br /&gt;
| - || 9 || 0xff + uint64_t&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Variable length string ===&lt;br /&gt;
&lt;br /&gt;
Variable length string can be stored using a variable length integer followed by the string itself.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || length || var_int || Length of the string&lt;br /&gt;
|-&lt;br /&gt;
| ? || string || char[] || The string itself (can be empty)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Network address ===&lt;br /&gt;
&lt;br /&gt;
When a network address is needed somewhere, this structure is used.  This protocol and structure supports IPv6, &#039;&#039;&#039;but note that the original client currently only supports IPv4 networking&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 8 || services || uint64_t || same service(s) listed in [[#version|version]]?&lt;br /&gt;
|-&lt;br /&gt;
| 16 || IPv6/4 || char[16] || IPv6 address. Network byte order. The original client only supports IPv4 and only reads the last 4 bytes to get the IPv4 address. However, the IPv4 address is written into the message as a 16 byte [http://en.wikipedia.org/wiki/IPv6#IPv4-mapped_IPv6_addresses IPv4-mapped IPv6 address]&lt;br /&gt;
(12 bytes &#039;&#039;00 00 00 00  00 00 00 00  00 00 FF FF&#039;&#039;, followed by the 4 bytes of the IPv4 address).&lt;br /&gt;
|-&lt;br /&gt;
| 2 || port || uint16_t || port number, network byte order&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Hexdump example of Network address structure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0000   01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................&lt;br /&gt;
0010   00 00 FF FF 0A 00 00 01  20 8D                    ........ .&lt;br /&gt;
&lt;br /&gt;
Network address:&lt;br /&gt;
 01 00 00 00 00 00 00 00                         - 1 (NODE_NETWORK? see services listed under version command)&lt;br /&gt;
 00 00 00 00 00 00 00 00 00 00 FF FF 0A 00 00 01 - IPv6: ::ffff:10.0.0.1 or IPv4: 10.0.0.1&lt;br /&gt;
 20 8D                                           - Port 8333&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Inventory Vectors ===&lt;br /&gt;
&lt;br /&gt;
Inventory vectors are used for notifying other nodes about objects they have or data which is being requested.&lt;br /&gt;
&lt;br /&gt;
Inventory vectors consist of the following data format:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || type || uint32_t || Identifies the object type linked to this inventory&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash || char[32] || Hash of the object&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The object type is currently defined as one of the following possibilities:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || ERROR || Any data of with this number may be ignored&lt;br /&gt;
|-&lt;br /&gt;
| 1 || MSG_TX || Hash is related to a transaction&lt;br /&gt;
|-&lt;br /&gt;
| 2 || MSG_BLOCK || Hash is related to a data block&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Other Data Type values are considered reserved for future implementations.&lt;br /&gt;
&lt;br /&gt;
=== Block Headers ===&lt;br /&gt;
&lt;br /&gt;
Block headers are sent in a headers packet in response to a getheaders message.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || Block version information, based upon the software version creating this block&lt;br /&gt;
|-&lt;br /&gt;
| 32 || prev_block || char[32] || The hash value of the previous block this particular block references&lt;br /&gt;
|-&lt;br /&gt;
| 32 || merkle_root || char[32] || The reference to a Merkle tree collection which is a hash of all transactions related to this block&lt;br /&gt;
|-&lt;br /&gt;
| 4 || timestamp || uint32_t || A timestamp recording when this block was created (Limited to 2106!)&lt;br /&gt;
|-&lt;br /&gt;
| 4 || bits || uint32_t || The calculated difficulty target being used for this block&lt;br /&gt;
|-&lt;br /&gt;
| 4 || nonce || uint32_t || The nonce used to generate this block… to allow variations of the header and compute different hashes&lt;br /&gt;
|-&lt;br /&gt;
| 1 || txn_count || uint8_t || Number of transaction entries, this value is always 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Message types ==&lt;br /&gt;
&lt;br /&gt;
=== version ===&lt;br /&gt;
&lt;br /&gt;
When a node receives an incoming connection, it will immediately advertise its version. No futher communication is possible until both peers have exchanged their version.&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || Identifies protocol version being used by the node&lt;br /&gt;
|-&lt;br /&gt;
| 8 || services || uint64_t || bitfield of features to be enabled for this connection&lt;br /&gt;
|-&lt;br /&gt;
| 8 || timestamp || uint64_t || standard UNIX timestamp in seconds&lt;br /&gt;
|-&lt;br /&gt;
| 26 || addr_me || net_addr || The network address of the node emitting this message&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| version &amp;gt;= 106&lt;br /&gt;
|-&lt;br /&gt;
| 26 || addr_you || net_addr || The network address seen by the node emitting this message (ie, the address of the receiving node)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || nonce || uint64_t || Node random unique id. This id is used to detect connections to self&lt;br /&gt;
|-&lt;br /&gt;
| ? || sub_version_num || var_str || Secondary Version information (null terminated?)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| version &amp;gt;= 209&lt;br /&gt;
|-&lt;br /&gt;
| 4 || start_height || uint32_t || The last block received by the emitting node&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the emitter of the packet has version &amp;gt;= 209, a &amp;quot;verack&amp;quot; packet shall be sent if the version packet was accepted.&lt;br /&gt;
&lt;br /&gt;
The following services are currently assigned:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || NODE_NETWORK || This node can be asked for full blocks instead of just headers.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Hexdump example of version message (note the message header for this version message does not have a checksum):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0000   F9 BE B4 D9 76 65 72 73  69 6F 6E 00 00 00 00 00   ....version.....&lt;br /&gt;
0010   55 00 00 00 9C 7C 00 00  01 00 00 00 00 00 00 00   U....|..........&lt;br /&gt;
0020   E6 15 10 4D 00 00 00 00  01 00 00 00 00 00 00 00   ...M............&lt;br /&gt;
0030   00 00 00 00 00 00 00 00  00 00 FF FF 0A 00 00 01   ................&lt;br /&gt;
0040   DA F6 01 00 00 00 00 00  00 00 00 00 00 00 00 00   ................&lt;br /&gt;
0050   00 00 00 00 FF FF 0A 00  00 02 20 8D DD 9D 20 2C   .......... ... ,&lt;br /&gt;
0060   3A B4 57 13 00 55 81 01  00                        :.W..U...&lt;br /&gt;
&lt;br /&gt;
Message header:&lt;br /&gt;
 F9 BE B4 D9                                                                   - Main network magic bytes&lt;br /&gt;
 76 65 72 73 69 6F 6E 00 00 00 00 00                                           - &amp;quot;version&amp;quot; command&lt;br /&gt;
 55 00 00 00                                                                   - Payload is 85 bytes long&lt;br /&gt;
                                                                              - No checksum in version message&lt;br /&gt;
Version message:&lt;br /&gt;
 9C 7C 00 00                                                                   - 31900 (version 0.3.19)&lt;br /&gt;
 01 00 00 00 00 00 00 00                                                       - 1 (NODE_NETWORK services)&lt;br /&gt;
 E6 15 10 4D 00 00 00 00                                                       - Mon Dec 20 21:50:14 EST 2010&lt;br /&gt;
 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 0A 00 00 01 DA F6 - Sender address info - see Network Address&lt;br /&gt;
 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 0A 00 00 02 20 8D - Recipient address info - see Network Address&lt;br /&gt;
 DD 9D 20 2C 3A B4 57 13                                                       - Node random unique ID&lt;br /&gt;
 00                                                                            - &amp;quot;&amp;quot; sub-version string (string is 0 bytes long)&lt;br /&gt;
 55 81 01 00                                                                   - Last block sending node has is block #98645&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== verack ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;verack&#039;&#039; message is sent in reply to &#039;&#039;version&#039;&#039; for clients &amp;gt;= 209.  This message consists of only a [[#Message structure|message header]] with the command string &amp;quot;verack&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Hexdump of the verack message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0000   F9 BE B4 D9 76 65 72 61  63 6B 00 00 00 00 00 00   ....verack......&lt;br /&gt;
0010   00 00 00 00                                        ....&lt;br /&gt;
&lt;br /&gt;
Message header:&lt;br /&gt;
 F9 BE B4 D9                          - Main network magic bytes&lt;br /&gt;
 76 65 72 61  63 6B 00 00 00 00 00 00 - &amp;quot;verack&amp;quot; command&lt;br /&gt;
 00 00 00 00                          - Payload is 0 bytes long&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== addr ===&lt;br /&gt;
&lt;br /&gt;
Provide information on known nodes of the network. Non-advertised nodes should be forgotten after typically 3 hours&lt;br /&gt;
&lt;br /&gt;
Payload (maximum payload length: 1000 bytes):&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || count || var_int || Number of address entries&lt;br /&gt;
|-&lt;br /&gt;
| 30x? || addr_list || (uint32_t + net_addr)[] || Address of other nodes on the network. version &amp;lt; 209 will only read the first one&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Starting version 31402, addresses are prefixed with a timestamp. If no timestamp is present, the addresses should not be relayed to other peers, unless it is indeed confirmed they are up.&lt;br /&gt;
&lt;br /&gt;
Hexdump example of &#039;&#039;addr&#039;&#039; message:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0000   F9 BE B4 D9 61 64 64 72  00 00 00 00 00 00 00 00   ....addr........&lt;br /&gt;
0010   1F 00 00 00 7F 85 39 C2  01 E2 15 10 4D 01 00 00   ......9.....M...&lt;br /&gt;
0020   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 FF   ................&lt;br /&gt;
0030   FF 0A 00 00 01 20 8D                               .D(.. .&lt;br /&gt;
&lt;br /&gt;
Message Header:&lt;br /&gt;
 F9 BE B4 D9                                     - Main network magic bytes&lt;br /&gt;
 61 64 64 72  00 00 00 00 00 00 00 00            - &amp;quot;addr&amp;quot;&lt;br /&gt;
 1F 00 00 00                                     - payload is 31 bytes long&lt;br /&gt;
 7F 85 39 C2                                     - checksum of payload&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
 01                                              - 1 address in this message&lt;br /&gt;
&lt;br /&gt;
Address:&lt;br /&gt;
 E2 15 10 4D                                     - Mon Dec 20 21:50:10 EST 2010 (only when version is &amp;gt;= 31402)&lt;br /&gt;
 01 00 00 00 00 00 00 00                         - 1 (NODE_NETWORK service - see version message)&lt;br /&gt;
 00 00 00 00 00 00 00 00 00 00 FF FF 0A 00 00 01 - IPv4: 10.0.0.1, IPv6: ::ffff:10.0.0.1 (IPv4-mapped IPv6 address)&lt;br /&gt;
 20 8D                                           - port 8333&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== inv ===&lt;br /&gt;
&lt;br /&gt;
Allows a node to advertise its knowledge of one or more objects. It can be received unsolicited, or in reply to &#039;&#039;getblocks&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Payload (maximum payload length: 50000 bytes):&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || count || var_int || Number of inventory entries&lt;br /&gt;
|-&lt;br /&gt;
| 36x? || inventory || inv_vect[] || Inventory vectors&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== getdata ===&lt;br /&gt;
&lt;br /&gt;
getdata is used in response to inv, to retrieve the content of a specific object, and is usually sent after receiving an &#039;&#039;inv&#039;&#039; packet, after filtering known elements.&lt;br /&gt;
&lt;br /&gt;
Payload (maximum payload length: 50000 bytes):&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || count || var_int || Number of inventory entries&lt;br /&gt;
|-&lt;br /&gt;
| 36x? || inventory || inv_vect[] || Inventory vectors&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== getblocks ===&lt;br /&gt;
&lt;br /&gt;
Return an &#039;&#039;inv&#039;&#039; packet containing the list of blocks starting at hash_start, up to hash_stop or 500 blocks, whichever comes first. To receive the next blocks hashes, one needs to issue getblocks again with the last known hash.&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || start count || var_int || number of hash_start entries&lt;br /&gt;
|-&lt;br /&gt;
| 32+ || hash_start || char[32] || hash of the last known block of the emitting node&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash_stop || char[32] || hash of the last desired block. Set to zero to get as many blocks as possible (500)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== getheaders ===&lt;br /&gt;
&lt;br /&gt;
Return a &#039;&#039;headers&#039;&#039; packet containing the headers for blocks starting at hash_start, up to hash_stop or 2000 blocks, whichever comes first. To receive the next blocks hashes, one needs to issue getheaders again with the last known hash. The &#039;&#039;getheaders&#039;&#039; command is used by thin clients to quickly download the blockchain where the contents of the transactions would be irrelevant (because they are not ours). &lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || start count || var_int || number of hash_start entries&lt;br /&gt;
|-&lt;br /&gt;
| 32+ || hash_start || char[32] || hash of the last known block of the emitting node&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash_stop || char[32] || hash of the last desired block. Set to zero to get as many blocks as possible (2000)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== tx ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;tx&#039;&#039; describes a bitcoin transaction, in reply to &#039;&#039;getdata&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || Transaction data format version&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || tx_in count || var_int || Number of Transaction inputs&lt;br /&gt;
|-&lt;br /&gt;
| 41+ || tx_in || tx_in[] || A list of 1 or more transaction inputs or sources for coins&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || tx_out count || var_int || Number of Transaction outputs&lt;br /&gt;
|-&lt;br /&gt;
| 8+ || tx_out || tx_out[] || A list of 1 or more transaction outputs or destinations for coins&lt;br /&gt;
|-&lt;br /&gt;
| 4 || lock_time || uint32_t || The block number or timestamp at which this transaction is locked, or 0 if the transaction is always locked. A non-locked transaction must not be included in blocks, and it can be modified by broadcasting a new version before the time has expired (replacement is currently disabled in Bitcoin, however, so this is useless).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
TxIn consists of the following fields:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 36 || previous_output || outpoint || The previous output transaction reference, as an OutPoint structure&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || script length || var_int || The length of the signature script&lt;br /&gt;
|-&lt;br /&gt;
| ? || signature script || uchar[] || Computational Script for confirming transaction authorization&lt;br /&gt;
|-&lt;br /&gt;
| 4 || sequence || uint32_t || Transaction version as defined by the sender. Intended for &amp;quot;replacement&amp;quot; of transactions when information is updated before inclusion into a block.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The OutPoint structure consists of the following fields:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash || char[32] || The hash of the referenced transaction.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || index || uint32_t || The index of the specific output in the transaction. The first output is 0, etc.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The Script structure consists of a series of pieces of information and operations related to the value of the transaction.&lt;br /&gt;
&lt;br /&gt;
(Structure to be expanded in the future… see script.h and script.cpp for more information)&lt;br /&gt;
&lt;br /&gt;
The TxOut structure consists of the following fields:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 8 || value || uint64_t || Transaction Value&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || pk_script length || var_int || Length of the pk_script&lt;br /&gt;
|-&lt;br /&gt;
| ? || pk_script || uchar[] || Usually contains the public key as a Bitcoin script setting up conditions to claim this output.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example &#039;&#039;tx&#039;&#039; message:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
000000	F9 BE B4 D9 74 78 00 00  00 00 00 00 00 00 00 00   ....tx..........&lt;br /&gt;
000010	02 01 00 00 E2 93 CD BE  01 00 00 00 01 6D BD DB   .............m..&lt;br /&gt;
000020	08 5B 1D 8A F7 51 84 F0  BC 01 FA D5 8D 12 66 E9   .[...Q........f.&lt;br /&gt;
000030	B6 3B 50 88 19 90 E4 B4  0D 6A EE 36 29 00 00 00   .;P......j.6)...&lt;br /&gt;
000040	00 8B 48 30 45 02 21 00  F3 58 1E 19 72 AE 8A C7   ..H0E.!..X..r...&lt;br /&gt;
000050	C7 36 7A 7A 25 3B C1 13  52 23 AD B9 A4 68 BB 3A   .6zz%;..R#...h.:&lt;br /&gt;
000060	59 23 3F 45 BC 57 83 80  02 20 59 AF 01 CA 17 D0   Y#?E.W... Y.....&lt;br /&gt;
000070	0E 41 83 7A 1D 58 E9 7A  A3 1B AE 58 4E DE C2 8D   .A.z.X.z...XN...&lt;br /&gt;
000080	35 BD 96 92 36 90 91 3B  AE 9A 01 41 04 9C 02 BF   5...6..;...A....&lt;br /&gt;
000090	C9 7E F2 36 CE 6D 8F E5  D9 40 13 C7 21 E9 15 98   .~.6.m...@..!...&lt;br /&gt;
0000A0	2A CD 2B 12 B6 5D 9B 7D  59 E2 0A 84 20 05 F8 FC   *.+..].}Y... ...&lt;br /&gt;
0000B0	4E 02 53 2E 87 3D 37 B9  6F 09 D6 D4 51 1A DA 8F   N.S..=7.o...Q...&lt;br /&gt;
0000C0	14 04 2F 46 61 4A 4C 70  C0 F1 4B EF F5 FF FF FF   ../FaJLp..K.....&lt;br /&gt;
0000D0	FF 02 40 4B 4C 00 00 00  00 00 19 76 A9 14 1A A0   ..@KL......v....&lt;br /&gt;
0000E0	CD 1C BE A6 E7 45 8A 7A  BA D5 12 A9 D9 EA 1A FB   .....E.z........&lt;br /&gt;
0000F0	22 5E 88 AC 80 FA E9 C7  00 00 00 00 19 76 A9 14   &amp;quot;^...........v..&lt;br /&gt;
000100	0E AB 5B EA 43 6A 04 84  CF AB 12 48 5E FD A0 B7   ..[.Cj.....H^...&lt;br /&gt;
000110	8B 4E CC 52 88 AC 00 00  00 00                     .N.R......&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Message header:&lt;br /&gt;
 F9 BE B4 D9                                       - main network magic bytes&lt;br /&gt;
 74 78 00 00 00 00 00 00 00 00 00 00               - &amp;quot;tx&amp;quot; command&lt;br /&gt;
 02 01 00 00                                       - payload is 258 bytes long&lt;br /&gt;
 E2 93 CD BE                                       - checksum of payload&lt;br /&gt;
&lt;br /&gt;
Transaction:&lt;br /&gt;
 01 00 00 00                                       - version&lt;br /&gt;
&lt;br /&gt;
Inputs:&lt;br /&gt;
 01                                                - number of transaction inputs&lt;br /&gt;
&lt;br /&gt;
Input 1:&lt;br /&gt;
 6D BD DB 08 5B 1D 8A F7  51 84 F0 BC 01 FA D5 8D  - previous output (outpoint)&lt;br /&gt;
 12 66 E9 B6 3B 50 88 19  90 E4 B4 0D 6A EE 36 29&lt;br /&gt;
 00 00 00 00&lt;br /&gt;
&lt;br /&gt;
 8B                                                - script is 139 bytes long&lt;br /&gt;
&lt;br /&gt;
 48 30 45 02 21 00 F3 58  1E 19 72 AE 8A C7 C7 36  - signature script (scriptSig)&lt;br /&gt;
 7A 7A 25 3B C1 13 52 23  AD B9 A4 68 BB 3A 59 23&lt;br /&gt;
 3F 45 BC 57 83 80 02 20  59 AF 01 CA 17 D0 0E 41&lt;br /&gt;
 83 7A 1D 58 E9 7A A3 1B  AE 58 4E DE C2 8D 35 BD&lt;br /&gt;
 96 92 36 90 91 3B AE 9A  01 41 04 9C 02 BF C9 7E&lt;br /&gt;
 F2 36 CE 6D 8F E5 D9 40  13 C7 21 E9 15 98 2A CD&lt;br /&gt;
 2B 12 B6 5D 9B 7D 59 E2  0A 84 20 05 F8 FC 4E 02&lt;br /&gt;
 53 2E 87 3D 37 B9 6F 09  D6 D4 51 1A DA 8F 14 04&lt;br /&gt;
 2F 46 61 4A 4C 70 C0 F1  4B EF F5&lt;br /&gt;
&lt;br /&gt;
 FF FF FF FF                                       - sequence&lt;br /&gt;
&lt;br /&gt;
Outputs:&lt;br /&gt;
 02                                                - 2 Output Transactions&lt;br /&gt;
&lt;br /&gt;
Output 1:&lt;br /&gt;
 40 4B 4C 00 00 00 00 00                           - 0.05 BTC (5000000)&lt;br /&gt;
 19                                                - pk_script is 25 bytes long&lt;br /&gt;
&lt;br /&gt;
 76 A9 14 1A A0 CD 1C BE  A6 E7 45 8A 7A BA D5 12  - pk_script&lt;br /&gt;
 A9 D9 EA 1A FB 22 5E 88  AC&lt;br /&gt;
&lt;br /&gt;
Output 2:&lt;br /&gt;
 80 FA E9 C7 00 00 00 00                           - 33.54 BTC (3354000000)&lt;br /&gt;
 19                                                - pk_script is 25 bytes long&lt;br /&gt;
&lt;br /&gt;
 76 A9 14 0E AB 5B EA 43  6A 04 84 CF AB 12 48 5E  - pk_script&lt;br /&gt;
 FD A0 B7 8B 4E CC 52 88  AC&lt;br /&gt;
&lt;br /&gt;
Locktime:&lt;br /&gt;
 00 00 00 00                                       - lock time&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== block ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;block&#039;&#039;&#039; message is sent in response to a getdata message which requests transaction information from a block hash.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || Block version information, based upon the software version creating this block&lt;br /&gt;
|-&lt;br /&gt;
| 32 || prev_block || char[32] || The hash value of the previous block this particular block references&lt;br /&gt;
|-&lt;br /&gt;
| 32 || merkle_root || char[32] || The reference to a Merkle tree collection which is a hash of all transactions related to this block&lt;br /&gt;
|-&lt;br /&gt;
| 4 || timestamp || uint32_t || A timestamp recording when this block was created (Limited to 2106!)&lt;br /&gt;
|-&lt;br /&gt;
| 4 || bits || uint32_t || The calculated difficulty target being used for this block&lt;br /&gt;
|-&lt;br /&gt;
| 4 || nonce || uint32_t || The nonce used to generate this block… to allow variations of the header and compute different hashes&lt;br /&gt;
|-&lt;br /&gt;
| ? || txn_count || var_int || Number of transaction entries&lt;br /&gt;
|-&lt;br /&gt;
| ? || txns || tx[] || Block transactions, in format of &amp;quot;tx&amp;quot; command&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The SHA256 hash that identifies each block (and which must have a run of 0 bits) is calculated from the first 6 fields of this structure (version, prev_block, merkle_root, timestamp, bits, nonce, and standard SHA256 padding, making two 64-byte chunks in all) and &#039;&#039;not&#039;&#039; from the complete block. To calculate the hash, only two chunks need to be processed by the SHA256 algorithm. Since the &#039;&#039;nonce&#039;&#039; field is in the second chunk, the first chunk stays constant during mining and therefore only the second chunk needs to be processed. However, a Bitcoin hash is the hash of the hash, so two SHA256 rounds are needed for each mining iteration.&lt;br /&gt;
&lt;br /&gt;
=== headers ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;headers&#039;&#039; packet returns block headers in response to a &#039;&#039;getheaders&#039;&#039; packet. &lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || count || var_int || Number of block headers&lt;br /&gt;
|-&lt;br /&gt;
| 77x? || headers || block_header[] || Block headers&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== getaddr ===&lt;br /&gt;
&lt;br /&gt;
The getaddr message sends a request to a node asking for information about known active peers to help with identifying potential nodes in the network. The response to receiving this message is to transmit an addr message with one or more peers from a database of known active peers. The typical presumption is that a node is likely to be active if it has been sending a message within the last three hours.&lt;br /&gt;
&lt;br /&gt;
No additional data is transmitted with this message.&lt;br /&gt;
&lt;br /&gt;
=== checkorder ===&lt;br /&gt;
&lt;br /&gt;
This message is used for [[IP Transactions]], to ask the peer if it accepts such transactions and allow it to look at the content of the order.&lt;br /&gt;
&lt;br /&gt;
It contains a CWalletTx object&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| Fields from CMerkleTx&lt;br /&gt;
|-&lt;br /&gt;
| ? || hashBlock&lt;br /&gt;
|-&lt;br /&gt;
| ? || vMerkleBranch&lt;br /&gt;
|-&lt;br /&gt;
| ? || nIndex&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| Fields from CWalletTx&lt;br /&gt;
|-&lt;br /&gt;
| ? || vtxPrev&lt;br /&gt;
|-&lt;br /&gt;
| ? || mapValue&lt;br /&gt;
|-&lt;br /&gt;
| ? || vOrderForm&lt;br /&gt;
|-&lt;br /&gt;
| ? || fTimeReceivedIsTxTime&lt;br /&gt;
|-&lt;br /&gt;
| ? || nTimeReceived&lt;br /&gt;
|-&lt;br /&gt;
| ? || fFromMe&lt;br /&gt;
|-&lt;br /&gt;
| ? || fSpent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== submitorder ===&lt;br /&gt;
&lt;br /&gt;
Confirms an order has been submitted. &lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash || char[32] || Hash of the transaction&lt;br /&gt;
|-&lt;br /&gt;
| ? || wallet_entry || CWalletTx || Same payload as checkorder&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== reply ===&lt;br /&gt;
&lt;br /&gt;
Generic reply for [[IP Transactions]]&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || reply || uint32_t || reply code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || SUCCESS || The IP Transaction can proceed (&#039;&#039;checkorder&#039;&#039;), or has been accepted (&#039;&#039;submitorder&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || WALLET_ERROR || AcceptWalletTransaction() failed&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DENIED || IP Transactions are not accepted by this node&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== ping ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;ping&#039;&#039; message is sent primarily to confirm that the TCP/IP connection is still valid. An error in transmission is presumed to be a closed connection and the address is removed as a current peer. No reply is expected as a result of this message being sent nor any sort of action expected on the part of a client when it is used.&lt;br /&gt;
&lt;br /&gt;
=== alert ===&lt;br /&gt;
&lt;br /&gt;
An &#039;&#039;&#039;alert&#039;&#039;&#039; is sent between nodes to send a general notification message throughout the network. If the alert can be confirmed with the signature as having come from the the core development group of the Bitcoin software, the message is suggested to be displayed for end-users. Attempts to perform transactions, particularly automated transactions through the client, are suggested to be halted. The text in the Message string should be relayed to log files and any user interfaces.&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || message || var_str || System message which is coded to convey some information to all nodes in the network&lt;br /&gt;
|-&lt;br /&gt;
| ? || signature || var_str || A signature which can be confirmed with a public key verifying that it is Satoshi (the originator of Bitcoins) who has &amp;quot;authorized&amp;quot; or created the message&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The signature is to be compared to this ECDSA public key:&lt;br /&gt;
&lt;br /&gt;
 04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284&lt;br /&gt;
 (hash) 1AGRxqDa5WjUKBwHB9XYEjmkv1ucoUUy1s&lt;br /&gt;
&lt;br /&gt;
Source: [http://www.bitcoin.org/smf/index.php?topic=898.0]&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
See [[script]].&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Network]]&lt;br /&gt;
* [[Protocol rules]]&lt;br /&gt;
[[zh-cn:协议说明]]&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Simapple</name></author>
	</entry>
</feed>