第01部分何跃444715148odim校对.docx
- 文档编号:29294862
- 上传时间:2023-07-22
- 格式:DOCX
- 页数:13
- 大小:143.26KB
第01部分何跃444715148odim校对.docx
《第01部分何跃444715148odim校对.docx》由会员分享,可在线阅读,更多相关《第01部分何跃444715148odim校对.docx(13页珍藏版)》请在冰豆网上搜索。
第01部分何跃444715148odim校对
翻译第1部分
FinddetailedinformationabouttheBitcoinprotocolandrelatedspecifications.
比特币协议和相关规范的细节说明
TheDeveloperGuideaimstoprovidetheinformationyouneedtostartbuildingBitcoin-basedapplications.Tomakethebestuseofthisguide,youmaywanttoinstallthecurrentversionofBitcoinCore,eitherfrom source orfroma pre-compiledexecutable.
这个开发者指南的目标是在你开发一个比特币周边应用的时候,给你提供足够的信息。
为了更好地使用这个指南,你需要安装最新的bitcoin内核的客户端,可以下载github里面的源码或者官网的预编译版本。
Onceinstalled,you’llhaveaccesstothreeprograms:
bitcoind, bitcoin-qt,andbitcoin-cli.Whenrunwithnoarguments,allthreeprogramsdefaulttoBitcoin’smainnetwork (mainnet)whichwillrequireyoupurchase satoshis inordertogeneratetransactions.
一旦安装完毕,你将有以下的三个可执行程序:
bitcoind, bitcoin-qt,andbitcoin-cli。
如果你启动的时候没带参数,所有的程序都会默认连接到比特币主网络network (mainnet)。
要在网络上创建交易,你就要支付比特币。
比特币的最小单位是“聪(satoshis)”,0.00000001BTC=1 satoshis。
However,fordevelopment,it’ssaferandcheapertouseBitcoin’stest network (testnet)wherethe satoshis spenthavenoreal-worldvalue. Testnet alsorelaxessomerestrictions(suchas standardtransaction checks)soyoucantestfunctionswhichmightcurrentlybedisabledbydefaulton mainnet.
但是,为了开发,使用比特币测试网络更为安全和便宜 network (testnet),在测试网络中的比特币没有真实世界的价值。
测试网络 对有些限制有所放松,(如对标准交易的检测),它能测试一些在主网络中被禁止的函数,
Touse testnet,usetheargument -testnet witheachprogramoradd testnet=1 toyour bitcoin.conf file.Togetfree satoshis fortesting,use PiotrPiasecki’stestnetfaucet. Testnet isapublicresourceprovidedforfreebymembersofthecommunity,sopleasedon’tabuseit.
如果要使用测试网络testnet,启动的时候需要添加参数 -testnet 或者添加testnet=1到你的bitcoin.conf 文件里面.在PiotrPiasecki’stestnetfaucet,你可以获得一些免费的测试比特币。
测试网络是社区人员免费提供的公共资源,请不要滥用。
Youcanspeedupdevelopmentfurtherusingthe regressiontestmode whichcreatesanew testnet localtoyourcomputer.Thisregtestmodewillletyougenerate blocksalmostinstantlywitha RPC commandsoyoucangenerateyourown satoshis andaddtransactionstothe blockchain immediately.
你可以进一步使用regressiontestmode(回归测试模式)来加快你的开发,这个模式可以在你的电脑上创建一个本地的测试网络。
回归测试模式可以让你通过RPC命令快速创建blocks、获取测试比特币、即刻在blockchain上生成交易。
•bitcoin-qt providesacombinationfullBitcoin peer and wallet frontend.FromtheHelpmenu,youcanaccessaconsolewhereyoucanenterthe RPC commandsusedthroughoutthisdocument.
•bitcoin-qt 提供了一个完整的Bitcoin peer 和钱包的前端.在帮助菜单中,你可以找到一个敲RPC 命令的终端
•bitcoind ismoreusefulforprogramming:
itprovidesafull peer whichyoucaninteractwiththrough RPCs toport8332(or18332for testnet).
•bitcoind 是个更有用的程序:
它提供了一个完整的 peer(节点) 你可以使用RPCs命令和它交流,正式端口默认8332(测试网络默认端口18332).
•
•bitcoin-cli allowsyoutosend RPC commandsto bitcoind fromthecommandline.Forexample, bitcoin-clihelp
•bitcoin-cli 允许你通过命令行发送 RPC 命令给bitcoind .举个例子,bitcoin-clihelp
•Allthreeprogramsgetsettingsfrom bitcoin.conf inthe Bitcoin applicationdirectiory:
这三个程序都会从Bitcoin程序目录里的bitcoin.conf中读取参数设置:
•Windows:
%APPDATA%\Bitcoin\
•OSX:
$HOME/Library/ApplicationSupport/Bitcoin/
•Linux:
$HOME/.bitcoin/
QuestionsaboutBitcoindevelopmentarebestsenttotheBitcoin Forum and IRCchannels.ErrorsorsuggestionsrelatedtodocumentationonBitcoin.orgcanbesubmittedasanissue orpostedtothe bitcoin-documentationmailinglist.
关于比特币开发的问题最好发送到比特币论坛 和IRC频道.对于Bitcoin.org的文档的错误和建议,请以提案的方式提交或者发送到 bitcoin-documentation邮件列表.
Inthefollowingguide,somestringshavebeenshortenedorwrapped:
“[…]”indicatesextradatawasremoved,andlinesendinginasinglebackslash“\”arecontinuedbelow.Ifyouhoveryourmouseoveraparagraph,cross-referencelinkswillbeshowninblue.Ifyouhoveroveracross-referencelink,abriefdefinitionofthetermwillbedisplayedinatooltip.
在以下的指南里,某些字符串被缩写成:
“[…]”,表示额外的数据被删除了,以“\”结束的行表明下面还有.如果你把你的鼠标移动到一个段落,有链接的文字会变成蓝色。
如果你移动到有链接的文字上,在工具提示上会出现一个简介。
BlockChain
区块链
The blockchain providesBitcoin’spublicledger,atimestampedrecordofall confirmedtransactions.Thissystemisusedtoprotectagainst doublespending andmodificationofprevioustransactionrecords,using proofofwork verifiedbythe peer-to-peernetwork tomaintainaglobalconsensus.
区块链提供了比特币的公开总账本,这个总账本由所有有时序的已确定的交易组成。
这个系统被用于防止双花和修改以前的交易记录,通过被全球P2P网络验证的 工作量证明POW 来保证全球的一致性.
BlockChainOverview
区块链概览
Theillustrationaboveshowsasimplifiedversionofa blockchain.A block ofoneormorenewtransactionsiscollectedintothetransactiondatapartofa block.Copiesofeachtransactionarehashed,andthehashesarethenpaired,hashed,pairedagain,andhashedagainuntilasinglehashremains,the Merkleroot ofa Merkletree.
上面的插图展示了一个简化版本的区块链.一个包含一个或者多个交易的区块 会被收集到区块的交易数据部分.每个交易的副本都会被哈希,然后将哈希值进行配对,然后再进行哈希,再配对,再哈系,直到只剩下一个哈希值,这个剩下的哈希值就是 Merkletree(Merkle树)的Merkleroot(根节点)。
The Merkleroot isstoredinthe blockheader.Each block alsostoresthehashoftheprevious block’s header,chainingthe blocks together.Thisensuresatransactioncannotbemodifiedwithoutmodifyingthe block thatrecordsitandallfollowing blocks.
Merkle根节点 被存储在 区块头.每个区块 也会存储上一个区块头的哈希值,以把所有的区块链接在一起.这保证了在不修改当前和后面的所有区块的情况下,交易记录是不会被修改的。
Transactionsarealsochainedtogether.Bitcoin wallet softwaregivestheimpressionthat satoshis aresentfromandto addresses,but bitcoins reallymovefromtransactiontotransaction.Each standardtransaction spendsthe satoshis previouslyspentinoneormoreearliertransactions,sothe input ofonetransactionisthe output ofaprevioustransaction.
交易记录也被链接在一起。
比特币钱包 软件只记录了比特币的发送接收,但比特币确实在交易间转移。
每个标准交易花费的satoshis 是前一个交易转移过来的币,所以一个交易的输入是上一个交易的输出。
Asingletransactioncanspend bitcoins tomultiple outputs,aswouldbethecasewhensending satoshis tomultiple addresses,buteach output ofaparticulartransactioncanonlybeusedasan input onceinthe blockchain.Anysubsequentreferenceisaforbidden doublespend—anattempttospendthesame satoshis twice.
单个比特币交易能把比特币 发送到不同的输出中,就像你把比特币一次发送到不同的地址一样,但是一次输出在区块链中只能使用一次所有的后续引用都禁止双花—一种把比特币花两次的尝试。
Outputs arenotthesameasBitcoin addresses.Youcanusethesame address inmultipletransactions,butyoucanonlyuseeach output once. Outputs aretiedtotransactionidentifiers(TXIDs),whicharethehashesofsignedtransactions.
输出不同于比特币 地址。
你可以在多个交易中使用同一个地址,但是输出 只能被使用一次。
输出 与交易id(TXIDs)绑定,txid就是签名交易的哈希值
Becauseeach output ofaparticulartransactioncanonlybespentonce,alltransactionsincludedinthe blockchain canbecategorizedaseither UnspentTransactionOutputs(UTXOs) orspenttransaction outputs.Forapaymenttobevalid,itmustonlyuseUTXOs as inputs.
因为每个交易的输出只能被使用一次,所有在区块链 中的输出能被分类为未使用交易输出UnspentTransactionOutputs(UTXOs) 或者已使用输出.为了让支付有效,必须使用 未使用输出UTXOs 来作为输入.
Satoshis cannotbeleftina UTXO afteratransactionortheywillbeirretrievablylost,soanydifferencebetweenthenumberof satoshis inatransaction’s inputs and outputs isgivenasa transactionfee totheBitcoin miner whocreatesthe block containingthattransaction.Forexample,intheillustrationabove,eachtransactionspends10,000satoshis fewerthanitreceivesfromitscombined inputs,effectivelypayinga10,000satoshi transactionfee.
比特币在产生交易之后,不能留在UTXO中,否则这个余额会永久的丢失掉,所以输入和输出之间的差值就是交易费,都是对把这个交易打包到区块的矿工的奖励。
例如,在上面的插图中,每次交易收到的都比发出的会少1000聪,这10000聪就是交易费
ProofOfWork
ProofOfWork工作量证明
The blockchain iscollaborativelymaintainedona peer-to-peernetwork,soBitcoinrequireseach block proveasignificantamountofworkwasinvestedinitscreationtoensurethatuntrustworthy peers whowanttomodifypast blocks havetoworkharderthantrustworthy peers whoonlywanttoaddnew blocks tothe blockchain.
区块链 是由P2P网络(peer-to-peernetwork)协作维护的,比特币网络要求在创建区块的时候要提供一定的工作量证明,以保证那些想改变历史区块的不诚实的节点必须付出比那些仅仅想在链上加一个新区块的诚实节点更多的资源。
Chaining blocks togethermakesitimpossibletomodifytransactionsincludedinanyblock withoutmodifyingallfollowing blocks.Asaresult,thecosttomodifyaparticularblock increaseswitheverynew block addedtothe blockchain,magnifyingtheeffectofthe proofofwork.
如果不修改后面所有的区块,修改已经打包到区块中的交易成为一件不可能的事情,这也是把区块链接到一起的用处。
因此,修改一个区块的费用会随着新区块的增加而增加,工作量证明的作用也就随之变大。
The proofofwork usedinBitcointakesadvantageoftheapparentlyrandomnatureofcryptographichashes.Agoodcryptographichashalgorithmconvertsarbitrarydataintoaseemingly-randomnumber.Ifthedataismodifiedinanywayandthehashre-run,anewseemingly-randomnumberisproduced,sothereisnowaytomodifythedatatomakethehashnumberpredictable.
比特币网络中的工作量证明利用了密码学哈希算法的伪随机性。
一个好的密码学哈希可以把任意的数据转换成一个看起来随机的数字。
如果这个原始数据的任何地方被更改,然后重新计算哈希,将会生成一个完全不同的新的哈希结果。
所以修改数据以预知哈希的结果是不可能的。
Toproveyoudidsomeextraworktocreatea block,youmustcreateahashoftheblockheader whichdoesnotexceedacertainvalue.Forexample,ifthemaximumpossiblehashvalueis 2256 − 1,youcanprovethatyoutrieduptotwocombinationsbyproducingahashvaluelessthan 2256 − 1.
为了证明你已经做了一些创建区块的工作,你需要计算出一个不大于某个特定值的块头的哈希值。
举个例子:
如果这个最大哈希值是2256 − 1,你只要证明你做了两次组合就可以使哈希值小于2256 − 1。
Intheexamplegivenabove,youwillalmostcertainlyproduceasuccessfulhashonyourfirsttry.Youcanevenestimatetheprobabilitythatagivenhashattemptwillgenerateanumberbelowthe target threshold.Bitcoinitselfdoesnottrackprobabilitiesbutinsteadsimplyassumesthattheloweritmakesthe target threshold,themorehashattempts,onaverage,willneedtobetried.
在上面的例子中,你很有可能在第一次尝试的时候就生成了一个成功的哈希值。
你甚至可以估算你要达到的某个阈值所需要的尝试的次数。
比特币本身并不能控制这个可能性,但是单纯假设这个阈值越小需要尝试的次数越多,平均下来也就是个平均数(这个是概率平均)。
New blocks willonlybeaddedtothe blockchain iftheirhashisatleastaschallengingasa difficulty valueexpectedbythe peer-to-peernetwork.Every2,016 blocks,thenetwork usestimestampsstoredineach blockheader tocalculatethenumberofsecondselapsedbetweengenerationofthefirstandlastofthoselast2,016 blocks.Theidealvalue
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 01 部分 444715148 odim 校对
![提示](https://static.bdocx.com/images/bang_tan.gif)