1#include <xrpld/app/main/Application.h>
2#include <xrpld/rpc/Context.h>
3#include <xrpld/rpc/Role.h>
4#include <xrpld/rpc/detail/RPCHelpers.h>
6#include <xrpl/basics/StringUtilities.h>
7#include <xrpl/basics/base_uint.h>
8#include <xrpl/basics/strHex.h>
9#include <xrpl/beast/utility/instrumentation.h>
10#include <xrpl/json/json_value.h>
11#include <xrpl/protocol/ErrorCodes.h>
12#include <xrpl/protocol/PayChan.h>
13#include <xrpl/protocol/RPCErr.h>
14#include <xrpl/protocol/SecretKey.h>
15#include <xrpl/protocol/Serializer.h>
16#include <xrpl/protocol/XRPAmount.h>
17#include <xrpl/protocol/jss.h>
40 auto const& params(context.
params);
41 for (
auto const& p : {jss::channel_id, jss::amount})
43 if (!params.isMember(p))
50 if (!params.isMember(jss::key_type) && !params.isMember(jss::secret))
59 "xrpl::doChannelAuthorize : valid keyPair or an error");
67 if (!channelId.
parseHex(params[jss::channel_id].asString()))
71 params[jss::amount].isString() ?
toUInt64(params[jss::amount].asString()) : std::nullopt;
83 auto const buf =
sign(pk, sk, msg.
slice());
84 result[jss::signature] =
strHex(buf);
virtual Config & config()=0
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Slice slice() const noexcept
std::optional< std::pair< PublicKey, SecretKey > > keypairForSignature(json::Value const ¶ms, json::Value &error, unsigned int apiVersion)
Generates a keypair for signature from RPC parameters.
json::Value makeError(ErrorCodeI code)
Returns a new json object that reflects the error code.
bool containsError(json::Value const &json)
Returns true if the json contains an rpc error specification.
json::Value missingFieldError(std::string const &name)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string strHex(FwdIt begin, FwdIt end)
void serializePayChanAuthorization(Serializer &msg, uint256 const &key, XRPAmount const &amt)
json::Value doChannelAuthorize(RPC::JsonContext &context)
json::Value rpcError(ErrorCodeI iError)
std::optional< std::uint64_t > toUInt64(std::string const &s)
Buffer sign(PublicKey const &pk, SecretKey const &sk, Slice const &message)
Generate a signature for a message.