Skip to content

Commit 9e0e51b

Browse files
committed
Merge bitcoin#29870: rpc: Reword SighashFromStr error message
fa6ab0d rpc: Reword SighashFromStr error message (MarcoFalke) Pull request description: Put quotes around the parameter. In theory, `std::quoted` should be used, but that seems overkill. This should avoid error messages such as `A valid sighash parameter is not a valid sighash parameter. (code -8)`. Also, it should fix fuzz false positives when searching for internal bugs in the `rpc` fuzz target. For example, `ZGVzY3JpcHRvcnByb2Nlc3Nwc2J0XP9ce1tdXOVJbnRlcm5hbCBidWcgZGV0ZWN0ZWQAXQ0AHfcAXQ1p7TJv`. ACKs for top commit: dergoegge: ACK fa6ab0d brunoerg: utACK fa6ab0d Tree-SHA512: e2c0cc0126de61873a863af38b7b0a23d2dadd596ca0418dae2ad091e8acfb6a9d657c376d59187bb008989dc78c6b44fe518590e5217e4049a867b220c9fb18
2 parents 19d59c9 + fa6ab0d commit 9e0e51b

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/core_read.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,6 @@ util::Result<int> SighashFromStr(const std::string& sighash)
256256
if (it != map_sighash_values.end()) {
257257
return it->second;
258258
} else {
259-
return util::Error{Untranslated(sighash + " is not a valid sighash parameter.")};
259+
return util::Error{Untranslated("'" + sighash + "' is not a valid sighash parameter.")};
260260
}
261261
}

test/functional/rpc_psbt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ def test_psbt_input_keys(psbt_input, keys):
877877
assert_equal(comb_psbt, psbt)
878878

879879
self.log.info("Test walletprocesspsbt raises if an invalid sighashtype is passed")
880-
assert_raises_rpc_error(-8, "all is not a valid sighash parameter.", self.nodes[0].walletprocesspsbt, psbt, sighashtype="all")
880+
assert_raises_rpc_error(-8, "'all' is not a valid sighash parameter.", self.nodes[0].walletprocesspsbt, psbt, sighashtype="all")
881881

882882
self.log.info("Test decoding PSBT with per-input preimage types")
883883
# note that the decodepsbt RPC doesn't check whether preimages and hashes match
@@ -983,7 +983,7 @@ def test_psbt_input_keys(psbt_input, keys):
983983
self.nodes[2].sendrawtransaction(processed_psbt['hex'])
984984

985985
self.log.info("Test descriptorprocesspsbt raises if an invalid sighashtype is passed")
986-
assert_raises_rpc_error(-8, "all is not a valid sighash parameter.", self.nodes[2].descriptorprocesspsbt, psbt, [descriptor], sighashtype="all")
986+
assert_raises_rpc_error(-8, "'all' is not a valid sighash parameter.", self.nodes[2].descriptorprocesspsbt, psbt, [descriptor], sighashtype="all")
987987

988988

989989
if __name__ == '__main__':

test/functional/rpc_signrawtransactionwithkey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def invalid_sighashtype_test(self):
124124
self.log.info("Test signing transaction with invalid sighashtype")
125125
tx = self.nodes[0].createrawtransaction(INPUTS, OUTPUTS)
126126
privkeys = [self.nodes[0].get_deterministic_priv_key().key]
127-
assert_raises_rpc_error(-8, "all is not a valid sighash parameter.", self.nodes[0].signrawtransactionwithkey, tx, privkeys, sighashtype="all")
127+
assert_raises_rpc_error(-8, "'all' is not a valid sighash parameter.", self.nodes[0].signrawtransactionwithkey, tx, privkeys, sighashtype="all")
128128

129129
def run_test(self):
130130
self.successful_signing_test()

test/functional/wallet_signrawtransactionwithwallet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_with_lock_outputs(self):
5555

5656
def test_with_invalid_sighashtype(self):
5757
self.log.info("Test signrawtransactionwithwallet raises if an invalid sighashtype is passed")
58-
assert_raises_rpc_error(-8, "all is not a valid sighash parameter.", self.nodes[0].signrawtransactionwithwallet, hexstring=RAW_TX, sighashtype="all")
58+
assert_raises_rpc_error(-8, "'all' is not a valid sighash parameter.", self.nodes[0].signrawtransactionwithwallet, hexstring=RAW_TX, sighashtype="all")
5959

6060
def script_verification_error_test(self):
6161
"""Create and sign a raw transaction with valid (vin 0), invalid (vin 1) and one missing (vin 2) input script.

0 commit comments

Comments
 (0)