Cleanup: Add braces for clarity
This commit is contained in:
@@ -694,8 +694,9 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
// Height to rescan from
|
// Height to rescan from
|
||||||
int nRescanHeight = 0;
|
int nRescanHeight = 0;
|
||||||
if (params.size() > 2)
|
if (params.size() > 2) {
|
||||||
nRescanHeight = params[2].get_int();
|
nRescanHeight = params[2].get_int();
|
||||||
|
}
|
||||||
if (nRescanHeight < 0 || nRescanHeight > chainActive.Height()) {
|
if (nRescanHeight < 0 || nRescanHeight > chainActive.Height()) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
||||||
}
|
}
|
||||||
@@ -706,8 +707,9 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)
|
|||||||
auto addr = vkey.address();
|
auto addr = vkey.address();
|
||||||
|
|
||||||
{
|
{
|
||||||
if (pwalletMain->HaveSpendingKey(addr))
|
if (pwalletMain->HaveSpendingKey(addr)) {
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this viewing key");
|
throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this viewing key");
|
||||||
|
}
|
||||||
|
|
||||||
// Don't throw error in case a viewing key is already there
|
// Don't throw error in case a viewing key is already there
|
||||||
if (pwalletMain->HaveViewingKey(addr)) {
|
if (pwalletMain->HaveViewingKey(addr)) {
|
||||||
@@ -717,8 +719,9 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)
|
|||||||
} else {
|
} else {
|
||||||
pwalletMain->MarkDirty();
|
pwalletMain->MarkDirty();
|
||||||
|
|
||||||
if (!pwalletMain->AddViewingKey(vkey))
|
if (!pwalletMain->AddViewingKey(vkey)) {
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding viewing key to wallet");
|
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding viewing key to wallet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to scan for transactions and notes
|
// We want to scan for transactions and notes
|
||||||
|
|||||||
@@ -252,22 +252,27 @@ bool CWallet::LoadZKey(const libzcash::SpendingKey &key)
|
|||||||
|
|
||||||
bool CWallet::AddViewingKey(const libzcash::ViewingKey &vk)
|
bool CWallet::AddViewingKey(const libzcash::ViewingKey &vk)
|
||||||
{
|
{
|
||||||
if (!CCryptoKeyStore::AddViewingKey(vk))
|
if (!CCryptoKeyStore::AddViewingKey(vk)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
nTimeFirstKey = 1; // No birthday information for viewing keys.
|
nTimeFirstKey = 1; // No birthday information for viewing keys.
|
||||||
if (!fFileBacked)
|
if (!fFileBacked) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return CWalletDB(strWalletFile).WriteViewingKey(vk);
|
return CWalletDB(strWalletFile).WriteViewingKey(vk);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::RemoveViewingKey(const libzcash::ViewingKey &vk)
|
bool CWallet::RemoveViewingKey(const libzcash::ViewingKey &vk)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
if (!CCryptoKeyStore::RemoveViewingKey(vk))
|
if (!CCryptoKeyStore::RemoveViewingKey(vk)) {
|
||||||
return false;
|
return false;
|
||||||
if (fFileBacked)
|
}
|
||||||
if (!CWalletDB(strWalletFile).EraseViewingKey(vk))
|
if (fFileBacked) {
|
||||||
|
if (!CWalletDB(strWalletFile).EraseViewingKey(vk)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user