|
|
@ -500,8 +500,7 @@ UniValue importwallet(const JSONRPCRequest& request)
|
|
|
|
if (vstr.size() < 2)
|
|
|
|
if (vstr.size() < 2)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
CBitcoinSecret vchSecret;
|
|
|
|
CBitcoinSecret vchSecret;
|
|
|
|
if (!vchSecret.SetString(vstr[0]))
|
|
|
|
if (vchSecret.SetString(vstr[0])) {
|
|
|
|
continue;
|
|
|
|
|
|
|
|
CKey key = vchSecret.GetKey();
|
|
|
|
CKey key = vchSecret.GetKey();
|
|
|
|
CPubKey pubkey = key.GetPubKey();
|
|
|
|
CPubKey pubkey = key.GetPubKey();
|
|
|
|
assert(key.VerifyPubKey(pubkey));
|
|
|
|
assert(key.VerifyPubKey(pubkey));
|
|
|
@ -534,6 +533,19 @@ UniValue importwallet(const JSONRPCRequest& request)
|
|
|
|
if (fLabel)
|
|
|
|
if (fLabel)
|
|
|
|
pwallet->SetAddressBook(keyid, strLabel, "receive");
|
|
|
|
pwallet->SetAddressBook(keyid, strLabel, "receive");
|
|
|
|
nTimeBegin = std::min(nTimeBegin, nTime);
|
|
|
|
nTimeBegin = std::min(nTimeBegin, nTime);
|
|
|
|
|
|
|
|
} else if(IsHex(vstr[0])) {
|
|
|
|
|
|
|
|
std::vector<unsigned char> vData(ParseHex(vstr[0]));
|
|
|
|
|
|
|
|
CScript script = CScript(vData.begin(), vData.end());
|
|
|
|
|
|
|
|
if (pwallet->HaveCScript(script)) {
|
|
|
|
|
|
|
|
LogPrintf("Skipping import of %s (script already present)\n", vstr[0]);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!pwallet->AddCScript(script)) {
|
|
|
|
|
|
|
|
LogPrintf("Error importing script %s\n", vstr[0]);
|
|
|
|
|
|
|
|
fGood = false;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
file.close();
|
|
|
|
file.close();
|
|
|
|
pwallet->ShowProgress("", 100); // hide progress dialog in GUI
|
|
|
|
pwallet->ShowProgress("", 100); // hide progress dialog in GUI
|
|
|
@ -542,7 +554,7 @@ UniValue importwallet(const JSONRPCRequest& request)
|
|
|
|
pwallet->MarkDirty();
|
|
|
|
pwallet->MarkDirty();
|
|
|
|
|
|
|
|
|
|
|
|
if (!fGood)
|
|
|
|
if (!fGood)
|
|
|
|
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet");
|
|
|
|
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys/scripts to wallet");
|
|
|
|
|
|
|
|
|
|
|
|
return NullUniValue;
|
|
|
|
return NullUniValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|