By not letting LogInfo
do the formatting, there’s no tinyformat::format_error
error handling anymore. This makes the code less robust to the malformed format strings we do not catch at compile time. For example, with this diff:
0diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
1index 83e96adf07..e6a2576f0a 100644
2--- a/src/wallet/wallet.cpp
3+++ b/src/wallet/wallet.cpp
4@@ -3822,7 +3822,7 @@ void CWallet::LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool intern
5 // Legacy wallets have only one ScriptPubKeyManager and it's active for all output and change types.
6 Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
7
8- WalletLogPrintf("Setting spkMan to active: id = %s, type = %s, internal = %s\n", id.ToString(), FormatOutputType(type), internal ? "true" : "false");
9+ WalletLogPrintf("Setting spkMan to active: id = %s, type = %s, internal = %*s\n", id.ToString(), FormatOutputType(type), internal ? "true" : "false");
10 auto& spk_mans = internal ? m_internal_spk_managers : m_external_spk_managers;
11 auto& spk_mans_other = internal ? m_external_spk_managers : m_internal_spk_managers;
12 auto spk_man = m_spk_managers.at(id).get();
on master
, this would still allow a wallet to be loaded (with just the logging failing):
0% bitcoin-cli loadwallet test
1{
2 "name": "test"
3}
4
5...
6
72024-09-19T10:32:57Z init message: Loading wallet…
82024-09-19T10:32:57Z [test] Wallet file version = 10500, last client version = 289900
92024-09-19T10:32:57Z [test] Descriptors: 8, Descriptor Keys: 1 plaintext, 0 encrypted, 1 total.
102024-09-19T10:32:57Z Error "tinyformat: Cannot convert from argument type to integer for use as variable width or precision" while formatting log message: %s Setting spkMan to active: id = %s, type = %s, internal = %*s
112024-09-19T10:32:57Z Error "tinyformat: Cannot convert from argument type to integer for use as variable width or precision" while formatting log message: %s Setting spkMan to active: id = %s, type = %s, internal = %*s
122024-09-19T10:32:57Z Error "tinyformat: Cannot convert from argument type to integer for use as variable width or precision" while formatting log message: %s Setting spkMan to active: id = %s, type = %s, internal = %*s
132024-09-19T10:32:57Z Error "tinyformat: Cannot convert from argument type to integer for use as variable width or precision" while formatting log message: %s Setting spkMan to active: id = %s, type = %s, internal = %*s
142024-09-19T10:32:57Z Error "tinyformat: Cannot convert from argument type to integer for use as variable width or precision" while formatting log message: %s Setting spkMan to active: id = %s, type = %s, internal = %*s
152024-09-19T10:32:57Z Error "tinyformat: Cannot convert from argument type to integer for use as variable width or precision" while formatting log message: %s Setting spkMan to active: id = %s, type = %s, internal = %*s
162024-09-19T10:32:57Z Error "tinyformat: Cannot convert from argument type to integer for use as variable width or precision" while formatting log message: %s Setting spkMan to active: id = %s, type = %s, internal = %*s
172024-09-19T10:32:57Z Error "tinyformat: Cannot convert from argument type to integer for use as variable width or precision" while formatting log message: %s Setting spkMan to active: id = %s, type = %s, internal = %*s
182024-09-19T10:32:57Z [test] Wallet completed loading in 281ms
whereas on facbcd4cef8890ae18976fb53b67ea56b3c04454, you get:
0% bitcoin-cli loadwallet test
1error code: -4
2error message:
3Wallet loading failed. Error loading <...>/signet/wallets/test/wallet.dat: Wallet corrupted
4
5...
6
72024-09-19T11:00:08Z init message: Loading wallet…
82024-09-19T11:00:08Z [test] Wallet file version = 10500, last client version = 289900
92024-09-19T11:00:09Z [test] Descriptors: 8, Descriptor Keys: 1 plaintext, 0 encrypted, 1 total.
102024-09-19T11:00:09Z [test] Releasing wallet test..
Similar concern in scriptpubkeyman.h
.