Skip to content

Commit a55a018

Browse files
committed
Merge #8548: [wallet] Use __func__ to get function name for output printing
fa785d1 Use __func__ to get function name for output printing (MarcoFalke)
2 parents 2468292 + fa785d1 commit a55a018

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3942,7 +3942,7 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
39423942
// Create new
39433943
CBlockIndex* pindexNew = new CBlockIndex();
39443944
if (!pindexNew)
3945-
throw runtime_error("LoadBlockIndex(): new CBlockIndex failed");
3945+
throw runtime_error(std::string(__func__) + ": new CBlockIndex failed");
39463946
mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
39473947
pindexNew->phashBlock = &((*mi).first);
39483948

src/primitives/transaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ CAmount CTransaction::GetValueOut() const
100100
{
101101
nValueOut += it->nValue;
102102
if (!MoneyRange(it->nValue) || !MoneyRange(nValueOut))
103-
throw std::runtime_error("CTransaction::GetValueOut(): value out of range");
103+
throw std::runtime_error(std::string(__func__) + ": value out of range");
104104
}
105105
return nValueOut;
106106
}

src/wallet/wallet.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ CPubKey CWallet::GenerateNewKey()
108108

109109
// try to get the master key
110110
if (!GetKey(hdChain.masterKeyID, key))
111-
throw std::runtime_error("CWallet::GenerateNewKey(): Master key not found");
111+
throw std::runtime_error(std::string(__func__) + ": Master key not found");
112112

113113
masterKey.SetMaster(key.begin(), key.size());
114114

@@ -135,7 +135,7 @@ CPubKey CWallet::GenerateNewKey()
135135

136136
// update the chain model in the database
137137
if (!CWalletDB(strWalletFile).WriteHDChain(hdChain))
138-
throw std::runtime_error("CWallet::GenerateNewKey(): Writing HD chain model failed");
138+
throw std::runtime_error(std::string(__func__) + ": Writing HD chain model failed");
139139
} else {
140140
secret.MakeNewKey(fCompressed);
141141
}
@@ -152,7 +152,7 @@ CPubKey CWallet::GenerateNewKey()
152152
nTimeFirstKey = nCreationTime;
153153

154154
if (!AddKeyPubKey(secret, pubkey))
155-
throw std::runtime_error("CWallet::GenerateNewKey(): AddKey failed");
155+
throw std::runtime_error(std::string(__func__) + ": AddKey failed");
156156
return pubkey;
157157
}
158158

@@ -1094,7 +1094,7 @@ isminetype CWallet::IsMine(const CTxOut& txout) const
10941094
CAmount CWallet::GetCredit(const CTxOut& txout, const isminefilter& filter) const
10951095
{
10961096
if (!MoneyRange(txout.nValue))
1097-
throw std::runtime_error("CWallet::GetCredit(): value out of range");
1097+
throw std::runtime_error(std::string(__func__) + ": value out of range");
10981098
return ((IsMine(txout) & filter) ? txout.nValue : 0);
10991099
}
11001100

@@ -1123,7 +1123,7 @@ bool CWallet::IsChange(const CTxOut& txout) const
11231123
CAmount CWallet::GetChange(const CTxOut& txout) const
11241124
{
11251125
if (!MoneyRange(txout.nValue))
1126-
throw std::runtime_error("CWallet::GetChange(): value out of range");
1126+
throw std::runtime_error(std::string(__func__) + ": value out of range");
11271127
return (IsChange(txout) ? txout.nValue : 0);
11281128
}
11291129

@@ -1147,7 +1147,7 @@ CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) co
11471147
{
11481148
nDebit += GetDebit(txin, filter);
11491149
if (!MoneyRange(nDebit))
1150-
throw std::runtime_error("CWallet::GetDebit(): value out of range");
1150+
throw std::runtime_error(std::string(__func__) + ": value out of range");
11511151
}
11521152
return nDebit;
11531153
}
@@ -1159,7 +1159,7 @@ CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) c
11591159
{
11601160
nCredit += GetCredit(txout, filter);
11611161
if (!MoneyRange(nCredit))
1162-
throw std::runtime_error("CWallet::GetCredit(): value out of range");
1162+
throw std::runtime_error(std::string(__func__) + ": value out of range");
11631163
}
11641164
return nCredit;
11651165
}
@@ -1171,7 +1171,7 @@ CAmount CWallet::GetChange(const CTransaction& tx) const
11711171
{
11721172
nChange += GetChange(txout);
11731173
if (!MoneyRange(nChange))
1174-
throw std::runtime_error("CWallet::GetChange(): value out of range");
1174+
throw std::runtime_error(std::string(__func__) + ": value out of range");
11751175
}
11761176
return nChange;
11771177
}
@@ -1200,7 +1200,7 @@ CPubKey CWallet::GenerateNewHDMasterKey()
12001200

12011201
// write the key&metadata to the database
12021202
if (!AddKeyPubKey(key, pubkey))
1203-
throw std::runtime_error(std::string(__func__)+": AddKeyPubKey failed");
1203+
throw std::runtime_error(std::string(__func__) + ": AddKeyPubKey failed");
12041204
}
12051205

12061206
return pubkey;
@@ -1227,7 +1227,7 @@ bool CWallet::SetHDChain(const CHDChain& chain, bool memonly)
12271227
{
12281228
LOCK(cs_wallet);
12291229
if (!memonly && !CWalletDB(strWalletFile).WriteHDChain(chain))
1230-
throw runtime_error("AddHDChain(): writing chain failed");
1230+
throw runtime_error(std::string(__func__) + ": writing chain failed");
12311231

12321232
hdChain = chain;
12331233
return true;
@@ -2712,7 +2712,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
27122712
if (!setKeyPool.empty())
27132713
nEnd = *(--setKeyPool.end()) + 1;
27142714
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
2715-
throw runtime_error("TopUpKeyPool(): writing generated key failed");
2715+
throw runtime_error(std::string(__func__) + ": writing generated key failed");
27162716
setKeyPool.insert(nEnd);
27172717
LogPrintf("keypool added key %d, size=%u\n", nEnd, setKeyPool.size());
27182718
}
@@ -2739,9 +2739,9 @@ void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool)
27392739
nIndex = *(setKeyPool.begin());
27402740
setKeyPool.erase(setKeyPool.begin());
27412741
if (!walletdb.ReadPool(nIndex, keypool))
2742-
throw runtime_error("ReserveKeyFromKeyPool(): read failed");
2742+
throw runtime_error(std::string(__func__) + ": read failed");
27432743
if (!HaveKey(keypool.vchPubKey.GetID()))
2744-
throw runtime_error("ReserveKeyFromKeyPool(): unknown key in key pool");
2744+
throw runtime_error(std::string(__func__) + ": unknown key in key pool");
27452745
assert(keypool.vchPubKey.IsValid());
27462746
LogPrintf("keypool reserve %d\n", nIndex);
27472747
}
@@ -2800,7 +2800,7 @@ int64_t CWallet::GetOldestKeyPoolTime()
28002800
CWalletDB walletdb(strWalletFile);
28012801
int64_t nIndex = *(setKeyPool.begin());
28022802
if (!walletdb.ReadPool(nIndex, keypool))
2803-
throw runtime_error("GetOldestKeyPoolTime(): read oldest key in keypool failed");
2803+
throw runtime_error(std::string(__func__) + ": read oldest key in keypool failed");
28042804
assert(keypool.vchPubKey.IsValid());
28052805
return keypool.nTime;
28062806
}
@@ -3027,11 +3027,11 @@ void CWallet::GetAllReserveKeys(set<CKeyID>& setAddress) const
30273027
{
30283028
CKeyPool keypool;
30293029
if (!walletdb.ReadPool(id, keypool))
3030-
throw runtime_error("GetAllReserveKeyHashes(): read failed");
3030+
throw runtime_error(std::string(__func__) + ": read failed");
30313031
assert(keypool.vchPubKey.IsValid());
30323032
CKeyID keyID = keypool.vchPubKey.GetID();
30333033
if (!HaveKey(keyID))
3034-
throw runtime_error("GetAllReserveKeyHashes(): unknown key in key pool");
3034+
throw runtime_error(std::string(__func__) + ": unknown key in key pool");
30353035
setAddress.insert(keyID);
30363036
}
30373037
}
@@ -3331,7 +3331,7 @@ bool CWallet::InitLoadWallet()
33313331
// generate a new master key
33323332
CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey();
33333333
if (!walletInstance->SetHDMasterKey(masterPubKey))
3334-
throw std::runtime_error("CWallet::GenerateNewKey(): Storing master key failed");
3334+
throw std::runtime_error(std::string(__func__) + ": Storing master key failed");
33353335
}
33363336
CPubKey newDefaultKey;
33373337
if (walletInstance->GetKeyFromPool(newDefaultKey)) {

src/wallet/walletdb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
215215

216216
Dbc* pcursor = GetCursor();
217217
if (!pcursor)
218-
throw runtime_error("CWalletDB::ListAccountCreditDebit(): cannot create DB cursor");
218+
throw runtime_error(std::string(__func__) + ": cannot create DB cursor");
219219
unsigned int fFlags = DB_SET_RANGE;
220220
while (true)
221221
{
@@ -231,7 +231,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
231231
else if (ret != 0)
232232
{
233233
pcursor->close();
234-
throw runtime_error("CWalletDB::ListAccountCreditDebit(): error scanning DB");
234+
throw runtime_error(std::string(__func__) + ": error scanning DB");
235235
}
236236

237237
// Unserialize

0 commit comments

Comments
 (0)