Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


importprivkey is very slow #1085

dooglus opened this Issue · 11 comments

9 participants


I recently needed to import some private keys into my wallet.

I knew the addresses had never been used, and so didn't need to rescan the blockchain, but there's no way to import a private key without the client automatically rescanning the whole blockchain.

There's also no way to import multiple private keys at once, so to import 5 private keys I had to wait while the client scanned the whole blockchain 5 times over for transactions I knew it wouldn't find anyway.

I'd like to be able to either:

  • import multiple keys with a single importprivkey RPC call, or
  • optionally suppress the blockchain rescan

Or both.

I ended up commenting these two lines in rpcdump.cpp to get the job done:

    // pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
    // pwalletMain->ReacceptWalletTransactions();

but would prefer a better solution.


Both sound good with me, as they can be useful in different scenarios.

  1. Make it possible to pass a JSON array of keys to import as well as a single key
    • to import multiple keys faster, but still safely
  2. And add a flag to suppress rescan
    • if you can guarantee or don't care whether the private key is used before

I think it had also been mentioned that it might be useful to be able to specify how far back to rescan (either from a block or a date I guess).


The second part seems to have been fixed by 44051af.


Why not simply remove the automatic rescan since a manual rescan can be performed any time someone wishes to run one?


@rebroad because that would leave the wallet in an undertested 'inconsistent' state. (e.g. you may find out transactions from the network spending prior transactions of yours which you don't know about)


this is an issue, would love to see the suggested features
import multiple keys with a single importprivkey RPC call, or
optionally suppress the blockchain rescan


This was fixed by 44051af which allows you to suppress the rescan.


I think this is fixed, closing.

@sipa sipa closed this

it's really not clear from the current help output how to suppress the rescan...


Yes, this should be clarified. Moreover, there's no way to stop the rescan once it has started. You can't even close bitcoin (AFAIK), only kill it with -9. Actually, the format for the command is importprivkey 5HzBeH... "account name" false if you don't want to rescan. And the default is true which is confusing — the help line looks like importprivkey "bitcoinprivkey" ( "label" rescan ) so it makes me think that if I don't add rescan it won't be rescanned.


#4922 raised to address this, @rkfg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.