mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
rpc: Quote user supplied strings in error messages
This commit is contained in:
parent
767c012665
commit
fa24a3df87
4 changed files with 8 additions and 8 deletions
|
@ -1134,7 +1134,7 @@ CoinStatsHashType ParseHashType(const std::string& hash_type_input)
|
|||
} else if (hash_type_input == "none") {
|
||||
return CoinStatsHashType::NONE;
|
||||
} else {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s is not a valid hash_type", hash_type_input));
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("'%s' is not a valid hash_type", hash_type_input));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2213,7 +2213,7 @@ static RPCHelpMan getblockstats()
|
|||
for (const std::string& stat : stats) {
|
||||
const UniValue& value = ret_all[stat];
|
||||
if (value.isNull()) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid selected statistic %s", stat));
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid selected statistic '%s'", stat));
|
||||
}
|
||||
ret.pushKV(stat, value);
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ CPubKey AddrToPubKey(const FillableSigningProvider& keystore, const std::string&
|
|||
}
|
||||
CKeyID key = GetKeyForDestination(keystore, dest);
|
||||
if (key.IsNull()) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("%s does not refer to a key", addr_in));
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("'%s' does not refer to a key", addr_in));
|
||||
}
|
||||
CPubKey vchPubKey;
|
||||
if (!keystore.GetPubKey(key, vchPubKey)) {
|
||||
|
|
|
@ -329,7 +329,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
assert 'muhash' not in r
|
||||
|
||||
# Unknown hash_type raises an error
|
||||
assert_raises_rpc_error(-8, "foohash is not a valid hash_type", node.gettxoutsetinfo, "foohash")
|
||||
assert_raises_rpc_error(-8, "'foo hash' is not a valid hash_type", node.gettxoutsetinfo, "foo hash")
|
||||
|
||||
def _test_getblockheader(self):
|
||||
self.log.info("Test getblockheader")
|
||||
|
|
|
@ -147,12 +147,12 @@ class GetblockstatsTest(BitcoinTestFramework):
|
|||
['minfee', inv_sel_stat, 'maxfee'],
|
||||
]
|
||||
for inv_stat in inv_stats:
|
||||
assert_raises_rpc_error(-8, 'Invalid selected statistic %s' % inv_sel_stat,
|
||||
assert_raises_rpc_error(-8, f"Invalid selected statistic '{inv_sel_stat}'",
|
||||
self.nodes[0].getblockstats, hash_or_height=1, stats=inv_stat)
|
||||
|
||||
# Make sure we aren't always returning inv_sel_stat as the culprit stat
|
||||
assert_raises_rpc_error(-8, 'Invalid selected statistic aaa%s' % inv_sel_stat,
|
||||
self.nodes[0].getblockstats, hash_or_height=1, stats=['minfee' , 'aaa%s' % inv_sel_stat])
|
||||
assert_raises_rpc_error(-8, f"Invalid selected statistic 'aaa{inv_sel_stat}'",
|
||||
self.nodes[0].getblockstats, hash_or_height=1, stats=['minfee', f'aaa{inv_sel_stat}'])
|
||||
# Mainchain's genesis block shouldn't be found on regtest
|
||||
assert_raises_rpc_error(-5, 'Block not found', self.nodes[0].getblockstats,
|
||||
hash_or_height='000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f')
|
||||
|
|
Loading…
Reference in a new issue