mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-15 16:38:23 +01:00
init: fix fatal error on '-wallet' negated option value
Because we don't have type checking for command-line/settings/config args, strings are interpreted as 'false' for non-boolean args. By convention, this "forces" us to interpret negated strings as 'true', which conflicts with the negated option definition in all the settings classes (they expect negated options to always be false and ignore any other value preceding them). Consequently, when retrieving all "wallet" values from the command-line/settings/config, we also fetch the negated string boolean value, which is not of the expected 'string' type. This mismatch leads to an internal fatal error, resulting in an unclean shutdown during initialization. Furthermore, this error displays a poorly descriptive error message: "JSON value of type bool is not of expected type string" This commit fixes the fatal error by ensuring that only string values are returned in the "wallet" settings list, failing otherwise. It also improves the clarity of the returned error message. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -153,6 +153,13 @@ class ConfArgsTest(BitcoinTestFramework):
|
||||
expected_msg='Error: Error parsing command line arguments: Can not set -proxy with no value. Please specify value with -proxy=value.',
|
||||
extra_args=['-proxy'],
|
||||
)
|
||||
# Provide a value different from 1 to the -wallet negated option
|
||||
if self.is_wallet_compiled():
|
||||
for value in [0, 'not_a_boolean']:
|
||||
self.nodes[0].assert_start_raises_init_error(
|
||||
expected_msg="Error: Invalid value detected for '-wallet' or '-nowallet'. '-wallet' requires a string value, while '-nowallet' accepts only '1' to disable all wallets",
|
||||
extra_args=[f'-nowallet={value}'],
|
||||
)
|
||||
|
||||
def test_log_buffer(self):
|
||||
self.stop_node(0)
|
||||
|
||||
Reference in New Issue
Block a user