mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
wallettool: Print warnings to stderr instead of stdout
This commit is contained in:
parent
e58751bb13
commit
2ea48ee1aa
@ -214,14 +214,14 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
|||||||
tfm::format(std::cerr, "%s\n", error.original);
|
tfm::format(std::cerr, "%s\n", error.original);
|
||||||
return ret;
|
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;
|
return ret;
|
||||||
} else if (command == "createfromdump") {
|
} else if (command == "createfromdump") {
|
||||||
bilingual_str error;
|
bilingual_str error;
|
||||||
std::vector<bilingual_str> warnings;
|
std::vector<bilingual_str> warnings;
|
||||||
bool ret = CreateFromDump(args, name, path, error, warnings);
|
bool ret = CreateFromDump(args, name, path, error, warnings);
|
||||||
for (const auto& warning : 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()) {
|
if (!ret && !error.empty()) {
|
||||||
tfm::format(std::cerr, "%s\n", error.original);
|
tfm::format(std::cerr, "%s\n", error.original);
|
||||||
|
@ -45,10 +45,10 @@ class ToolWalletTest(BitcoinTestFramework):
|
|||||||
assert_equal(stdout, '')
|
assert_equal(stdout, '')
|
||||||
assert_equal(stderr.strip(), error)
|
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)
|
p = self.bitcoin_wallet_process(*args)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
assert_equal(stderr, '')
|
assert_equal(stderr, stderr)
|
||||||
assert_equal(stdout, output)
|
assert_equal(stdout, output)
|
||||||
assert_equal(p.poll(), 0)
|
assert_equal(p.poll(), 0)
|
||||||
|
|
||||||
@ -167,10 +167,10 @@ class ToolWalletTest(BitcoinTestFramework):
|
|||||||
load_output = ""
|
load_output = ""
|
||||||
if file_format is not None and file_format != dump_data["format"]:
|
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)
|
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()
|
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)
|
rt_dump_data = self.read_dump(rt_dumppath)
|
||||||
wallet_dat = self.nodes[0].wallets_path / wallet_name / "wallet.dat"
|
wallet_dat = self.nodes[0].wallets_path / wallet_name / "wallet.dat"
|
||||||
@ -325,7 +325,7 @@ class ToolWalletTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.info('Checking basic dump')
|
self.log.info('Checking basic dump')
|
||||||
wallet_dump = self.nodes[0].datadir_path / "wallet.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)
|
dump_data = self.read_dump(wallet_dump)
|
||||||
orig_dump = dump_data.copy()
|
orig_dump = dump_data.copy()
|
||||||
|
Loading…
Reference in New Issue
Block a user