From 2ea48ee1aa6f16fffb9124e6b6481e1252820f05 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 19 Nov 2020 22:43:22 +0000 Subject: [PATCH] wallettool: Print warnings to stderr instead of stdout --- src/wallet/wallettool.cpp | 4 ++-- test/functional/tool_wallet.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp index df3b3e7f40..b7a0f2cf89 100644 --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -214,14 +214,14 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command) tfm::format(std::cerr, "%s\n", error.original); return ret; } - tfm::format(std::cout, "The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n"); + tfm::format(std::cerr, "The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n"); return ret; } else if (command == "createfromdump") { bilingual_str error; std::vector warnings; bool ret = CreateFromDump(args, name, path, error, warnings); for (const auto& warning : warnings) { - tfm::format(std::cout, "%s\n", warning.original); + tfm::format(std::cerr, "%s\n", warning.original); } if (!ret && !error.empty()) { tfm::format(std::cerr, "%s\n", error.original); diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py index fc042bca66..446f0bf2a0 100755 --- a/test/functional/tool_wallet.py +++ b/test/functional/tool_wallet.py @@ -45,10 +45,10 @@ class ToolWalletTest(BitcoinTestFramework): assert_equal(stdout, '') assert_equal(stderr.strip(), error) - def assert_tool_output(self, output, *args): + def assert_tool_output(self, output, *args, stderr=''): p = self.bitcoin_wallet_process(*args) stdout, stderr = p.communicate() - assert_equal(stderr, '') + assert_equal(stderr, stderr) assert_equal(stdout, output) assert_equal(p.poll(), 0) @@ -167,10 +167,10 @@ class ToolWalletTest(BitcoinTestFramework): load_output = "" if file_format is not None and file_format != dump_data["format"]: load_output += "Warning: Dumpfile wallet format \"{}\" does not match command line specified format \"{}\".\n".format(dump_data["format"], file_format) - self.assert_tool_output(load_output, *args) + self.assert_tool_output('', *args, stderr=load_output) assert (self.nodes[0].wallets_path / wallet_name).is_dir() - self.assert_tool_output("The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n", '-wallet={}'.format(wallet_name), '-dumpfile={}'.format(rt_dumppath), 'dump') + self.assert_tool_output('', '-wallet={}'.format(wallet_name), '-dumpfile={}'.format(rt_dumppath), 'dump', stderr="The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n") rt_dump_data = self.read_dump(rt_dumppath) wallet_dat = self.nodes[0].wallets_path / wallet_name / "wallet.dat" @@ -325,7 +325,7 @@ class ToolWalletTest(BitcoinTestFramework): self.log.info('Checking basic dump') wallet_dump = self.nodes[0].datadir_path / "wallet.dump" - self.assert_tool_output('The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n', '-wallet=todump', '-dumpfile={}'.format(wallet_dump), 'dump') + self.assert_tool_output('', '-wallet=todump', '-dumpfile={}'.format(wallet_dump), 'dump', stderr='The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n') dump_data = self.read_dump(wallet_dump) orig_dump = dump_data.copy()