




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、翻譯 第1部分 Find detailed information about the Bitcoin protocol and related specifications.比特幣協(xié)議和相關規(guī)范的細節(jié)說明The Developer Guide aims to provide the information you need to start building Bitcoin-based applications. To make the best use of this guide, you may want to install the current version of Bitcoin
2、 Core, either from source or from a pre-compiled executable.這個開發(fā)者指南的目標是為了在你開發(fā)一個比特幣周邊應用的時候提供,給你提供足夠的信息。為了更好地使用這個指南,你需要安裝最新的bitcoin內核的客戶端,可以下載github里面的源碼或者官網的預編譯版本 。Once installed, youll have access to three programs: bitcoind, bitcoin-qt, and bitcoin-cli. When run with no arg
3、uments, all three programs default to Bitcoins mainnetwork (mainnet) which will require you purchase satoshis in order to generate transactions.一旦安裝完畢,你將有以下的三個可執(zhí)行程序:bitcoind, bitcoin-qt, andbitcoin-cli。 如果你啟動的時候沒帶參數(shù),所有的程序都會默認連接到比特幣主網絡network (mainnet)。這樣要在網絡上創(chuàng)建就你在交易,你的時候就需要支
4、付比特幣才能創(chuàng)建交易。比特幣的最小單位是“聰(satoshis)”,0.00000001 BTC = 1 satoshis。However, for development, its safer and cheaper to use Bitcoins test network (testnet) where the satoshis spent have no real-world value. Testnet also relaxes some restrictions (such as standard tra
5、nsaction checks) so you can test functions which might currently be disabled by default on mainnet.但是,為了開發(fā),使用比特幣測試網絡更為安全和便宜 network (testnet) ,在測試網絡中的比特幣沒有真實世界的價值。 測試網絡 對有些限制有所放松,(如對標準交易的檢測),它能測試一些在主網絡中被禁止的一些函數(shù),對有些限制有所放松,(比如標準交易 交易是否標準檢測)。To use testnet, use t
6、he argument -testnet with each program or add testnet=1 to your bitcoin.conf file. To get free satoshis for testing, use Piotr Piaseckis testnet faucet. Testnet is a public resource provided for free by members of the community, so please dont a
7、buse it.如果要使用測試網絡testnet, 啟動的時候需要添加參數(shù) -testnet 或者添加testnet=1到你的bitcoin.conf 文件里面. 在Piotr Piaseckis testnet faucet,你這里可以獲得一些免費的測試比特幣Piotr Piaseckis testnet faucet。測試網絡是社區(qū)人員免費提供的公共資源,請不要濫用。You can speed up development further using the regression test mode which creates a new&
8、#160;testnet local to your computer. This regtest mode will let you generate blocks almost instantly with a RPC command so you can generate your own satoshis and add transactions to the block chain immediately.你可以進一步使用regression test mode(回歸測試模式)來加快你的開發(fā),這個模式可以
9、在你的電腦上創(chuàng)建一個本地的測試網絡。 回歸測試模式可以讓你通過RPC命令快速很快地創(chuàng)建blocks、獲取測試比特幣、即刻在生成交易到block chain上生成交易。 bitcoin-qt provides a combination full Bitcoin peer and wallet frontend. From the Help menu, you can access a console where you can enter the RPC commands used throughout this docum
10、ent. bitcoin-qt 提供了一個完整的Bitcoin peer 和錢包的前端.在幫助菜單中錢包里面,你可以找到一個敲RPC 命令的終端 bitcoind is more useful for programming: it provides a full peer which you can interact with through RPCs to port 8332 (or 18332 for testnet). bitcoind 是個更有用的程序: 它提供了一個完整的&
11、#160;peer(節(jié)點) 你可以使用RPCs命令和它交流,正式端口默認8332 (測試網絡默認端口18332). bitcoin-cli allows you to send RPC commands to bitcoind from the command line. For example, bitcoin-cli help bitcoin-cli 允許你通過命令行發(fā)送 RPC 命令給bitcoind . 舉個例子,bitcoin-cli help All three progr
12、ams get settings from bitcoin.conf in the Bitcoin application directiory:這三個程序都會從Bitcoin程序目錄里的bitcoin.conf中讀取參數(shù)設置配置文件bitcoin.conf,這個文件在Bitcoin程序目錄里面: Windows: %APPDATA%Bitcoin OSX: $HOME/Library/Application Support/Bitcoin/ Linux: $HOME/.bitcoin/Questions about Bit
13、coin development are best sent to the Bitcoin Forum and IRC channels. Errors or suggestions related to documentation on B can be submitted as an issue or posted to the bitcoin-documentation mailing list.關于比特幣開發(fā)的問題最好發(fā)送到比特幣論壇 和IRC 頻道. 對于B的文檔的錯誤和建議,請以提案
14、的方式提交提交一個提案或者發(fā)送到 bitcoin-documentation 郵件列表.In the following guide, some strings have been shortened or wrapped: “” indicates extra data was removed, and lines ending in a single backslash “” are continued below. If you hover your mouse over a paragraph, cross-reference links will be shown in b
15、lue. If you hover over a cross-reference link, a brief definition of the term will be displayed in a tooltip.在以下下面的指南書里面, 某些字符串被縮寫成: “” ,標表示明額外的數(shù)據(jù)被刪除了, 以 “” 結束的行表標明下面的還有. 如果你把你的鼠標移動到一個段落,有鏈接的文字會變成藍色。如果你移動到有鏈接的文字上,在工具提示上會出現(xiàn)有一個簡明的簡介。在上面Block Chain區(qū)塊鏈The block chain provides Bitcoins public l
16、edger, a timestamped record of all confirmed transactions. This system is used to protect against double spending and modification of previous transaction records, using proof of work verified by the peer-to-peer network to maintain a global consensus.區(qū)塊鏈提供了比特幣的所有公
17、開總賬本, 這個總賬本由所有有時序的已確定的交易組成。這個系統(tǒng)被用于防止保護雙花雙發(fā)和修改以前的交易記錄, 通過由被全球P2P網絡驗證的 工作量證明POW 來保證全球的的一致性.Block Chain Overview區(qū)塊鏈概覽The illustration above shows a simplified version of a block chain. A block of one or more new transactions is collected into the transaction data part of a
18、;block. Copies of each transaction are hashed, and the hashes are then paired, hashed, paired again, and hashed again until a single hash remains, the Merkle root of a Merkle tree.上面的這個插圖展示了一個簡化版本的區(qū)塊鏈. 一個包含一個或者多個交易的區(qū)塊 的會被收集一個或者多個交易到區(qū)塊的交易數(shù)據(jù)部分. 每個交易的副本都會被哈希hashed,然后將哈希值進行hash配對,然后再
19、進行哈希hash,再配對,再哈系hash,直到只、配對到只剩下一個哈希hash值,這個剩下的哈希hash值就是 Merkle tree(Merkle 樹)的Merkle root(根節(jié)點)。The Merkle root is stored in the block header. Each block also stores the hash of the previous blocks header, chaining the blocks together. This ensures a
20、transaction cannot be modified without modifying the block that records it and all following blocks.Merkle根節(jié)點 被存儲在 區(qū)塊頭. 每個區(qū)塊 也會存儲上一個區(qū)塊的頭的哈希值, 以用于把所有的區(qū)塊鏈接在一起. 這保證了在如果你不修改把當前和后面的所有區(qū)塊都修改的情況下,你是不可能修改交易記錄是不會被修改的。Transactions are also chained together. Bitcoin wallet
21、0;software gives the impression that satoshis are sent from and to addresses, but bitcoins really move from transaction to transaction. Each standard transaction spends the satoshis previously spent in one or more earlier transactions, so the input
22、160;of one transaction is the output of a previous transaction.交易記錄也被鏈接在一起。. 比特幣錢包 軟件只記錄了比特幣的發(fā)送接收從一個地址發(fā)送到另外一個地址, 但是比特幣確實真實的在一個交易間和一個交易之間轉移。. 每個標準交易花費的satoshis 的是前一個交易轉移過來的幣, 所以一個交易的 輸入的交易是上一個交易的輸出。A single transaction can spend bitcoins to multiple outputs, as
23、 would be the case when sending satoshis to multiple addresses, but each output of a particular transaction can only be used as an input once in the block chain. Any subsequent reference is a forbidden double spendan attempt to spend the same satoshi
24、s twice.單個比特幣比交易能把比特幣 發(fā)送到不同的輸出中, 就像你把比特幣一次發(fā)送到不同的比特幣地址一樣,但是一次輸出只能在區(qū)塊鏈中只能使用一次 所有的后續(xù)引用都禁止的雙花發(fā)一種把比特幣花兩次的嘗試。Outputs are not the same as Bitcoin addresses. You can use the same address in multiple transactions, but you can only use each output once. Outputs
25、0;are tied to transaction identifiers (TXIDs), which are the hashes of signed transactions.輸出不同于比特幣 地址。你可以在多個交易中使用同一個地址 在復合交易中, 但是輸出 只能被使用一次。輸出 被綁定在交易id上與交易id(TXIDs)綁定, txid就是交易簽名交易的哈希值Because each output of a particular transaction can only be spent once, all transacti
26、ons included in the block chain can be categorized as either Unspent Transaction Outputs (UTXOs) or spent transaction outputs. For a payment to be valid, it must only useUTXOs as inputs.因為每個交易的輸出只能被使用一次, 所有在區(qū)塊鏈 中的輸出能被分類為未使用交易輸出Unspent Transaction Outputs (UTXO
27、s) 或者已使用輸出. 為了讓了一個支付是有效的, 必須使用 未使用輸出UTXOs 來作為輸入.Satoshis cannot be left in a UTXO after a transaction or they will be irretrievably lost, so any difference between the number of satoshis in a transactions inputs and outputs is given as a
28、60;transaction fee to the Bitcoin miner who creates the block containing that transaction. For example, in the illustration above, each transaction spends 10,000satoshis fewer than it receives from its combined inputs, effectively paying a 10,000satoshi transa
29、ction fee.比特幣在產生交易之后,不能留在UTXO中, 否則這個余額會永久的丟失掉, 所以有在輸入和輸出之間的差值就是交易費,都是對給把這個交易打包到一個區(qū)塊的礦工的獎勵。舉例如,在上面的插圖中,每次交易收到的都比發(fā)出的會少1000聰, 這10000聰就是交易費Proof Of WorkProof Of Work 工作量證明The block chain is collaboratively maintained on a peer-to-peer network, so Bitcoin requires each block prov
30、e a significant amount of work was invested in its creation to ensure that untrustworthy peers who want to modify past blocks have to work harder than trustworthy peers who only want to add new blocks to the block chain.區(qū)塊鏈 是由P2P網絡(peer-to-peer netwo
31、rk)協(xié)作維護的, 比特幣網絡要求在創(chuàng)建區(qū)塊的時候要提供一定的工作量證明,以用來保證那些想改變歷史區(qū)塊的不誠實的節(jié)點必須付出比那些僅僅想在鏈上加一個新區(qū)塊的誠實節(jié)點更多的資源。Chaining blocks together makes it impossible to modify transactions included in any block without modifying all following blocks. As a result, the cost to modify a particular block increa
32、ses with every new block added to the block chain, magnifying the effect of the proof of work.如果不修改后面所有的區(qū)塊,修改改變已經打包到區(qū)塊中的交易成為一件不可能的事情,這也是把區(qū)塊鏈接到一起的用處。 因此,修改一個一個區(qū)塊鏈的費用數(shù)據(jù)會隨著新區(qū)塊鏈的增加而增加,增加了工作量證明的作用也就隨之變大。The proof of work used in Bitcoin takes advantage of the apparently rand
33、om nature of cryptographic hashes. A good cryptographic hash algorithm converts arbitrary data into a seemingly-random number. If the data is modified in any way and the hash re-run, a new seemingly-random number is produced, so there is no way to modify the data to make the hash number predictable.
34、用在比特幣網絡中的工作量證明利用了密碼學哈希算法的偽隨機性。一個好的密碼學哈??梢园讶我獾臄?shù)據(jù)轉換成一個看起來隨機的數(shù)字。如果這個原始數(shù)據(jù)的更改任何地方被更改,然后重新計算哈希,有將會生成一個完全不同的新的哈希結果。所以沒有辦法可以讓一個修改數(shù)據(jù)以預知哈希的結果是不可能的可以預測。To prove you did some extra work to create a block, you must create a hash of the block header which does not exceed a certain value. For example, if
35、 the maximum possible hash value is 22561, you can prove that you tried up to two combinations by producing a hash value less than 22561.為了證明你已經做了一些創(chuàng)建區(qū)塊的工作,你需要計算出一個不大于某個特定值的去塊頭的哈希值。舉個例子: 如果這個最大哈希值是22561,你只需要證明你做了兩2次組合就可以使哈希值小于22561。In the example given above, you will almost certainly prod
36、uce a successful hash on your first try. You can even estimate the probability that a given hash attempt will generate a number below the target threshold. Bitcoin itself does not track probabilities but instead simply assumes that the lower it makes the target threshold, the mor
37、e hash attempts, on average, will need to be tried.在上面的例子中,你很有可能在第一次嘗試的時候就產生成了一個成功的哈希值在你第一次嘗試的時候。你甚至可以估算評估你需要達到的某個閾值所,你需要的嘗試的次數(shù)。比特幣本身并不能控制這個可能性,但是單純假設這個閾值越小,需要嘗試的次數(shù)越多,差不多平均下起來也就是個平均數(shù)(這個是概率平均)。New blocks will only be added to the block chain if their hash is at least as challengin
38、g as a difficulty value expected by the peer-to-peer network. Every 2,016 blocks, the network uses timestamps stored in each block header to calculate the number of seconds elapsed between generation of the first and last of those last 2,016 blocks. The ideal
39、value is 1,209,600 seconds (two weeks).只有當哈系值至少跟P2P網絡預期的難度值難度相當?shù)臅r候,算出的在期待閾值以下最小的那個哈希值的節(jié)點才能把新的區(qū)塊才會被加到區(qū)塊鏈上。, 比特幣網絡使用儲存在存在2016個區(qū)塊頭的時間戳的差值來計算下一輪的難度。這個差值的理想的間隔是1,209,600秒(兩周)。 If it took fewer than two weeks to generate the 2,016 blocks, the expected difficulty value is increased proportionally
40、 (by as much as 300%) so that the next 2,016 blocks should take exactly two weeks to generate if hashes are checked at the same rate. 如果產生2016個區(qū)塊需要的時間小于兩周,預期期待的難度將成比例地提高(大約300%)以便于下一個塊能夠準確地在兩周生成10分鐘左右,前提是保證在當前的HASH在同一算力. If it took more than two weeks to generate the blocks, the expected
41、160;difficulty value is decreased proportionally (by as much as 75%) for the same reason. 如果產生2016個塊的時間超過兩周,同樣地,預期期待的難度將降低(75%左右)。(Note: an off-by-one error in the Bitcoin Core implementation causes the difficulty to be updated every 2,016 blocks using timestamps from only 2
42、,015 blocks, creating a slight skew.)(注意: 由于比特幣內核實現(xiàn)的一個實現(xiàn)差一錯誤,導致每到造成了要在2016區(qū)塊的時候,因為使用了第2015塊的時間戳,難度就會更新難度很難,因為使用了第2015塊的時間戳,這導致了輕微的偏差。Because each block header must hash to a value below the target threshold, and because each block is linked to the block t
43、hat preceded it, it requires (on average) as much hashing power to propagate a modified block as the entire Bitcoin network expended between the time the original block was created and the present time. Only if you acquired a majority of the networks hashing power
44、could you reliably execute such a 51 percent attack against transaction history.由于每一塊的頭的部哈希值必須小于某個閾值,而且每一所有的區(qū)塊也必須鏈接到它前面的一個這個區(qū)塊的前面一個。要在原始區(qū)塊生成到當前這段時間里傳送一個已修改的區(qū)塊,(一般來說)需要消耗和整個比特幣網絡消耗的算力一樣多的哈系算力。it requires (on average) as much hashing power to propagate a modified block as the entire Bitcoin
45、network expended between the time the original block was created and the present time。只有你掌握了全網大多數(shù)哈希算力,例你才能有效地實現(xiàn)對交易歷史進行的51%的攻擊。The block header provides several easy-to-modify fields, such as a dedicated nonce field, so obtaining new hashes doesnt require waiting for new transactions. Also,
46、 only the 80-byte block header is hashed for proof-of-work, so adding more bytes of transaction data to a block does not slow down hashing with extra I/O.區(qū)塊頭提供了一些容易改的字段,例比如dedicated nonce field,所以獲取新塊的哈希不需要等新的交易的到來。同樣,. 只有80字節(jié)的區(qū)塊頭會被計算到POW的哈希中,因此所以添加更多的交易信息不會降低讓伴有額外IO的哈希計算降低速
47、度和額外的IO.Block Height And Forking區(qū)塊高度及分叉Any Bitcoin miner who successfully hashes a block header to a value below the target threshold can add the entire block to the block chain. (Assuming the block is otherwise valid.) These blocks are com
48、monly addressed by their block heightthe number of blocks between them and the first Bitcoin block (block 0, most commonly known as the genesis block). For example, block 2016 is where difficulty could have been first adjusted.任何所有成功計算出小于閾值的哈系值的礦工可以能把整這個區(qū)
49、塊加到區(qū)塊鏈中(假設這個區(qū)塊是有效的)。這些區(qū)塊被標記為當前區(qū)塊的高度-就是當前區(qū)塊到第一個塊(genesis block)的差值. 比如,第2016塊是第一個調整難度的塊。Multiple blocks can all have the same block height, as is common when two or more miners each produce a block at roughly the same time. This creates an apparent fork in the&
50、#160;block chain, as shown in the illustration above.多個區(qū)有很多塊可以會有同樣的區(qū)塊高度,這在兩個或兩個以上的礦工幾乎在同一時間創(chuàng)建了一個區(qū)塊的情況下是很常見的。當兩個或者多個礦工幾乎在同一時間創(chuàng)建了一個區(qū)塊. 這就正如上圖所示,區(qū)塊鏈上出現(xiàn)了顯然的在區(qū)塊鏈上分叉了,就像上面的插圖一樣。When miners produce simultaneous blocks at the end of the block chain, each peer individually choos
51、es which block to trust. (In the absence of other considerations, discussed below, peers usually trust the first block they see.)當?shù)V工同時在區(qū)塊鏈的末端生成區(qū)塊的時候創(chuàng)建了一個塊在區(qū)塊鏈的最后的時候,每個節(jié)點都獨立地選擇相信哪個區(qū)塊。.(在沒有其他考慮的情況下,節(jié)點通常選擇相信他們接收到的第一個塊)。Eventually a miner produces another blo
52、ck which attaches to only one of the competing simultaneously-mined blocks. This makes that side of the fork longer than the other side. Assuming a fork only contains valid blocks, normal peers always follow the longestfork (the most difficult chain
53、to recreate) and throw away (orphan) blocks belonging to shorter forks.最終,礦工會創(chuàng)建一個新塊,這個區(qū)塊附在其中一個競爭的會在并行區(qū)塊鏈的一條后面添加一個新塊。,這會使這個分支比別的分支更長。假設一個分支只包括有效的區(qū)塊,正常所有的節(jié)點將選擇最長的那個分支(最難創(chuàng)建的一個鏈),然后拋棄比它短的分支。Long-term forks are possible if different miners work at cross-purposes, such as somemine
54、rs diligently working to extend the block chain at the same time other miners are attempting a 51 percent attack to revise transaction history.長期的分叉是可能的,如果這些礦工有其他意圖,比如一些礦工在分叉之后的一條分支上奮力計算,嘗試51%攻擊去修改交易歷史。Since multiple blocks can have the same height during
55、 a block chain fork, block heightshould not be used as a globally unique identifier. Instead, blocks are usually referenced by the SHA256(SHA256() hash of their header.由于很多區(qū)塊在分叉的時候會有同樣的高度,所以高度不能作為唯一的區(qū)分。通常,都用它的SHA256的哈希值來表示這個區(qū)塊。Transaction DataEvery block must inclu
56、de one or more transactions. The first one of these transactions must be a coinbase transaction which should collect and spend the block reward and any transaction fees paid by transactions included in this block.每個區(qū)塊必須包含一個或者多個交易記錄,第一個交易記錄必須是coinbase(幣基)記錄,這個記錄包含了區(qū)
57、塊獎勵和本區(qū)塊的所有的交易費。The UTXO of a coinbase transaction has the special condition that it cannot be spent (used as an input) for at least 100 blocks. This temporarily prevents a miner from spending the transaction fees and block reward from a
58、0;block that may later be orphaned (destroyed) after a block chain fork.由挖礦出來的幣有一個特殊的使用條件,就是在此后的100塊只能不能使用。這個可以部分防止有的礦工花費可能以后被拋棄的區(qū)塊獎勵(分叉之后,這個礦工的這條鏈被拋棄)。Blocks are not required to include any non-coinbase transactions, but miners almost always do include additional trans
59、actions in order to collect their transaction fees.區(qū)塊不是必須包含所有的非-coinbase的交易,但是礦工們通常會為了他們的交易費把這些交易記錄給收錄進來。All transactions, including the coinbase transaction, are encoded into blocks in binaryrawtransaction format prefixed by a block transaction sequence numbe
60、r.所有的交易記錄,包含coinbase記錄,會在前面加上交易隊列的編報,并被編碼為rawtransaction格式的二進制進行存儲。The rawtransaction format is hashed to create the transaction identifier (txid). From these txids, the Merkle tree is constructed by pairing each txid with one other txid and then hashing them together. If there are
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025屆湖北恩施龍鳳民族初級中學七年級數(shù)學第二學期期末教學質量檢測模擬試題含解析
- 重要回顧的軟件設計師考試試題及答案
- 2025軟考網絡管理員考試精準試題及答案
- 網絡性能監(jiān)測技術及試題及答案分析
- 軟件設計師考試綜合素質評估試題及答案
- 計算機網絡的基礎設施考核試題及答案
- 2025年軟件設計師考試細節(jié)與試題及答案
- 法學概論考試技巧與復習策略試題及答案
- 2025法學概論考試的教師發(fā)展與試題及答案
- 2025年江蘇省蘇州市初三(上)化學期末陽光調研測卷含答案
- 宏觀經濟學知到智慧樹章節(jié)測試課后答案2024年秋浙江大學
- 2024年中考數(shù)學復習:中點模型專項練習
- 旅行社企業(yè)章程范本
- 2025年寧波余姚市直屬企業(yè)招招聘筆試參考題庫含答案解析
- 《心理健康測試》課件
- 《心房顫動》課件
- 靜脈輸液操作考試流程
- 校園藝術團指導教師聘用合同
- 藥店管理系統(tǒng)
- 物理化學知到智慧樹章節(jié)測試課后答案2024年秋華東理工大學
- 裝修代售合同范文
評論
0/150
提交評論