Bitcoin Forum
April 25, 2024, 02:29:41 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Double-spend question - Legit coins vs duplicates  (Read 3186 times)
Alex Beckenham (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 22, 2011, 02:42:10 PM
 #1

Please imagine the following scenario:

I have a new wallet on device A which I receive 2 transactions:

12 BTC
8 BTC

So my balance is 20 BTC.

I then copy that wallet.dat to an installation on device B.

From device B, I spend exactly 8 BTC, leaving a balance of 12 BTC
(I assume this spend should come directly from the address that received 8 BTC so 'change' will not be an issue).

Let's say this 8 BTC spend gets old and has many confirmations.

Now, I go back to device A, which still shows a total balance of 20 BTC.

I then 'spend' the whole 20 BTC, dropping the balance to 0.00 in the client display.

This transaction should never be confirmed as 8 of it is a double spend, so my question is:

How to get the 12 legitimate coins back from this state of limbo and back into my balance?


1714012181
Hero Member
*
Offline Offline

Posts: 1714012181

View Profile Personal Message (Offline)

Ignore
1714012181
Reply with quote  #2

1714012181
Report to moderator
1714012181
Hero Member
*
Offline Offline

Posts: 1714012181

View Profile Personal Message (Offline)

Ignore
1714012181
Reply with quote  #2

1714012181
Report to moderator
1714012181
Hero Member
*
Offline Offline

Posts: 1714012181

View Profile Personal Message (Offline)

Ignore
1714012181
Reply with quote  #2

1714012181
Report to moderator
"I'm sure that in 20 years there will either be very large transaction volume or no volume." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714012181
Hero Member
*
Offline Offline

Posts: 1714012181

View Profile Personal Message (Offline)

Ignore
1714012181
Reply with quote  #2

1714012181
Report to moderator
1714012181
Hero Member
*
Offline Offline

Posts: 1714012181

View Profile Personal Message (Offline)

Ignore
1714012181
Reply with quote  #2

1714012181
Report to moderator
1714012181
Hero Member
*
Offline Offline

Posts: 1714012181

View Profile Personal Message (Offline)

Ignore
1714012181
Reply with quote  #2

1714012181
Report to moderator
Gareth Nelson
Hero Member
*****
Offline Offline

Activity: 721
Merit: 503


View Profile
May 22, 2011, 02:58:53 PM
 #2

Please imagine the following scenario:

I have a new wallet on device A which I receive 2 transactions:

12 BTC
8 BTC

So my balance is 20 BTC.

I then copy that wallet.dat to an installation on device B.

From device B, I spend exactly 8 BTC, leaving a balance of 12 BTC
(I assume this spend should come directly from the address that received 8 BTC so 'change' will not be an issue).

Let's say this 8 BTC spend gets old and has many confirmations.

Now, I go back to device A, which still shows a total balance of 20 BTC.

I then 'spend' the whole 20 BTC, dropping the balance to 0.00 in the client display.

This transaction should never be confirmed as 8 of it is a double spend, so my question is:

How to get the 12 legitimate coins back from this state of limbo and back into my balance?



You go back to device A, the client figures out your current balance from the blockchain, not from wallet.dat and it shows 12BTC
theboos
Member
**
Offline Offline

Activity: 87
Merit: 10


View Profile
May 22, 2011, 03:01:04 PM
 #3

The coins aren't in limbo. Such a transaction would not be accepted by the network so your 12 BTC is still usable in another valid transaction.
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
May 22, 2011, 03:18:51 PM
 #4

Please imagine the following scenario:

I have a new wallet on device A which I receive 2 transactions:

12 BTC
8 BTC

So my balance is 20 BTC.

I then copy that wallet.dat to an installation on device B.

From device B, I spend exactly 8 BTC, leaving a balance of 12 BTC
(I assume this spend should come directly from the address that received 8 BTC so 'change' will not be an issue).

Let's say this 8 BTC spend gets old and has many confirmations.

Now, I go back to device A, which still shows a total balance of 20 BTC.

It won't. It will see the spend on the network, and add a corresponding spending transaction to the wallet, bringing the balance to 12 BTC.

I then 'spend' the whole 20 BTC, dropping the balance to 0.00 in the client display.

This transaction should never be confirmed as 8 of it is a double spend, so my question is:

How to get the 12 legitimate coins back from this state of limbo and back into my balance?

If you do manage to spend the 20 BTC from B, without it having noticed the spend by A, you've indeed brought you wallet in a corrupted state, since it contains a transaction that conflicts with the block chain. It's possible to detect this conflict (I wrote a patch for that), but it's not yet merged in mainline bitcoin.

I do Bitcoin stuff.
Alex Beckenham (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 22, 2011, 03:35:00 PM
 #5

Well, the above scenario appears to have happened to me.

I'll try to gather real-life details shortly... m0Ray was helping out with it in another thread.


Alex Beckenham (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 22, 2011, 03:35:56 PM
 #6

The coins aren't in limbo. Such a transaction would not be accepted by the network so your 12 BTC is still usable in another valid transaction.

Yes, but the client instantly deducts the 20 as soon as it says "payment sent"... long before the network has a chance to see that it's invalid.

So the client says 0.00 even though only 8 out of 20 was a double spend.

Maybe I do have a corrupt wallet.dat (or several). I'm not ruling that out.

Gareth Nelson
Hero Member
*****
Offline Offline

Activity: 721
Merit: 503


View Profile
May 22, 2011, 03:49:06 PM
 #7

try the -rescan parameter?
Alex Beckenham (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 22, 2011, 03:53:05 PM
 #8

try the -rescan parameter?

Thanks. Tried rescan. Tried upgrading client. Tried new block chain.

The above figures were examples only, but I'm basically out 12 btc at this point Sad

I think what I might do is just not touch them for a few days and see if it works itself out.

p.s. This is all home pc stuff... none of this affects the wallet on bitcointoss.com or flipforbits.com.

Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
May 22, 2011, 03:58:24 PM
 #9

The coins aren't in limbo. Such a transaction would not be accepted by the network so your 12 BTC is still usable in another valid transaction.

Yes, but the client instantly deducts the 20 as soon as it says "payment sent"... long before the network has a chance to see that it's invalid.

So the client says 0.00 even though only 8 out of 20 was a double spend.

Maybe I do have a corrupt wallet.dat (or several). I'm not ruling that out.

If you're able to build from source and trust me, you can try https://github.com/sipa/bitcoin/tree/rejectedtx.

It will detect transactions that conflict with the block chain, and mark them inactive.

Make sure you have a backup of wallet.dat, though.

I do Bitcoin stuff.
m0Ray
Sr. Member
****
Offline Offline

Activity: 868
Merit: 251


View Profile
May 22, 2011, 03:59:19 PM
 #10

The coins aren't in limbo. Such a transaction would not be accepted by the network so your 12 BTC is still usable in another valid transaction.
Yes, but the client instantly deducts the 20 as soon as it says "payment sent"... long before the network has a chance to see that it's invalid.
...
Maybe I do have a corrupt wallet.dat (or several).
Quite right.

The problem of "hung" transactions in wallet.dat becomes annoying. For myself I wrote a simple utility, but it needs compilation and so is not suitable for ordinary users.
Tomorrow I'll (maybe) try to implement "full rescan" patch to bitcoin. Going asleep today.
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
May 22, 2011, 04:00:41 PM
 #11

Tomorrow I'll (maybe) try to implement "full rescan" patch to bitcoin. Going asleep today.

Sorry, did it myself already. https://github.com/bitcoin/bitcoin/pull/255

I do Bitcoin stuff.
m0Ray
Sr. Member
****
Offline Offline

Activity: 868
Merit: 251


View Profile
May 22, 2011, 04:01:23 PM
 #12

If you're able to build from source and trust me, you can try https://github.com/sipa/bitcoin/tree/rejectedtx.
It will detect transactions that conflict with the block chain, and mark them inactive.
Yet another utility for the same problem. Wink

We definitely need a "full rescan" option.
m0Ray
Sr. Member
****
Offline Offline

Activity: 868
Merit: 251


View Profile
May 22, 2011, 04:03:00 PM
 #13

Sorry, did it myself already. https://github.com/bitcoin/bitcoin/pull/255
Great! Now I can sleep peacefully. Wink
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
May 22, 2011, 04:04:27 PM
 #14

By the way, the "full rescan" I suggested/implemented does not remove transactions from the wallet, only adds/updates them, so it's not a solution for doood's problem.

I do Bitcoin stuff.
Alex Beckenham (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 22, 2011, 04:08:02 PM
 #15

The coins aren't in limbo. Such a transaction would not be accepted by the network so your 12 BTC is still usable in another valid transaction.
Yes, but the client instantly deducts the 20 as soon as it says "payment sent"... long before the network has a chance to see that it's invalid.
...
Maybe I do have a corrupt wallet.dat (or several).
Quite right.

The problem of "hung" transactions in wallet.dat becomes annoying. For myself I wrote a simple utility, but it needs compilation and so is not suitable for ordinary users.
Tomorrow I'll (maybe) try to implement "full rescan" patch to bitcoin. Going asleep today.

Your "full rescan" sounds like it could be exactly what's needed...

Will definitely pay you for it, although I'm lost when it comes to compiling C...

theymos
Administrator
Legendary
*
Offline Offline

Activity: 5180
Merit: 12884


View Profile
May 23, 2011, 06:46:07 AM
 #16

You can just restore your wallet from a backup.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
Alex Beckenham (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 23, 2011, 06:54:17 AM
 #17

You can just restore your wallet from a backup.

The problem extends there for me unfortunately as I backed up too soon after doing this, overwriting my oooold backup. Whoops. Will keep these 'empty' wallets for later as an unintended savings account, until the day I can extract the legit coins out of them.

m0Ray
Sr. Member
****
Offline Offline

Activity: 868
Merit: 251


View Profile
May 23, 2011, 09:44:51 AM
 #18

Added a pull request for "-purgetx" option.
Works for me.
Alex Beckenham (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 23, 2011, 11:08:59 AM
 #19

Added a pull request for "-purgetx" option.
Works for me.

Awesome. If someone wants to expedite a win32 binary, I'll pay for it (+ btc to m0Ray) Cheesy

Alex Beckenham (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 27, 2011, 04:21:00 PM
 #20

Added a pull request for "-purgetx" option.

Sorry I still don't know what a 'pull request' is although I've seen the term floating around this forum.

Is this -purgetx likely to end up in the official client any time soon or should I find it elsewhere? I'm in the process right now of learning a little more linux; just downloaded ubuntu livecd.

Pages: [1] 2 »  All
  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!