Bitcoin Forum
November 27, 2026, 03:20:38 PM *
News: Latest Bitcoin Core release: 32.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How does the network check for double spending efficiently?  (Read 76 times)
tiffy (OP)
Jr. Member
*
Offline

Activity: 58
Merit: 61


View Profile
December 13, 2024, 07:44:31 PM
 #1

Why do I have to rescan the blockchain for hours to see the correct balance when I add a (old) descriptor/key, but when I broadcast a transaction, it is confirmed in no time at all? Sometimes it really only takes a few minutes to get the first confirmation. I usually end up in the next block or the one after that.  

How does the network check for double spending so efficiently?

Sorry for the maybe stupid question, but I'm stumped right now.
Mia Chloe
Legendary
*
Offline

Activity: 1274
Merit: 2325


Contact me for you designs...


View Profile
December 13, 2024, 07:58:08 PM
 #2

When you add an old descriptor/key to your Bitcoin wallet it actually initiates a blockchain rescan to update its internal UTXO set and reflect the correct balance. The process may actually ttake hours because your wallet is re-processing the entire blockchain, checking for any transactions related to the newly added key, and updating its wallet database accordingly also maybe because you network connection is a little slow.

In contrast when you broadcast a Bitcoin transaction the network checks the mempool for duplicate transactions, verifying the transaction's TXID and hash, checking the blockchain headers for proof-of-work validation, and using SPV  to verify the transaction's inclusion in the blockchain. These actually enable the network to efficiently prevent double-spending.

Op also note that the speed of your confirmation depends on the depth location of your transactions in the MEMPOOL. To place it at a lower depth in the MEMPOOL means you need to broadcast with a higher fee in that way it gets confirmed faster.

ABCbits
Legendary
*
Offline

Activity: 3808
Merit: 10529



View Profile
December 14, 2024, 09:09:34 AM
Merited by hosemary (2), Coin-1 (1), tiffy (1)
 #3

Why do I have to rescan the blockchain for hours to see the correct balance when I add a (old) descriptor/key

Actually it doesn't need to take hours if you specify "timestamp" on the imported descriptor.

How does the network check for double spending so efficiently?

Short answer, full node use UTXO index/database.

When you add an old descriptor/key to your Bitcoin wallet it actually initiates a blockchain rescan to update its internal UTXO set and reflect the correct balance. The process may actually ttake hours because your wallet is re-processing the entire blockchain, checking for any transactions related to the newly added key, and updating its wallet database accordingly also maybe because you network connection is a little slow.

Blockchain rescan doesn't require network connection.

In contrast when you broadcast a Bitcoin transaction the network checks the mempool for duplicate transactions, verifying the transaction's TXID and hash, checking the blockchain headers for proof-of-work validation, and using SPV  to verify the transaction's inclusion in the blockchain. These actually enable the network to efficiently prevent double-spending.

Please double check what you write. Transaction which just arrived on mempool is unconfirmed, so checking blockchain or block header isn't relevant. Using SPV approach doesn't make sense to full node either.

Op also note that the speed of your confirmation depends on the depth location of your transactions in the MEMPOOL. To place it at a lower depth in the MEMPOOL means you need to broadcast with a higher fee in that way it gets confirmed faster.

To be exact, higher fee rate.

tiffy (OP)
Jr. Member
*
Offline

Activity: 58
Merit: 61


View Profile
December 14, 2024, 10:32:25 AM
 #4

Short answer, full node use UTXO index/database.

Oh, that makes sense. Many thanks for the tip. I found a good explanation here:

https://www.reddit.com/r/Bitcoin/comments/wywsre/comment/im0g45w
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!