btcwallet icon indicating copy to clipboard operation
btcwallet copied to clipboard

Implement better private key import RPC extension.

Open jrick opened this issue 12 years ago • 3 comments

The standard RPC call for importing private keys, importprivkey, has a number of issues. Namely:

  1. The command does not allow specifying any hints as to when an address first appeard, either by date or blockchain height. This can result in unnecessarily long rescans.
  2. As a rescan is triggered for each import, and importprivkey has no way of importing multiple private keys at once, this ends up triggering multiple rescans.

An extension RPC command should be added which resolves these issues.

jrick avatar Dec 16 '13 14:12 jrick

As a workaround for issue 2), I tried the following: When batch-importing, I used importprivkey <key> <label> false to avoid triggering multiple rescans.

My idea was that I could trigger a rescan afterwards manually. But alas, there is apparently no way to trigger a rescan (see #250)

By the way, after importing the keys as indicated above, btcwallet starts up like as follows:

14:00:35 2015-04-18 [INF] WLLT: Started rescan from block 00000000f952d926901f537502c834baa9790a8a178adc46ec9d7c82cb5d5bf0 (height 349578) for 14 addresses
14:00:35 2015-04-18 [INF] WLLT: Finished rescan for 14 addresses (synced to block 00000000f952d926901f537502c834baa9790a8a178adc46ec9d7c82cb5d5bf0, height 349578)

arnuschky avatar Apr 18 '15 14:04 arnuschky

For completeness, here the hint from @jrick how to trigger a rescan manuall:

On master (which uses the old txstore package) this can be triggered by closing wallet, deleting the file ~/.btcwallet/{main,test,sim}net/tx.bin, and restarting

arnuschky avatar Apr 18 '15 17:04 arnuschky

Rather than adding an extension to the legacy RPC server, these improvements should be added to the walletrpc.WalletService/ImportPrivateKey RPC.

jrick avatar Mar 09 '16 16:03 jrick