diff --git a/doc/release-notes-28113.md b/doc/release-notes-28113.md new file mode 100644 index 0000000000..c1a3a07b17 --- /dev/null +++ b/doc/release-notes-28113.md @@ -0,0 +1,7 @@ +RPC Wallet +---------- + +- The `signrawtransactionwithkey`, `signrawtransactionwithwallet`, + `walletprocesspsbt` and `descriptorprocesspsbt` calls now return more + specific RPC_INVALID_PARAMETER instead of RPC_PARSE_ERROR if their + sighashtype argument is malformed or not a string. diff --git a/src/Makefile.am b/src/Makefile.am index aba6f00756..dfea7146aa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -898,8 +898,8 @@ if BUILD_BITCOIN_KERNEL_LIB lib_LTLIBRARIES += $(LIBBITCOINKERNEL) libbitcoinkernel_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) $(PTHREAD_FLAGS) -libbitcoinkernel_la_LIBADD = $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) $(LIBSECP256K1) -libbitcoinkernel_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) +libbitcoinkernel_la_LIBADD = $(LIBBITCOIN_CRYPTO) $(LIBLEVELDB) $(LIBMEMENV) $(LIBSECP256K1) +libbitcoinkernel_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) # libbitcoinkernel requires default symbol visibility, explicitly specify that # here so that things still work even when user configures with diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 0c25ddf373..103d8885db 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -562,6 +562,16 @@ static CAmount AmountFromValue(const UniValue& value) return amount; } +static std::vector ParseHexUV(const UniValue& v, const std::string& strName) +{ + std::string strHex; + if (v.isStr()) + strHex = v.getValStr(); + if (!IsHex(strHex)) + throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')"); + return ParseHex(strHex); +} + static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr) { int nHashType = SIGHASH_ALL; diff --git a/src/core_io.h b/src/core_io.h index 997f3bfd5b..1f5ecbaea6 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -6,6 +6,7 @@ #define BITCOIN_CORE_IO_H #include +#include #include #include @@ -45,8 +46,7 @@ bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header); * @see ParseHashV for an RPC-oriented version of this */ bool ParseHashStr(const std::string& strHex, uint256& result); -std::vector ParseHexUV(const UniValue& v, const std::string& strName); -int ParseSighashString(const UniValue& sighash); +[[nodiscard]] util::Result SighashFromStr(const std::string& sighash); // core_write.cpp UniValue ValueFromAmount(const CAmount amount); diff --git a/src/core_read.cpp b/src/core_read.cpp index 84cd559b7f..dfabf3a0c2 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -10,7 +10,7 @@ #include