简体   繁体   English

区块链中的交易如何运作? 分步演练

[英]How does a transaction in Blockchain work? Step-by-Step walkthrough

I'm really new to Blockchain and how Bitcoin works and I really can't find any single source that goes through how a transaction in blockchain works in detail and a step by step manner. 我对区块链真的很陌生,对于比特币是如何工作的,我真的找不到任何单个来源来了解区块链中的交易如何详细,逐步地工作。

So the following is what I have pieced together from many many sites and I'm still not sure if it's the right thing because everyone seems to say different things. 因此,以下是我在许多网站上总结的内容,但我仍然不确定这是否正确,因为每个人似乎都在说不同的话。

Please do let me know if I'm wrong somewhere: 如果在某处有错,请告诉我:

A user will have a bitcoin wallet that is not really a wallet. 用户将拥有一个不是真正的钱包的比特币钱包。 It stores your wallet address or your public key. 它存储您的钱包地址或公共密钥。 This public key can be used to see how many transactions you've done ever and if you even have the money required for the transaction. 此公用密钥可用于查看您曾经进行过多少笔交易,甚至查看您是否有交易所需的资金。 You also have a private key. 您也有一个私钥。

If you want to make a transaction then your private key and your transactions details are hashed together to create a signature. 如果您要进行交易,则将您的私钥和交易详细信息混在一起以创建签名。

This signature is broadcasted to all the members of the network, that is, the nodes. 该签名被广播到网络的所有成员,即节点。

The transaction can be validated to see if I even have the money that I'm sending by the members of the network or the nodes. 可以验证该交易,以查看我是否还拥有网络成员或节点发送的钱。 This is done using my public key and the signature that was broadcasted. 这是使用我的公钥和广播的签名完成的。

Once validated, my signature or the hash of my transaction along with my private key is send to miners who get a lot of other transactions too. 一旦通过验证,我的签名或交易的哈希值以及我的私钥就会发送给矿工,他们也将获得许多其他交易。 These transactions are hashed using the merkle tree and finally a block header is created. 使用merkle树对这些事务进行哈希处理,最后创建一个块头。 The block header is checked by the other miners to see if it's valid or not. 区块头由其他矿工检查,以查看其是否有效。 If it is, then it is added to the blockchain. 如果是,则将其添加到区块链。

The blockheader is basically a hash of the root hash, the previous blocks hash and the nonce. 块头基本上是根哈希,前面的块哈希和随机数的哈希。

A user will have a bitcoin wallet that is not really a wallet. 用户将拥有一个不是真正的钱包的比特币钱包。 It stores your wallet address or your public key. 它存储您的钱包地址或公共密钥。 This public key can be used to see how many transactions you've done ever and if you even have the money required for the transaction. 此公用密钥可用于查看您曾经进行过多少笔交易,甚至查看您是否有交易所需的资金。 You also have a private key. 您也有一个私钥。

Correct, but not completely precise. 正确,但不完全精确。 You can have multiple public keys which belong to a single private key. 您可以有多个公用密钥,它们属于一个专用密钥。 The private key is essentially your 'wallet' and also necessary to count all coins which belong to you. 私钥本质上是您的“钱包”,也是计算属于您的所有硬币的必要条件。 It gives access to all your funds. 它可以访问您所有的资金。

The transaction can be validated to see if I even have the money that I'm sending by the members of the network or the nodes. 可以验证该交易,以查看我是否还拥有网络成员或节点发送的钱。 This is done using my public key and the signature that was broadcasted. 这是使用我的公钥和广播的签名完成的。

Also you will need your private key here, as you can send from multiple inputs as well 另外,您还需要在这里输入私钥,因为您也可以从多个输入中发送

You are using validation interchangeably here but there is two kinds I guess: 您在这里互换使用验证,但是我猜有两种:

  • creating a valid transaction (which can be done offline with your keys) 创建有效的交易(可以使用您的钥匙离线完成交易)

  • having a transaction validated by the network (which happens online, when it is included in a block) 由网络验证交易(在线交易在区块中包含时)

Once validated, my signature or the hash of my transaction along with my private key is send to miners ... 验证后,我的签名或交易的哈希值以及我的私钥将发送给矿工...

I better hope your private key is not sent anywhere. 最好不要将您的私钥发送到任何地方。 What you send is the transaction which contains your public key and is signed with the private one. 你发什么是包含你的公钥和与一个私人签订的交易。 Once again, this is possible and even encouraged to be done offline in order not to expose your private key. 再一次,这是可能的,甚至鼓励离线进行以免暴露您的私钥。 The signed transaction can safely be sent to the network without exposing any keys. 可以在不暴露任何密钥的情况下将已签名的交易安全地发送到网络。 This is a security feature of Hardware wallets such as Ledger 这是诸如Ledger之类的硬件钱包的安全功能

..who get a lot of other transactions too. ..谁也获得许多其他交易。

It is sent to the mempool, which is the queue in which unconfirmed but signed transactions wait for validation by the miners. 它被发送到内存池,该内存池中未确认但已签名的交易等待矿工进行验证。 When a miner finds a block by solving the nonce it picks an amount of transactions from the mempool. 当矿工通过解决随机数找到一个区块时,它会从内存池中选择一定数量的交易。 These are then persisted in the block and removed from the mempool. 然后将它们保留在块中,并从内存池中删除。

These transactions are hashed using the merkle tree and finally a block header is created. 使用merkle树对这些事务进行哈希处理,最后创建一个块头。 The block header is checked by the other miners to see if it's valid or not. 区块头由其他矿工检查,以查看其是否有效。 If it is, then it is added to the blockchain. 如果是,则将其添加到区块链。

Yeah, sounds about right. 是的,听起来不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM