if (strMethod == "keypoolrefill" && n > 0) ConvertTo<int64_t>(params[0]);
if (strMethod == "keypoolreset" && n > 0) ConvertTo<int64_t>(params[0]);
if (strMethod == "importaddress" && n > 2) ConvertTo<bool>(params[2]);
+ if (strMethod == "importprivkey" && n > 2) ConvertTo<bool>(params[2]);
return params;
}
{
LOCK2(cs_main, pwalletMain->cs_wallet);
- pwalletMain->MarkDirty();
- pwalletMain->SetAddressBookName(addr, strLabel);
-
// Don't throw error in case a key is already there
if (pwalletMain->HaveKey(keyid))
return Value::null;
pwalletMain->mapKeyMetadata[addr].nCreateTime = 1;
-
if (!pwalletMain->AddKey(key))
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
- // whenever a key is imported, we need to scan the whole chain
- pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value'
+ pwalletMain->MarkDirty();
+ pwalletMain->SetAddressBookName(addr, strLabel);
- if (fRescan)
+ if (fRescan)
{
+ // whenever a key is imported, we need to scan the whole chain
+ pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value'
+
pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
pwalletMain->ReacceptWalletTransactions();
}