add rescan bool to importprivkey to control whether to do a rescan after import #2080

Merged
merged 1 commit into from Dec 12, 2012

Conversation

Projects
None yet
6 participants
Contributor

mcassano commented Dec 6, 2012

I use a lot of vanity addresses and I don't need to rescan the chain when importing. I like the ability to optionally request not to do a rescan. Attached is a working example of this.

@gavinandresen gavinandresen and 1 other commented on an outdated diff Dec 6, 2012

src/rpcdump.cpp
@@ -61,9 +67,11 @@ Value importprivkey(const Array& params, bool fHelp)
if (!pwalletMain->AddKey(key))
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
-
- pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
- pwalletMain->ReacceptWalletTransactions();
+
+ if (fRescan) {
@gavinandresen

gavinandresen Dec 6, 2012

Contributor

Nit: our coding style is:
4 space indenting, no tabs

(see doc/coding.txt)

@mcassano

mcassano Dec 6, 2012

Contributor

My mistake, fixed now.

Diapolo commented Dec 6, 2012

Now you just need to merge your 2 commits into one.

@Diapolo Diapolo commented on an outdated diff Dec 6, 2012

src/rpcdump.cpp
@@ -61,9 +67,11 @@ Value importprivkey(const Array& params, bool fHelp)
if (!pwalletMain->AddKey(key))
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
-
- pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
- pwalletMain->ReacceptWalletTransactions();
+
+ if (fRescan) {
+ pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
@Diapolo

Diapolo Dec 6, 2012

And this are still only 2 spaces (same above and below).

Contributor

mcassano commented Dec 6, 2012

Thank you for the feedback, I just rebased so I think it's just one commit now with proper spacing.

Owner

sipa commented Dec 6, 2012

Now fix the commit message, and you're golden. ACK on the code change.

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/331bc98a7fb0aa5bee965faa8cf1a58868d28558 for binaries and test log.

Contributor

mcassano commented Dec 7, 2012

I removed the mention of the tabs and spaces from the commit, I assume that is what was wrong with the message. Thanks for the ACK.

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/44051af1a87a5fb8f4e88442c0eb64a1b4ecf2e6 for binaries and test log.

gavinandresen merged commit 51dc438 into bitcoin:master Dec 12, 2012

mcassano deleted the mcassano:importprivkey_rescan_false branch Feb 18, 2013

Contributor

rebroad commented on src/rpcdump.cpp in 44051af Apr 1, 2013

I would prefer to see this default to false.

Contributor

rebroad replied Jul 18, 2014

This doesn't actually work...

Owner

sipa replied Jul 18, 2014

Changing the default to false would 1) break backward compatibility 2) be unsafe

Contributor

mcassano replied Jul 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment