1#include <test/jtx/Account.h>
2#include <test/jtx/CaptureLogs.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/TestHelpers.h>
5#include <test/jtx/acctdelete.h>
6#include <test/jtx/amount.h>
7#include <test/jtx/balance.h>
8#include <test/jtx/batch.h>
9#include <test/jtx/delegate.h>
10#include <test/jtx/delivermin.h>
11#include <test/jtx/did.h>
12#include <test/jtx/domain.h>
13#include <test/jtx/fee.h>
14#include <test/jtx/flags.h>
15#include <test/jtx/mpt.h>
16#include <test/jtx/multisign.h>
17#include <test/jtx/noop.h>
18#include <test/jtx/offer.h>
19#include <test/jtx/paths.h>
20#include <test/jtx/pay.h>
21#include <test/jtx/permissioned_domains.h>
22#include <test/jtx/rate.h>
23#include <test/jtx/regkey.h>
24#include <test/jtx/sendmax.h>
25#include <test/jtx/sig.h>
26#include <test/jtx/sponsor.h>
27#include <test/jtx/ter.h>
28#include <test/jtx/trust.h>
29#include <test/jtx/txflags.h>
30#include <test/jtx/vault.h>
32#include <xrpl/basics/Number.h>
33#include <xrpl/basics/Slice.h>
34#include <xrpl/basics/base_uint.h>
35#include <xrpl/basics/strHex.h>
36#include <xrpl/beast/unit_test/suite.h>
37#include <xrpl/core/ServiceRegistry.h>
38#include <xrpl/json/json_value.h>
39#include <xrpl/json/to_string.h>
40#include <xrpl/ledger/helpers/DelegateHelpers.h>
41#include <xrpl/protocol/ErrorCodes.h>
42#include <xrpl/protocol/Feature.h>
43#include <xrpl/protocol/Indexes.h>
44#include <xrpl/protocol/Issue.h>
45#include <xrpl/protocol/KeyType.h>
46#include <xrpl/protocol/Permissions.h>
47#include <xrpl/protocol/SField.h>
48#include <xrpl/protocol/STObject.h>
49#include <xrpl/protocol/STTx.h>
50#include <xrpl/protocol/SecretKey.h>
51#include <xrpl/protocol/TER.h>
52#include <xrpl/protocol/TxFlags.h>
53#include <xrpl/protocol/TxSettings.h>
54#include <xrpl/protocol/XRPAmount.h>
55#include <xrpl/protocol/jss.h>
74 testcase(
"test feature not enabled");
77 Env env{*
this, features};
81 env.
fund(
XRP(1000000), gw, alice, bob);
98 testcase(
"test valid request creating, updating, deleting permissions");
104 env.
fund(
XRP(100000), gw, alice);
116 "TrustlineAuthorize",
124 auto const comparePermissions = [&](
json::Value const& jle,
129 !jle[jss::result].isMember(jss::error) && jle[jss::result].isMember(jss::node));
130 BEAST_EXPECT(jle[jss::result][jss::node][
"LedgerEntryType"] == jss::Delegate);
131 BEAST_EXPECT(jle[jss::result][jss::node][jss::Account] == account.human());
132 BEAST_EXPECT(jle[jss::result][jss::node][sfAuthorize.jsonName] == authorize.human());
134 auto const& jPermissions = jle[jss::result][jss::node][sfPermissions.jsonName];
136 for (
auto const& permission : permissions)
139 jPermissions[i][sfPermission.jsonName][sfPermissionValue.jsonName] ==
146 comparePermissions(
delegate::entry(env, gw, alice), permissions, gw, alice);
149 auto const newPermissions =
156 comparePermissions(
delegate::entry(env, gw, alice), newPermissions, gw, alice);
162 BEAST_EXPECT(jle[jss::result][jss::error] ==
"entryNotFound");
164 BEAST_EXPECT(jle[jss::result][jss::error_message] ==
"Entry not found.");
169 comparePermissions(
delegate::entry(env, alice, gw), permissions, alice, gw);
172 BEAST_EXPECT(response[jss::result][jss::error] ==
"entryNotFound");
174 BEAST_EXPECT(response[jss::result][jss::error_message] ==
"Entry not found.");
180 testcase(
"test invalid DelegateSet");
183 Env env(*
this, features);
187 env.
fund(
XRP(100000), gw, alice, bob);
220 jv[jss::TransactionType] = jss::DelegateSet;
221 jv[jss::Account] = gw.
human();
222 jv[sfAuthorize.jsonName] = alice.
human();
225 permissionValue[sfPermissionValue.jsonName] =
"Payment";
227 permissionObj[sfPermission.jsonName] = permissionValue;
228 permissionsJson.
append(permissionObj);
229 jv[sfPermissions.jsonName] = permissionsJson;
230 jv[sfFee.jsonName] = -1;
244 "TrustlineAuthorize",
246 "TrustlineAuthorize",
259 Vault const vault{env};
260 auto [tx,
keylet] = vault.create({.owner = gw, .asset =
xrpIssue()});
264 auto const sleVault = env.
le(
keylet);
265 BEAST_EXPECT(sleVault);
266 Account const vaultPseudo{
"vault", sleVault->at(sfAccount)};
314 env.
fund(
XRP(100000), bob, carol);
364 auto const setup = [&](
Env& env) {
368 env.fund(
XRP(1000), alice, bob, carol);
376 auto [alice, bob, carol] = setup(env);
378 auto const aliceBalance = env.
balance(alice);
379 auto const bobBalance = env.
balance(bob);
380 auto const carolBalance = env.
balance(carol);
384 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
385 BEAST_EXPECT(env.
balance(bob) == bobBalance);
386 BEAST_EXPECT(env.
balance(carol) == carolBalance);
392 auto [alice, bob, carol] = setup(env);
396 auto const aliceBalance = env.
balance(alice);
397 auto const bobBalance = env.
balance(bob);
398 auto const carolBalance = env.
balance(carol);
400 auto const sendAmt =
XRP(100);
401 auto const feeAmt =
XRP(10);
404 BEAST_EXPECT(env.
balance(alice) == aliceBalance - sendAmt);
405 BEAST_EXPECT(env.
balance(bob) == bobBalance - feeAmt);
406 BEAST_EXPECT(env.
balance(carol) == carolBalance + sendAmt);
412 auto [alice, bob, carol] = setup(env);
416 auto const aliceBalance = env.
balance(alice);
417 auto const bobBalance = env.
balance(bob);
418 auto const carolBalance = env.
balance(carol);
420 env(
pay(alice, carol,
XRP(100)),
425 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
426 BEAST_EXPECT(env.
balance(bob) == bobBalance);
427 BEAST_EXPECT(env.
balance(carol) == carolBalance);
437 auto const setup = [&](
Env& env) {
442 auto const baseFee = env.current()->fees().base;
443 auto const reserve = env.current()->fees().accountReserve(1, 1);
444 auto const paymentAmount =
XRP(1);
445 auto const highFee =
reserve + baseFee;
446 BEAST_EXPECT(highFee >
reserve);
448 env.fund(paymentAmount +
reserve + baseFee, alice);
449 env.fund(
XRP(1000), bob);
450 env.fund(
XRP(1000), carol);
469 auto [alice, bob, carol, paymentAmount, highFee,
reserve] = setup(env);
470 auto const aliceBalance = env.
balance(alice);
471 auto const bobBalance = env.
balance(bob);
472 auto const carolBalance = env.
balance(carol);
477 BEAST_EXPECT(env.
balance(alice) == aliceBalance - highFee);
478 BEAST_EXPECT(env.
balance(bob) == bobBalance);
479 BEAST_EXPECT(env.
balance(carol) == carolBalance);
486 auto [alice, bob, carol, paymentAmount, highFee,
reserve] = setup(env);
488 auto const alicePrePay = env.
balance(alice,
XRP);
490 auto const carolPrePay = env.
balance(carol,
XRP);
508 auto const baseFee = env.
current()->fees().base;
509 auto const baseReserve = env.
current()->fees().accountReserve(0, 1);
511 env.
fund(env.
current()->fees().accountReserve(1, 1) + baseFee +
XRP(1), alice);
512 env.
fund(baseReserve, bob);
519 auto const alicePreTx = env.
balance(alice,
XRP);
528 BEAST_EXPECT(env.
balance(bob,
XRP) < baseReserve);
543 auto const baseFee = env.
current()->fees().base;
557 auto const alicePrePay = env.
balance(alice,
XRP);
559 auto const carolPrePay = env.
balance(carol,
XRP);
580 env.
fund(
XRP(10000), alice, bob, carol);
583 auto aliceSeq = env.
seq(alice);
584 auto bobSeq = env.
seq(bob);
588 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 1);
589 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
590 aliceSeq = env.
seq(alice);
591 bobSeq = env.
seq(bob);
593 for (
auto i = 0; i < 20; ++i)
598 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 1);
599 BEAST_EXPECT(env.
seq(bob) == bobSeq);
600 aliceSeq = env.
seq(alice);
604 BEAST_EXPECT(env.
seq(alice) == aliceSeq);
605 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
606 bobSeq = env.
seq(bob);
611 BEAST_EXPECT(env.
seq(alice) == aliceSeq);
612 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
613 bobSeq = env.
seq(bob);
617 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 1);
618 BEAST_EXPECT(env.
seq(bob) == bobSeq);
619 aliceSeq = env.
seq(alice);
636 env.
fund(
XRP(100000), alice, bob, carol);
643 BEAST_EXPECT(env.
closed()->exists(delegateKey));
647 dir.
begin(), dir.
end(), [&](
auto const& sle) { return sle->key() == key; });
657 auto const aliceBalance = env.
balance(alice);
658 auto const carolBalance = env.
balance(carol);
662 auto const deleteFee =
drops(env.
current()->fees().increment);
668 BEAST_EXPECT(!env.
closed()->exists(delegateKey));
671 BEAST_EXPECT(env.
balance(carol) == carolBalance + aliceBalance - deleteFee);
682 env.
fund(
XRP(100000), alice, bob, carol);
689 BEAST_EXPECT(env.
closed()->exists(delegateKey));
693 dir.
begin(), dir.
end(), [&](
auto const& sle) { return sle->key() == key; });
701 BEAST_EXPECT(sleAlice);
702 BEAST_EXPECT(sleAlice->getFieldU32(sfOwnerCount) == 1);
707 auto const bobBalance = env.
balance(bob);
708 auto const carolBalance = env.
balance(carol);
714 auto const deleteFee =
drops(env.
current()->fees().increment);
720 BEAST_EXPECT(!env.
closed()->exists(delegateKey));
723 BEAST_EXPECT(env.
balance(carol) == carolBalance + bobBalance - deleteFee);
727 BEAST_EXPECT(sleAlice2);
728 BEAST_EXPECT(sleAlice2->getFieldU32(sfOwnerCount) == 0);
730 auto const aliceDeleteFee =
drops(env.
current()->fees().increment);
746 env.
fund(
XRP(100000), alice, bob, carol, dave);
759 dir.
begin(), dir.
end(), [&](
auto const& sle) { return sle->key() == key; });
763 BEAST_EXPECT(env.
closed()->exists(aliceBobKey));
764 BEAST_EXPECT(env.
closed()->exists(carolBobKey));
771 auto const bobBalance = env.
balance(bob);
772 auto const daveBalance = env.
balance(dave);
774 auto const deleteFee =
drops(env.
current()->fees().increment);
783 BEAST_EXPECT(!env.
closed()->exists(aliceBobKey));
784 BEAST_EXPECT(!env.
closed()->exists(carolBobKey));
790 BEAST_EXPECT(env.
balance(dave) == daveBalance + bobBalance - deleteFee);
797 testcase(
"test delegate transaction");
871 auto const usd = gw[
"USD"];
872 auto const eur = gw2[
"EUR"];
877 env.
trust(usd(200), alice);
878 env.
trust(eur(400), gw);
923 BEAST_EXPECT(env.
balance(bob, usd) == usd(0));
933 BEAST_EXPECT(env.
balance(bob, usd) == usd(0));
951 env(
pay(gw2, gw, eur(200)));
975 auto const usd = gw[
"USD"];
980 env.
trust(usd(200), alice);
985 auto const aliceBalance = env.
balance(alice,
XRP);
986 auto const bobBalance = env.
balance(bob,
XRP);
1015 BEAST_EXPECT(env.
balance(bob, usd) == usd(0));
1021 Env env(*
this, features);
1026 auto const usd = gw[
"USD"];
1028 env.
fund(
XRP(10000), alice, bob, carol, gw);
1030 env.
trust(usd(50000), alice);
1031 env.
trust(usd(50000), bob);
1032 env.
trust(usd(50000), carol);
1033 env(
pay(gw, alice, usd(10000)));
1034 env(
pay(gw, bob, usd(10000)));
1035 env(
pay(gw, carol, usd(10000)));
1040 env(
offer(carol,
XRP(100), usd(501)));
1048 env(
pay(gw, alice, usd(500)),
1056 env(
pay(gw, alice, usd(5000)),
1063 env(
pay(gw, alice, usd(5000)),
1077 env(
offer(bob,
XRP(100), usd(501)));
1085 env(
pay(alice, gw, usd(500)),
1093 env(
pay(alice, gw, usd(5000)),
1100 env(
pay(alice, gw, usd(5000)),
1116 Env env(*
this, features);
1120 auto const usd = gw[
"USD"];
1121 env.
fund(
XRP(10000), alice, bob, gw);
1122 env.
trust(usd(200), alice);
1146 auto const gwUSD = gw[
"USD"];
1147 auto const aliceUSD = alice[
"USD"];
1149 env.
fund(
XRP(10000), alice, bob, gw);
1150 env.
trust(gwUSD(200), alice);
1153 env(
pay(gw, alice, gwUSD(50)));
1160 env.
trust(gwUSD(0), alice);
1162 BEAST_EXPECT(env.
limit(alice, gwUSD.issue()) == gwUSD(0));
1164 env(
trust(gw, aliceUSD(200)));
1175 Env env(*
this, features);
1179 auto const gwUSD = gw[
"USD"];
1180 auto const aliceUSD = alice[
"USD"];
1182 env.
fund(
XRP(10000), alice, bob, gw);
1183 env.
trust(gwUSD(200), alice);
1186 env(
pay(gw, alice, gwUSD(50)));
1192 env(
trust(gw, aliceUSD(200)));
1198 if (!features[fixCleanup3_4_0])
1231 Env env(*
this, features);
1235 auto const gwUSD = gw[
"USD"];
1236 auto const aliceUSD = alice[
"USD"];
1238 env.
fund(
XRP(10000), alice, bob, gw);
1239 env.
trust(gwUSD(200), alice);
1242 env(
pay(gw, alice, gwUSD(50)));
1243 env(
trust(gw, aliceUSD(200)));
1246 env(
delegate::set(alice, bob, {
"PaymentBurn",
"PaymentMint"}));
1256 Env env(*
this, features);
1260 auto const usd = gw[
"USD"];
1261 env.
fund(
XRP(10000), alice, bob, gw);
1262 env.
trust(usd(200), alice);
1271 env(
pay(gw, alice, usd(100)),
1276 env(
pay(alice, gw, usd(50)),
1283 env(
pay(gw, alice, usd(100)),
1287 env(
pay(alice, gw, usd(50)),
1293 env(
pay(gw, alice, usd(100)),
1297 env(
pay(alice, gw, usd(50)),
1303 for (
auto const flag : {tfPartialPayment, tfNoRippleDirect, tfLimitQuality})
1305 env(
pay(gw, alice, usd(100)),
1309 env(
pay(alice, gw, usd(50)),
1324 Env env(*
this, features);
1328 auto const usd = gw[
"USD"];
1329 env.
fund(
XRP(10000), alice, bob, gw);
1330 env.
trust(usd(200), alice);
1351 MPTTester mpt(env, gw, {.holders = {alice, bob}});
1352 mpt.
create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer});
1354 mpt.authorize({.account = alice});
1355 mpt.authorize({.account = bob});
1357 auto const gwMPT = mpt[
"MPT"];
1358 env(
pay(gw, alice, gwMPT(500)));
1359 env(
pay(gw, bob, gwMPT(500)));
1361 auto aliceMPT = env.
balance(alice, gwMPT);
1362 auto const bobMPT = env.
balance(bob, gwMPT);
1370 BEAST_EXPECT(env.
balance(alice, gwMPT) == aliceMPT + gwMPT(50));
1371 BEAST_EXPECT(env.
balance(bob, gwMPT) == bobMPT);
1372 aliceMPT = env.
balance(alice, gwMPT);
1381 BEAST_EXPECT(env.
balance(alice, gwMPT) == aliceMPT - gwMPT(50));
1382 BEAST_EXPECT(env.
balance(bob, gwMPT) == bobMPT);
1383 aliceMPT = env.
balance(alice, gwMPT);
1388 env(
delegate::set(alice, bob, {
"PaymentBurn",
"PaymentMint",
"Payment"}));
1391 BEAST_EXPECT(env.
balance(alice, gwMPT) == aliceMPT - gwMPT(50));
1392 BEAST_EXPECT(env.
balance(bob, gwMPT) == bobMPT);
1393 aliceMPT = env.
balance(alice, gwMPT);
1395 BEAST_EXPECT(env.
balance(alice, gwMPT) == aliceMPT - gwMPT(100));
1396 BEAST_EXPECT(env.
balance(bob, gwMPT) == bobMPT + gwMPT(100));
1410 auto const gwUSD = gw[
"USD"];
1411 auto const aliceUSD = alice[
"USD"];
1413 env.
fund(
XRP(10000), alice, bob, gw);
1414 env.
trust(gwUSD(200), alice);
1418 env(
pay(gw, alice, gwUSD(100)));
1431 env(
pay(gw, alice, aliceUSD(50)),
1450 env(
pay(alice, gw, aliceUSD(50)),
1470 Account const gw2{
"gateway2"};
1471 auto const gwUSD = gw[
"USD"];
1473 env.
fund(
XRP(10000), alice, bob, gw, gw2);
1476 env.
trust(gwUSD(200), alice);
1479 env(
pay(gw, alice, gwUSD(100)));
1482 env(
delegate::set(alice, bob, {
"PaymentMint",
"PaymentBurn"}));
1485 env(
pay(alice, gw, gw2[
"USD"](50)),
1492 Env env(*
this, features);
1496 Account const gw2{
"gateway2"};
1501 MPTTester mpt(env, gw, {.holders = {alice, bob}});
1502 mpt.
create({.ownerCount = 1, .flags = tfMPTCanTransfer});
1504 mpt.authorize({.account = alice});
1505 mpt.authorize({.account = bob});
1507 auto const gwMPT = mpt[
"MPT"];
1508 env(
pay(gw, alice, gwMPT(500)));
1509 env(
pay(gw, bob, gwMPT(500)));
1512 env(
delegate::set(alice, bob, {
"PaymentMint",
"PaymentBurn"}));
1526 env.
fund(
XRP(10000), alice, bob, gw);
1529 env(
delegate::set(alice, bob, {
"PaymentMint",
"PaymentBurn"}));
1532 env(
pay(alice, gw, alice[
"USD"](50)),
1544 auto const gwUSD = gw[
"USD"];
1545 auto const aliceUSD = alice[
"USD"];
1547 env.
fund(
XRP(10000), alice, bob, gw);
1553 env.
trust(gwUSD(200), alice);
1561 env(
pay(alice, gw, aliceUSD(50)),
1571 env(
trust(gw, aliceUSD(200)));
1575 env(
pay(alice, gw, aliceUSD(100)));
1584 env(
pay(gw, alice, aliceUSD(50)),
1596 env.
fund(
XRP(10000), alice, bob, gw);
1597 env.
trust(gw[
"USD"](200), alice);
1604 env(
pay(alice, gw, alice[
"USD"](50)),
1616 auto const usd = gw[
"USD"];
1617 env.
fund(
XRP(10000), alice, bob, gw);
1618 env.
trust(usd(200), alice);
1622 env(
delegate::set(alice, bob, {
"AccountDomainSet",
"PaymentMint"}));
1630 auto jt =
noop(alice);
1631 jt[sfDomain] =
strHex(domain);
1632 jt[sfDelegate] = bob.
human();
1634 BEAST_EXPECT((*env.
le(alice))[sfDomain] ==
makeSlice(domain));
1647 testcase(
"test TrustSet granular permissions");
1648 using namespace jtx;
1656 env.
fund(
XRP(10000), gw, alice, bob);
1657 env(
fset(gw, asfRequireAuth));
1668 env(
trust(alice, gw[
"USD"](50)));
1676 env(
trust(alice, gw[
"USD"](50), tfSetNoRipple),
1679 env(
trust(alice, gw[
"USD"](50), tfClearNoRipple),
1682 env(
trust(gw, gw[
"USD"](0), alice, tfSetDeepFreeze),
1685 env(
trust(gw, gw[
"USD"](0), alice, tfClearDeepFreeze),
1691 env(
trust(gw, gw[
"USD"](0), alice, tfSetfAuth),
1694 env(
trust(gw, gw[
"USD"](0), alice, tfSetFreeze),
1701 env(
trust(gw, gw[
"USD"](0), alice, tfClearFreeze),
1707 env(
trust(gw, gw[
"USD"](50), alice, tfSetfAuth),
1715 env(
delegate::set(gw, bob, {
"TrustlineAuthorize",
"TrustlineFreeze"}));
1719 env(
delegate::set(gw, bob, {
"TrustlineAuthorize",
"TrustlineUnfreeze"}));
1725 env(
trust(gw, gw[
"USD"](0), alice, tfSetFreeze),
1735 auto tx =
trust(alice, gw[
"USD"](50));
1736 tx[
"QualityIn"] =
"1000";
1738 auto tx2 =
trust(alice, gw[
"USD"](50));
1739 tx2[
"QualityOut"] =
"1000";
1741 auto tx3 =
trust(gw, alice[
"USD"](50));
1742 tx3[
"QualityIn"] =
"1000";
1744 auto tx4 =
trust(gw, alice[
"USD"](50));
1745 tx4[
"QualityOut"] =
"1000";
1751 auto tx5 =
trust(gw, alice[
"USD"](50));
1752 tx5[
"QualityOut"] =
"1000";
1754 auto tx6 =
trust(alice, gw[
"USD"](50));
1755 tx6[
"QualityOut"] =
"1000";
1768 env.
fund(
XRP(10000), gw, alice, bob);
1769 env(
fset(gw, asfRequireAuth));
1774 env(
delegate::set(alice, bob, {
"TrustlineUnfreeze",
"NFTokenCreateOffer"}));
1783 {
"TrustlineUnfreeze",
"NFTokenCreateOffer",
"TrustSet",
"AccountTransferRateSet"}));
1791 {
"TrustlineUnfreeze",
"NFTokenCreateOffer",
"TrustSet",
"AccountTransferRateSet"}));
1813 env.
fund(
XRP(10000), gw, alice, bob);
1814 env(
fset(gw, asfRequireAuth));
1816 env(
trust(alice, gw[
"USD"](50)));
1830 env.
fund(
XRP(10000), gw, alice, bob);
1832 env(
fset(gw, asfRequireAuth));
1834 env(
trust(alice, gw[
"USD"](50)));
1844 txJson[sfQualityOut.jsonName] = 100;
1848 env(
trust(gw, gw[
"USD"](0), alice, tfSetfAuth | tfSetNoRipple),
1857 testcase(
"test AccountSet granular permissions");
1858 using namespace jtx;
1865 auto const alice =
Account{
"alice"};
1866 auto const bob =
Account{
"bob"};
1867 env.
fund(
XRP(10000), alice, bob);
1878 auto jt =
noop(alice);
1879 jt[sfDomain] =
strHex(domain);
1880 jt[sfDelegate] = bob.human();
1884 env(
delegate::set(alice, bob, {
"TrustlineUnfreeze",
"AccountEmailHashSet"}));
1894 BEAST_EXPECT((*env.
le(alice))[sfDomain] ==
makeSlice(domain));
1899 BEAST_EXPECT(!env.
le(alice)->isFieldPresent(sfDomain));
1902 std::string const failDomain =
"fail_domain_update";
1903 jt[sfFlags] = tfRequireAuth;
1904 jt[sfDomain] =
strHex(failDomain);
1911 jt[sfDomain] =
strHex(domain);
1912 std::string const mh(
"5F31A79367DC3137FADA860C05742EE6");
1913 jt[sfEmailHash] = mh;
1917 env(
delegate::set(alice, bob, {
"AccountDomainSet",
"AccountEmailHashSet"}));
1920 BEAST_EXPECT(
to_string((*env.
le(alice))[sfEmailHash]) == mh);
1921 BEAST_EXPECT((*env.
le(alice))[sfDomain] ==
makeSlice(domain));
1925 jt[sfMessageKey] =
strHex(rkp.first.slice());
1930 alice, bob, {
"AccountDomainSet",
"AccountEmailHashSet",
"AccountMessageKeySet"}));
1935 BEAST_EXPECT(
strHex((*env.
le(alice))[sfMessageKey]) ==
strHex(rkp.first.slice()));
1936 jt[sfMessageKey] =
"";
1938 BEAST_EXPECT(!env.
le(alice)->isFieldPresent(sfMessageKey));
1949 "AccountEmailHashSet",
1950 "AccountMessageKeySet",
1951 "AccountTransferRateSet",
1954 auto jtRate =
rate(alice, 2.0);
1955 jtRate[sfDelegate] = bob.human();
1957 BEAST_EXPECT((*env.
le(alice))[sfTransferRate] == 2000000000);
1969 "AccountEmailHashSet",
1970 "AccountMessageKeySet",
1971 "AccountTransferRateSet",
1972 "AccountTickSizeSet",
1976 BEAST_EXPECT((*env.
le(alice))[sfTickSize] == 8);
1988 env(
fset(alice, asfRequireAuth));
1997 alice, bob, {
"AccountDomainSet",
"AccountEmailHashSet",
"AccountMessageKeySet"}));
2002 "9633EC8AF54F16B5286DB1D7B519EF49EEFC050C0C8AC4384F1D88ACD1BFDF"
2004 auto jv2 =
noop(alice);
2005 jv2[sfDomain] =
strHex(domain);
2006 jv2[sfDelegate] = bob.human();
2007 jv2[sfWalletLocator] = locator;
2016 auto const alice =
Account{
"alice"};
2017 auto const bob =
Account{
"bob"};
2018 env.
fund(
XRP(10000), alice, bob);
2025 env(
fset(alice, flag));
2033 testSetClearFlag(asfRequireAuth);
2034 testSetClearFlag(asfAllowTrustLineClawback);
2038 alice, bob, {
"AccountDomainSet",
"AccountEmailHashSet",
"AccountMessageKeySet"}));
2041 testSetClearFlag(asfDefaultRipple);
2042 testSetClearFlag(asfDepositAuth);
2043 testSetClearFlag(asfDisallowIncomingCheck);
2044 testSetClearFlag(asfDisallowIncomingNFTokenOffer);
2045 testSetClearFlag(asfDisallowIncomingPayChan);
2046 testSetClearFlag(asfDisallowIncomingTrustline);
2047 testSetClearFlag(asfDisallowXRP);
2048 testSetClearFlag(asfRequireDest);
2049 testSetClearFlag(asfGlobalFreeze);
2053 env(
fset(alice, asfAccountTxnID));
2055 BEAST_EXPECT(env.
le(alice)->isFieldPresent(sfAccountTxnID));
2060 jt[sfDelegate] = bob.human();
2061 jt[sfNFTokenMinter] = bob.human();
2066 bob, alice, {
"AccountDomainSet",
"AccountEmailHashSet",
"AccountMessageKeySet"}));
2073 env(
fset(bob, asfNoFreeze));
2081 env(
regkey(bob, bobKey));
2083 env(
fset(alice, asfDisableMaster),
2094 env.
fund(
XRP(10000), alice, bob);
2097 env(
delegate::set(alice, bob, {
"AccountDomainSet",
"AccountEmailHashSet"}));
2101 auto jt =
noop(alice);
2102 jt[sfDomain] =
strHex(domain);
2103 jt[sfDelegate] = bob.
human();
2107 BEAST_EXPECT((*env.
le(alice))[sfDomain] ==
makeSlice(domain));
2113 auto const alice =
Account{
"alice"};
2114 auto const bob =
Account{
"bob"};
2115 env.
fund(
XRP(10000), alice, bob);
2123 auto txJson =
noop(alice);
2124 txJson[sfDomain] =
strHex(domain);
2125 txJson[sfDelegate] = bob.human();
2129 txJson[sfNFTokenMinter] = bob.human();
2140 env.
fund(
XRP(10000), alice, bob);
2146 auto jt =
noop(alice);
2147 jt[sfDelegate] = bob.
human();
2156 env.
fund(
XRP(10000), alice, bob);
2163 auto jt =
noop(alice);
2164 jt[sfDomain] =
strHex(domain);
2165 jt[sfDelegate] = bob.
human();
2179 testcase(
"test MPTokenIssuanceSet granular");
2180 using namespace jtx;
2187 env.
fund(
XRP(100000), alice, bob);
2190 MPTTester mpt(env, alice, {.fund =
false});
2192 mpt.create({.flags = tfMPTCanLock});
2216 mpt.set({.account = alice, .flags = tfMPTLock, .delegate = bob});
2219 .flags = tfMPTUnlock,
2225 env(
delegate::set(alice, bob, {
"MPTokenIssuanceLock",
"MPTokenIssuanceUnlock"}));
2227 mpt.set({.account = alice, .flags = tfMPTUnlock, .delegate = bob});
2228 mpt.set({.account = alice, .flags = tfMPTLock, .delegate = bob});
2237 env.
fund(
XRP(100000), alice, bob);
2240 MPTTester mpt(env, alice, {.fund =
false});
2242 mpt.create({.flags = tfMPTCanLock});
2248 mpt.set({.account = alice, .flags = tfMPTLock, .delegate = bob});
2252 .flags = tfMPTUnlock,
2259 env(
delegate::set(alice, bob, {
"NFTokenMint",
"MPTokenIssuanceLock",
"NFTokenBurn"}));
2264 .flags = tfMPTUnlock,
2273 {
"NFTokenMint",
"MPTokenIssuanceLock",
"NFTokenBurn",
"MPTokenIssuanceSet"}));
2274 mpt.set({.account = alice, .flags = tfMPTUnlock, .delegate = bob});
2276 mpt.set({.account = alice, .flags = tfMPTLock});
2277 mpt.set({.account = alice, .flags = tfMPTUnlock, .delegate = bob});
2278 mpt.set({.account = alice, .flags = tfMPTLock, .delegate = bob});
2286 env.
fund(
XRP(100000), alice, bob);
2289 MPTTester mpt(env, alice, {.fund =
false});
2291 mpt.create({.flags = tfMPTCanLock});
2305 env.
fund(
XRP(100000), alice, bob);
2307 MPTTester mpt(env, alice, {.fund =
false});
2308 mpt.
create({.flags = tfMPTCanLock});
2320 .flags = tfMPTSetCanLock,
2338 Account const credIssuer{
"credIssuer"};
2339 env.
fund(
XRP(100000), alice, bob, credIssuer);
2342 env(
pdomain::setTx(credIssuer, {{.issuer = credIssuer, .credType =
"credential"}}));
2346 MPTTester mpt(env, alice, {.fund =
false});
2347 mpt.
create({.flags = tfMPTCanLock | tfMPTCanTransfer});
2351 env(
delegate::set(alice, bob, {
"MPTokenIssuanceLock",
"MPTokenIssuanceUnlock"}));
2357 {.transferFee = 100},
2358 {.metadata =
"test"},
2359 {.domainID = domainID},
2360 {.flags = tfMPTSetCanTrade},
2361 {.flags = tfMPTSetCanClawback},
2364 {.flags = tfMPTLock, .domainID = domainID},
2367 for (
auto arg : args)
2369 arg.account = alice;
2381 testcase(
"test granular permission with sponsor common fields");
2382 using namespace jtx;
2388 auto const usd = gw[
"USD"];
2389 auto const feeAmt =
XRP(10);
2395 env.
trust(usd(200), alice);
2402 auto const gwBalance = env.
balance(gw);
2403 auto const bobBalance = env.
balance(bob);
2405 env(
pay(gw, alice, usd(50)),
2412 BEAST_EXPECT(env.
balance(gw) == gwBalance);
2413 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2420 env(
pay(gw, alice, usd(50)),
2426 BEAST_EXPECT(env.
balance(gw) == gwBalance);
2427 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2439 using namespace jtx;
2445 env.
fund(
XRP(100000), alice, bob, carol);
2451 auto const aliceBalance = env.
balance(alice);
2452 auto const bobBalance = env.
balance(bob);
2453 auto const carolBalance = env.
balance(carol);
2457 BEAST_EXPECT(env.
balance(alice) == aliceBalance -
XRP(100));
2458 BEAST_EXPECT(env.
balance(bob) == bobBalance -
XRP(10));
2459 BEAST_EXPECT(env.
balance(carol) == carolBalance +
XRP(100));
2465 testcase(
"test single sign with bad secret");
2466 using namespace jtx;
2473 env.
fund(
XRP(100000), alice, bob, carol);
2479 auto const aliceBalance = env.
balance(alice);
2480 auto const bobBalance = env.
balance(bob);
2481 auto const carolBalance = env.
balance(carol);
2483 env(
pay(alice, carol,
XRP(100)),
2489 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
2490 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2491 BEAST_EXPECT(env.
balance(carol) == carolBalance);
2499 env.
fund(
XRP(100000), alice, bob, carol);
2505 auto const aliceBalance = env.
balance(alice);
2506 auto const bobBalance = env.
balance(bob);
2507 auto const carolBalance = env.
balance(carol);
2509 env(
pay(alice, carol,
XRP(100)),
2515 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
2516 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2517 BEAST_EXPECT(env.
balance(carol) == carolBalance);
2519 env(
pay(alice, carol,
XRP(100)),
2525 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
2526 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2527 BEAST_EXPECT(env.
balance(carol) == carolBalance);
2535 env.
fund(
XRP(100000), alice, bob, carol);
2538 auto const aliceBalance = env.
balance(alice);
2539 auto const bobBalance = env.
balance(bob);
2540 auto const carolBalance = env.
balance(carol);
2542 env(
pay(alice, carol,
XRP(100)),
2548 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
2549 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2550 BEAST_EXPECT(env.
balance(carol) == carolBalance);
2552 env(
pay(alice, carol,
XRP(100)),
2558 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
2559 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2560 BEAST_EXPECT(env.
balance(carol) == carolBalance);
2568 using namespace jtx;
2575 Account const edward{
"edward"};
2576 env.
fund(
XRP(100000), alice, bob, carol, daria, edward);
2579 env(
signers(bob, 2, {{daria, 1}, {edward, 1}}));
2585 auto const aliceBalance = env.
balance(alice);
2586 auto const bobBalance = env.
balance(bob);
2587 auto const carolBalance = env.
balance(carol);
2588 auto const dariaBalance = env.
balance(daria);
2589 auto const edwardBalance = env.
balance(edward);
2593 BEAST_EXPECT(env.
balance(alice) == aliceBalance -
XRP(100));
2594 BEAST_EXPECT(env.
balance(bob) == bobBalance -
XRP(10));
2595 BEAST_EXPECT(env.
balance(carol) == carolBalance +
XRP(100));
2596 BEAST_EXPECT(env.
balance(daria) == dariaBalance);
2597 BEAST_EXPECT(env.
balance(edward) == edwardBalance);
2603 testcase(
"test multi sign which does not meet quorum");
2604 using namespace jtx;
2611 Account const edward{
"edward"};
2613 env.
fund(
XRP(100000), alice, bob, carol, daria, edward, fred);
2616 env(
signers(bob, 3, {{daria, 1}, {edward, 1}, {fred, 1}}));
2622 auto const aliceBalance = env.
balance(alice);
2623 auto const bobBalance = env.
balance(bob);
2624 auto const carolBalance = env.
balance(carol);
2625 auto const dariaBalance = env.
balance(daria);
2626 auto const edwardBalance = env.
balance(edward);
2628 env(
pay(alice, carol,
XRP(100)),
2631 Msig(daria, edward),
2634 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
2635 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2636 BEAST_EXPECT(env.
balance(carol) == carolBalance);
2637 BEAST_EXPECT(env.
balance(daria) == dariaBalance);
2638 BEAST_EXPECT(env.
balance(edward) == edwardBalance);
2647 testcase(
"test delegator as multisigner in delegate's signer list");
2648 using namespace jtx;
2655 env.
fund(
XRP(100000), alice, bob, carol, daria);
2662 env(
signers(bob, 2, {{alice, 1}, {daria, 1}}));
2665 auto aliceBalance = env.
balance(alice);
2666 auto bobBalance = env.
balance(bob);
2667 auto carolBalance = env.
balance(carol);
2668 auto const amt = 100;
2674 BEAST_EXPECT(env.
balance(alice) == aliceBalance -
XRP(amt));
2675 BEAST_EXPECT(env.
balance(bob) == bobBalance -
XRP(10));
2676 BEAST_EXPECT(env.
balance(carol) == carolBalance +
XRP(amt));
2683 aliceBalance = env.
balance(alice);
2684 bobBalance = env.
balance(bob);
2685 carolBalance = env.
balance(carol);
2690 env(
pay(alice, carol,
XRP(50)),
2696 BEAST_EXPECT(env.
balance(alice) == aliceBalance);
2697 BEAST_EXPECT(env.
balance(bob) == bobBalance);
2698 BEAST_EXPECT(env.
balance(carol) == carolBalance);
2706 testcase(
"test sign_for with delegated transaction");
2707 using namespace jtx;
2714 env.
fund(
XRP(100000), alice, bob, carol, daria);
2721 env(
signers(bob, 2, {{alice, 1}, {daria, 1}}));
2724 auto const baseFee = env.
current()->fees().base;
2726 auto const sendAmt = 1'000'000;
2729 jv[jss::tx_json][jss::Account] = alice.
human();
2730 jv[jss::tx_json][sfDelegate.jsonName] = bob.
human();
2731 jv[jss::tx_json][jss::TransactionType] = jss::Payment;
2732 jv[jss::tx_json][jss::Destination] = carol.
human();
2733 jv[jss::tx_json][jss::Amount] = sendAmt;
2735 jv[jss::tx_json][jss::Sequence] = env.
seq(alice);
2736 jv[jss::tx_json][jss::SigningPubKey] =
"";
2742 auto const aliceBalance = env.
balance(alice);
2743 auto const bobBalance = env.
balance(bob);
2744 auto const dariaBalance = env.
balance(daria);
2745 auto const carolBalance = env.
balance(carol);
2748 jv[jss::account] = alice.
human();
2749 jv[jss::secret] = alice.
name();
2750 auto jrr = env.
rpc(
"json",
"sign_for",
to_string(jv))[jss::result];
2751 BEAST_EXPECT(jrr[jss::status] ==
"success");
2754 jv2[jss::tx_json] = jrr[jss::tx_json];
2755 jv2[jss::account] = daria.
human();
2756 jv2[jss::secret] = daria.
name();
2757 jrr = env.
rpc(
"json",
"sign_for",
to_string(jv2))[jss::result];
2758 BEAST_EXPECT(jrr[jss::status] ==
"success");
2761 jvSubmit[jss::tx_json] = jrr[jss::tx_json];
2762 jrr = env.
rpc(
"json",
"submit_multisigned",
to_string(jvSubmit))[jss::result];
2763 BEAST_EXPECT(jrr[jss::status] ==
"success");
2766 BEAST_EXPECT(env.
balance(bob) == bobBalance - (10 * baseFee));
2767 BEAST_EXPECT(env.
balance(daria) == dariaBalance);
2774 jv[jss::account] = bob.
human();
2775 jv[jss::secret] = bob.
name();
2776 auto jrr = env.
rpc(
"json",
"sign_for",
to_string(jv))[jss::result];
2777 BEAST_EXPECT(jrr[jss::status] ==
"error");
2778 BEAST_EXPECT(jrr[jss::error] ==
"invalidParams");
2781 jrr[jss::error_message] ==
2782 "A Signer may not be the transaction's Account (" + bob.
human() +
").");
2790 using namespace jtx;
2792 Env env(*
this, features);
2796 env.
fund(
XRP(100000), alice, bob);
2799 auto const buildRequest = [&](
auto value) ->
json::Value {
2801 jv[jss::TransactionType] = jss::DelegateSet;
2802 jv[jss::Account] = alice.
human();
2803 jv[sfAuthorize.jsonName] = bob.
human();
2807 permissionValue[sfPermissionValue.jsonName] = value;
2809 permissionObj[sfPermission.jsonName] = permissionValue;
2810 permissionsJson.
append(permissionObj);
2811 jv[sfPermissions.jsonName] = permissionsJson;
2818 for (
auto const value : {0, 100000, 54321})
2820 auto const jv = buildRequest(value);
2828 testcase(
"test delegate disabled tx");
2829 using namespace jtx;
2836 {
"AMMClawback", featureAMMClawback},
2837 {
"DIDSet", featureDID},
2838 {
"DIDDelete", featureDID},
2839 {
"OracleSet", featurePriceOracle},
2840 {
"OracleDelete", featurePriceOracle},
2841 {
"LedgerStateFix", fixNFTokenPageLinks},
2842 {
"MPTokenIssuanceCreate", featureMPTokensV1},
2843 {
"MPTokenIssuanceDestroy", featureMPTokensV1},
2844 {
"MPTokenIssuanceSet", featureMPTokensV1},
2845 {
"MPTokenAuthorize", featureMPTokensV1},
2846 {
"CredentialCreate", featureCredentials},
2847 {
"CredentialAccept", featureCredentials},
2848 {
"CredentialDelete", featureCredentials},
2849 {
"NFTokenModify", featureDynamicNFT},
2850 {
"PermissionedDomainSet", featurePermissionedDomains},
2851 {
"PermissionedDomainDelete", featurePermissionedDomains},
2852 {
"SponsorshipSet", featureSponsor},
2858 BEAST_EXPECT(txRequiredFeatures.
contains(tx));
2860 Env env(*
this, features - txRequiredFeatures[tx]);
2864 env.
fund(
XRP(100000), alice, bob);
2870 for (
auto const& tx : txRequiredFeatures)
2871 txAmendmentDisabled(features, tx.first);
2877 auto const txAmendmentEnabled = [&](
std::string const& tx) {
2878 Env env(*
this, features);
2882 env.
fund(
XRP(100000), alice, bob);
2888 for (
auto const& tx : txRequiredFeatures)
2889 txAmendmentEnabled(tx.first);
2895 for (
auto const permission : {
"MPTokenIssuanceLock",
"MPTokenIssuanceUnlock"})
2897 Env env(*
this, features - featureMPTokensV1);
2901 env.
fund(
XRP(100000), alice, bob);
2912 testcase(
"Make sure GranularSandbox is checked after transaction-level permission");
2914 using namespace jtx;
2920 env.
fund(
XRP(10000), gw, alice, bob);
2922 env(
fset(gw, asfRequireAuth));
2924 env(
trust(alice, gw[
"USD"](50)));
2934 txJson[sfQualityOut.jsonName] = 100;
2938 env(
delegate::set(gw, bob, {
"TrustlineAuthorize",
"TrustSet"}));
2952 testcase(
"Delegable Transactions Completeness");
2956#pragma push_macro("UNWRAP")
2958#pragma push_macro("TRANSACTION")
2961#define UNWRAP(...) __VA_ARGS__
2962#define TRANSACTION(tag, value, name, settings, ...) \
2963 if ((xrpl::TxSettings UNWRAP settings).delegable == xrpl::Delegation::Delegable) \
2968#include <xrpl/protocol/detail/transactions.macro>
2971#pragma pop_macro("TRANSACTION")
2973#pragma pop_macro("UNWRAP")
2996 delegableCount == expectedDelegableCount,
2997 "\n[SECURITY] New delegable transaction detected!"
3001 "\n Action: Verify security requirements to interact with Delegation feature");
3007 testcase(
"non-delegable tx with sfDelegate is rejected at preflight");
3008 using namespace jtx;
3010 Env env(*
this, features);
3013 env.
fund(
XRP(10000), alice, bob);
3030 Vault const vault{env};
3034 env(vault.set({.owner = alice, .id = keylet.key}),
3037 env(vault.del({.owner = alice, .id = keylet.key}),
3040 env(vault.deposit({.depositor = alice, .id = keylet.key, .amount = XRP(1)}),
3043 env(vault.withdraw({.depositor = alice, .id = keylet.key, .amount = XRP(1)}),
3046 env(vault.clawback({.issuer = alice, .id = keylet.key, .holder = bob}),
3053 auto const seq = env.seq(alice);
3055 env(
batch::outer(alice, seq, batchFee, tfAllOrNothing),
3063 Vault const vault{env};
3095 testcase(
"DelegateUtils nullptr check");
3103 BEAST_EXPECT(granularPermissions.empty());
3109 testcase(
"test Permission to Tx type");
3125 for (
auto const gp : {
3126#pragma push_macro("GRANULAR_PERMISSION")
3127#undef GRANULAR_PERMISSION
3128#define GRANULAR_PERMISSION(type, txType, value, ...) GranularPermissionType::type,
3129#include <xrpl/protocol/detail/permissions.macro>
3130#undef GRANULAR_PERMISSION
3131#pragma pop_macro("GRANULAR_PERMISSION")
TestcaseT testcase
Memberspace for declaring test cases.
std::string const & arg() const
Return the argument associated with the runner.
Value & append(Value const &value)
Append value to array at the end.
Number is a floating point type that can represent a wide range of values.
static std::optional< TxType > permissionToTxType(std::uint32_t value)
void testNonDelegableTxWithDelegate(FeatureBitset features)
void testMultiSignDelegatorAsSigner()
void testMultiSignQuorumNotMet()
void testGranularSandboxCheckOrder()
void testSignForDelegated()
void testTrustSetGranular()
void testFeatureDisabled(FeatureBitset features)
void testInvalidRequest(FeatureBitset features)
void run() override
Runs the suite.
void testMPTokenIssuanceSetGranular()
void testDelegateTransaction()
void testGranularPermissionWithSponsorCommonFields()
void testSingleSignBadSecret()
void testDelegateUtilsNullptrCheck()
void testPermissionToTxType()
void testTxDelegableCount()
void testPaymentGranular(FeatureBitset features)
void testPermissionValue(FeatureBitset features)
void testAccountSetGranular()
void testTxRequireFeatures(FeatureBitset features)
Immutable cryptographic account descriptor.
std::string const & human() const
Returns the human readable public key.
std::string const & name() const
Return the name.
AccountID id() const
Returns the Account ID.
Sets the DeliverMin on a JTx.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
SLE::const_pointer le(Account const &account) const
Return an account root.
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
PrettyAmount limit(Account const &account, Issue const &issue) const
Returns the IOU limit on an account.
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
void require(Args const &... args)
Check a set of requirements.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Test helper for creating, mutating, and asserting MPT and confidential MPT ledger state.
void create(MPTCreate const &arg=MPTCreate{}, std::source_location const &loc=std::source_location::current())
Set a multisignature on a JTx.
Sets the SendMax on a JTx.
Set the regular signature on a JTx.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Adds an inner Batch transaction to a JTx and autofills it.
Sets the optional URI on a DIDSet.
@ Array
array value (ordered list)
Keylet computation functions.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Keylet account(AccountID const &id) noexcept
AccountID root.
json::Value outer(jtx::Account const &account, uint32_t seq, STAmount const &fee, std::uint32_t flags)
Build an outer Batch transaction JSON object.
XRPAmount calcBatchFee(jtx::Env const &env, uint32_t const &numSigners, uint32_t const &txns=0)
Calculate the expected outer Batch transaction fee.
json::Value create(A const &account, A const &dest, STAmount const &sendMax)
Create a check.
json::Value entry(jtx::Env &env, jtx::Account const &account, jtx::Account const &authorize)
json::Value set(jtx::Account const &account, jtx::Account const &authorize, std::vector< std::string > const &permissions)
json::Value set(jtx::Account const &account)
json::Value set(AccountID const &account, UInt256 const &vaultId, uint32_t flags)
json::Value coverWithdraw(AccountID const &account, UInt256 const &brokerID, STAmount const &amount, uint32_t flags)
json::Value coverDeposit(AccountID const &account, UInt256 const &brokerID, STAmount const &amount, uint32_t flags)
json::Value del(AccountID const &account, UInt256 const &brokerID, uint32_t flags)
json::Value coverClawback(AccountID const &account, std::uint32_t flags)
json::Value manage(AccountID const &account, UInt256 const &loanID, std::uint32_t flags)
json::Value set(AccountID const &account, UInt256 const &loanBrokerID, Number principalRequested, std::uint32_t flags)
json::Value del(AccountID const &account, UInt256 const &loanID, std::uint32_t flags)
json::Value pay(AccountID const &account, UInt256 const &loanID, STAmount const &amount, std::uint32_t flags)
UInt256 getNewDomain(std::shared_ptr< STObject const > const &meta)
json::Value setTx(AccountID const &account, Credentials const &credentials, std::optional< UInt256 > domain)
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
json::Value regkey(Account const &account, DisabledT)
Disable the regular key.
XrpT const XRP
Converts to XRP Issue or STAmount.
json::Value noop(Account const &account)
The null transaction.
bool expectOffers(Env const &env, AccountID const &account, std::uint16_t size, std::vector< Amounts > const &toMatch)
XRPAmount txFee(Env const &env, std::uint16_t n)
json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
FeatureBitset testableAmendments()
json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
std::vector< SLE::const_pointer > ownerDirEntries(ReadView const &view, AccountID const &account)
Return the ledger entries in an account's owner directory.
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
json::Value rate(Account const &account, double multiplier)
Set a transfer rate.
json::Value signers(Account const &account, std::uint32_t quorum, std::vector< Signer > const &v)
json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
STTx createTx(bool disabling, LedgerIndex seq, PublicKey const &txKey)
Create ttUNL_MODIFY Tx.
constexpr XRPAmount
Convert XRP to drops (integral types).
static XRPAmount reserve(jtx::Env const &env, std::uint32_t count)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr FlagValue spfSponsorFee
@ terNO_DELEGATE_PERMISSION
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
std::pair< PublicKey, SecretKey > randomKeyPair(KeyType type)
Create a key pair using secure random numbers.
std::unordered_set< GranularPermissionType > getGranularPermission(SLE::ConstRef delegate, TxType const &type)
Load the granular permissions granted to the delegate account for the specified transaction type.
std::string strHex(FwdIt begin, FwdIt end)
BaseUInt< 256 > Domain
Domain is a 256-bit hash representing a specific domain.
constexpr FlagValue tifMPTTransferFee
NotTEC checkTxPermission(SLE::ConstRef delegate, STTx const &tx)
Check if the delegate account has permission to execute the transaction.
std::string to_string(BaseUInt< Bits, Tag > const &a)
Slice makeSlice(std::array< T, N > const &a)
@ tecINSUFFICIENT_RESERVE
constexpr FlagValue tfFullyCanonicalSig