Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: MrCrank on August 21, 2017, 06:01:00 AM



Title: How can detect double spend transaction?
Post by: MrCrank on August 21, 2017, 06:01:00 AM
Hello,

How can I detect double spend transaction with full blockchain node?
Has transaction double-spend flag?
Or this is impossible?



Title: Re: How can detect double spend transaction?
Post by: onnz423 on August 21, 2017, 06:50:30 AM
At least blockchain.info, when looking up the transaction it should say the following if it is a double spend:

Code:
Warning! this bitcoin address contains transactions which may be double spends. You should be extremely careful when trusting any transactions to or from this address.

I do not know about the bitcoin core, but you should always wait for at least one confirmation if you are receiving money first without sending the goods.
Some people are trying to double spend to scam you.


Title: Re: How can detect double spend transaction?
Post by: ranochigo on August 21, 2017, 01:06:28 PM
How can I detect double spend transaction with full blockchain node?
Has transaction double-spend flag?
Or this is impossible?
Unless you are running a node which connects to a large number of nodes in the world, it can be hard for you to see any other existing competing and conflicting transaction. Reason being that the reference nodes doesn't relay double spend transactions and the propagation for them would be very bad. Transactions cannot have double spend flag, the flags you see are not included in the transaction itself.

Honestly, if you accept unconfirmed transactions, the risk is substantially higher. Double spend can be easy and hard to detect WITH the participation of a miner (knowingly) or (unknowingly) a miner having differing rules (eg. dust limits) from the rest of the network.


Title: Re: How can detect double spend transaction?
Post by: MrCrank on August 21, 2017, 03:48:00 PM
How can I detect double spend transaction with full blockchain node?
Has transaction double-spend flag?
Or this is impossible?
Unless you are running a node which connects to a large number of nodes in the world, it can be hard for you to see any other existing competing and conflicting transaction. Reason being that the reference nodes doesn't relay double spend transactions and the propagation for them would be very bad. Transactions cannot have double spend flag, the flags you see are not included in the transaction itself.

Honestly, if you accept unconfirmed transactions, the risk is substantially higher. Double spend can be easy and hard to detect WITH the participation of a miner (knowingly) or (unknowingly) a miner having differing rules (eg. dust limits) from the rest of the network.

But how blockchain.info detect and warning about it:
Code:
Warning! this bitcoin address contains transactions which may be double spends. You should be extremely careful when trusting any transactions to or from this address.
Really interest theme, unfortunately about this little information.
I want to understand how it works


Title: Re: How can detect double spend transaction?
Post by: ranochigo on August 22, 2017, 12:36:29 PM
But how blockchain.info detect and warning about it:
Code:
Warning! this bitcoin address contains transactions which may be double spends. You should be extremely careful when trusting any transactions to or from this address.
Blockchain.info has thousands of nodes that is connected to it. It has the ability to see most transactions that has been sent on the network. If a node has seen transaction A first, then receives transaction B, it will accept and relay transaction A. If another node sees transaction B first, it will accept and relay transaction B.

The reference client automatically rejects and refuses to relay double spends. This results in you being unable to see the transaction and your client will not know if there is a double spend or not.


Title: Re: How can detect double spend transaction?
Post by: MrCrank on August 23, 2017, 05:36:25 PM
But how blockchain.info detect and warning about it:
Code:
Warning! this bitcoin address contains transactions which may be double spends. You should be extremely careful when trusting any transactions to or from this address.
Blockchain.info has thousands of nodes that is connected to it. It has the ability to see most transactions that has been sent on the network. If a node has seen transaction A first, then receives transaction B, it will accept and relay transaction A. If another node sees transaction B first, it will accept and relay transaction B.

The reference client automatically rejects and refuses to relay double spends. This results in you being unable to see the transaction and your client will not know if there is a double spend or not.

Ok, thanks for explain.
I use one node only and understood that impossible for me.
Do you know any service with this options (double-spend flag) using API?


Title: Re: How can detect double spend transaction?
Post by: jackg on August 23, 2017, 05:54:33 PM
As the others have said, it comes up on blockchain.info with a warning.
But, if you want to check it yourself, you can got to a block explorer like blockchain.info and look at the address the transaction comes from and the INPUT script with that address.
IF there is another transaction of the same amount that also has the same input script, it is a double spend. You cannot have a regular transaction/client that reuses an input script (hence why change addresses are needed or two outputs are used to ensure a new input script is created in the same address).

AFAIK, even if blockchain.info only broadcasts and attempts to mine one of the transactions, it will still show both transactions in the block explorer.


Title: Re: How can detect double spend transaction?
Post by: MrCrank on September 01, 2017, 07:55:30 AM
As the others have said, it comes up on blockchain.info with a warning.
But, if you want to check it yourself, you can got to a block explorer like blockchain.info and look at the address the transaction comes from and the INPUT script with that address.
IF there is another transaction of the same amount that also has the same input script, it is a double spend. You cannot have a regular transaction/client that reuses an input script (hence why change addresses are needed or two outputs are used to ensure a new input script is created in the same address).

AFAIK, even if blockchain.info only broadcasts and attempts to mine one of the transactions, it will still show both transactions in the block explorer.

Ok, If happen really double spend transaction.. First TX (fake) , second TX is reall and confirmed.
How can I see first TX or it's disappear?

And if I have 2 TX and push first TX to pool with 0 fees, will TX confirm?



Title: Re: How can detect double spend transaction?
Post by: mocacinno on September 01, 2017, 08:05:41 AM
As the others have said, it comes up on blockchain.info with a warning.
But, if you want to check it yourself, you can got to a block explorer like blockchain.info and look at the address the transaction comes from and the INPUT script with that address.
IF there is another transaction of the same amount that also has the same input script, it is a double spend. You cannot have a regular transaction/client that reuses an input script (hence why change addresses are needed or two outputs are used to ensure a new input script is created in the same address).

AFAIK, even if blockchain.info only broadcasts and attempts to mine one of the transactions, it will still show both transactions in the block explorer.

Ok, If happen really double spend transaction.. First TX (fake) , second TX is reall and confirmed.
How can I see first TX or it's disappear?

And if I have 2 TX and push first TX to pool with 0 fees, will TX confirm?



In your story, both the first tx and the second tx are valid. The difference between the two transactions is that there was a miner out there whose mining node had the "real" tx in it's mempool. This miner found this tx interesting enough (the fee was sufficiently high) to put this tx in the block he was currently solving, and by pure luck, the hash he generated from the header of this block was under the current diff.

If the "real" tx gets added to a block, and this block is propagated to the network, all other nodes will remove the unspent outputs used for the "real" tx from their UTXO set, this will invalidate the "false" tx they had in their mempool because the "false" tx is now using unspent outputs that are no longer in the node's UTXO set (in case they had the false tx instead of the real one in the first place).

A site like blockchain.info, however, has a total independent database where they usually log things like double spends... It's only in such an external database you'll find the "false" transaction...

So, at a certain point, before the "real" transaction was put into a valid block, both transactions had a chance of becoming the "real" transaction, and after the "real" transaction was put into a block, the "false" transaction will dissapear from the network in a matter of seconds and can only be found in external databases that are maintained by thirth parties like blockchain.info.

As for your second question: yes, 0 sat transactions CAN in fact be broadcasted AND can in fact end up in a valid block... However, some nodes do not want to relay 0 fee transactions, and some miners won't add 0 fee transactions into the block they're currently working on, even if their mempool is empty... So, there are decent odds that a 0 fee transaction will long be pruned from the mempool of allmost all nodes before there even is a remote chance of it ending up in a block... It's all odds and averages tough. The odds of winning the bit pool in the national lottery are extremely small, but still, there are people that win the damn thing every couple of weeks/months.