Skip to content

Commit

Permalink
rpc: Reword SighashFromStr error message
Browse files Browse the repository at this point in the history
Github-Pull: #29870
Rebased-From: fa6ab0d
  • Loading branch information
MarcoFalke authored and fanquake committed Apr 24, 2024
1 parent 364bf01 commit a6a59cf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/core_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,6 @@ util::Result<int> SighashFromStr(const std::string& sighash)
if (it != map_sighash_values.end()) {
return it->second;
} else {
return util::Error{Untranslated(sighash + " is not a valid sighash parameter.")};
return util::Error{Untranslated("'" + sighash + "' is not a valid sighash parameter.")};
}
}
4 changes: 2 additions & 2 deletions test/functional/rpc_psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ def test_psbt_input_keys(psbt_input, keys):
assert_equal(comb_psbt, psbt)

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

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

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


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_signrawtransactionwithkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def invalid_sighashtype_test(self):
self.log.info("Test signing transaction with invalid sighashtype")
tx = self.nodes[0].createrawtransaction(INPUTS, OUTPUTS)
privkeys = [self.nodes[0].get_deterministic_priv_key().key]
assert_raises_rpc_error(-8, "all is not a valid sighash parameter.", self.nodes[0].signrawtransactionwithkey, tx, privkeys, sighashtype="all")
assert_raises_rpc_error(-8, "'all' is not a valid sighash parameter.", self.nodes[0].signrawtransactionwithkey, tx, privkeys, sighashtype="all")

def run_test(self):
self.successful_signing_test()
Expand Down
2 changes: 1 addition & 1 deletion test/functional/wallet_signrawtransactionwithwallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_with_lock_outputs(self):

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

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

0 comments on commit a6a59cf

Please sign in to comment.