Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: pbies on April 29, 2022, 09:43:14 AM



Title: Export private keys that had movement - Bitcoin Core
Post by: pbies on April 29, 2022, 09:43:14 AM
How can I export or other way around extract private keys or public keys that had movement in Bitcoin Core?

Surely I can export all private keys but I will not know which of them had received or sent BTC.

I am looking for a way to filter all private keys in wallet that had movement.


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: OmegaStarScream on April 29, 2022, 10:18:40 AM
Code:
listreceivedbyaddress

This will return all addresses which already received a transaction.

And then, you can export the private keys associated with these addresses:

Code:
dumpprivkey "address here"

If your wallet is encrypted, make sure to unlock it before exporting the private keys:

Code:
walletpassphrase "passphrase here" 60


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: nc50lc on April 29, 2022, 10:19:09 AM
There's dumpprivkey <address> command to export an address' private key.
Although it will not work in descriptor wallets.

For filtering addresses, use listtransactions "*" "100" to list the wallet's transaction together with the associated address(es).
Replace "100" if you think the wallet has more than 100 transaction history.

More info about the commands:
  • https://bitcoincore.org/en/doc/22.0.0/rpc/wallet/dumpprivkey/ (https://bitcoincore.org/en/doc/22.0.0/rpc/wallet/dumpprivkey/)
  • https://bitcoincore.org/en/doc/22.0.0/rpc/wallet/listtransactions/ (https://bitcoincore.org/en/doc/22.0.0/rpc/wallet/listtransactions/)


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: pbies on April 29, 2022, 01:30:28 PM
Code:
listreceivedbyaddress

This will return all addresses which already received a transaction.

This take ages! :(


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: Welsh on April 29, 2022, 02:20:22 PM
This take ages! :(
Unless you're running on a rather slow computer or you've made a lot of transactions, I wouldn't have thought it would take that long. If you're running it from the graphical console, you could attempt to run it via the terminal to see if that helps performance a little bit.

Goes without saying, if you're struggling with performance, terminate other programs until you've completed this step. If your CPU is maxing, you'll have difficulty with whatever you're trying to do.


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: pbies on April 29, 2022, 03:26:24 PM
Unless you're running on a rather slow computer or you've made a lot of transactions, I wouldn't have thought it would take that long. If you're running it from the graphical console, you could attempt to run it via the terminal to see if that helps performance a little bit.

Goes without saying, if you're struggling with performance, terminate other programs until you've completed this step. If your CPU is maxing, you'll have difficulty with whatever you're trying to do.

This is 9900K @ 5 GHz, 16 GB of RAM @ 4000 MHz and SSD drives (NVMe also).

This shouldn't be taking that long!

Wallet is big (1 GB) and has long history. It is running since few hours now.


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: LoyceV on April 29, 2022, 03:38:19 PM
Wallet is big (1 GB) and has long history. It is running since few hours now.
For what it's worth: my wallet is less than 1% of yours, and listreceivedbyaddress takes less than a second on much slower hardware.


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: pbies on April 30, 2022, 09:10:10 AM
Wallet is big (1 GB) and has long history. It is running since few hours now.
For what it's worth: my wallet is less than 1% of yours, and listreceivedbyaddress takes less than a second on much slower hardware.

It taken all night and didn't finished. I suspect some loops that didn't ended. I closed Bitcoin Core with no luck.


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: pbies on April 30, 2022, 09:26:23 PM
Simple GUI Export of transactions did the trick.

From console it has hanged working on sth.


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: BitMaxz on April 30, 2022, 11:34:44 PM
Why not use dumpwallet command it will export all of your private keys into a file and then open it with notepad and copy all private keys and export it to Electrum and let the Electrum sync.

Now, after sync, you can sort all of the addresses with balances you can go under the addresses tab and look for balance just click it it will sort all addresses with balances.

Here's what I'm talking about

https://i.imgur.com/KVfGJdd.png


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: Pmalek on May 01, 2022, 07:56:29 AM
<Snip>
It depends on how much activity and how many addresses OP has used already. He wrote that his walet.dat file is 1GB in size, so the number of used addresses is probably quite a significant one. If we are talking about thousands of addresses, he might experience problems importing all of them in Electrum. Electrum isn't really suited for such a load. But there are no limitations to how many Electrum wallets he can create, so he can work around that by dividing his private keys in two or more batches and creating a new Electrum wallet for each batch.


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: LoyceV on May 01, 2022, 11:44:24 AM
Splitting to multiple Electrum wallet is good idea, since it doesn't scale well.
If you want to check which addresses out of a very long list had (past) activity, this list (https://bitcointalk.org/index.php?topic=5265993.0) is the fastest solution I know. After downloading 21 GB, it's scales very well. You can check millions of addresses as fast as your hard drive can read them.


Title: Re: Export private keys that had movement - Bitcoin Core
Post by: pbies on May 01, 2022, 01:22:36 PM
Electrum is limited to ca 1000 private keys when importing. I am not sure if the limit is lower and it is 400.

I tried that earlier. Servers refuse to check that number of keys.