rpc: Quote user supplied descriptor in error msg

This commit is contained in:
MarcoFalke 2022-01-01 00:57:12 +13:00
parent 623745ca74
commit fa4c599145
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) 2018-2021 The Bitcoin Core developers
// Copyright (c) 2018-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -1222,7 +1222,7 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t& key_exp_index, Span<const
error = "A function is needed within P2WSH";
return nullptr;
}
error = strprintf("%s is not a valid descriptor function", std::string(expr.begin(), expr.end()));
error = strprintf("'%s' is not a valid descriptor function", std::string(expr.begin(), expr.end()));
return nullptr;
}

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright (c) 2019-2020 The Bitcoin Core developers
# Copyright (c) 2019-2022 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test getdescriptorinfo RPC.
@ -30,7 +30,7 @@ class DescriptorTest(BitcoinTestFramework):
def run_test(self):
assert_raises_rpc_error(-1, 'getdescriptorinfo', self.nodes[0].getdescriptorinfo)
assert_raises_rpc_error(-3, 'Expected type string', self.nodes[0].getdescriptorinfo, 1)
assert_raises_rpc_error(-5, 'is not a valid descriptor function', self.nodes[0].getdescriptorinfo, '')
assert_raises_rpc_error(-5, "'' is not a valid descriptor function", self.nodes[0].getdescriptorinfo, "")
# P2PK output with the specified public key.
self.test_desc('pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)', isrange=False, issolvable=True, hasprivatekeys=False)