简体   繁体   中英

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. 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

..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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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