0

I have a ton of old backed up wallet.dat files with zero BTC in them, but (probably) the records of my old Bitcoin transactions in them, which I'm trying to extract as CSV data.

I already looked at the command line options and found no instance of "extract" or "CSV", but is there some way to do something simple on the command line such as:

bitcoincore.exe --extract-csv-transactions-from-wallet=wallet1.dat -o wallet1.csv
bitcoincore.exe --extract-csv-transactions-from-wallet=wallet2.dat -o wallet2.csv
bitcoincore.exe --extract-csv-transactions-from-wallet=wallet3.dat -o wallet3.csv
...

?

My current method of manually loading four of them in at a time, manually adding them to the config file and starting Bitcoin Core, is a nightmare. It has been saying "Rescanning" for an hour now with no sign of it ever stopping and that's just for the first batch of four wallets... out of tons.

This is going to be a multi-weeker nightmare project, isn't it?

8
  • I would instead look at other utilities or libraries such as btcutils or pywallet. Oct 6 at 10:00
  • 1
    Does this answer your question? Dumping private keys from wallet.dat from command line (pywallet.py alternatives) (note the answers cover dumping all wallet data, not just keys) Oct 6 at 10:02
  • @RedGrittyBrick I don't trust anything but Bitcoin Core. And I'm not trying to dump any private keys. Oct 6 at 10:03
  • Why does it have to "Rescan"? Can't this be skipped? Oct 6 at 10:08
  • From elsewhere: 'The wallet file stores up to which block it has "seen" the chain. At startup, an automatic rescan happens for exactly the missing part.' I guess this is because the prime purpose of Bitcoin core is to function as a wallet, not to export CSV data from multiple wallet.dat files. It is presumably optimised for the former task, not the latter. Oct 6 at 10:15
1

There is no way to export all of the transactions to a csv. However you can get the transaction in JSON using the listtransactions RPC.

Bitcoin Core will always rescan when a wallet is loaded because it must be sure that it has seen all of the wallet's transactions so that the user does not appear to have lost any funds. For old wallets, it ends up having to rescan a significant portion of the blockchain. There is no way to disable this behavior.

However, if you are sure that no rescan is necessary, it is possible to force Bitcoin Core to not have any blockchain data so that the rescan completes quickly and does not do anything. You can do this by removing all blockchain data from the datadir and starting Bitcoin Core with -connect=0. This will force Bitcoin Core to not connect to the network so it will not be able to download the blockchain. Additionally, because you have removed any previous blockchain data, Bitcoin Core will be reset to the genesis block as the only block in the blockchain. Loading a wallet at this point will result in no rescan.

Lastly, to speed things up, instead of constantly stopping and starting Bitcoin Core to load new wallets, you can use the loadwallet RPC to load a wallet, and unloadwallet to unload the wallet when you are done with it.

Some python-like pseudocode that shows what this would look like:

for wallet in wallets:
    rpc.loadwallet(wallet)
    print(rpc.listtransactions())
    rpc.unloadwallet(wallet)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.