Bitcoin Forum
May 08, 2024, 06:23:51 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to delete a single transaction from wallet.dat?  (Read 7670 times)
tschaboo (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 19, 2011, 01:02:40 AM
 #1

Hi,

i sent a transaction without (the expected) fees which seems do be dropped by the bitcoin network. It has 0 confirmations but is about 24 hours old. Now the bitcoin-client (official v. 0.3.23-beta, Linux 64bit) doesn't allow me to access those coins. That's of course a good thing, because no node would accept a transaction with a non-existant input, right? Now, I want to delete that transaction locally since it's not going to be confirmed anyway.

Here's what I tried:
* deleting from GUI -> seems impossible
* finding some in-/export program. The most promising I found was the thread at http://forum.bitcoin.org/index.php?topic=4448.0 . I fetched the git-repository, and make'd the program. It seems to be a modified bitcoin-source, I didn't find some other executable. Later in the thread the author (Pieter Wuille) mentions RPC calls. So I tried to find out about that ... but no luck. I grepped the sources but didn't find the word dump anywhere.
* searched for documentation about the wallet.dat file-format. The only hint I found was that it's a Berkeley-DB file.
* installed berkeley tools and dumped the database. It seems to be something like a key/value store ... 1099 lines of hexadecimal numbers. Not nice!!

Where to go from here? Help appreciated.

Of course it was my fault to send a transaction lacking the necessary fees but I wanted to try it out. I didn't see complications like that coming.  Undecided

But I think it might happen to anyone that a transaction doesn't go through. Or simply not fast enough and you want to intentionally "double-spend" the amount. There should be some solution ?!?

1715149431
Hero Member
*
Offline Offline

Posts: 1715149431

View Profile Personal Message (Offline)

Ignore
1715149431
Reply with quote  #2

1715149431
Report to moderator
1715149431
Hero Member
*
Offline Offline

Posts: 1715149431

View Profile Personal Message (Offline)

Ignore
1715149431
Reply with quote  #2

1715149431
Report to moderator
1715149431
Hero Member
*
Offline Offline

Posts: 1715149431

View Profile Personal Message (Offline)

Ignore
1715149431
Reply with quote  #2

1715149431
Report to moderator
BitcoinCleanup.com: Learn why Bitcoin isn't bad for the environment
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715149431
Hero Member
*
Offline Offline

Posts: 1715149431

View Profile Personal Message (Offline)

Ignore
1715149431
Reply with quote  #2

1715149431
Report to moderator
1715149431
Hero Member
*
Offline Offline

Posts: 1715149431

View Profile Personal Message (Offline)

Ignore
1715149431
Reply with quote  #2

1715149431
Report to moderator
1715149431
Hero Member
*
Offline Offline

Posts: 1715149431

View Profile Personal Message (Offline)

Ignore
1715149431
Reply with quote  #2

1715149431
Report to moderator
Emraldfire
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
June 19, 2011, 01:25:42 AM
 #2

Yup it'll take awhile but it will go though. Also note that your wallet file is the only file that holds your money, don't lose or mess it up or all your money is gone forever.
tschaboo (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 19, 2011, 03:23:46 PM
 #3

Hello wcoenen & Emraldfire,

thanks a lot for your answers!

If your transaction was broadcast to other nodes (which you can check by double clicking it), then it will be confirmed eventually. Even if it has no transaction fee.

When I doubleclick now, I only see "0/no confirmations" but I remember that once it said something like "sent to 18 nodes". Probably that's because I restarted my computer in the meantime. So yes, it was sent.

Is your transaction visible in this list of unconfirmed transactions? http://bitcoincharts.com/bitcoin/

Thanks for that link, very helpful! But no, i don't see my transaction there. I searched for the amount of the transaction (0.001) and didn't find anything.

Also note that your wallet file is the only file that holds your money, don't lose or mess it up or all your money is gone forever.

Yes, after reading a few threads I realized that and I already have (versioned) on- and offline backups. Unfortunately no backup of before this one transaction. If I would, I could recover by simply restoring that backup. With the backups at hand, I would risk manipulating the file and just not doing any transactions inbetween.

Thanks again for your help so far. Further help would be much appreciated. I know it might sound absurd fighting that much for BTC 0.001, but first that's 5% of my fortune  Wink and second I'm really trying to test all that stuff to gain a deeper understanding of the technic behind bitcoin.

BouerBouer
Newbie
*
Offline Offline

Activity: 28
Merit: 0



View Profile WWW
June 19, 2011, 04:58:47 PM
 #4

Thanks again for your help so far. Further help would be much appreciated. I know it might sound absurd fighting that much for BTC 0.001, but first that's 5% of my fortune  Wink and second I'm really trying to test all that stuff to gain a deeper understanding of the technic behind bitcoin.

I know exactly what you mean. Just give it time, because it's peer-to-peer it will naturally take a while for your transfer to be confirmed. It takes on average around 6 hours for each of my transfers to be confirmed.

Also I'd give up trying to figure out how Bitcoins work, I mine for them and I STILL can't figure them out. :p
tschaboo (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 19, 2011, 05:18:30 PM
 #5

Just give it time, because it's peer-to-peer it will naturally take a while ....

Well, that's a question. How do I correctly interpret the fact that the transaction doesn't show up at http://bitcoincharts.com/bitcoin/ ?

I understand that the transaction-fees serve 2 purposes:
1.) Higher the chance that your transaction will be included in the limited space for transactions of the next block by giving an incentive to the blocks creator by paying him.
2.) Prevent spamming the system with transactions like mine. E.g. sending BTC 0.001 ...

What I don't know is, how 2.) is actually implemented. I assume that - to be effective - already the clients of the P2P network have to filter out some transactions they receive because otherwise someone might still flood the P2P network with small transactions. They wouldn't be confirmed but they would still consume bandwith and memory. Especially if they are never deleted!

If my assumption is correct - can anyone comment on that? - it might be likely that my transaction never reached a miner who might include it in a block, right?

Also I'd give up trying to figure out how Bitcoins work, I mine for them and I STILL can't figure them out. :p

No, I won't give up!!  Cool
Pieter Wuille
Legendary
*
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
June 20, 2011, 08:55:43 AM
 #6

The wallet.dat file is indeed a berkeley database with key/value pairs. It contains private keys, known addresses of others, transactions crediting and debiting you, account information and configuration settings.

If you did a transaction with low fees, the best suggestion is to keep the client open and connected for some hours. As it will occasionally retransmit, it should eventually reach a miner.

If you want to play around with the wallet.dat file yourself, there is Gavin's bitcointools, but I'm not sure what it supports. A possibility for undoing transactions may be added to the client itself somewhere, but not very soon - there are quite serious implications, as it may cause double spends, and wallet situations that are hard to recover from.

If you want to do things manually, there should be a data pair in your wallet.dat where the key is ([hex 02] "tx" [32 bytes containing tx hash]). If you remove this, the transaction should be removed from history.

I do Bitcoin stuff.
tschaboo (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 21, 2011, 09:50:32 PM
 #7

I finally managed to get rid of this transaction!

Using bitcointools i was able to find out the transaction number (which bitcoin-0.3.23 doesn't even show) quite easily. If you run
$ ./dbdump.py --wallet-tx
you get all stored transactions chronologically sorted.

I dumped the wallet.dat using
$ db4.8_dump ~/.bitcoin/wallet.dat > dumpfile

The really hard thing was to find the transaction there! I was almost going crazy until i found out that you have to reverse the the transaction-id (=read from right to left)! Then it was simply (carefully) deleting the right two lines from the dump and importing again with db4.8_load.

It worked; I tried sending all my coins to another wallet and the transaction was confirmed. Actually you can also simply delete all transactions. They are recreated out of the block chain at the next start. The lines that start with 0x02747 are the transactions.

Thanks for all your help!
tschaboo (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 21, 2011, 09:51:42 PM
 #8

I forgot to mention that I used db4.8_load to convert the dump file back to a Berkeley DB file, named that wallet.dat and put it in place of my original wallet.dat.

Reproduce at your own risk!
coga
Full Member
***
Offline Offline

Activity: 222
Merit: 100


www.btcbuy.info


View Profile WWW
December 31, 2011, 08:22:14 PM
 #9

I got stuck with those goddamn non-posting transactions in a very frustrating way. Your method worked perfectly. Thanks a lot!

GPG key: 6F8E305690A05365B58C50A
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!