CKey key;
bool fCompressed;
- CSecret secret = vchSecret.GetSecret(fCompressed);
+ auto secret = vchSecret.GetSecret(fCompressed);
key.SetSecret(secret, fCompressed);
- CKeyID keyid = key.GetPubKey().GetID();
+ auto keyid = key.GetPubKey().GetID();
CBitcoinAddress addr = CBitcoinAddress(keyid);
{
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();
}
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "It's senseless to import pubkey pair address.");
script.SetAddress(address);
} else if (IsHex(params[0].get_str())) {
- std::vector<unsigned char> data(ParseHex(params[0].get_str()));
+ auto data = ParseHex(params[0].get_str());
script = CScript(data.begin(), data.end());
} else
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Novacoin address or script");
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey pair addresses aren't supported.");
script.SetAddress(address);
} else if (IsHex(params[0].get_str())) {
- std::vector<unsigned char> data(ParseHex(params[0].get_str()));
+ auto data = ParseHex(params[0].get_str());
script = CScript(data.begin(), data.end());
} else
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address or script");
EnsureWalletIsUnlocked();
- string strAddress = params[0].get_str();
+ auto strAddress = params[0].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
EnsureWalletIsUnlocked();
- string strAddress = params[0].get_str();
+ auto strAddress = params[0].get_str();
SecureString strPassKey;
strPassKey.reserve(100);
strPassKey = params[2].get_str().c_str();
"importmalleablekey <Key data>\n"
"Imports the private key pair into your wallet.\n");
-
EnsureWalletIsUnlocked();
CMalleableKey mKey;