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>
33 #include <boost/optional.hpp>
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.
SetHexExact(params[jss::channel_id].asString()))
66 boost::optional<std::uint64_t>
const optDrops =
67 params[jss::amount].isString()
68 ?
to_uint64(params[jss::amount].asString())
81 auto const buf =
sign(pk, sk, msg.
slice());
82 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))
107 boost::optional<PublicKey> pk;
109 std::string const strPk = params[jss::public_key].asString();
125 if (!channelId.
SetHexExact(params[jss::channel_id].asString()))
128 boost::optional<std::uint64_t>
const optDrops =
129 params[jss::amount].isString()
130 ?
to_uint64(params[jss::amount].asString())
138 auto sig =
strUnHex(params[jss::signature].asString());
139 if (!sig || !sig->size())
146 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)
boost::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
boost::optional< std::uint64_t > to_uint64(std::string const &s)
boost::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
Json::Value doChannelVerify(RPC::JsonContext &)
void serializePayChanAuthorization(Serializer &msg, uint256 const &key, XRPAmount const &amt)
Json::Value missing_field_error(std::string const &name)
bool verify(PublicKey const &publicKey, Slice const &m, Slice const &sig, bool mustBeFullyCanonical)
Verify a signature on a message.
bool contains_error(Json::Value const &json)
Returns true if the json contains an rpc error specification.
Json::Value doChannelAuthorize(RPC::JsonContext &)
Slice slice() const noexcept
Json::Value rpcError(int iError, Json::Value jvResult)
bool SetHexExact(const char *psz)
Parse a hex string into a base_uint The string must contain exactly bytes * 2 hex characters and must...
@ 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)
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.