Bitcoin Forum
June 25, 2024, 01:31:35 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Question] Question about how does the bitcoin network prevent double-spending.  (Read 196 times)
yasmikash (OP)
Newbie
*
Offline Offline

Activity: 76
Merit: 0


View Profile
March 29, 2019, 02:13:19 PM
 #1

It is my first time started learning how do bitcoin transactions happen under the hood, and all the technology behind it.
So, I come across this double-spending thing and how does the network prevent it.
Basically, if I send the same 1BTC I have in my wallet to separate bitcoin addresses, one after another, only one transaction get confirmed (the first transaction most likely) , and the other one will be recognized as invalid. So, my question is how the network (or miners) confirm that a particular transaction is invalid(1BTC has already been spent)/valid(1BTC has not been spent), and according to what factors?

I know the technology behind the blockchain, and more specifically how transactions get added inside blocks and the proof-of-work miners do to include blocks into the blockchain.

WHAT I DON'T UNDERSTAND IS HOW THE NETWORK DETERMINE A CERTAIN TRANSACTION IS VALID OR NOT?

It'd be really great if one can explain it to me more clearly, so that I could understand the whole process, without having any doubts about anything.  
Carlton Banks
Legendary
*
Offline Offline

Activity: 3430
Merit: 3074



View Profile
March 29, 2019, 04:48:13 PM
 #2

so, your question is:

"I understand the whole of Bitcoin, but I don't understand it. will someone explain the whole of Bitcoin?"

Vires in numeris
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
March 29, 2019, 05:39:25 PM
Merited by Foxpup (3), bones261 (2)
 #3

Nodes validate transactions. Transactions must adhere to certain rules, and a node will check that it does. Since every node uses the same rules to validate, every node is in agreement as to whether a transaction is valid or invalid.

In particular, one of those nodes is that a transaction only spends Unspent Transaction Outputs. Nodes maintain a database of UTXOs and checks if a transaction's input spends something in that database. If it does, there is no double spend. If it doesn't, there may be a double spend, but it is invalid regardless. Either the output has already been spent (so it is a double spend and is thus invalid), or it spends an output that does not exist. Both are invalid things to do.

hv_
Legendary
*
Offline Offline

Activity: 2520
Merit: 1055

Clean Code and Scale


View Profile WWW
March 31, 2019, 03:15:59 PM
 #4

Miners are adding blocks to the chain and need to ensure the consensus rules, one of these are exactly to ensure no double spendings. In principal these double spending can happen if such txs come in via different mempools, where miners stack new txs to build blocks from. But if a miner did mine a block causing a double spend, others will reject it and the miner has mined for a loss / he will not get any mining reward.

So miners will not mine double spends since it is not

1 economical honored
2 would make bitcoin useless anyway.
3 sadly with rbf double spends / stealing txs can be done and cannot detected as such

Carpe diem  -  understand the White Paper and mine honest.
Fix real world issues: Check out b-vote.com
The simple way is the genius way - Satoshi's Rules: humana veris _
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!