Bitcoin Forum
August 18, 2018, 01:16:44 AM *
News: Latest stable version of Bitcoin Core: 0.16.2  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: If Bitcoin chooses longest chain, how is it reliable at all ?  (Read 138 times)
cowsgomoo
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
May 15, 2018, 06:07:58 AM
 #1

For example, from what I understand,
If Alice and Bob share an Bitcoin Account that holds 500 Bitcoin.

Alice could spend all 500 bitcoins on a car in North America when Bob spends it on a different car
in Asia. Both transactions would go to "pool" to be processed. Both of them would be processed in the next block.

What I don't understand is, 1) Would the transaction be visible on explorer site ? Both of them ?

2) I get that maybe a few blocks later, the longest chain would be taken and one of the transactions
would be revoked. But how is this reliable at all? The two cars are probably in possession of Alice and Bob already.

The seller needs to wait at least 4 blocks after the transaction is complete?
Also, regarding the 1st question, what happens on the explorer when the longest chain is taken ?
Before longest chain is picked, which one is displayed?

I am very confused with this. I would really appreciate a reply. Thank you very much in advance.
1534555004
Hero Member
*
Offline Offline

Posts: 1534555004

View Profile Personal Message (Offline)

Ignore
1534555004
Reply with quote  #2

1534555004
Report to moderator
1534555004
Hero Member
*
Offline Offline

Posts: 1534555004

View Profile Personal Message (Offline)

Ignore
1534555004
Reply with quote  #2

1534555004
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1534555004
Hero Member
*
Offline Offline

Posts: 1534555004

View Profile Personal Message (Offline)

Ignore
1534555004
Reply with quote  #2

1534555004
Report to moderator
1534555004
Hero Member
*
Offline Offline

Posts: 1534555004

View Profile Personal Message (Offline)

Ignore
1534555004
Reply with quote  #2

1534555004
Report to moderator
1534555004
Hero Member
*
Offline Offline

Posts: 1534555004

View Profile Personal Message (Offline)

Ignore
1534555004
Reply with quote  #2

1534555004
Report to moderator
Xynerise
Sr. Member
****
Offline Offline

Activity: 266
Merit: 274

39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD


View Profile
May 15, 2018, 06:46:37 AM
Merited by Jet Cash (2), ETFbitcoin (1), bones261 (1)
 #2

For example, from what I understand,
If Alice and Bob share an Bitcoin Account that holds 500 Bitcoin.
This statement is the root of your confusion.
Bitcoin does not have an account model -- like a bank -- but a UTXO model (like cash)
Think of every bitcoin payment (output) a wallet  receives as a distinct cash bill.
So a wallet is a collection of "bills" (i.e output), so there's no way that Alice and Bob can share a wallet securely, but assuming for the sake of discussion that they have the same wallet.dat file or mnemonic seed phrase corresponding to the ownership of certain UTXOs worth 500 BTC
Whatever happens depends on if the 500 BTC is in 1 UTXO or split in many UTXOs , and the amount being spent.
(continuing the analogy, it depends if the 500 BTC is in one 500 currency note or split in many eg $50 bills.)
Quote
Alice could spend all 500 bitcoins on a car in North America when Bob spends it on a different car
in Asia.

Since Alice spends ALL the UTXOs, Bob CANNOT spend the same UTXOs again, as other nodes in the network will reject it as they already have a conflicting transaction in their mempool.
Quote
Both transactions would go to "pool" to be processed.
Note that there  is no global pool, but each node has its own mempool, so it's  possible that both conflicting transactions spending  the same UTXO get  propagated.
Quote
Boh of them will be processed in the next block.
Only ONE of them CAN be added to a block.
Even though Alice's transaction went to miner A and he added it to his candidate block and is trying to find the target, while Bob's transaction went to miner B who also adds it to his candidate block, eventually one of them will find a valid block and whichever transaction is included in the block is the valid one, and the other transaction is rendered invalid and CANNOT be added to the blockchain again.
So if it was Alice's transaction that was mined, Bob's transaction is no longer valid and can't be mined; if it was Bob's transaction that was mined, Alice's transaction is invalid and can no longer be mined.
The blockchain is the arbiter and its decision is final.
Quote
What I don't understand is, 1) Would the transaction be visible on explorer site ? Both of them ?
Block explorers get their information from full nodes.
If , for example, Blockchain.info's node(s) first saw Alice's transaction when she broadcast it, it will display the transaction as unconfirmed, and it WILL NOT accept Bob's transaction since Alice's transaction spends the same UTXO, and so it will only show Alice's.
If Blockchair saw Bob's transaction first, it will not accept Alice's transaction, and will show Bob's transaction as unconfirmed.
When one transaction is finally included in a block, whichever node contained the invalid transaction will discard it in favour of the mined one.

Quote
2) I get that maybe a few blocks later, the longest chain would be taken and one of the transactions
would be revoked.
Imagine a rare case where miner A above mined Alice's transaction, while miner B simultaneously mined Bob's transaction.
Both blocks are valid, and there are 2 competing blocks..whichever block is mined on becomes the Prefered block because it has the most proof of work.
If the block containing Bob's transaction is mined on by other miners then the block containing Alice's transaction will eventually be orphaned by other nodes and Bob's transaction is the valid one.
Quote
But how is this reliable at all? The two cars are probably in possession of Alice and Bob already.

The seller needs to wait at least 4 blocks after the transaction is complete?
You answered your question yourself.
For merchants selling expensive goods, they have to wait for a certain number of blocks to be sure that the transaction that pays them won't be overwritten by a longer block with more proof for work.
6 confirmations is commonly but more expensive items can call for more confirmations eg 144 blocks (1 day)

Quote
Also, regarding the 1st question, what happens on the explorer when the longest chain is taken ??
The other one is dropped.
Foxpup
Legendary
*
Offline Offline

Activity: 2282
Merit: 1097



View Profile
May 15, 2018, 06:51:14 AM
Merited by mdayonliner (1)
 #3

Both of them would be processed in the next block.
They won't. A block cannot contain conflicting transactions. Only one of the transactions would make it into the next block (typically, whichever transaction happened to reach the miner first), at which point it is said to be "confirmed". Transactions that have not yet been included in a block are "unconfirmed" and merchants should be wary of unconfirmed transactions for exactly this reason.

1) Would the transaction be visible on explorer site ? Both of them ?
Many block explorers will indeed show both unconfirmed transactions, and also a warning that they are in conflict.

2) I get that maybe a few blocks later, the longest chain would be taken and one of the transactions
would be revoked. But how is this reliable at all? The two cars are probably in possession of Alice and Bob already.
As explained, that is not how it works, and in any case the seller would be advised to wait for the transaction to be confirmed before handing over the keys.

The seller needs to wait at least 4 blocks after the transaction is complete?
If he/she likes. This is what is meant by waiting for multiple confirmations, and provides extra security against chain reorganisation (which is what happens when a longer chain suddenly appears out of nowhere, typically due to a temporary split in network topology). The new chain may contain different transactions, so previously confirmed transactions can become unconfirmed again. Chain reorganisations longer than 1 or 2 blocks are extremely rare, however, for very high value transactions it doesn't hurt to be extra cautious.

Also, regarding the 1st question, what happens on the explorer when the longest chain is taken ?
Before longest chain is picked, which one is displayed?
Block explorers display whatever is currently the longest chain known to them. If a longer chain suddenly appears in a chain reorg, block explorers will switch to it immediately.

Will pretend to do unverifiable things (while actually eating an enchilada-style burrito) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
Killrbit
Jr. Member
*
Offline Offline

Activity: 154
Merit: 2


View Profile
May 17, 2018, 12:28:29 PM
 #4

For example, from what I understand,
If Alice and Bob share an Bitcoin Account that holds 500 Bitcoin.

Well the first bit of advice most people would tell you is not to share your private keys(even with a spouse/sibling/child/etc). The nature of blockchains means that you cannot hold btc jointly or share a btc account, and if two people do control one account it just means that both of them know the private keys to one public address. In this case any of them could move the money at anytime (its just a matter of who does it first). Furthermore even if you do trust the other person he could inadvertent disclose the key to someone else or have not kept it securely and there would be very little any one could do about it.

Alice could spend all 500 bitcoins on a car in North America when Bob spends it on a different car
in Asia. Both transactions would go to "pool" to be processed. Both of them would be processed in the next block.

No that is simply not possible, yes 2 people could open up the same address from two different places and broadcast two transactions on the block chain, but only one of them would ever be confirmed, dependent on who sent the transaction first/ the transaction fees offered or just pure luck on which transaction is piked up first by a miner. Both the transactions would of course show up on a blockchain explorer(each with their own transaction hash) as an unconfirmed transaction, while both the receiving addresses will also show the unconfirmed transaction as well as.( some wallets will often show the btc sent from these unconfirmed transaction as part of the receivers balance, however if he were to try to send btc from an unconfirmed transaction to a third wallet it would fail)

In essence once the first 500 btc transaction has been sent from the original address to the first reciever and been confirmed on the blockchain the second transaction hash for the second receiver would show that the btc which was to be sent from the original address has already been spent (check out what the difference is between a spent and unspent transaction for more clarity) and the transaction would fail

2) I get that maybe a few blocks later, the longest chain would be taken and one of the transactions
would be revoked. But how is this reliable at all? The two cars are probably in possession of Alice and Bob already.

Again this is why people wait for the transaction to have been confirmed by at least 6-10 blocks before actually give Alice or Bob the car, if the seller in this case has already given both of them the cars, there would be little he can do about it except file a complaint for fraud/theft or such and such.



The seller needs to wait at least 4 blocks after the transaction is complete?
Also, regarding the 1st question, what happens on the explorer when the longest chain is taken ?
Before longest chain is picked, which one is displayed?

I am very confused with this. I would really appreciate a reply. Thank you very much in advance.

There is also only ever one chain, the failed transaction will simply not be included in any block on the chain.
DannyHamilton
Legendary
*
Offline Offline

Activity: 2198
Merit: 1371



View Profile
May 17, 2018, 01:57:17 PM
 #5

however if he were to try to send btc from an unconfirmed transaction to a third wallet it would fail

This is not correct.

While it is generally a bad idea to do so, there are wallets which will allow users to spend BTC from unconfirmed transactions.  As long as the original transaction eventually confirms, this is not a problem.  However, if the original transaction becomes invalid (because some replacement transaction is confirmed), then the transaction spending the unconfirmed bitcoins will also become invalid.

2) I get that maybe a few blocks later, the longest chain would be taken and one of the transactions
would be revoked. But how is this reliable at all? The two cars are probably in possession of Alice and Bob already.

Again this is why people wait for the transaction to have been confirmed by at least 6-10 blocks before actually give Alice or Bob the car, if the seller in this case has already given both of them the cars, there would be little he can do about it except file a complaint for fraud/theft or such and such.

In this way, an unconfirmed transaction is a lot like a personal check.  Imagine that you and your wife share a bank account with a $50,000 balance.  You both go to separate car dealers and each purchase a $50,000 vehicle with a personal check drawn against the account.  Both dealers call the bank to make sure that the funds are in the account before accepting the check.  Then after you've both driven off with the cars, the dealers take the checks to the bank to deposit.  One check "confirms" and that dealer gets his money.  The other check "bounces".  This dealer still has the option to have you prosecuted if he has obtained enough information about you (drivers license, insurace card, home address, vehicle registration, vehicle GPS, etc) to track you down. The same is true of a Bitcoin transaction.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!