1#include <xrpld/app/misc/NetworkOPs.h>
2#include <xrpld/rpc/Context.h>
3#include <xrpld/rpc/Role.h>
4#include <xrpld/rpc/detail/RPCHelpers.h>
6#include <xrpl/basics/Log.h>
7#include <xrpl/protocol/ErrorCodes.h>
8#include <xrpl/protocol/RPCErr.h>
9#include <xrpl/protocol/jss.h>
18 bool removeUrl{
false};
47 for (
auto& it : context.
params[jss::streams])
53 if (streamName ==
"server")
57 else if (streamName ==
"ledger")
61 else if (streamName ==
"manifests")
65 else if (streamName ==
"transactions")
70 streamName ==
"transactions_proposed" ||
71 streamName ==
"rt_transactions")
75 else if (streamName ==
"validations")
79 else if (streamName ==
"peer_status")
83 else if (streamName ==
"consensus")
94 auto accountsProposed = context.
params.
isMember(jss::accounts_proposed)
95 ? jss::accounts_proposed
121 auto const& req = context.
params[jss::account_history_tx_stream];
122 if (!req.isMember(jss::account) || !req[jss::account].isString())
125 auto const id = parseBase58<AccountID>(req[jss::account].asString());
129 bool stopHistoryOnly =
false;
130 if (req.isMember(jss::stop_history_tx_only))
132 if (!req[jss::stop_history_tx_only].isBool())
134 stopHistoryOnly = req[jss::stop_history_tx_only].asBool();
139 <<
"doUnsubscribe: account_history_tx_stream: " <<
toBase58(*
id)
140 <<
" stopHistoryOnly=" << (stopHistoryOnly ?
"true" :
"false");
148 for (
auto& jv : context.
params[jss::books])
150 if (!jv.isObject() || !jv.isMember(jss::taker_pays) ||
151 !jv.isMember(jss::taker_gets) ||
152 !jv[jss::taker_pays].isObjectOrNull() ||
153 !jv[jss::taker_gets].isObjectOrNull())
164 if (!taker_pays.
isMember(jss::currency) ||
168 JLOG(context.
j.
info()) <<
"Bad taker_pays currency.";
173 ((taker_pays.
isMember(jss::issuer)) &&
174 (!taker_pays[jss::issuer].
isString() ||
180 JLOG(context.
j.
info()) <<
"Bad taker_pays issuer.";
186 if (!taker_gets.
isMember(jss::currency) ||
190 JLOG(context.
j.
info()) <<
"Bad taker_gets currency.";
196 ((taker_gets.
isMember(jss::issuer)) &&
197 (!taker_gets[jss::issuer].
isString() ||
203 JLOG(context.
j.
info()) <<
"Bad taker_gets issuer.";
208 if (book.
in == book.
out)
210 JLOG(context.
j.
info()) <<
"taker_gets same as taker_pays.";
214 if (jv.isMember(jss::domain))
217 if (!jv[jss::domain].isString() ||
218 !domain.
parseHex(jv[jss::domain].asString()))
231 if ((jv.isMember(jss::both) && jv[jss::both].asBool()) ||
232 (jv.isMember(jss::both_sides) && jv[jss::both_sides].asBool()))
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
std::optional< uint256 > domain
virtual bool unsubBook(std::uint64_t uListener, Book const &)=0
virtual bool unsubValidations(std::uint64_t uListener)=0
virtual bool unsubServer(std::uint64_t uListener)=0
virtual bool unsubPeerStatus(std::uint64_t uListener)=0
virtual bool tryRemoveRpcSub(std::string const &strUrl)=0
virtual bool unsubConsensus(std::uint64_t uListener)=0
virtual bool unsubLedger(std::uint64_t uListener)=0
virtual pointer findRpcSub(std::string const &strUrl)=0
virtual bool unsubTransactions(std::uint64_t uListener)=0
virtual void unsubAccount(ref isplistener, hash_set< AccountID > const &vnaAccountIDs, bool realTime)=0
virtual bool unsubManifests(std::uint64_t uListener)=0
virtual void unsubAccountHistory(ref ispListener, AccountID const &account, bool historyOnly)=0
unsubscribe an account's transactions
virtual bool unsubRTTransactions(std::uint64_t uListener)=0
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
@ objectValue
object value (collection of name/value pairs).
hash_set< AccountID > parseAccountIds(Json::Value const &jvArray)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
AccountID const & noAccount()
A placeholder for empty accounts.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Json::Value doUnsubscribe(RPC::JsonContext &)
bool isConsistent(Book const &book)
bool to_issuer(AccountID &, std::string const &)
Convert hex or base58 string to AccountID.
Book reversed(Book const &book)
Json::Value rpcError(int iError)
bool to_currency(Currency &, std::string const &)
Tries to convert a string to a Currency, returns true on success.