mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
kernel: Split ParseSighashString
This split is done in preparation for the next commit where the dependency on UniValue in the kernel library is removed.
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <core_io.h>
|
||||
#include <common/args.h>
|
||||
#include <consensus/amount.h>
|
||||
#include <script/interpreter.h>
|
||||
#include <key_io.h>
|
||||
#include <outputtype.h>
|
||||
#include <rpc/util.h>
|
||||
@@ -12,6 +14,7 @@
|
||||
#include <script/signingprovider.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/check.h>
|
||||
#include <util/result.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <util/translation.h>
|
||||
@@ -310,6 +313,21 @@ UniValue DescribeAddress(const CTxDestination& dest)
|
||||
return std::visit(DescribeAddressVisitor(), dest);
|
||||
}
|
||||
|
||||
int ParseSighashString(const UniValue& sighash)
|
||||
{
|
||||
if (sighash.isNull()) {
|
||||
return SIGHASH_DEFAULT;
|
||||
}
|
||||
if (!sighash.isStr()) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "sighash needs to be null or string");
|
||||
}
|
||||
const auto result{SighashFromStr(sighash.get_str())};
|
||||
if (!result) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, util::ErrorString(result).original);
|
||||
}
|
||||
return result.value();
|
||||
}
|
||||
|
||||
unsigned int ParseConfirmTarget(const UniValue& value, unsigned int max_target)
|
||||
{
|
||||
const int target{value.getInt<int>()};
|
||||
|
||||
Reference in New Issue
Block a user