Post
Topic
Board Beginners & Help
Re: Bitcoin transaction verify
by
DannyHamilton
on 24/10/2017, 15:43:29 UTC
Im try to understand verifing bitcoin transaction but I cant find this part anywhere. Summary, the proces before forming blocks. My questions is:

1) when i send transaction who validate it?

Every node on the network.

Your wallet or your service builds the transaction and sends it to connected peer nodes.  Each of those peer nodes validates it.  If it is invalid, they ignore it.  If it is valid, they send it to the peer nodes that they are connected to. Each of those peer nodes validates it.  If it is invalid, they ignore it.  If it is valid, they send it to the peer nodes that they are connected to. Each of those peer nodes validates it.  If it is invalid, they ignore it.  If it is valid, they send it to the peer nodes that they are connected to. This process repeats until nearly the entire network of nodes has all heard about and validated the transaction.

Here I think, who can check and found that I haven't got enough money in my wallet.

That's not how bitcoin transactions work.

They don't need to know how much money you have in your wallet.  They only need to know which previously unspent outputs you are using as inputs to your transaction, and whether you are allowed to spend those outputs.

Example; I send 100 BTC but I have only 50.

If you don't have the ability to satisfy the requirements of 100 BTC worth of unspent outputs, then you won't be able to build a valid transaction.

The problem is bigger becouse in my prior transactions, refund come back on "new" wallet

The only way to perform a "refund" to you in the bitcoin system is to send a transaction that pays you. That transaction is no different than any other transaction.

and who can trace all my wallet to sum how much I have in that situation.

That's not how bitcoin transactions work.

They don't need to know how much money you have in your wallet.  They only need to know which previously unspent outputs you are using as inputs to your transaction, and whether you are allowed to spend those outputs.

2) can one transaction go by mistake in two blocks,

No.

and who prevent this ?

Every node on the network.  If a transaction in a block tries to spend outputs which were already spent in a transaction in an earlier block, then that second transaction is invalid.  If a block includes an invalid transaction, then the block is invalid.

The miner or mining pool builds and solves a block and sends it to connected peer nodes.  Each of those peer nodes validates it.  If it is invalid, they ignore it.  If it is valid, they send it to the peer nodes that they are connected to. Each of those peer nodes validates it.  If it is invalid, they ignore it.  If it is valid, they send it to the peer nodes that they are connected to. Each of those peer nodes validates it.  If it is invalid, they ignore it.  If it is valid, they send it to the peer nodes that they are connected to. This process repeats until nearly the entire network of nodes has all heard about and validated the block.

But if my wallet takes care of my amount (that I can spend) why blockchain implement so much protection about double spending???

Your wallet protects YOU from creating an invalid transaction that the network will ignore.  However, without the protections of the blockchain, proof-of-work, and nodes, it would be possible for a malicious person to create their own wallet software that would break the rules. The entire system needs to be designed in a way that a single malicious person (or group of malicious people) are forced to follow the same rules as everyone else.

Suppouse that two transaction came into the same time (in milisecond) on network. Who than say you will be last transaction in block n-1, and you will be first in block n.

The miners (or mining pools) are allowed to choose any valid unconfirmed transactions for their blocks.  As long as the transactions are valid, there is no rule telling them which they can or can't choose, or what order they need to put the transactions in.  There is no central authority in charge.  The miner (or pool) just needs to make sure that they create blocks that all the nodes of the network will agree are valid.

If system is decentralized, what if other node say different.

All nodes of the system run with the same consensus rules.  If some nodes change the rules, that creates a fork in the system.  It forks into two different systems each with their own rules. That is what happened with "Bitcoin Cash" and "Bitcoin Gold".  It is also what might happen next month with "SegWit 2x".  In all those cases, nodes chose to operate with different rules, so the system split into separate systems.