20 #include <ripple/app/main/Application.h>
21 #include <ripple/basics/StringUtilities.h>
22 #include <ripple/ledger/ReadView.h>
23 #include <ripple/net/RPCErr.h>
24 #include <ripple/protocol/ErrorCodes.h>
25 #include <ripple/protocol/PayChan.h>
26 #include <ripple/protocol/STAccount.h>
27 #include <ripple/protocol/jss.h>
28 #include <ripple/resource/Fees.h>
29 #include <ripple/rpc/Context.h>
30 #include <ripple/rpc/impl/RPCHelpers.h>
31 #include <ripple/rpc/impl/Tuning.h>
46 auto const& params(context.
params);
47 for (
auto const& p : {jss::channel_id, jss::amount})
48 if (!params.isMember(p))
54 if (!params.isMember(jss::key_type) && !params.isMember(jss::secret))
63 if (!channelId.
parseHex(params[jss::channel_id].asString()))
67 ?
to_uint64(params[jss::amount].asString())
80 auto const buf =
sign(pk, sk, msg.
slice());
81 result[jss::signature] =
strHex(buf);
101 auto const& params(context.
params);
103 {jss::public_key, jss::channel_id, jss::amount, jss::signature})
104 if (!params.isMember(p))
109 std::string const strPk = params[jss::public_key].asString();
125 if (!channelId.
parseHex(params[jss::channel_id].asString()))
129 ?
to_uint64(params[jss::amount].asString())
137 auto sig =
strUnHex(params[jss::signature].asString());
138 if (!sig || !sig->size())
145 result[jss::signature_verified] =
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
Json::Value rpcError(int iError)
bool verify(PublicKey const &publicKey, Slice const &m, Slice const &sig, bool mustBeFullyCanonical) noexcept
Verify a signature on a message.
Json::Value doChannelVerify(RPC::JsonContext &)
void serializePayChanAuthorization(Serializer &msg, uint256 const &key, XRPAmount const &amt)
Json::Value missing_field_error(std::string const &name)
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
bool contains_error(Json::Value const &json)
Returns true if the json contains an rpc error specification.
Json::Value doChannelAuthorize(RPC::JsonContext &)
std::optional< std::uint64_t > to_uint64(std::string const &s)
Slice slice() const noexcept
@ rpcCHANNEL_AMT_MALFORMED
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Buffer sign(PublicKey const &pk, SecretKey const &sk, Slice const &m)
Generate a signature for a message.
std::pair< PublicKey, SecretKey > keypairForSignature(Json::Value const ¶ms, Json::Value &error)
std::string strHex(FwdIt begin, FwdIt end)
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.