Author

Topic: double spending scenario (Read 498 times)

legendary
Activity: 1218
Merit: 1007
July 22, 2017, 03:52:15 PM
#19
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
While it's not wrong really, since as soon as a confirmation is given to a transaction you can't doublespend it, but if the transaction is unconfirmed then you can perform a double-spend, as long as the transactions have different fees. If you tried to put both of them in as identical transactions then I believe it may be priority based, but that's an interesting experiment that I now want to try out sometime.

Technically speaking your idea might work but one of the transactions will get deleted, as other users have said, and this results in a much more difficult attempt at trying something like doublespending.
legendary
Activity: 4522
Merit: 3426
July 22, 2017, 03:44:55 PM
#18
So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?

Your logic is correct. That is why each of the receivers of your bitcoins should wait until their transaction is confirmed (included in a block) before considering the transaction to be done.
legendary
Activity: 3472
Merit: 4801
July 22, 2017, 03:13:27 PM
#17
You keep using the words "the mem pool" as if there is only one mem pool.

That is not how bitcoin works.

There are thousands of full node peers on the network.  Each node has its own mem pool.  There is no guarantee that any two nodes have the same transactions in there mem pool.

Generally, if a node already has a transaction in its mem pool, it will not accept a new competing transaction.  However, there is nothing preventing someone from writing and running their own node that will replace a transaction in the mem pool with a newer transaction, or from writing and running their own node that will keep multiple competing transactions in their mem pool.  They can't force any of their connected peers to do the same though.

Miners get to choose from their own mem pool which VALID transactions they include in the blocks they create.  If they include two competing transactions in a block, then their block is invalid and will not be accepted by any other nodes or miners.  As such, they will waste their time, money, and effort creating a useless block that pays them nothing.  This would be a pretty stupid waste of money, so miners that actually want to accomplish anything will not intentionally create invalid blocks.

Getting back to your original example:

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.

That full node relays that transaction to all the peers that he is connected to.  They also verify if, put it into their own mem pool, and relay it to all the peers they are connected to.  Those peers also verify if, put it into their own mem pool, and relay it to all the peers they are connected to, and so on. Very quickly all nodes on the network are aware of the transaction.

Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool.

If that different full node already heard about the first transaction, then they will generally not accept the new transaction.  If they have not yet heard about the first transaction, then they will validate it, accept it into their own mem pool, and relay it to all their connected peers.

Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation.

That depends on how many miners and mining pools heard about the first transaction, and how much hashpower they have. Generally, once a miner (or pool) has heard about the first transaction, they will not accept the second transaction. Since the first transaction had a head start in being relayed across the network, it has a much better chance of reaching more hashpower and therefore a much better chance of being confirmed into a solved block.

Thus I did my double spending.

Which part of my logic is wrong?

That depends on what you mean by double spending.

You created two incompatible transactions.  Only one of them will end up in the blockchain.  Anyone that doesn't have a trust relationship established with you, and doesn't want to risk the value of the transfer will (or at least should) wait for at least one confirmation.  Therefore, you will be identified for your fraud and will not accomplish anything with it.

There is no guarantee that your second transaction will ever get relayed by anyone since the first one will relay so quickly.  Even if it does relay to a few nodes, there is a very good chance that the intended recipient won't ever see it.

Furthermore a merchant could create a well connected node that monitors for competing transactions. He would see both transactions and would immediately know that he must wait for one of them to confirm to know which one will be valid and which will disappear.
full member
Activity: 210
Merit: 100
July 22, 2017, 02:02:56 PM
#16
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
I was once a beneficiary of a double spend transaction, this was when you sent a transaction with a low fee it could take almost a week or more to confirm, I sent the first payment after an hour or so, i saw that the funds had returned to my account and later the transaction went through and still the funds were in my account.

That's not how double spend works. Based on what you have said, you sent the first tx, btc was returned, then confirmed and still was in your balance? That couldn't happen since that scenario would have created two instances of the same value you have sent, and that will negate the 21 million mineable coins of bitcoin since you just created another bitcoins out of thin air that is beyond the 21 million coins bitcoin officially has.

In an extreme case, what if both tx have similar fees and both were picked up into the same block. what will happen?

It wouldn't happen. Whichever gets confirmed first by the network would be the accepted tx and the other one would just be dumped.


I think I understand it probably won't happen that these two tx are picked up by one block. But I don't understand how this pick-up process work in such a way to avoid it.  In another case, i can have two legit tx in the mem pool at the same time(no double spending), so the mem pool can only have one tx include in one block even if I have two legit tx in the mem pool?

Two different tx initiated by the same address can be picked up in a single block. Now we are not referring to any double-spend scenario in here but basically creating two tx from one address. Why would you do that when you can send one tx with two outputs? That would be more economical and viable in your end since you will be paying less fees compared to two tx.

economically I wouldn't do it. But it could happen in many ways. for example, some people don't know how to send two outputs. or after I send first one, I forget I need to send another one. Or the first one sent a wrong amount, I add more on second one.

I think I am more concerned technically how the mem pool works to avoid this double spending, if it happens.
full member
Activity: 210
Merit: 100
July 22, 2017, 01:59:49 PM
#15
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
I was once a beneficiary of a double spend transaction, this was when you sent a transaction with a low fee it could take almost a week or more to confirm, I sent the first payment after an hour or so, i saw that the funds had returned to my account and later the transaction went through and still the funds were in my account.

That's not how double spend works. Based on what you have said, you sent the first tx, btc was returned, then confirmed and still was in your balance? That couldn't happen since that scenario would have created two instances of the same value you have sent, and that will negate the 21 million mineable coins of bitcoin since you just created another bitcoins out of thin air that is beyond the 21 million coins bitcoin officially has.

In an extreme case, what if both tx have similar fees and both were picked up into the same block. what will happen?

It wouldn't happen. Whichever gets confirmed first by the network would be the accepted tx and the other one would just be dumped.


I think I understand it probably won't happen that these two tx are picked up by one block. But I don't understand how this pick-up process work in such a way to avoid it.  In another case, i can have two legit tx in the mem pool at the same time(no double spending), so the mem pool can only have one tx include in one block even if I have two legit tx in the mem pool?

Two different tx initiated by the same address can be picked up in a single block. Now we are not referring to any double-spend scenario in here but basically creating two tx from one address. Why would you do that when you can send one tx with two outputs? That would be more economical and viable in your end since you will be paying less fees compared to two tx.

economically I wouldn't do it. But it could happen in many ways. for example, some people don't know how to send two outputs. or after I send first one, I forget I need to send another one. Or the first one sent a wrong amount, I add more on second one.
legendary
Activity: 3542
Merit: 1352
July 22, 2017, 01:53:08 PM
#14
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
I was once a beneficiary of a double spend transaction, this was when you sent a transaction with a low fee it could take almost a week or more to confirm, I sent the first payment after an hour or so, i saw that the funds had returned to my account and later the transaction went through and still the funds were in my account.

That's not how double spend works. Based on what you have said, you sent the first tx, btc was returned, then confirmed and still was in your balance? That couldn't happen since that scenario would have created two instances of the same value you have sent, and that will negate the 21 million mineable coins of bitcoin since you just created another bitcoins out of thin air that is beyond the 21 million coins bitcoin officially has.

In an extreme case, what if both tx have similar fees and both were picked up into the same block. what will happen?

It wouldn't happen. Whichever gets confirmed first by the network would be the accepted tx and the other one would just be dumped.


I think I understand it probably won't happen that these two tx are picked up by one block. But I don't understand how this pick-up process work in such a way to avoid it.  In another case, i can have two legit tx in the mem pool at the same time(no double spending), so the mem pool can only have one tx include in one block even if I have two legit tx in the mem pool?

Two different tx initiated by the same address can be picked up in a single block. Now we are not referring to any double-spend scenario in here but basically creating two tx from one address. Why would you do that when you can send one tx with two outputs? That would be more economical and viable in your end since you will be paying less fees compared to two tx.
full member
Activity: 210
Merit: 100
July 22, 2017, 01:51:01 PM
#13
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
2nd transaction will be removed from mem pool.


How can the mem pool determine which one to remove? Is there a timestamp? because the first one comes earlier or what reasons?
Transactions of double spending (from conformed blocks) never accepted in mem pool, and removed if have.


I thought as long as your tx is verified by a node, it can be accepted by mem pool. So if these two tx were verified by two different nodes in a short period of time. both of them can be accepted by  mem pool.
full member
Activity: 210
Merit: 100
July 22, 2017, 01:48:05 PM
#12
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
I was once a beneficiary of a double spend transaction, this was when you sent a transaction with a low fee it could take almost a week or more to confirm, I sent the first payment after an hour or so, i saw that the funds had returned to my account and later the transaction went through and still the funds were in my account.

That's not how double spend works. Based on what you have said, you sent the first tx, btc was returned, then confirmed and still was in your balance? That couldn't happen since that scenario would have created two instances of the same value you have sent, and that will negate the 21 million mineable coins of bitcoin since you just created another bitcoins out of thin air that is beyond the 21 million coins bitcoin officially has.

In an extreme case, what if both tx have similar fees and both were picked up into the same block. what will happen?

It wouldn't happen. Whichever gets confirmed first by the network would be the accepted tx and the other one would just be dumped.


I think I understand it probably won't happen that these two tx are picked up by one block. But I don't understand how this pick-up process work in such a way to avoid it.  In another case, i can have two legit tx in the mem pool at the same time(no double spending), so the mem pool can only have one tx include in one block even if I have two legit tx in the mem pool?
full member
Activity: 560
Merit: 111
July 22, 2017, 01:37:27 PM
#11
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
2nd transaction will be removed from mem pool.


How can the mem pool determine which one to remove? Is there a timestamp? because the first one comes earlier or what reasons?
Transactions of double spending (from conformed blocks) never accepted in mem pool, and removed if have.
hero member
Activity: 938
Merit: 559
Did you see that ludicrous display last night?
July 22, 2017, 01:36:22 PM
#10
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
2nd transaction will be removed from mem pool.

Is there a timestamp?
Here's what satoshi says about this:
Quote from: satoshi
In a nutshell, the network works like a distributed timestamp server, stamping the first transaction to spend a coin. It takes advantage of the nature of information being easy to spread but hard to stifle.
You can read what he said on this site.

The main point of the blockchain is to prevent double spends without requiring a third party.

For a detailed explanation on how this works, please refer to this video.  It'll give you information right from the start to avoid any misconceptions.
full member
Activity: 448
Merit: 100
July 22, 2017, 01:24:49 PM
#9
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
I was once a beneficiary of a double spend transaction, this was when you sent a transaction with a low fee it could take almost a week or more to confirm, I sent the first payment after an hour or so, i saw that the funds had returned to my account and later the transaction went through and still the funds were in my account.

Really, how is this possible. So if I understand it right, it seems you created new bitcoin out of nowhere. the total amount of bitcoins increased?Huh

It seems to me that it was just some kind of technical mistake. I can not understand how a double waste can occur. After all, the bitcoin network is transparent and understandable and there can not be any misunderstandings
legendary
Activity: 3542
Merit: 1352
July 22, 2017, 01:21:04 PM
#8
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
I was once a beneficiary of a double spend transaction, this was when you sent a transaction with a low fee it could take almost a week or more to confirm, I sent the first payment after an hour or so, i saw that the funds had returned to my account and later the transaction went through and still the funds were in my account.

That's not how double spend works. Based on what you have said, you sent the first tx, btc was returned, then confirmed and still was in your balance? That couldn't happen since that scenario would have created two instances of the same value you have sent, and that will negate the 21 million mineable coins of bitcoin since you just created another bitcoins out of thin air that is beyond the 21 million coins bitcoin officially has.

In an extreme case, what if both tx have similar fees and both were picked up into the same block. what will happen?

It wouldn't happen. Whichever gets confirmed first by the network would be the accepted tx and the other one would just be dumped.
full member
Activity: 210
Merit: 100
July 22, 2017, 01:19:01 PM
#7
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
I was once a beneficiary of a double spend transaction, this was when you sent a transaction with a low fee it could take almost a week or more to confirm, I sent the first payment after an hour or so, i saw that the funds had returned to my account and later the transaction went through and still the funds were in my account.

Really, how is this possible. So if I understand it right, it seems you created new bitcoin out of nowhere. the total amount of bitcoins increased?Huh
full member
Activity: 210
Merit: 100
July 22, 2017, 01:16:08 PM
#6
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
2nd transaction will be removed from mem pool.


How can the mem pool determine which one to remove? Is there a timestamp? because the first one comes earlier or what reasons?

Whichever gets confirmed first will be kept in the chain, and the one that remains unconfirmed gets deleted. Most of the time, tx with high fees gets confirmed faster than those with lower fees. So on *most* cases, the one who has the lower fees gets deleted regardless of time the tx was initiated since it will, theoretically, be confirmed slower than the one who has more fees into the tx.


In an extreme case, what if both tx have similar fees and both were picked up into the same block. what will happen?
sr. member
Activity: 434
Merit: 250
July 22, 2017, 01:08:24 PM
#5
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
I was once a beneficiary of a double spend transaction, this was when you sent a transaction with a low fee it could take almost a week or more to confirm, I sent the first payment after an hour or so, i saw that the funds had returned to my account and later the transaction went through and still the funds were in my account.
legendary
Activity: 3542
Merit: 1352
July 22, 2017, 01:02:53 PM
#4
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
2nd transaction will be removed from mem pool.


How can the mem pool determine which one to remove? Is there a timestamp? because the first one comes earlier or what reasons?

Whichever gets confirmed first will be kept in the chain, and the one that remains unconfirmed gets deleted. Most of the time, tx with high fees gets confirmed faster than those with lower fees. So on *most* cases, the one who has the lower fees gets deleted regardless of time the tx was initiated since it will, theoretically, be confirmed slower than the one who has more fees into the tx.
full member
Activity: 210
Merit: 100
July 22, 2017, 12:46:51 PM
#3
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
2nd transaction will be removed from mem pool.


How can the mem pool determine which one to remove? Is there a timestamp? because the first one comes earlier or what reasons?
legendary
Activity: 3542
Merit: 1352
July 22, 2017, 12:43:12 PM
#2
Your logic is correct, however take note that as more confirmations is being made on the first transaction you made, the harder it will be to perform a double-spend. Ideally, you might do double-spending on an unconfirmed transaction since it will just be left out and the one with the higher fee would be accepted regardless of which was registered first in the mempool.
full member
Activity: 210
Merit: 100
July 22, 2017, 12:36:38 PM
#1
Hello, I'm new to this bitcoin technology. And I have a question about double spending. Can you take a look at the following case and tell me what I am wrong

So let's say my wallet has 5 BTC. First I send a payment of 1 BTC to receiver A. It is verified by a full node and put into the mem pool.
Immediately after that, I send all 5 BTC to B. It is then verified by a different full node and also put into the mem pool. Because I put more transaction fees on the second transaction, the second transaction will mostly likely picked up by a miner faster than the 1st transaction and get 1st confirmation. Thus I did my double spending.

Which part of my logic is wrong?
Jump to: