rippled
Loading...
Searching...
No Matches
Env.cpp
1#include <test/jtx/Env.h>
2#include <test/jtx/JSONRPCClient.h>
3#include <test/jtx/balance.h>
4#include <test/jtx/fee.h>
5#include <test/jtx/flags.h>
6#include <test/jtx/pay.h>
7#include <test/jtx/seq.h>
8#include <test/jtx/sig.h>
9#include <test/jtx/trust.h>
10#include <test/jtx/utility.h>
11
12#include <xrpld/app/ledger/LedgerMaster.h>
13#include <xrpld/app/misc/NetworkOPs.h>
14#include <xrpld/rpc/RPCCall.h>
15
16#include <xrpl/basics/Slice.h>
17#include <xrpl/basics/contract.h>
18#include <xrpl/basics/scope.h>
19#include <xrpl/json/to_string.h>
20#include <xrpl/net/HTTPClient.h>
21#include <xrpl/protocol/ErrorCodes.h>
22#include <xrpl/protocol/Indexes.h>
23#include <xrpl/protocol/Serializer.h>
24#include <xrpl/protocol/TER.h>
25#include <xrpl/protocol/TxFlags.h>
26#include <xrpl/protocol/UintTypes.h>
27#include <xrpl/protocol/jss.h>
28
29#include <memory>
30
31namespace xrpl {
32namespace test {
33namespace jtx {
34
35//------------------------------------------------------------------------------
36
42 : AppBundle()
43{
44 using namespace beast::severities;
45 if (logs)
46 {
47 setDebugLogSink(logs->makeSink("Debug", kFatal));
48 }
49 else
50 {
51 logs = std::make_unique<SuiteLogs>(suite);
52 // Use kFatal threshold to reduce noise from STObject.
54 }
55 auto timeKeeper_ = std::make_unique<ManualTimeKeeper>();
56 timeKeeper = timeKeeper_.get();
57 // Hack so we don't have to call Config::setup
58 HTTPClient::initializeSSLContext(config->SSL_VERIFY_DIR, config->SSL_VERIFY_FILE, config->SSL_VERIFY, debugLog());
59 owned = make_Application(std::move(config), std::move(logs), std::move(timeKeeper_));
60 app = owned.get();
61 app->logs().threshold(thresh);
62 if (!app->setup({}))
63 Throw<std::runtime_error>("Env::AppBundle: setup failed");
64 timeKeeper->set(app->getLedgerMaster().getClosedLedger()->header().closeTime);
65 app->start(false /*don't start timers*/);
66 thread = std::thread([&]() { app->run(); });
67
69}
70
72{
73 client.reset();
74 // Make sure all jobs finish, otherwise tests
75 // might not get the coverage they expect.
76 if (app)
77 {
79 app->signalStop("~AppBundle");
80 }
81 if (thread.joinable())
82 thread.join();
83
84 // Remove the debugLogSink before the suite goes out of scope.
85 setDebugLogSink(nullptr);
86}
87
88//------------------------------------------------------------------------------
89
95
96bool
98{
99 // Round up to next distinguishable value
100 using namespace std::chrono_literals;
101 bool res = true;
102 closeTime += closed()->header().closeTimeResolution - 1s;
103 timeKeeper().set(closeTime);
104 // Go through the rpc interface unless we need to simulate
105 // a specific consensus delay.
106 if (consensusDelay)
107 app().getOPs().acceptLedger(consensusDelay);
108 else
109 {
110 auto resp = rpc("ledger_accept");
111 if (resp["result"]["status"] != std::string("success"))
112 {
113 std::string reason = "internal error";
114 if (resp.isMember("error_what"))
115 reason = resp["error_what"].asString();
116 else if (resp.isMember("error_message"))
117 reason = resp["error_message"].asString();
118 else if (resp.isMember("error"))
119 reason = resp["error"].asString();
120
121 JLOG(journal.error()) << "Env::close() failed: " << reason;
122 res = false;
123 }
124 }
125 timeKeeper().set(closed()->header().closeTime);
126 return res;
127}
128
129void
130Env::memoize(Account const& account)
131{
132 map_.emplace(account.id(), account);
133}
134
135Account const&
136Env::lookup(AccountID const& id) const
137{
138 auto const iter = map_.find(id);
139 if (iter == map_.end())
140 {
141 std::cout << "Unknown account: " << id << "\n";
142 Throw<std::runtime_error>("Env::lookup:: unknown account ID");
143 }
144 return iter->second;
145}
146
147Account const&
148Env::lookup(std::string const& base58ID) const
149{
150 auto const account = parseBase58<AccountID>(base58ID);
151 if (!account)
152 Throw<std::runtime_error>("Env::lookup: invalid account ID");
153 return lookup(*account);
154}
155
157Env::balance(Account const& account) const
158{
159 auto const sle = le(account);
160 if (!sle)
161 return XRP(0);
162 return {sle->getFieldAmount(sfBalance), ""};
163}
164
166Env::balance(Account const& account, Issue const& issue) const
167{
168 if (isXRP(issue.currency))
169 return balance(account);
170 auto const sle = le(keylet::line(account.id(), issue));
171 if (!sle)
172 return {STAmount(issue, 0), account.name()};
173 auto amount = sle->getFieldAmount(sfBalance);
174 amount.setIssuer(issue.account);
175 if (account.id() > issue.account)
176 amount.negate();
177 return {amount, lookup(issue.account).name()};
178}
179
181Env::balance(Account const& account, MPTIssue const& mptIssue) const
182{
183 MPTID const id = mptIssue.getMptID();
184 if (!id)
185 return {STAmount(mptIssue, 0), account.name()};
186
187 AccountID const issuer = mptIssue.getIssuer();
188 if (account.id() == issuer)
189 {
190 // Issuer balance
191 auto const sle = le(keylet::mptIssuance(id));
192 if (!sle)
193 return {STAmount(mptIssue, 0), account.name()};
194
195 // Make it negative
196 STAmount const amount{mptIssue, sle->getFieldU64(sfOutstandingAmount), 0, true};
197 return {amount, lookup(issuer).name()};
198 }
199 else
200 {
201 // Holder balance
202 auto const sle = le(keylet::mptoken(id, account));
203 if (!sle)
204 return {STAmount(mptIssue, 0), account.name()};
205
206 STAmount const amount{mptIssue, sle->getFieldU64(sfMPTAmount)};
207 return {amount, lookup(issuer).name()};
208 }
209}
210
212Env::balance(Account const& account, Asset const& asset) const
213{
214 return std::visit([&](auto const& issue) { return balance(account, issue); }, asset.value());
215}
216
218Env::limit(Account const& account, Issue const& issue) const
219{
220 auto const sle = le(keylet::line(account.id(), issue));
221 if (!sle)
222 return {STAmount(issue, 0), account.name()};
223 auto const aHigh = account.id() > issue.account;
224 if (sle && sle->isFieldPresent(aHigh ? sfLowLimit : sfHighLimit))
225 return {(*sle)[aHigh ? sfLowLimit : sfHighLimit], account.name()};
226 return {STAmount(issue, 0), account.name()};
227}
228
230Env::ownerCount(Account const& account) const
231{
232 auto const sle = le(account);
233 if (!sle)
234 Throw<std::runtime_error>("missing account root");
235 return sle->getFieldU32(sfOwnerCount);
236}
237
239Env::seq(Account const& account) const
240{
241 auto const sle = le(account);
242 if (!sle)
243 Throw<std::runtime_error>("missing account root");
244 return sle->getFieldU32(sfSequence);
245}
246
248Env::le(Account const& account) const
249{
250 return le(keylet::account(account.id()));
251}
252
254Env::le(Keylet const& k) const
255{
256 return current()->read(k);
257}
258
259void
260Env::fund(bool setDefaultRipple, STAmount const& amount, Account const& account)
261{
262 memoize(account);
263 if (setDefaultRipple)
264 {
265 // VFALCO NOTE Is the fee formula correct?
266 apply(
267 pay(master, account, amount + drops(current()->fees().base)),
272 require(flags(account, asfDefaultRipple));
273 }
274 else
275 {
278 }
279 require(jtx::balance(account, amount));
280}
281
282void
283Env::trust(STAmount const& amount, Account const& account)
284{
285 auto const start = balance(account);
287 apply(
288 pay(master, account, drops(current()->fees().base)),
292 test.expect(balance(account) == start);
293}
294
297{
298 auto error = [](ParsedResult& parsed, Json::Value const& object) {
299 // Use an error code that is not used anywhere in the transaction
300 // engine to distinguish this case.
301 parsed.ter = telENV_RPC_FAILED;
302 // Extract information about the error
303 if (!object.isObject())
304 return;
305 if (object.isMember(jss::error_code))
306 parsed.rpcCode = safe_cast<error_code_i>(object[jss::error_code].asInt());
307 if (object.isMember(jss::error_message))
308 parsed.rpcMessage = object[jss::error_message].asString();
309 if (object.isMember(jss::error))
310 parsed.rpcError = object[jss::error].asString();
311 if (object.isMember(jss::error_exception))
312 parsed.rpcException = object[jss::error_exception].asString();
313 };
314 ParsedResult parsed;
315 if (jr.isObject() && jr.isMember(jss::result))
316 {
317 auto const& result = jr[jss::result];
318 if (result.isMember(jss::engine_result_code))
319 {
320 parsed.ter = TER::fromInt(result[jss::engine_result_code].asInt());
321 parsed.rpcCode.emplace(rpcSUCCESS);
322 }
323 else
324 error(parsed, result);
325 }
326 else
327 error(parsed, jr);
328
329 return parsed;
330}
331
332void
334{
335 ParsedResult parsedResult;
336 auto const jr = [&]() {
337 if (jt.stx)
338 {
339 txid_ = jt.stx->getTransactionID();
340 Serializer s;
341 jt.stx->add(s);
342 auto const jr = rpc("submit", strHex(s.slice()));
343
344 parsedResult = parseResult(jr);
345 test.expect(parsedResult.ter, "ter uninitialized!");
346 ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
347
348 return jr;
349 }
350 else
351 {
352 // Parsing failed or the JTx is
353 // otherwise missing the stx field.
354 parsedResult.ter = ter_ = temMALFORMED;
355
356 return Json::Value();
357 }
358 }();
359 return postconditions(jt, parsedResult, jr);
360}
361
362void
364{
365 auto const account = lookup(jt.jv[jss::Account].asString());
366 auto const& passphrase = account.name();
367
368 Json::Value jr;
369 if (params.isNull())
370 {
371 // Use the command line interface
372 auto const jv = to_string(jt.jv);
373 jr = rpc("submit", passphrase, jv);
374 }
375 else
376 {
377 // Use the provided parameters, and go straight
378 // to the (RPC) client.
379 assert(params.isObject());
380 if (!params.isMember(jss::secret) && !params.isMember(jss::key_type) && !params.isMember(jss::seed) &&
381 !params.isMember(jss::seed_hex) && !params.isMember(jss::passphrase))
382 {
383 params[jss::secret] = passphrase;
384 }
385 params[jss::tx_json] = jt.jv;
386 jr = client().invoke("submit", params);
387 }
388
389 if (!txid_.parseHex(jr[jss::result][jss::tx_json][jss::hash].asString()))
390 txid_.zero();
391
392 ParsedResult const parsedResult = parseResult(jr);
393 test.expect(parsedResult.ter, "ter uninitialized!");
394 ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
395
396 return postconditions(jt, parsedResult, jr);
397}
398
399void
400Env::postconditions(JTx const& jt, ParsedResult const& parsed, Json::Value const& jr)
401{
402 auto const line = jt.testLine ? " (" + to_string(*jt.testLine) + ")" : "";
403 bool bad = !test.expect(parsed.ter, "apply: No ter result!" + line);
404 bad =
405 (jt.ter && parsed.ter &&
406 !test.expect(
407 *parsed.ter == *jt.ter,
408 "apply: Got " + transToken(*parsed.ter) + " (" + transHuman(*parsed.ter) + "); Expected " +
409 transToken(*jt.ter) + " (" + transHuman(*jt.ter) + ")" + line));
410 using namespace std::string_literals;
411 bad = (jt.rpcCode &&
412 !test.expect(
413 parsed.rpcCode == jt.rpcCode->first && parsed.rpcMessage == jt.rpcCode->second,
414 "apply: Got RPC result "s +
415 (parsed.rpcCode ? RPC::get_error_info(*parsed.rpcCode).token.c_str() : "NO RESULT") + " (" +
416 parsed.rpcMessage + "); Expected " + RPC::get_error_info(jt.rpcCode->first).token.c_str() + " (" +
417 jt.rpcCode->second + ")" + line)) ||
418 bad;
419 // If we have an rpcCode (just checked), then the rpcException check is
420 // optional - the 'error' field may not be defined, but if it is, it must
421 // match rpcError.
422 bad = (jt.rpcException &&
423 !test.expect(
424 (jt.rpcCode && parsed.rpcError.empty()) ||
425 (parsed.rpcError == jt.rpcException->first &&
426 (!jt.rpcException->second || parsed.rpcException == *jt.rpcException->second)),
427 "apply: Got RPC result "s + parsed.rpcError + " (" + parsed.rpcException + "); Expected " +
428 jt.rpcException->first + " (" + jt.rpcException->second.value_or("n/a") + ")" + line)) ||
429 bad;
430 if (bad)
431 {
432 test.log << pretty(jt.jv) << std::endl;
433 if (jr)
434 test.log << pretty(jr) << std::endl;
435 // Don't check postconditions if
436 // we didn't get the expected result.
437 return;
438 }
439 if (trace_)
440 {
441 if (trace_ > 0)
442 --trace_;
443 test.log << pretty(jt.jv) << std::endl;
444 }
445 for (auto const& f : jt.require)
446 f(*this);
447}
448
451{
452 if (current()->txCount() != 0)
453 {
454 // close the ledger if it has not already been closed
455 // (metadata is not finalized until the ledger is closed)
456 close();
457 }
458 auto const item = closed()->txRead(txid_);
459 auto const result = item.second;
460 if (result == nullptr)
461 {
462 test.log << "Env::meta: no metadata for txid: " << txid_ << std::endl;
463 test.log << "This is probably because the transaction failed with a "
464 "non-tec error."
465 << std::endl;
466 Throw<std::runtime_error>("Env::meta: no metadata for txid");
467 }
468 return result;
469}
470
472Env::tx() const
473{
474 return current()->txRead(txid_).first;
475}
476
477void
479{
480 auto& jv = jt.jv;
481
482 scope_success success([&]() {
483 // Call all the post-signers after the main signers or autofill are done
484 for (auto const& signer : jt.postSigners)
485 signer(*this, jt);
486 });
487
488 // Call all the main signers
489 if (!jt.mainSigners.empty())
490 {
491 for (auto const& signer : jt.mainSigners)
492 signer(*this, jt);
493 return;
494 }
495
496 // If the sig is still needed, get it here.
497 if (!jt.fill_sig)
498 return;
499 auto const account = jv.isMember(sfDelegate.jsonName) ? lookup(jv[sfDelegate.jsonName].asString())
500 : lookup(jv[jss::Account].asString());
501 if (!app().checkSigs())
502 {
503 jv[jss::SigningPubKey] = strHex(account.pk().slice());
504 // dummy sig otherwise STTx is invalid
505 jv[jss::TxnSignature] = "00";
506 return;
507 }
508 auto const ar = le(account);
509 if (ar && ar->isFieldPresent(sfRegularKey))
510 jtx::sign(jv, lookup(ar->getAccountID(sfRegularKey)));
511 else
512 jtx::sign(jv, account);
513}
514
515void
517{
518 auto& jv = jt.jv;
519 if (jt.fill_fee)
520 jtx::fill_fee(jv, *current());
521 if (jt.fill_seq)
522 jtx::fill_seq(jv, *current());
523
524 if (jt.fill_netid)
525 {
526 uint32_t networkID = app().config().NETWORK_ID;
527 if (!jv.isMember(jss::NetworkID) && networkID > 1024)
528 jv[jss::NetworkID] = std::to_string(networkID);
529 }
530
531 // Must come last
532 try
533 {
535 }
536 catch (parse_error const&)
537 {
539 test.log << "parse failed:\n" << pretty(jv) << std::endl;
540 Rethrow();
541 }
542}
543
546{
547 // The parse must succeed, since we
548 // generated the JSON ourselves.
550 try
551 {
552 obj = jtx::parse(jt.jv);
553 }
554 catch (jtx::parse_error const&)
555 {
556 test.log << "Exception: parse_error\n" << pretty(jt.jv) << std::endl;
557 Rethrow();
558 }
559
560 try
561 {
562 return sterilize(STTx{std::move(*obj)});
563 }
564 catch (std::exception const&)
565 {
566 }
567 return nullptr;
568}
569
572{
573 // The parse must succeed, since we
574 // generated the JSON ourselves.
576 try
577 {
578 obj = jtx::parse(jt.jv);
579 }
580 catch (jtx::parse_error const&)
581 {
582 test.log << "Exception: parse_error\n" << pretty(jt.jv) << std::endl;
583 Rethrow();
584 }
585
586 try
587 {
588 return std::make_shared<STTx const>(std::move(*obj));
589 }
590 catch (std::exception const&)
591 {
592 }
593 return nullptr;
594}
595
598 unsigned apiVersion,
599 std::vector<std::string> const& args,
601{
602 auto response = rpcClient(args, app().config(), app().logs(), apiVersion, headers);
603
604 for (unsigned ctr = 0; (ctr < retries_) and (response.first == rpcINTERNAL); ++ctr)
605 {
606 JLOG(journal.error()) << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ...";
608
609 response = rpcClient(args, app().config(), app().logs(), apiVersion, headers);
610 }
611
612 return response.second;
613}
614
615void
617{
618 // Env::close() must be called for feature
619 // enable to take place.
620 app().config().features.insert(feature);
621}
622
623void
625{
626 // Env::close() must be called for feature
627 // enable to take place.
628 app().config().features.erase(feature);
629}
630
631} // namespace jtx
632} // namespace test
633} // namespace xrpl
constexpr char const * c_str() const
Definition json_value.h:58
Represents a JSON value.
Definition json_value.h:131
bool isObject() const
std::string asString() const
Returns the unquoted string value.
bool isNull() const
isNull() tests to see if this field is null.
bool isMember(char const *key) const
Return true if the object has a member named key.
Stream error() const
Definition Journal.h:319
A testsuite class.
Definition suite.h:52
log_os< char > log
Logging output stream.
Definition suite.h:145
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition suite.h:222
virtual bool setup(boost::program_options::variables_map const &options)=0
virtual Config & config()=0
virtual void signalStop(std::string msg)=0
virtual LedgerMaster & getLedgerMaster()=0
virtual void run()=0
virtual Logs & logs()=0
virtual JobQueue & getJobQueue()=0
virtual void start(bool withTimers)=0
virtual NetworkOPs & getOPs()=0
constexpr value_type const & value() const
Definition Asset.h:155
uint32_t NETWORK_ID
Definition Config.h:138
std::unordered_set< uint256, beast::uhash<> > features
Definition Config.h:257
static void initializeSSLContext(std::string const &sslVerifyDir, std::string const &sslVerifyFile, bool sslVerify, beast::Journal j)
A currency issued by an account.
Definition Issue.h:14
Currency currency
Definition Issue.h:16
AccountID account
Definition Issue.h:17
void rendezvous()
Block until no jobs running.
Definition JobQueue.cpp:229
std::shared_ptr< Ledger const > getClosedLedger()
beast::severities::Severity threshold() const
Definition Log.cpp:140
constexpr MPTID const & getMptID() const
Definition MPTIssue.h:27
AccountID const & getIssuer() const
Definition MPTIssue.cpp:21
virtual std::uint32_t acceptLedger(std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)=0
Accepts the current transaction tree, return the new ledger's sequence.
Slice slice() const noexcept
Definition Serializer.h:45
static constexpr TERSubset fromInt(int from)
Definition TER.h:414
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Definition base_uint.h:472
virtual Json::Value invoke(std::string const &cmd, Json::Value const &params={})=0
Submit a command synchronously.
Immutable cryptographic account descriptor.
Definition Account.h:20
std::string const & name() const
Return the name.
Definition Account.h:64
Application & app()
Definition Env.h:230
static ParsedResult parseResult(Json::Value const &jr)
Gets the TER result and didApply flag from a RPC Json result object.
Definition Env.cpp:296
std::shared_ptr< STTx const > st(JTx const &jt)
Create a STTx from a JTx The framework requires that JSON is valid.
Definition Env.cpp:545
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
Definition Env.cpp:230
void autofill_sig(JTx &jt)
Definition Env.cpp:478
void sign_and_submit(JTx const &jt, Json::Value params=Json::nullValue)
Use the submit RPC command with a provided JTx object.
Definition Env.cpp:363
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
Definition Env.cpp:91
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition Env.cpp:248
Account const & lookup(AccountID const &id) const
Returns the Account given the AccountID.
Definition Env.cpp:136
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:260
void enableFeature(uint256 const feature)
Definition Env.cpp:616
virtual void submit(JTx const &jt)
Submit an existing JTx.
Definition Env.cpp:333
PrettyAmount limit(Account const &account, Issue const &issue) const
Returns the IOU limit on an account.
Definition Env.cpp:218
void disableFeature(uint256 const feature)
Definition Env.cpp:624
void postconditions(JTx const &jt, ParsedResult const &parsed, Json::Value const &jr=Json::Value())
Check expected postconditions of JTx submission.
Definition Env.cpp:400
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:239
virtual void autofill(JTx &jt)
Definition Env.cpp:516
bool close()
Close and advance the ledger.
Definition Env.h:358
Account const & master
Definition Env.h:102
Json::Value do_rpc(unsigned apiVersion, std::vector< std::string > const &args, std::unordered_map< std::string, std::string > const &headers={})
Definition Env.cpp:597
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
Definition Env.h:473
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition Env.cpp:157
unsigned retries_
Definition Env.h:702
Env & apply(JsonValue &&jv, FN const &... fN)
Apply funclets and submit.
Definition Env.h:544
uint256 txid_
Definition Env.h:699
beast::unit_test::suite & test
Definition Env.h:100
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:283
std::shared_ptr< STTx const > ust(JTx const &jt)
Create a STTx from a JTx without sanitizing Use to inject bogus values into test transactions by firs...
Definition Env.cpp:571
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
Definition Env.cpp:450
std::unordered_map< AccountID, Account > map_
Definition Env.h:744
ManualTimeKeeper & timeKeeper()
Definition Env.h:242
bool parseFailureExpected_
Definition Env.h:701
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
Definition Env.cpp:472
void memoize(Account const &account)
Associate AccountID with account.
Definition Env.cpp:130
beast::Journal const journal
Definition Env.h:139
AbstractClient & client()
Returns the connected client.
Definition Env.h:260
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:298
A balance matches.
Definition balance.h:20
Set the fee on a JTx.
Definition fee.h:18
Match set account flags.
Definition flags.h:109
Match clear account flags.
Definition flags.h:125
Check a set of conditions.
Definition require.h:47
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition rpc.h:16
Set the regular signature on a JTx.
Definition sig.h:16
T emplace(T... args)
T empty(T... args)
T endl(T... args)
T is_same_v
A namespace for easy access to logging severity values.
Definition Journal.h:11
Severity
Severity level / threshold of a Journal message.
Definition Journal.h:13
ErrorInfo const & get_error_info(error_code_i code)
Returns an ErrorInfo that reflects the error code.
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:462
Keylet line(AccountID const &id0, AccountID const &id1, Currency const &currency) noexcept
The index of a trust line for a given currency.
Definition Indexes.cpp:214
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:474
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:160
void fill_seq(Json::Value &jv, ReadView const &view)
Set the sequence number automatically.
Definition utility.cpp:52
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:13
XRP_t const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:90
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:11
static autofill_t const autofill
Definition tags.h:23
void sign(Json::Value &jv, Account const &account, Json::Value &sigObject)
Sign automatically into a specific Json field of the jv object.
Definition utility.cpp:27
STObject parse(Json::Value const &jv)
Convert JSON to STObject.
Definition utility.cpp:18
auto const amount
void fill_fee(Json::Value &jv, ReadView const &view)
Set the fee automatically.
Definition utility.cpp:44
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition flags.cpp:10
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
std::unique_ptr< AbstractClient > makeJSONRPCClient(Config const &cfg, unsigned rpc_version)
Returns a client using JSON-RPC over HTTP/S.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
@ telENV_RPC_FAILED
Definition TER.h:49
bool isXRP(AccountID const &c)
Definition AccountID.h:71
beast::Journal debugLog()
Returns a debug journal.
Definition Log.cpp:445
std::unique_ptr< beast::Journal::Sink > setDebugLogSink(std::unique_ptr< beast::Journal::Sink > sink)
Set the sink for the debug journal.
Definition Log.cpp:439
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:598
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:11
std::string transHuman(TER code)
Definition TER.cpp:252
std::pair< int, Json::Value > rpcClient(std::vector< std::string > const &args, Config const &config, Logs &logs, unsigned int apiVersion, std::unordered_map< std::string, std::string > const &headers)
Internal invocation of RPC client.
Definition RPCCall.cpp:1437
std::string transToken(TER code)
Definition TER.cpp:243
std::unique_ptr< Application > make_Application(std::unique_ptr< Config > config, std::unique_ptr< Logs > logs, std::unique_ptr< TimeKeeper > timeKeeper)
constexpr std::uint32_t asfDefaultRipple
Definition TxFlags.h:65
@ temMALFORMED
Definition TER.h:68
void Rethrow()
Rethrow the exception currently being handled.
Definition contract.h:29
std::shared_ptr< STTx const > sterilize(STTx const &stx)
Sterilize a transaction.
Definition STTx.cpp:767
@ rpcINTERNAL
Definition ErrorCodes.h:111
@ rpcSUCCESS
Definition ErrorCodes.h:25
T sleep_for(T... args)
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
Json::StaticString token
Definition ErrorCodes.h:186
ManualTimeKeeper * timeKeeper
Definition Env.h:123
std::unique_ptr< AbstractClient > client
Definition Env.h:125
std::unique_ptr< Application > owned
Definition Env.h:122
Used by parseResult() and postConditions()
Definition Env.h:106
std::optional< TER > ter
Definition Env.h:107
std::optional< error_code_i > rpcCode
Definition Env.h:112
Execution context for applying a JSON transaction.
Definition JTx.h:26
std::optional< TER > ter
Definition JTx.h:29
std::vector< std::function< void(Env &, JTx &)> > postSigners
Definition JTx.h:41
std::vector< std::function< void(Env &, JTx &)> > mainSigners
Definition JTx.h:38
requires_t require
Definition JTx.h:28
std::shared_ptr< STTx const > stx
Definition JTx.h:36
std::optional< std::pair< error_code_i, std::string > > rpcCode
Definition JTx.h:30
std::optional< std::pair< std::string, std::optional< std::string > > > rpcException
Definition JTx.h:31
std::optional< int > testLine
Definition JTx.h:44
Json::Value jv
Definition JTx.h:27
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
Thrown when parse fails.
Definition utility.h:19
Set the sequence number on a JTx.
Definition seq.h:15
A signer in a SignerList.
Definition multisign.h:20
T to_string(T... args)
T value_or(T... args)
T visit(T... args)