Each of the following RPC functions
- importprivkey
- importaddress
- importpubkey
- importwallet
- importmulti
define a variable reference LegacyScriptPubKeyMan& spk_man
which is not used, leading to compiler warnings in the current master branch (bdda137878904e9401a84e308ac74c93c2ef87c1):
0 CXX wallet/libbitcoin_wallet_a-rpcdump.o
1wallet/rpcdump.cpp:137:28: warning: unused variable 'spk_man' [-Wunused-variable]
2 LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
3 ^
4wallet/rpcdump.cpp:265:28: warning: unused variable 'spk_man' [-Wunused-variable]
5 LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*pwallet);
6 ^
7wallet/rpcdump.cpp:468:28: warning: unused variable 'spk_man' [-Wunused-variable]
8 LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
9 ^
10wallet/rpcdump.cpp:552:28: warning: unused variable 'spk_man' [-Wunused-variable]
11 LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
12 ^
13wallet/rpcdump.cpp:1349:28: warning: unused variable 'spk_man' [-Wunused-variable]
14 LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
15 ^
165 warnings generated.
The call to GetLegacyScriptPubKeyMan()
still serves the purpose to throw an error if the wallet doesn’t have a LegacyScriptPubKeyMan instance (indicating that the command is not supported, as pointed out by the error message):
https://github.com/bitcoin/bitcoin/blob/bdda137878904e9401a84e308ac74c93c2ef87c1/src/wallet/rpcdump.cpp#L90-L97
This commit casts the functions return value to introduces a new function void
to point out that the value is thrown away, and adds a comment on why the function call is needed as well.RequireLegacyScriptPubKeyMan()
which in turn calls GetLegacyScriptPubKeyMan()
but discards its return value.