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