Remove no longer necessary `WinCmdLineArgs` class
What changed, and why it matters
This commit removes a Windows-specific helper class that converted command-line arguments from Windows' native wide-character format to the standard character format used by the rest of the program. The change is a cleanup to avoid using a C++ standard library feature (`std::wstring_convert`) that is being phased out. It is not a security fix and does not appear to introduce a vulnerability; it simply changes how Windows command-line arguments are handled, likely relying on a newer mechanism elsewhere.
No security action required. Treat as routine maintenance. If reviewing for build compatibility, verify that the Windows entry point still receives correct UTF-8 command-line arguments after this removal (e.g., via the `MAIN_FUNCTION` macro or CRT initialization).
Security signals we found
No security-relevant signal: code removal is a deprecation-driven cleanup
Removed use of deprecated C++ standard library conversion facility
No change to argument parsing semantics or trust boundaries visible in diff
Evidence from the diff
The WinCmdLineArgs class in src/common/args.cpp/args.h used CommandLineToArgvW + std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> to produce a UTF-8 argc/argv pair on Windows. The commit deletes this class and all call sites in bitcoin-cli, bitcoin-wallet, bitcoind, and the Qt GUI. The stated motivation is removing one use of std::wstring_convert, deprecated in C++17 and removed in C++26. The diff shows no replacement logic in these files; the implication is that the conversion is now handled elsewhere (e.g., by a newer MAIN_FUNCTION macro or startup code). No memory-safety bug, input-validation flaw, or security boundary change is visible in the diff.
Changed components
src/common/args.cppsrc/common/args.hsrc/bitcoin-cli.cppsrc/bitcoin-wallet.cppsrc/bitcoind.cppsrc/qt/bitcoin.cppInspect captured patch +0 / −64
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 56f2a906..279aa89e 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -1328,10 +1328,6 @@ static int CommandLineRPC(int argc, char *argv[])
MAIN_FUNCTION
{
-#ifdef WIN32
- common::WinCmdLineArgs winArgs;
- std::tie(argc, argv) = winArgs.get();
-#endif
SetupEnvironment();
if (!SetupNetworking()) {
tfm::format(std::cerr, "Error: Initializing networking failed\n");
diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp
index c8715231..6811f8c5 100644
--- a/src/bitcoin-wallet.cpp
+++ b/src/bitcoin-wallet.cpp
@@ -94,10 +94,6 @@ static std::optional<int> WalletAppInit(ArgsManager& args, int argc, char* argv[
MAIN_FUNCTION
{
ArgsManager& args = gArgs;
-#ifdef WIN32
- common::WinCmdLineArgs winArgs;
- std::tie(argc, argv) = winArgs.get();
-#endif
int exit_status;
std::unique_ptr<interfaces::Init> init = interfaces::MakeWalletInit(argc, argv, exit_status);
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index a4373daf..37cacb2a 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -259,11 +259,6 @@ static bool AppInit(NodeContext& node)
MAIN_FUNCTION
{
-#ifdef WIN32
- common::WinCmdLineArgs winArgs;
- std::tie(argc, argv) = winArgs.get();
-#endif
-
NodeContext node;
int exit_status;
std::unique_ptr<interfaces::Init> init = interfaces::MakeNodeInit(node, argc, argv, exit_status);
diff --git a/src/common/args.cpp b/src/common/args.cpp
index d44cd431..50b99029 100644
--- a/src/common/args.cpp
+++ b/src/common/args.cpp
@@ -19,8 +19,6 @@
#include <util/string.h>
#ifdef WIN32
-#include <codecvt>
-#include <shellapi.h>
#include <shlobj.h>
#endif
@@ -879,30 +877,3 @@ void ArgsManager::LogArgs() const
}
logArgsPrefix("Command-line arg:", "", m_settings.command_line_options);
}
-
-namespace common {
-#ifdef WIN32
-WinCmdLineArgs::WinCmdLineArgs()
-{
- wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
- std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> utf8_cvt;
- argv = new char*[argc];
- args.resize(argc);
- for (int i = 0; i < argc; i++) {
- args[i] = utf8_cvt.to_bytes(wargv[i]);
- argv[i] = &*args[i].begin();
- }
- LocalFree(wargv);
-}
-
-WinCmdLineArgs::~WinCmdLineArgs()
-{
- delete[] argv;
-}
-
-std::pair<int, char**> WinCmdLineArgs::get()
-{
- return std::make_pair(argc, argv);
-}
-#endif
-} // namespace common
diff --git a/src/common/args.h b/src/common/args.h
index d907ad76..1b9233ec 100644
--- a/src/common/args.h
+++ b/src/common/args.h
@@ -480,21 +480,4 @@ std::string HelpMessageGroup(const std::string& message);
*/
std::string HelpMessageOpt(const std::string& option, const std::string& message);
-namespace common {
-#ifdef WIN32
-class WinCmdLineArgs
-{
-public:
- WinCmdLineArgs();
- ~WinCmdLineArgs();
- std::pair<int, char**> get();
-
-private:
- int argc;
- char** argv;
- std::vector<std::string> args;
-};
-#endif
-} // namespace common
-
#endif // BITCOIN_COMMON_ARGS_H
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index fe552a57..59e74f92 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -478,11 +478,6 @@ static void SetupUIArgs(ArgsManager& argsman)
int GuiMain(int argc, char* argv[])
{
-#ifdef WIN32
- common::WinCmdLineArgs winArgs;
- std::tie(argc, argv) = winArgs.get();
-#endif
-
std::unique_ptr<interfaces::Init> init = interfaces::MakeGuiInit(argc, argv);
SetupEnvironment();
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.