Permalink
Browse files

Importprivkey updates

  • Loading branch information...
Tranz5 committed Jul 16, 2014
1 parent 5d16ea4 commit bd3e1cc6358e728379f5b3f288c91b22e173c0b6
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/rpcdump.cpp
View
@@ -61,9 +61,18 @@ Value importprivkey(CWallet* pWallet, const Array& params, bool fHelp)
pWallet->MarkDirty();
pWallet->SetAddressBookName(vchAddress, strLabel);
// Don't throw error in case a key is already there
if (pWallet->HaveKey(vchAddress))
return Value::null;
pWallet ->mapKeyMetadata[vchAddress].nCreateTime = 1;
if (!pWallet->AddKey(key))
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
// whenever a key is imported, we need to scan the whole chain
pWallet->nTimeFirstKey = 1; // 0 would be considered 'no value'
pWallet->ScanForWalletTransactions(pindexGenesisBlock, true);
pWallet->ReacceptWalletTransactions();
}

0 comments on commit bd3e1cc

Please sign in to comment.