mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-13 19:37:04 +01:00
wallet, logging: Switch LogInfo to LogWarning/LogError
Switch to LogWarning / LogError in obvious places where wallet code is clearly outputting warnings and errors. Suggested by hodlinator in https://github.com/bitcoin/bitcoin/pull/30343#discussion_r1655406670 https://github.com/bitcoin/bitcoin/pull/30343#discussion_r1655407301 https://github.com/bitcoin/bitcoin/pull/30343#discussion_r1655436010
This commit is contained in:
parent
fab945da71
commit
b7e37883da
4 changed files with 16 additions and 16 deletions
|
@ -598,7 +598,7 @@ RPCHelpMan importwallet()
|
|||
LogInfo(log, "Importing %s...\n", EncodeDestination(PKHash(keyid)));
|
||||
|
||||
if (!pwallet->ImportPrivKeys({{keyid, key}}, time)) {
|
||||
LogInfo(log, "Error importing key for %s\n", EncodeDestination(PKHash(keyid)));
|
||||
LogError(log, "Error importing key for %s\n", EncodeDestination(PKHash(keyid)));
|
||||
fGood = false;
|
||||
continue;
|
||||
}
|
||||
|
@ -613,7 +613,7 @@ RPCHelpMan importwallet()
|
|||
int64_t time = script_pair.second;
|
||||
|
||||
if (!pwallet->ImportScripts({script}, time)) {
|
||||
LogInfo(log, "Error importing script %s\n", HexStr(script));
|
||||
LogError(log, "Error importing script %s\n", HexStr(script));
|
||||
fGood = false;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -789,7 +789,7 @@ bool LegacyDataSPKM::LoadCScript(const CScript& redeemScript)
|
|||
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
|
||||
{
|
||||
std::string strAddr = EncodeDestination(ScriptHash(redeemScript));
|
||||
LogInfo(m_log, "%s: Warning: This wallet contains a redeemScript of size %i which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n", __func__, redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr);
|
||||
LogWarning(m_log, "%s: Warning: This wallet contains a redeemScript of size %i which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n", __func__, redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2475,11 +2475,11 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
|
|||
|
||||
const std::string& encoded_dest = EncodeDestination(address);
|
||||
if (new_purpose && !batch.WritePurpose(encoded_dest, PurposeToString(*new_purpose))) {
|
||||
LogInfo(m_log, "Error: fail to write address book 'purpose' entry\n");
|
||||
LogError(m_log, "Error: fail to write address book 'purpose' entry\n");
|
||||
return false;
|
||||
}
|
||||
if (!batch.WriteName(encoded_dest, strName)) {
|
||||
LogInfo(m_log, "Error: fail to write address book 'name' entry\n");
|
||||
LogError(m_log, "Error: fail to write address book 'name' entry\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2517,19 +2517,19 @@ bool CWallet::DelAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
|
|||
}
|
||||
// Delete data rows associated with this address
|
||||
if (!batch.EraseAddressData(address)) {
|
||||
LogInfo(m_log, "Error: cannot erase address book entry data\n");
|
||||
LogError(m_log, "Error: cannot erase address book entry data\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete purpose entry
|
||||
if (!batch.ErasePurpose(dest)) {
|
||||
LogInfo(m_log, "Error: cannot erase address book entry purpose\n");
|
||||
LogError(m_log, "Error: cannot erase address book entry purpose\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete name entry
|
||||
if (!batch.EraseName(dest)) {
|
||||
LogInfo(m_log, "Error: cannot erase address book entry name\n");
|
||||
LogError(m_log, "Error: cannot erase address book entry name\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -485,7 +485,7 @@ static DBErrors LoadWalletFlags(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIV
|
|||
uint64_t flags;
|
||||
if (batch.Read(DBKeys::FLAGS, flags)) {
|
||||
if (!pwallet->LoadWalletFlags(flags)) {
|
||||
LogInfo(log, "Error reading wallet database: Unknown non-tolerable wallet flags found\n");
|
||||
LogError(log, "Error reading wallet database: Unknown non-tolerable wallet flags found\n");
|
||||
return DBErrors::TOO_NEW;
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ static LoadResult LoadRecords(CWallet* pwallet, DatabaseBatch& batch, const std:
|
|||
Assume(!prefix.empty());
|
||||
std::unique_ptr<DatabaseCursor> cursor = batch.GetNewPrefixCursor(prefix);
|
||||
if (!cursor) {
|
||||
LogInfo(log, "Error getting database cursor for '%s' records\n", key);
|
||||
LogError(log, "Error getting database cursor for '%s' records\n", key);
|
||||
result.m_result = DBErrors::CORRUPT;
|
||||
return result;
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ static LoadResult LoadRecords(CWallet* pwallet, DatabaseBatch& batch, const std:
|
|||
if (status == DatabaseCursor::Status::DONE) {
|
||||
break;
|
||||
} else if (status == DatabaseCursor::Status::FAIL) {
|
||||
LogInfo(log, "Error reading next '%s' record for wallet database\n", key);
|
||||
LogError(log, "Error reading next '%s' record for wallet database\n", key);
|
||||
result.m_result = DBErrors::CORRUPT;
|
||||
return result;
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ static LoadResult LoadRecords(CWallet* pwallet, DatabaseBatch& batch, const std:
|
|||
std::string error;
|
||||
DBErrors record_res = load_func(pwallet, ssKey, ssValue, error);
|
||||
if (record_res != DBErrors::LOAD_OK) {
|
||||
LogInfo(log, "%s\n", error);
|
||||
LogError(log, "%s\n", error);
|
||||
}
|
||||
result.m_result = std::max(result.m_result, record_res);
|
||||
++result.m_records;
|
||||
|
@ -560,13 +560,13 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
prefix << type;
|
||||
std::unique_ptr<DatabaseCursor> cursor = batch.GetNewPrefixCursor(prefix);
|
||||
if (!cursor) {
|
||||
LogInfo(log, "Error getting database cursor for '%s' records\n", type);
|
||||
LogError(log, "Error getting database cursor for '%s' records\n", type);
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
|
||||
DatabaseCursor::Status status = cursor->Next(key, value);
|
||||
if (status != DatabaseCursor::Status::DONE) {
|
||||
LogInfo(log, "Error: Unexpected legacy entry found in descriptor wallet %s. The wallet might have been tampered with or created with malicious intent.\n", pwallet->GetName());
|
||||
LogError(log, "Error: Unexpected legacy entry found in descriptor wallet %s. The wallet might have been tampered with or created with malicious intent.\n", pwallet->GetName());
|
||||
return DBErrors::UNEXPECTED_LEGACY_ENTRY;
|
||||
}
|
||||
}
|
||||
|
@ -1000,7 +1000,7 @@ static DBErrors LoadAddressBookRecords(CWallet* pwallet, DatabaseBatch& batch) E
|
|||
value >> purpose_str;
|
||||
std::optional<AddressPurpose> purpose{PurposeFromString(purpose_str)};
|
||||
if (!purpose) {
|
||||
LogInfo(log, "Warning: nonstandard purpose string '%s' for address '%s'\n", purpose_str, strAddress);
|
||||
LogWarning(log, "Warning: nonstandard purpose string '%s' for address '%s'\n", purpose_str, strAddress);
|
||||
}
|
||||
pwallet->m_address_book[DecodeDestination(strAddress)].purpose = purpose;
|
||||
return DBErrors::LOAD_OK;
|
||||
|
@ -1199,7 +1199,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
|||
|
||||
#ifndef ENABLE_EXTERNAL_SIGNER
|
||||
if (pwallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER)) {
|
||||
LogInfo(log, "Error: External signer wallet being loaded without external signer support compiled\n");
|
||||
LogError(log, "Error: External signer wallet being loaded without external signer support compiled\n");
|
||||
return DBErrors::EXTERNAL_SIGNER_SUPPORT_REQUIRED;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue