xrpld
Loading...
Searching...
No Matches
TransactionProposalCreate_test.cpp
1#include <test/jtx/AMM.h>
2#include <test/jtx/Account.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/TestHelpers.h>
5#include <test/jtx/amount.h>
6#include <test/jtx/delegate.h>
7#include <test/jtx/deposit.h>
8#include <test/jtx/fee.h>
9#include <test/jtx/flags.h>
10#include <test/jtx/multisign.h>
11#include <test/jtx/noop.h>
12#include <test/jtx/offer.h>
13#include <test/jtx/pay.h>
14#include <test/jtx/proposal.h>
15#include <test/jtx/sig.h>
16#include <test/jtx/sponsor.h>
17#include <test/jtx/ter.h>
18#include <test/jtx/ticket.h>
19#include <test/jtx/token.h>
20#include <test/jtx/trust.h>
21
22#include <xrpl/basics/base_uint.h>
23#include <xrpl/basics/strHex.h>
24#include <xrpl/beast/unit_test/suite.h>
25#include <xrpl/beast/utility/Journal.h>
26#include <xrpl/json/json_value.h>
27#include <xrpl/ledger/OpenView.h>
28#include <xrpl/ledger/helpers/ProposalHelpers.h>
29#include <xrpl/protocol/AccountID.h>
30#include <xrpl/protocol/Feature.h>
31#include <xrpl/protocol/Indexes.h>
32#include <xrpl/protocol/Keylet.h>
33#include <xrpl/protocol/SField.h>
34#include <xrpl/protocol/STAmount.h>
35#include <xrpl/protocol/STArray.h>
36#include <xrpl/protocol/STLedgerEntry.h>
37#include <xrpl/protocol/STObject.h>
38#include <xrpl/protocol/SeqProxy.h>
39#include <xrpl/protocol/TER.h>
40#include <xrpl/protocol/TxFlags.h>
41#include <xrpl/protocol/TxFormats.h>
42#include <xrpl/protocol/jss.h>
43
44#include <chrono> // IWYU pragma: keep
45#include <cstddef>
46#include <cstdint>
47#include <functional>
48#include <memory>
49#include <string>
50#include <utility>
51#include <vector>
52
53namespace xrpl::test {
54
56{
57 void
59 {
60 testcase("proposal reserve");
61
62 using namespace jtx;
63
64 BEAST_EXPECT(proposal::kProposalOwnerCount == 5);
65 BEAST_EXPECT(proposal::kBatchProposalOwnerCount == 10);
66 }
67
68 // Nothing about the transaction is available before the amendment is
69 // active, not even to an otherwise valid proposal.
70 void
72 {
73 testcase("amendment disabled");
74
75 using namespace jtx;
76 using namespace std::chrono_literals;
77
78 Env env{*this, features - featureCosign};
79
80 Account const target{"target"};
81 Account const bob{"bob"};
82 env.fund(XRP(10000), target, bob);
83 env.close();
84
85 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
86
88 target,
89 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq),
90 proposal::expiration(env, 100s)),
93 env.close();
94
95 // Its own Ticket is the only thing target owns; the rejected
96 // proposal adds nothing on top of it.
97 BEAST_EXPECT(ownerCount(env, target) == 1);
98 }
99
100 // The proposed transaction must be a transaction that could be submitted on
101 // its own. Each case below takes an otherwise valid payload and breaks
102 // exactly one of those rules; the rules about its signature fields are
103 // covered by testRejectedSignatureFields.
104 void
106 {
107 testcase("reject payload that must not be stored");
108
109 using namespace jtx;
110 using namespace std::chrono_literals;
111
112 Env env{*this, features};
113
114 Account const target{"target"};
115 Account const bob{"bob"};
116 env.fund(XRP(10000), target, bob);
117 env.close();
118
119 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
120
121 std::uint32_t const expiration = proposal::expiration(env, 100s);
122
123 // A payload that is accepted as-is; every case starts from this.
124 auto const payload = [&] {
125 return proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq);
126 };
127
128 // target's own Ticket is the only thing it owns throughout; a
129 // rejected proposal never adds anything on top of it.
130 auto const reject = [&](json::Value const& proposedTx, TER expected) {
131 env(proposal::create(target, proposedTx, expiration),
132 Ter(expected),
134 env.close();
135 BEAST_EXPECT(ownerCount(env, target) == 1);
136 };
137
138 // An unrecognized TransactionType cannot even be constructed as an
139 // STTx (there is no format to validate it against), so it is
140 // rejected the same as any other malformed payload.
141 {
142 json::Value tx = payload();
143 tx[jss::TransactionType] = 65535;
144 reject(tx, temMALFORMED);
145 }
146
147 // A pseudo-transaction is never submittable by an account. This
148 // payload also carries Payment-shaped fields (Amount, Destination)
149 // that aren't part of EnableAmendment's own template, so it fails
150 // STTx construction before ever reaching our own isPseudoTx check.
151 {
152 json::Value tx = payload();
153 tx[jss::TransactionType] = jss::EnableAmendment;
154 reject(tx, temMALFORMED);
155 }
156
157 // An inner batch transaction bypasses the ordinary signature checks.
158 // The proposed transaction's own preflight rejects a standalone
159 // tfInnerBatchTxn (no enclosing Batch, no parentBatchId) with its own
160 // more specific code before reaching our own tfInnerBatchTxn check.
161 {
162 json::Value tx = payload();
163 tx[jss::Flags] = tfInnerBatchTxn;
164 reject(tx, temINVALID_INNER_BATCH);
165 }
166
167 // Proposals do not nest. This payload also isn't a valid instance of
168 // TransactionProposalCreate's own template (it lacks Expiration and
169 // ProposedTransaction), so it fails STTx construction before ever
170 // reaching our own nesting check.
171 {
172 json::Value tx = payload();
173 tx[jss::TransactionType] = "TransactionProposalCreate";
174 reject(tx, temMALFORMED);
175 }
176
177 // Nor may a proposed Batch smuggle a nested proposal in as one of its
178 // own inner transactions. A second, ordinary inner transaction rides
179 // along only to satisfy Batch's own minimum of two inner
180 // transactions; it isn't itself the point of this case.
181 {
182 json::Value const nestedProposal =
183 proposal::create(target, payload(), proposal::expiration(env, 100s));
185 env,
186 target,
187 targetTicketSeq,
188 tfAllOrNothing,
189 {
190 proposal::innerTx(nestedProposal, env.seq(target)),
191 proposal::innerTx(pay(target, bob, XRP(1)), env.seq(target) + 1),
192 });
193 reject(tx, temINVALID);
194 }
195
196 // A Batch inner lacking TransactionType cannot be constructed as an
197 // STTx, so Create rejects the payload as temMALFORMED before the
198 // nesting walk runs at all. That inner would otherwise make the walk
199 // report temINVALID, so this pins the ordering.
200 {
201 json::Value missingType;
202 missingType[jss::Account] = target.human();
203 missingType[jss::Flags] = tfInnerBatchTxn;
204 missingType[jss::Sequence] = env.seq(target);
205 missingType[jss::Fee] = "10";
206 missingType[jss::SigningPubKey] = "";
207
208 reject(
210 env,
211 target,
212 targetTicketSeq,
213 tfAllOrNothing,
214 {
215 proposal::innerTx(pay(target, bob, XRP(1)), env.seq(target) + 1),
216 missingType,
217 }),
219 }
220
221 // The walk rejects such an inner in its own right. Nothing submitted
222 // through Create can reach that guard — the case above shows STTx
223 // construction throwing first — so it is checked directly here, which
224 // also pins it for a caller that does not build an STTx beforehand.
225 {
226 STObject inner(sfRawTransaction);
227 inner.setAccountID(sfAccount, target.id());
228
229 STArray rawTxns(sfRawTransactions);
230 rawTxns.push_back(std::move(inner));
231
233 batch.setFieldU16(sfTransactionType, ttBATCH);
234 batch.setFieldArray(sfRawTransactions, rawTxns);
235
237 }
238
239 // The proposed transaction must be ticket-based: a missing
240 // TicketSequence, or a live Sequence alongside it, is rejected.
241 {
242 json::Value tx = payload();
243 tx.removeMember(sfTicketSequence.getJsonName());
244 reject(tx, temSEQ_AND_TICKET);
245 }
246 {
247 json::Value tx = payload();
248 tx[jss::Sequence] = 1;
249 reject(tx, temSEQ_AND_TICKET);
250 }
251
252 // If this TransactionProposalCreate itself pays with a Ticket, and the
253 // proposed transaction targets that same account and Ticket, applying
254 // this transaction consumes the Ticket the proposal depends on before
255 // the proposal is even stored: it would be dead on arrival. target is
256 // proposing for itself here, so this is the Ticket it is about to pay
257 // with and the Ticket its own proposed payload names.
258 {
259 std::uint32_t const selfTicketSeq = proposal::createTicket(env, target);
260
261 json::Value const tx =
262 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), selfTicketSeq);
263 env(proposal::create(target, tx, expiration),
264 ticket::Use(selfTicketSeq),
266 env.close();
267 BEAST_EXPECT(!proposal::entry(env, target, selfTicketSeq));
268 BEAST_EXPECT(env.le(keylet::ticket(target.id(), SeqProxy::rawTicket(selfTicketSeq))));
269 BEAST_EXPECT(ownerCount(env, target) == 2);
270
271 // Consume the leftover Ticket so target's OwnerCount is back to
272 // just its original Ticket for the remaining cases below.
273 env(noop(target), ticket::Use(selfTicketSeq));
274 env.close();
275 BEAST_EXPECT(ownerCount(env, target) == 1);
276 }
277
278 // A payload that fails its own transaction type's preflight surfaces
279 // that type's own code, not a generic error (On-Chain Cosigner spec §5.3.1.2).
280 {
281 json::Value tx = payload();
282 tx[jss::Amount] = "0";
283 reject(tx, temBAD_AMOUNT);
284 }
285
286 // A payload that fails passesLocalChecks (On-Chain Cosigner spec
287 // §5.3.1 rule 2) is rejected as temMALFORMED. An oversized Memos
288 // array trips isMemoOkay; no transactor preflight step bounds
289 // memo size.
290 {
291 json::Value tx = payload();
292 tx[sfMemos.jsonName][0u][sfMemo.jsonName][sfMemoData.jsonName] =
293 strHex(std::string(1100, 'A')); // > 1024 bytes serialized
294 reject(tx, temMALFORMED);
295 }
296
297 // Expiration must be present and non-zero.
298 {
299 env(proposal::create(target, payload(), 0),
302 env.close();
303 BEAST_EXPECT(ownerCount(env, target) == 1);
304 }
305 }
306
307 // A proposal is stored in unsigned canonical form: an empty SigningPubKey
308 // and no signature field whatsoever. Signatures may only ever arrive
309 // through TransactionProposalSign, so a payload is rejected for carrying a
310 // signature container at all — whatever that container happens to hold.
311 // Each container below is therefore filled every way it could be,
312 // including combinations that could never verify: an empty container, a
313 // key with no signature, a signature with no key, and a signature next to
314 // the empty SigningPubKey the canonical form requires.
315 //
316 // The rejection code is not uniform, though. A fill that leaves actual
317 // signature bytes behind (a non-empty TxnSignature, or one inside a
318 // Signers entry) is, for some containers, intercepted before ever
319 // reaching our own hasSignatureField check: the payload's own top-level
320 // fields are checked by Transactor::preflight2's dry-run simulate-key
321 // logic, and LoanSet forwards its CounterpartySignature through that same
322 // logic, both yielding temINVALID instead. SponsorSignature and
323 // BatchSigners are not inspected that way — only their presence is
324 // checked elsewhere — so they always reach our own check regardless of
325 // what they hold.
326 void
328 {
329 testcase("reject payload carrying a signature");
330
331 using namespace jtx;
332 using namespace std::chrono_literals;
333
334 Env env{*this, features};
335
336 Account const target{"target"};
337 Account const bob{"bob"};
338 env.fund(XRP(10000), target, bob);
339 env.close();
340
341 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
342
343 std::uint32_t const expiration = proposal::expiration(env, 100s);
344
345 std::string const key = strHex(bob.pk().slice());
346 std::string const sig = "DEADBEEF";
347
348 // The payloads every case starts from, each accepted as-is. Two cases
349 // below would otherwise build the same payload, and the same proposal
350 // cannot be submitted twice — the second is turned away as a duplicate
351 // rather than judged again — so each call pays a different amount.
352 // Nothing here turns on the amount.
353 std::uint32_t paid = 0;
354 auto const payment = [&] {
355 return proposal::unsignedPayload(env, pay(target, bob, drops(++paid)), targetTicketSeq);
356 };
357 auto const sponsoredPayment = [&] {
358 // bob is just standing in for an arbitrary sponsor here; every case
359 // is rejected for carrying a signature field before the sponsor
360 // itself is ever examined.
361 json::Value tx = pay(target, bob, drops(++paid));
362 tx[sfSponsor.getJsonName()] = bob.human();
363 tx[sfSponsorFlags.getJsonName()] = spfSponsorFee;
364 return proposal::unsignedPayload(env, tx, targetTicketSeq);
365 };
366 auto const loanSet = [&] {
367 json::Value tx = loan::set(target, UInt256{1}, 1'000 + ++paid);
368 tx[sfCounterparty.getJsonName()] = bob.human();
369 return proposal::unsignedPayload(env, tx, targetTicketSeq);
370 };
371 auto const batchTx = [&] {
373 env,
374 target,
375 targetTicketSeq,
376 tfAllOrNothing,
377 {
378 proposal::innerTx(pay(target, bob, drops(++paid)), env.seq(target)),
379 proposal::innerTx(pay(target, bob, drops(++paid)), env.seq(target) + 1),
380 });
381 };
382
383 // target's own Ticket is the only thing it owns throughout; a
384 // rejected proposal never adds anything on top of it.
385 auto const reject = [&](json::Value const& proposedTx, TER expected) {
386 env(proposal::create(target, proposedTx, expiration),
387 Ter(expected),
389 env.close();
390 BEAST_EXPECT(ownerCount(env, target) == 1);
391 };
392
393 // Every way of filling in a signature. The payload's own signature
394 // fields and a co-signature object hold the same three members, so the
395 // same fills apply to both. `signs` marks a fill that leaves actual
396 // signature bytes behind, which some containers' own dry-run
397 // simulate-key check reacts to (see the class comment above).
398 struct Fill
399 {
401 bool signs;
402 };
403
404 std::vector<Fill> const fills{
405 {.apply = [&](json::Value& o) { o[jss::SigningPubKey] = key; }, .signs = false},
406 {
407 .apply = [&](json::Value& o) { o[sfTxnSignature.getJsonName()] = sig; },
408 .signs = true,
409 },
410 {
411 .apply =
412 [&](json::Value& o) {
413 o[jss::SigningPubKey] = "";
414 o[sfTxnSignature.getJsonName()] = sig;
415 },
416 .signs = true,
417 },
418 // Signed the ordinary way, which is the likeliest way one of these
419 // arrives here.
420 {
421 .apply =
422 [&](json::Value& o) {
423 o[jss::SigningPubKey] = key;
424 o[sfTxnSignature.getJsonName()] = sig;
425 },
426 .signs = true,
427 },
428 // Multi-signed: the signer's own key is empty and the signatures
429 // sit in a nested Signers array. Each entry needs all three of
430 // Account, SigningPubKey and TxnSignature to parse at all, so only
431 // their values can vary.
432 {
433 .apply =
434 [&](json::Value& o) {
435 o[jss::SigningPubKey] = "";
436 auto& signer = o[sfSigners.getJsonName()][0u][sfSigner.getJsonName()];
437 signer[jss::Account] = bob.human();
438 signer[jss::SigningPubKey] = key;
439 signer[sfTxnSignature.getJsonName()] = sig;
440 },
441 .signs = true,
442 },
443 {
444 .apply =
445 [&](json::Value& o) {
446 o[jss::SigningPubKey] = "";
447 auto& signer = o[sfSigners.getJsonName()][0u][sfSigner.getJsonName()];
448 signer[jss::Account] = bob.human();
449 signer[jss::SigningPubKey] = "";
450 signer[sfTxnSignature.getJsonName()] = sig;
451 },
452 .signs = true,
453 },
454 };
455
456 // Every place a signature could sit, on a payload of a type that
457 // carries it: a Counterparty's signature belongs to a LoanSet and
458 // BatchSigners to a Batch, while a Sponsor's signature and the
459 // payload's own signature fields sit on any transaction. A signature
460 // is no more storable for being a field its transaction type expects
461 // (On-Chain Cosigner spec §6.1, §6.6.3). `checksSignatureContent`
462 // marks a place whose own preflight forwards the container through a
463 // dry-run simulate-key check, the same as the payload's own top-level
464 // fields.
465 struct Place
466 {
467 std::function<json::Value()> payload;
469 bool checksSignatureContent;
470 };
471
472 std::vector<Place> const places{
473 {
474 .payload = payment,
475 .at = [](json::Value& tx) -> json::Value& { return tx; },
476 .checksSignatureContent = true,
477 },
478 {
479 .payload = loanSet,
480 .at = [](json::Value& tx) -> json::Value& {
481 auto& o = tx[sfCounterpartySignature.getJsonName()];
483 return o;
484 },
485 .checksSignatureContent = true,
486 },
487 {
488 .payload = sponsoredPayment,
489 .at = [](json::Value& tx) -> json::Value& {
490 auto& o = tx[sfSponsorSignature.getJsonName()];
492 return o;
493 },
494 .checksSignatureContent = false,
495 },
496 // A BatchSigners entry names the account it speaks for; the other
497 // two co-signatures are fixed by the transaction they belong to and
498 // do not.
499 {
500 .payload = batchTx,
501 .at = [&](json::Value& tx) -> json::Value& {
502 auto& o = tx[sfBatchSigners.getJsonName()][0u][sfBatchSigner.getJsonName()];
503 o[jss::Account] = bob.human();
504 return o;
505 },
506 .checksSignatureContent = false,
507 },
508 };
509
510 for (auto const& place : places)
511 {
512 for (auto const& fill : fills)
513 {
514 json::Value tx = place.payload();
515 fill.apply(place.at(tx));
516 reject(tx, place.checksSignatureContent && fill.signs ? temINVALID : temBAD_SIGNER);
517 }
518 }
519
520 // Every place but the payload itself: a co-signature object is
521 // disqualifying by its presence alone, so each is rejected left empty
522 // too. The payload's own fields have no such case — left alone they are
523 // the canonical form. An empty container never trips a simulate-key
524 // check, so this is temBAD_SIGNER regardless of checksSignatureContent.
525 for (std::size_t i = 1; i < places.size(); ++i)
526 {
527 json::Value tx = places[i].payload();
528 places[i].at(tx);
529 reject(tx, temBAD_SIGNER);
530 }
531
532 // Nor does the payload have a counterpart for an absent SigningPubKey:
533 // in a co-signature object an absent member is just an unfilled one,
534 // but at the top level it is not the same as an empty one, with or
535 // without a signature beside it. SigningPubKey is a required common
536 // field, so its absence means proposedTx isn't a valid instance of its
537 // own type; that's caught while constructing it as an STTx, before
538 // reaching our own hasEmptySigningPubKey check.
539 {
540 json::Value tx = payment();
541 tx.removeMember(jss::SigningPubKey);
542 reject(tx, temMALFORMED);
543 }
544 {
545 json::Value tx = payment();
546 tx.removeMember(jss::SigningPubKey);
547 tx[sfTxnSignature.getJsonName()] = sig;
548 reject(tx, temMALFORMED);
549 }
550 }
551
552 // A proposal that could never be completed must not be stored, and a
553 // target-and-ticket pair may hold at most one proposal.
554 void
556 {
557 testcase("reject proposal that cannot be completed");
558
559 using namespace jtx;
560 using namespace std::chrono_literals;
561
562 Env env{*this, features};
563
564 Account const target{"target"};
565 Account const bob{"bob"};
566 Account const carol{"carol"}; // never funded
567 env.fund(XRP(10000), target, bob);
568 env.close();
569
570 std::uint32_t const firstTicketSeq = proposal::createTicket(env, target, 3);
571
572 std::uint32_t const expiration = proposal::expiration(env, 100s);
573
574 auto const payload = [&](std::uint32_t ticketSeq) {
575 return proposal::unsignedPayload(env, pay(target, bob, XRP(1)), ticketSeq);
576 };
577
578 // target's three Tickets are owned throughout, so its OwnerCount
579 // never drops below 3; each successful proposal adds kProposalOwnerCount
580 // on top of that baseline.
581
582 // The proposal's own expiration has already passed.
583 {
584 env(proposal::create(target, payload(firstTicketSeq), proposal::expiration(env, 0s)),
587 env.close();
588 BEAST_EXPECT(ownerCount(env, target) == 3);
589 }
590
591 // The proposed transaction's own ledger bound has passed: the ordinary
592 // path would reject it with tefMAX_LEDGER, so it can never complete.
593 {
594 json::Value tx = payload(firstTicketSeq);
595 tx[sfLastLedgerSequence.getJsonName()] = env.current()->seq() - 1;
596 env(proposal::create(target, tx, expiration),
599 env.close();
600 BEAST_EXPECT(ownerCount(env, target) == 3);
601 }
602
603 // A LastLedgerSequence equal to the current ledger leaves no window to
604 // collect signatures before the proposed transaction's own bound
605 // passes, so it is rejected the same as one already in the past
606 // (On-Chain Cosigner spec §5.3.2.2).
607 {
608 json::Value tx = payload(firstTicketSeq);
609 tx[sfLastLedgerSequence.getJsonName()] = env.current()->seq();
610 env(proposal::create(target, tx, expiration),
613 env.close();
614 BEAST_EXPECT(ownerCount(env, target) == 3);
615 }
616
617 // With no ledger bound on the proposed transaction, the proposal is
618 // created normally.
619 {
620 env(proposal::create(target, payload(firstTicketSeq), expiration),
622 env.close();
623 BEAST_EXPECT(ownerCount(env, target) == 3 + proposal::kProposalOwnerCount);
624 }
625
626 // The target and ticket already carry a proposal.
627 {
628 env(proposal::create(target, payload(firstTicketSeq), expiration),
631 env.close();
632 BEAST_EXPECT(ownerCount(env, target) == 3 + proposal::kProposalOwnerCount);
633 }
634
635 // A different ticket of the same target is a different proposal.
636 {
637 env(proposal::create(target, payload(firstTicketSeq + 1), expiration),
639 env.close();
640 BEAST_EXPECT(ownerCount(env, target) == 3 + (2 * proposal::kProposalOwnerCount));
641 }
642
643 // The target account does not exist, so it can never sign. target
644 // itself is just standing in here as an arbitrary funded submitter —
645 // the account under test is carol, the (nonexistent) target.
646 {
648 target, proposal::unsignedPayload(env, pay(carol, bob, XRP(1)), 1), expiration),
651 env.close();
652 BEAST_EXPECT(ownerCount(env, target) == 3 + (2 * proposal::kProposalOwnerCount));
653 }
654
655 // The referenced ticket does not exist: the proposal would reserve a
656 // ticket that was never created (On-Chain Cosigner spec §5.3.2).
657 {
658 std::uint32_t const noSuchTicketSeq = firstTicketSeq + 100;
659 env(proposal::create(target, payload(noSuchTicketSeq), expiration),
662 env.close();
663 BEAST_EXPECT(ownerCount(env, target) == 3 + (2 * proposal::kProposalOwnerCount));
664 }
665 }
666
667 // Only the target account itself, or an account on its SignerList, may
668 // create a proposal against it. Otherwise any unrelated account could
669 // spam or squat the target's Tickets with unwanted proposals (On-Chain
670 // Cosigner V1 authorization scope).
671 void
673 {
674 testcase("reject proposal from an unauthorized proposer");
675
676 using namespace jtx;
677 using namespace std::chrono_literals;
678
679 Env env{*this, features};
680
681 Account const target{"target"};
682 Account const signer{"signer"};
683 Account const stranger{"stranger"};
684 Account const bob{"bob"};
685 env.fund(XRP(10000), target, signer, stranger, bob);
686 env.close();
687
688 env(signers(target, 1, {{signer, 1}}));
689 env.close();
690
691 auto const payload = [&](std::uint32_t ticketSeq) {
692 return proposal::unsignedPayload(env, pay(target, bob, XRP(1)), ticketSeq);
693 };
694
695 // The target account itself needs no SignerList entry.
696 {
697 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
698 env(proposal::create(target, payload(ticketSeq), proposal::expiration(env, 100s)),
700 env.close();
701 BEAST_EXPECT(proposal::entry(env, target, ticketSeq));
702 }
703
704 // An account on the target's SignerList may propose for it.
705 {
706 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
707 env(proposal::create(signer, payload(ticketSeq), proposal::expiration(env, 100s)),
709 env.close();
710 BEAST_EXPECT(proposal::entry(env, target, ticketSeq));
711 }
712
713 // An account that is neither the target nor on its SignerList may not.
714 {
715 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
716 env(proposal::create(stranger, payload(ticketSeq), proposal::expiration(env, 100s)),
719 env.close();
720 BEAST_EXPECT(!proposal::entry(env, target, ticketSeq));
721 BEAST_EXPECT(ownerCount(env, stranger) == 0);
722 }
723
724 // A target with no SignerList at all may only be proposed for by
725 // itself.
726 {
727 Account const bare{"bare"};
728 env.fund(XRP(10000), bare);
729 env.close();
730
731 std::uint32_t const ticketSeq = proposal::createTicket(env, bare);
733 stranger,
734 proposal::unsignedPayload(env, pay(bare, bob, XRP(1)), ticketSeq),
735 proposal::expiration(env, 100s)),
738 env.close();
739 BEAST_EXPECT(!proposal::entry(env, bare, ticketSeq));
740 }
741
742 // A SignerList with several entries authorizes every one of them, not
743 // just the first, matching a real-world multi-signer setup rather
744 // than only ever exercising a single-signer list.
745 {
746 Account const s1{"s1"};
747 Account const s2{"s2"};
748 Account const s3{"s3"};
749 Account const s4{"s4"};
750 Account const s5{"s5"};
751 env.fund(XRP(10000), s1, s2, s3, s4, s5);
752 env.close();
753
754 env(signers(target, 3, {{s1, 1}, {s2, 1}, {s3, 1}, {s4, 1}, {s5, 1}}));
755 env.close();
756
757 for (Account const& s : {s1, s2, s3, s4, s5})
758 {
759 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
760 env(proposal::create(s, payload(ticketSeq), proposal::expiration(env, 100s)),
762 env.close();
763 BEAST_EXPECT(proposal::entry(env, target, ticketSeq));
764 }
765
766 // The old SignerList's sole signer is no longer on the new one.
767 {
768 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
769 env(proposal::create(signer, payload(ticketSeq), proposal::expiration(env, 100s)),
772 env.close();
773 BEAST_EXPECT(!proposal::entry(env, target, ticketSeq));
774 }
775
776 // An unrelated account still may not.
777 {
778 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
779 env(proposal::create(stranger, payload(ticketSeq), proposal::expiration(env, 100s)),
782 env.close();
783 BEAST_EXPECT(!proposal::entry(env, target, ticketSeq));
784 }
785 }
786 }
787
788 // An on-ledger ltSIGNER_LIST that cannot be read as signer entries is
789 // unexpected ledger state, not a malformed transaction. preclaim must
790 // surface tefBAD_LEDGER (not temMALFORMED, not tefINTERNAL which is
791 // reserved for truly unreachable paths, and not the tefEXCEPTION that
792 // applySteps would wrap an uncaught throw with).
793 //
794 // SignerEntries::deserialize returns unexpected(temMALFORMED) when
795 // sfSignerEntries is missing or an element is not named sfSignerEntry.
796 // It still throws from STObject accessors when an sfSignerEntry is
797 // missing required fields (getAccountID → "Field not found: Account").
798 // Do not close() after the synthetic corruption: a closed ledger would
799 // drop the overlay and restore a well-formed list.
800 void
802 {
803 testcase("unparseable on-ledger SignerList is tefBAD_LEDGER");
804
805 using namespace jtx;
806 using namespace std::chrono_literals;
807
808 auto const setup = [&](Env& env, Account const& target, Account const& signer) {
809 env.fund(XRP(10000), target, signer);
810 env.close();
811 env(signers(target, 1, {{signer, 1}}));
812 env.close();
813 // Ticket first: createTicket closes, which would drop a later
814 // open-ledger overlay and restore a well-formed SignerList.
815 return proposal::createTicket(env, target);
816 };
817
818 auto const proposeAsSigner =
819 [&](Env& env, Account const& target, Account const& signer, std::uint32_t ticketSeq) {
821 signer,
822 proposal::unsignedPayload(env, pay(target, signer, XRP(1)), ticketSeq),
823 proposal::expiration(env, 100s)),
826 BEAST_EXPECT(!proposal::entry(env, target, ticketSeq));
827 };
828
829 {
830 Env env{*this, features};
831 Account const target{"targetMissing"};
832 Account const signer{"signerMissing"};
833 std::uint32_t const ticketSeq = setup(env, target, signer);
834
835 auto const signerListKeylet = keylet::signerList(target.id());
836 BEAST_EXPECT(env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal) {
837 auto const sle = view.read(signerListKeylet);
838 if (!sle)
839 return false;
840 auto const replacement = std::make_shared<SLE>(*sle);
841 if (!replacement->delField(sfSignerEntries))
842 return false;
843 view.rawReplace(replacement);
844 return true;
845 }));
846 BEAST_EXPECT(env.le(signerListKeylet));
847
848 proposeAsSigner(env, target, signer, ticketSeq);
849 }
850
851 {
852 Env env{*this, features};
853 Account const target{"targetBadEntry"};
854 Account const signer{"signerBadEntry"};
855 std::uint32_t const ticketSeq = setup(env, target, signer);
856
857 auto const signerListKeylet = keylet::signerList(target.id());
858 BEAST_EXPECT(env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal) {
859 auto const sle = view.read(signerListKeylet);
860 if (!sle)
861 return false;
862 auto const replacement = std::make_shared<SLE>(*sle);
863 STArray badEntries;
864 badEntries.pushBack(STObject{sfSigner});
865 replacement->setFieldArray(sfSignerEntries, badEntries);
866 view.rawReplace(replacement);
867 return true;
868 }));
869 BEAST_EXPECT(env.le(signerListKeylet));
870
871 proposeAsSigner(env, target, signer, ticketSeq);
872 }
873
874 {
875 Env env{*this, features};
876 Account const target{"targetMissingAccount"};
877 Account const signer{"signerMissingAccount"};
878 std::uint32_t const ticketSeq = setup(env, target, signer);
879
880 auto const signerListKeylet = keylet::signerList(target.id());
881 BEAST_EXPECT(env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal) {
882 auto const sle = view.read(signerListKeylet);
883 if (!sle)
884 return false;
885 auto const replacement = std::make_shared<SLE>(*sle);
886 STArray badEntries;
887 // Right inner name, but no sfAccount: deserialize calls
888 // getAccountID and throws (Field not found), which the
889 // catch maps to tefBAD_LEDGER.
890 badEntries.pushBack(STObject{sfSignerEntry});
891 replacement->setFieldArray(sfSignerEntries, badEntries);
892 view.rawReplace(replacement);
893 return true;
894 }));
895 BEAST_EXPECT(env.le(signerListKeylet));
896
897 proposeAsSigner(env, target, signer, ticketSeq);
898 }
899 }
900
901 // The target account may delegate authority over the proposed
902 // transaction's own type to another account (Permission Delegation,
903 // XLS-75); if it does, that delegate — or an account on the delegate's
904 // own SignerList — may also create the proposal, since it will need to
905 // help complete the proposed transaction's own authorization anyway.
906 // Naming an account as Delegate in the proposed transaction is not
907 // itself trusted: a real DelegateSet grant is required.
908 void
910 {
911 testcase("proposer authorized through a delegated proposed txn");
912
913 using namespace jtx;
914 using namespace std::chrono_literals;
915
916 Env env{*this, features};
917
918 Account const target{"target"};
919 Account const delegateAcct{"delegateAcct"};
920 Account const ds1{"ds1"}; // on delegateAcct's own SignerList
921 Account const ds2{"ds2"}; // on delegateAcct's own SignerList
922 Account const stranger{"stranger"};
923 Account const bob{"bob"};
924 env.fund(XRP(10000), target, delegateAcct, ds1, ds2, stranger, bob);
925 env.close();
926
927 auto const delegatedPayload = [&](std::uint32_t ticketSeq) {
928 json::Value tx = pay(target, bob, XRP(1));
929 tx[sfDelegate.jsonName] = delegateAcct.human();
930 return proposal::unsignedPayload(env, tx, ticketSeq);
931 };
932
933 // Without a real DelegateSet grant, naming an account as Delegate in
934 // the proposed transaction does not authorize it.
935 {
936 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
938 delegateAcct, delegatedPayload(ticketSeq), proposal::expiration(env, 100s)),
941 env.close();
942 BEAST_EXPECT(!proposal::entry(env, target, ticketSeq));
943 }
944
945 // The target grants delegateAcct permission over Payment transactions.
946 env(delegate::set(target, delegateAcct, {"Payment"}));
947 env.close();
948
949 // The delegate itself may now create the proposal.
950 {
951 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
953 delegateAcct, delegatedPayload(ticketSeq), proposal::expiration(env, 100s)),
955 env.close();
956 BEAST_EXPECT(proposal::entry(env, target, ticketSeq));
957 }
958
959 // An account on the delegate's own SignerList may likewise create it.
960 {
961 env(signers(delegateAcct, 1, {{ds1, 1}, {ds2, 1}}));
962 env.close();
963
964 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
965 env(proposal::create(ds1, delegatedPayload(ticketSeq), proposal::expiration(env, 100s)),
967 env.close();
968 BEAST_EXPECT(proposal::entry(env, target, ticketSeq));
969 }
970
971 // An account with no relationship to the target or the delegate is
972 // still rejected.
973 {
974 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
976 stranger, delegatedPayload(ticketSeq), proposal::expiration(env, 100s)),
979 env.close();
980 BEAST_EXPECT(!proposal::entry(env, target, ticketSeq));
981 }
982 }
983
984 // A delegate holding only a granular permission (XLS-75) that would
985 // authorize submitting the proposed transaction may also create a
986 // proposal for it. A granular grant that fails checkGranularSandbox
987 // still cannot.
988 void
990 {
991 testcase("proposer authorized through granular delegate permission");
992
993 using namespace jtx;
994 using namespace std::chrono_literals;
995
996 Env env{*this, features};
997
998 Account const gw{"gw"}; // issuer / proposed-tx Account
999 Account const alice{"alice"}; // holder of the trust line being authorized
1000 Account const bob{"bob"}; // delegate with TrustlineAuthorize only
1001 env.fund(XRP(10000), gw, alice, bob);
1002 env(fset(gw, asfRequireAuth));
1003 env.close();
1004
1005 env(trust(alice, gw["USD"](50)));
1006 env.close();
1007 env(delegate::set(gw, bob, {"TrustlineAuthorize"}));
1008 env.close();
1009
1010 auto const delegatedTrustSet = [&](std::uint32_t ticketSeq, std::uint32_t flags) {
1011 json::Value tx = trust(gw, gw["USD"](0), alice, flags);
1012 tx[sfDelegate.jsonName] = bob.human();
1013 return proposal::unsignedPayload(env, tx, ticketSeq);
1014 };
1015
1016 // TrustlineAuthorize is sufficient for a tfSetfAuth TrustSet against
1017 // an existing line whose limit is unchanged — the same shape that
1018 // submits successfully under invokeCheckPermission.
1019 {
1020 std::uint32_t const ticketSeq = proposal::createTicket(env, gw);
1021 env(proposal::create(
1022 bob, delegatedTrustSet(ticketSeq, tfSetfAuth), proposal::expiration(env, 100s)),
1024 env.close();
1025 BEAST_EXPECT(proposal::entry(env, gw, ticketSeq));
1026 }
1027
1028 // tfSetFreeze is not in TrustlineAuthorize's sandbox.
1029 {
1030 std::uint32_t const ticketSeq = proposal::createTicket(env, gw);
1031 env(proposal::create(
1032 bob,
1033 delegatedTrustSet(ticketSeq, tfSetFreeze),
1034 proposal::expiration(env, 100s)),
1037 env.close();
1038 BEAST_EXPECT(!proposal::entry(env, gw, ticketSeq));
1039 }
1040
1041 // sfQualityOut is a valid TrustSet field but not in the granular
1042 // template, so checkGranularSandbox rejects it.
1043 {
1044 std::uint32_t const ticketSeq = proposal::createTicket(env, gw);
1045 json::Value tx = trust(gw, gw["USD"](0), alice, tfSetfAuth);
1046 tx[sfDelegate.jsonName] = bob.human();
1047 tx[sfQualityOut.jsonName] = 100;
1048 env(proposal::create(
1049 bob,
1050 proposal::unsignedPayload(env, tx, ticketSeq),
1051 proposal::expiration(env, 100s)),
1054 env.close();
1055 BEAST_EXPECT(!proposal::entry(env, gw, ticketSeq));
1056 }
1057 }
1058
1059 // Same failure mode as testCorruptSignerList, but reached through the
1060 // delegate branch: preclaim looks up the delegate's own SignerList when
1061 // the proposer is neither the target, on the target's SignerList, nor the
1062 // delegate itself. If the delegate's SignerList is unparseable, preclaim
1063 // must surface tefBAD_LEDGER — exercising the second isAuthorizedFor call
1064 // that runs against the delegate rather than the target.
1065 void
1067 {
1068 testcase("unparseable delegate SignerList is tefBAD_LEDGER");
1069
1070 using namespace jtx;
1071 using namespace std::chrono_literals;
1072
1073 Env env{*this, features};
1074
1075 Account const target{"target"};
1076 Account const delegateAcct{"delegateAcct"};
1077 Account const ds1{"ds1"}; // on delegateAcct's own SignerList, not target's
1078 Account const bob{"bob"};
1079 env.fund(XRP(10000), target, delegateAcct, ds1, bob);
1080 env.close();
1081
1082 // Grant delegate Payment permission for target; give delegate its own
1083 // SignerList so that isAuthorizedFor(delegateAccount) actually reads
1084 // and deserializes it. Do not give target a SignerList: proposer ds1
1085 // must fail isAuthorizedFor(target) before ever reaching the delegate
1086 // branch.
1087 env(delegate::set(target, delegateAcct, {"Payment"}));
1088 env(signers(delegateAcct, 1, {{ds1, 1}}));
1089 env.close();
1090
1091 // Ticket first: createTicket closes, which would drop a later
1092 // open-ledger overlay and restore a well-formed SignerList.
1093 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
1094
1095 // Corrupt delegate's SignerList in the open ledger overlay only. Do
1096 // not close() afterward: a closed ledger would drop the overlay.
1097 auto const delegateSignerListKeylet = keylet::signerList(delegateAcct.id());
1098 BEAST_EXPECT(env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal) {
1099 auto const sle = view.read(delegateSignerListKeylet);
1100 if (!sle)
1101 return false;
1102 auto const replacement = std::make_shared<SLE>(*sle);
1103 // Right inner name, but no sfAccount: deserialize calls
1104 // getAccountID and throws (Field not found), which the catch
1105 // maps to tefBAD_LEDGER.
1106 STArray badEntries;
1107 badEntries.pushBack(STObject{sfSignerEntry});
1108 replacement->setFieldArray(sfSignerEntries, badEntries);
1109 view.rawReplace(replacement);
1110 return true;
1111 }));
1112 BEAST_EXPECT(env.le(delegateSignerListKeylet));
1113
1114 json::Value tx = pay(target, bob, XRP(1));
1115 tx[sfDelegate.jsonName] = delegateAcct.human();
1116 env(proposal::create(
1117 ds1,
1118 proposal::unsignedPayload(env, tx, ticketSeq),
1119 proposal::expiration(env, 100s)),
1122 BEAST_EXPECT(!proposal::entry(env, target, ticketSeq));
1123 }
1124
1125 // The target account must be able to authorize a transaction through a
1126 // SignerList, so a pseudo-account (here an AMM's) cannot be a target even
1127 // though it exists on-ledger (On-Chain Cosigner spec §5.3.2.5).
1128 void
1130 {
1131 testcase("reject proposal targeting a pseudo-account");
1132
1133 using namespace jtx;
1134 using namespace std::chrono_literals;
1135
1136 Env env{*this, features};
1137
1138 Account const proposer{"proposer"};
1139 Account const alice{"alice"}; // the AMM creator
1140 Account const gw{"gw"};
1141 Account const bob{"bob"};
1142 // NOLINTNEXTLINE(readability-identifier-naming)
1143 auto const USD = gw["USD"];
1144 env.fund(XRP(10000), proposer, alice, gw, bob);
1145 env.close();
1146 env.trust(USD(1'000'000), alice);
1147 env.close();
1148 env(pay(gw, alice, USD(10'000)));
1149 env.close();
1150
1151 AMM const amm(env, alice, XRP(1'000), USD(1'000), Ter(tesSUCCESS));
1152 env.close();
1153
1154 // A well-formed Payment whose target is the AMM's pseudo-account.
1155 json::Value tx = pay(alice, bob, XRP(1));
1156 tx[jss::Account] = toBase58(amm.ammAccount());
1157 json::Value const proposedTx = proposal::unsignedPayload(env, tx, 1);
1158
1159 env(proposal::create(proposer, proposedTx, proposal::expiration(env, 100s)),
1162 env.close();
1163 }
1164
1165 void
1167 {
1168 testcase("create proposal object");
1169
1170 using namespace jtx;
1171 using namespace std::chrono_literals;
1172
1173 Env env{*this, features};
1174
1175 Account const target{"target"};
1176 Account const bob{"bob"};
1177 env.fund(XRP(10000), target, bob);
1178 env.close();
1179
1180 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1181
1182 // The proposed transaction is stored unsigned: no signature fields and
1183 // an empty SigningPubKey. It is ticket-based so unrelated target account
1184 // activity cannot invalidate it while signatures are collected.
1185 json::Value const proposedTx =
1186 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq);
1187
1188 std::uint32_t const expiration = proposal::expiration(env, 100s);
1189
1190 env(proposal::create(target, proposedTx, expiration), proposal::verify::create());
1191 env.close();
1192
1193 auto const sle = proposal::entry(env, target, targetTicketSeq);
1194 if (!BEAST_EXPECT(sle))
1195 return;
1196
1197 BEAST_EXPECT(sle->getAccountID(sfOwner) == target.id());
1198 BEAST_EXPECT(sle->getFieldU32(sfExpiration) == expiration);
1199
1200 auto const stored = sle->getFieldObject(sfProposedTransaction);
1201 BEAST_EXPECT(stored.getAccountID(sfAccount) == target.id());
1202 BEAST_EXPECT(stored.getFieldU32(sfSequence) == 0);
1203 BEAST_EXPECT(stored.getFieldU32(sfTicketSequence) == targetTicketSeq);
1204 BEAST_EXPECT(stored.getFieldVL(sfSigningPubKey).empty());
1205
1206 // The proposal reserves several owner increments against the proposer,
1207 // which proposal::verify::create() checks. Here target is both: it owns
1208 // the Ticket used by the proposed transaction, and it owns the proposal
1209 // itself since it is proposing for its own account.
1210 BEAST_EXPECT(ownerCount(env, target) == 1 + proposal::kProposalOwnerCount);
1211 }
1212
1213 // A proposal carries a transaction of any type: what the proposal requires
1214 // of the payload — unsigned, ticket-based, fee fixed — is independent of
1215 // the transaction being proposed, so anything a target account's signer
1216 // list could authorize can be proposed for it.
1217 void
1219 {
1220 testcase("proposals for other transaction types");
1221
1222 using namespace jtx;
1223 using namespace std::chrono_literals;
1224
1225 Env env{*this, features};
1226
1227 Account const target{"target"};
1228 Account const bob{"bob"};
1229 Account const gw{"gw"};
1230 // NOLINTNEXTLINE(readability-identifier-naming)
1231 auto const USD = gw["USD"];
1232 env.fund(XRP(10000), target, bob, gw);
1233 env.close();
1234
1235 // One payload per transaction type, each straight from the generator
1236 // the ordinary tests for that type use.
1237 std::vector<json::Value> const payloads{
1238 noop(target), // AccountSet
1239 offer(target, USD(1), XRP(1)), // OfferCreate
1240 trust(target, USD(1000)), // TrustSet
1241 signers(target, 1, {{bob, 1}}), // SignerListSet
1242 deposit::auth(target, bob), // DepositPreauth
1243 token::mint(target, 0), // NFTokenMint
1244 };
1245
1246 // A proposal is keyed by target and ticket, so each payload needs its
1247 // own ticket.
1248 std::uint32_t const firstTicketSeq =
1249 proposal::createTicket(env, target, static_cast<std::uint32_t>(payloads.size()));
1250 std::uint32_t const expiration = proposal::expiration(env, 100s);
1251
1252 for (std::size_t i = 0; i < payloads.size(); ++i)
1253 {
1254 std::uint32_t const ticketSeq = firstTicketSeq + static_cast<std::uint32_t>(i);
1255 env(proposal::create(
1256 target, proposal::unsignedPayload(env, payloads[i], ticketSeq), expiration),
1258 env.close();
1259 }
1260
1261 // target owns one Ticket per payload plus one proposal per payload.
1262 BEAST_EXPECT(
1263 ownerCount(env, target) == payloads.size() * (1 + proposal::kProposalOwnerCount));
1264 }
1265
1266 // A proposed transaction may itself require an auxiliary co-signer beyond
1267 // its own Account: a LoanSet's Counterparty, or the Sponsor of an
1268 // account-level SponsorshipTransfer (On-Chain Cosigner spec §6.1, §6.6.3). That co-signature
1269 // field is collected later via TransactionProposalSign, so — just like
1270 // the ordinary signature fields — it must be absent, not required, at
1271 // creation time.
1272 void
1274 {
1275 testcase("proposal for a transaction type with an auxiliary co-signature");
1276
1277 using namespace jtx;
1278 using namespace std::chrono_literals;
1279
1280 Env env{*this, features};
1281
1282 Account const borrower{"borrower"}; // the target account, proposing for itself
1283 Account const bob{"bob"}; // an arbitrary sponsor placeholder
1284
1285 env.fund(XRP(10000), borrower, bob);
1286 env.close();
1287
1288 std::uint32_t const expiration = proposal::expiration(env, 100s);
1289
1290 // LoanSet: the Counterparty's signature is collected later; it must
1291 // not be required up front.
1292 {
1293 std::uint32_t const ticketSeq = proposal::createTicket(env, borrower);
1294
1295 json::Value const tx =
1296 proposal::unsignedPayload(env, loan::set(borrower, UInt256{1}, 1'000), ticketSeq);
1297
1298 env(proposal::create(borrower, tx, expiration), proposal::verify::create());
1299 env.close();
1300 }
1301
1302 // SponsorshipTransfer (account-level reserve sponsorship): the
1303 // Sponsor's signature is likewise collected later.
1304 {
1305 std::uint32_t const ticketSeq = proposal::createTicket(env, borrower);
1306
1307 json::Value tx = sponsor::transfer(borrower, tfSponsorshipCreate);
1308 tx[sfSponsor.getJsonName()] = bob.human();
1309 tx[sfSponsorFlags.getJsonName()] = spfSponsorReserve;
1310
1311 env(proposal::create(
1312 borrower, proposal::unsignedPayload(env, tx, ticketSeq), expiration),
1314 env.close();
1315 }
1316 }
1317
1318 // The proposer holds the proposal's reserve until it is resolved.
1319 void
1321 {
1322 testcase("proposer reserve");
1323
1324 using namespace jtx;
1325 using namespace std::chrono_literals;
1326
1327 Env env{*this, features};
1328
1329 Account const alice{"alice"};
1330 Account const target{"target"};
1331 Account const bob{"bob"};
1332 env.fund(XRP(10000), target, bob);
1333 env.close();
1334 proposal::authorizeProposer(env, target, alice);
1335
1336 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1337
1338 // Fund alice just short of the reserve the proposal requires.
1339 env.fund(
1340 env.current()->fees().accountReserve(proposal::kProposalOwnerCount, 1) - drops(1),
1341 alice);
1342 env.close();
1343
1344 std::uint32_t const expiration = proposal::expiration(env, 100s);
1345 json::Value const proposedTx =
1346 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq);
1347
1348 env(proposal::create(alice, proposedTx, expiration),
1351 env.close();
1352
1353 env(pay(bob, alice, XRP(10)));
1354 env.close();
1355
1356 env(proposal::create(alice, proposedTx, expiration), proposal::verify::create());
1357 env.close();
1358 }
1359
1360 // A proposer may pay for the Create with one of its own Tickets. The
1361 // Ticket's reserve goes as the proposal's arrives, so the proposer's owner
1362 // count moves by the difference.
1363 void
1365 {
1366 testcase("create paid for with the proposer's own ticket");
1367
1368 using namespace jtx;
1369 using namespace std::chrono_literals;
1370
1371 Env env{*this, features};
1372
1373 Account const alice{"alice"}; // the proposer
1374 Account const target{"target"}; // the account the proposal is for
1375 Account const bob{"bob"};
1376 env.fund(XRP(10000), alice, target, bob);
1377 env.close();
1378 proposal::authorizeProposer(env, target, alice);
1379
1380 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1381 std::uint32_t const aliceTicketSeq = proposal::createTicket(env, alice);
1382 std::uint32_t const aliceSeq = env.seq(alice);
1383 std::uint32_t const targetOwnerCount = ownerCount(env, target);
1384 BEAST_EXPECT(ownerCount(env, alice) == 1);
1385
1386 // The proposal's reserve lands on alice less the Ticket she paid with,
1387 // and her Sequence is untouched.
1388 env(proposal::create(
1389 alice,
1390 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq),
1391 proposal::expiration(env, 100s)),
1392 ticket::Use(aliceTicketSeq),
1394 env.close();
1395
1396 BEAST_EXPECT(proposal::entry(env, target, targetTicketSeq));
1397 BEAST_EXPECT(!env.le(keylet::ticket(alice.id(), SeqProxy::rawTicket(aliceTicketSeq))));
1398 BEAST_EXPECT(env.seq(alice) == aliceSeq);
1399 BEAST_EXPECT(ownerCount(env, alice) == proposal::kProposalOwnerCount);
1400
1401 // The target's Ticket, the one the proposal is keyed to, stays.
1402 BEAST_EXPECT(ownerCount(env, target) == targetOwnerCount);
1403 }
1404
1405 // The proposal's reserve can instead be sponsored: the reserve is charged
1406 // to the sponsor's account, and the ledger object records the sponsor, the
1407 // same as any other reserve-sponsorable object (TransactionProposalCreate
1408 // is on the reserve-sponsorship allow-list).
1409 void
1411 {
1412 testcase("proposer reserve sponsored");
1413
1414 using namespace jtx;
1415 using namespace std::chrono_literals;
1416
1417 // Reserve sponsorship requires the Sponsor amendment, independent of
1418 // Cosign: with Cosign enabled but Sponsor disabled, a proposal that
1419 // tries to attach a sponsor is rejected before it ever reaches the
1420 // reserve-sponsorship allow-list.
1421 {
1422 Env env{*this, features - featureSponsor};
1423
1424 Account const alice{"alice"};
1425 Account const target{"target"};
1426 Account const bob{"bob"};
1427 Account const backer{"backer"};
1428 env.fund(XRP(10000), alice, target, bob, backer);
1429 env.close();
1430 proposal::authorizeProposer(env, target, alice);
1431
1432 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1433 json::Value const proposedTx =
1434 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq);
1435
1436 env(proposal::create(alice, proposedTx, proposal::expiration(env, 100s)),
1438 Sig(sfSponsorSignature, backer),
1441 env.close();
1442 BEAST_EXPECT(!proposal::entry(env, target, targetTicketSeq));
1443 }
1444
1445 Env env{*this, features};
1446
1447 Account const alice{"alice"}; // the proposer
1448 Account const target{"target"}; // the account the proposal is for
1449 Account const bob{"bob"};
1450 Account const backer{"backer"}; // sponsors alice's proposal reserve
1451
1452 env.fund(XRP(10000), alice, target, bob, backer);
1453 env.close();
1454 proposal::authorizeProposer(env, target, alice);
1455
1456 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1457 json::Value const proposedTx =
1458 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq);
1459
1460 env(proposal::create(alice, proposedTx, proposal::expiration(env, 100s)),
1462 Sig(sfSponsorSignature, backer),
1464 env.close();
1465
1466 auto const sle = proposal::entry(env, target, targetTicketSeq);
1467 if (!BEAST_EXPECT(sle))
1468 return;
1469
1470 BEAST_EXPECT(sle->isFieldPresent(sfSponsor));
1471 BEAST_EXPECT(sle->getAccountID(sfSponsor) == backer.id());
1472
1473 // alice still owns the proposal — her OwnerCount reflects that, same
1474 // as an unsponsored proposal. What moves to the sponsor is the
1475 // reserve requirement itself, tracked separately: alice's owner count
1476 // is covered by backer's sponsorship rather than her own balance.
1477 BEAST_EXPECT(ownerCount(env, alice) == proposal::kProposalOwnerCount);
1478 BEAST_EXPECT(ownerCount(env, backer) == 0);
1479 BEAST_EXPECT(sponsoredOwnerCount(env, alice) == proposal::kProposalOwnerCount);
1480 BEAST_EXPECT(sponsoringOwnerCount(env, backer) == proposal::kProposalOwnerCount);
1481 }
1482
1483 // A proposal's sponsored reserve can be reassigned to a new sponsor
1484 // through SponsorshipTransfer, the same as any other reserve-sponsored
1485 // ledger entry.
1486 void
1488 {
1489 testcase("proposer reserve sponsorship transferred");
1490
1491 using namespace jtx;
1492 using namespace std::chrono_literals;
1493
1494 Env env{*this, features};
1495
1496 Account const alice{"alice"}; // the proposer
1497 Account const target{"target"}; // the account the proposal is for
1498 Account const bob{"bob"};
1499 Account const backer1{"backer1"}; // the original sponsor
1500 Account const backer2{"backer2"}; // the new sponsor
1501
1502 env.fund(XRP(10000), alice, target, bob, backer1, backer2);
1503 env.close();
1504 proposal::authorizeProposer(env, target, alice);
1505
1506 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1507 json::Value const proposedTx =
1508 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq);
1509
1510 env(proposal::create(alice, proposedTx, proposal::expiration(env, 100s)),
1512 Sig(sfSponsorSignature, backer1),
1514 env.close();
1515
1516 BEAST_EXPECT(sponsoringOwnerCount(env, backer1) == proposal::kProposalOwnerCount);
1517 BEAST_EXPECT(sponsoringOwnerCount(env, backer2) == 0);
1518
1519 Keylet const proposalKeylet = keylet::txProposal(target.id(), targetTicketSeq);
1520
1521 env(sponsor::transfer(alice, tfSponsorshipReassign, proposalKeylet.key),
1523 Sig(sfSponsorSignature, backer2));
1524 env.close();
1525
1526 auto const sle = proposal::entry(env, target, targetTicketSeq);
1527 if (!BEAST_EXPECT(sle))
1528 return;
1529
1530 BEAST_EXPECT(sle->isFieldPresent(sfSponsor));
1531 BEAST_EXPECT(sle->getAccountID(sfSponsor) == backer2.id());
1532
1533 // alice's own OwnerCount is unaffected by the reassignment: only the
1534 // sponsor of the redirected reserve changes.
1535 BEAST_EXPECT(ownerCount(env, alice) == proposal::kProposalOwnerCount);
1536 BEAST_EXPECT(sponsoredOwnerCount(env, alice) == proposal::kProposalOwnerCount);
1537 BEAST_EXPECT(sponsoringOwnerCount(env, backer1) == 0);
1538 BEAST_EXPECT(sponsoringOwnerCount(env, backer2) == proposal::kProposalOwnerCount);
1539 }
1540
1541 // TransactionProposalCreate's own transaction fee can be sponsored like
1542 // any other transaction's, independent of whether its reserve is
1543 // sponsored (On-Chain Cosigner spec sponsorship is orthogonal to fee
1544 // sponsorship).
1545 void
1547 {
1548 testcase("proposal creation fee sponsored");
1549
1550 using namespace jtx;
1551 using namespace std::chrono_literals;
1552
1553 Env env{*this, features};
1554
1555 Account const target{"target"}; // the proposer, proposing for itself
1556 Account const bob{"bob"};
1557 Account const backer{"backer"}; // sponsors target's transaction fee
1558
1559 env.fund(XRP(10000), target, bob, backer);
1560 env.close();
1561
1562 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1563 json::Value const proposedTx =
1564 proposal::unsignedPayload(env, pay(target, bob, XRP(1)), targetTicketSeq);
1565
1566 auto const targetBalance = env.balance(target);
1567 auto const backerBalance = env.balance(backer);
1568 // A generous fixed fee: the exact amount isn't the point of this
1569 // test, only that the sponsor pays it instead of the proposer, so it
1570 // should comfortably clear the minimum even under local fee escalation
1571 // rather than assume the reference fee is some specific small value.
1572 STAmount const feeAmt = XRP(1);
1573
1574 env(proposal::create(target, proposedTx, proposal::expiration(env, 100s)),
1575 Fee(feeAmt),
1576 sponsor::As(backer, spfSponsorFee),
1577 Sig(sfSponsorSignature, backer),
1579 env.close();
1580
1581 BEAST_EXPECT(proposal::entry(env, target, targetTicketSeq));
1582 BEAST_EXPECT(env.balance(target) == targetBalance);
1583 BEAST_EXPECT(env.balance(backer) == backerBalance - feeAmt);
1584 }
1585
1586 // A proposed Batch holds several inner transactions and the signatures of
1587 // every account they touch, so it reserves more than an ordinary proposal.
1588 void
1590 {
1591 testcase("proposed batch reserve");
1592
1593 using namespace jtx;
1594 using namespace std::chrono_literals;
1595
1596 Env env{*this, features};
1597
1598 Account const target{"target"};
1599 Account const bob{"bob"};
1600 env.fund(XRP(10000), target, bob);
1601 env.close();
1602
1603 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1604
1605 // Both inner transactions are the outer account's own, so no further
1606 // signatures will be collected for them.
1607 json::Value const proposedTx = proposal::unsignedBatch(
1608 env,
1609 target,
1610 targetTicketSeq,
1611 tfAllOrNothing,
1612 {
1613 proposal::innerTx(pay(target, bob, XRP(1)), env.seq(target)),
1614 proposal::innerTx(pay(target, bob, XRP(1)), env.seq(target) + 1),
1615 });
1616
1617 env(proposal::create(target, proposedTx, proposal::expiration(env, 100s)),
1619 env.close();
1620
1621 // target owns its own Ticket plus the batch proposal.
1622 BEAST_EXPECT(ownerCount(env, target) == 1 + proposal::kBatchProposalOwnerCount);
1623 }
1624
1625 // A multi-account Batch is the primary motivating case (On-Chain Cosigner spec §10): its inner
1626 // transactions touch accounts other than the outer one, so submitting it
1627 // directly would require a BatchSigners entry per participant. A proposal is
1628 // stored unsigned, so those signatures are collected on-ledger afterward and
1629 // the signer-presence match is skipped at creation time (On-Chain Cosigner spec §5.3.1.2).
1630 void
1632 {
1633 testcase("proposed multi-account batch");
1634
1635 using namespace jtx;
1636 using namespace std::chrono_literals;
1637
1638 Env env{*this, features};
1639
1640 Account const target{"target"}; // outer account of the batch, proposing for itself
1641 Account const bob{"bob"}; // a distinct inner participant
1642 env.fund(XRP(10000), target, bob);
1643 env.close();
1644
1645 std::uint32_t const targetTicketSeq = proposal::createTicket(env, target);
1646
1647 // One inner from the outer account, one from bob: bob is a required
1648 // signer, so a direct submission would need his BatchSigners entry.
1649 json::Value const proposedTx = proposal::unsignedBatch(
1650 env,
1651 target,
1652 targetTicketSeq,
1653 tfAllOrNothing,
1654 {
1655 proposal::innerTx(pay(target, bob, XRP(1)), env.seq(target)),
1656 proposal::innerTx(pay(bob, target, XRP(1)), env.seq(bob)),
1657 });
1658
1659 env(proposal::create(target, proposedTx, proposal::expiration(env, 100s)),
1661 env.close();
1662
1663 auto const sle = proposal::entry(env, target, targetTicketSeq);
1664 if (!BEAST_EXPECT(sle))
1665 return;
1666
1667 // The proposal is stored without any BatchSigners: the participants'
1668 // signatures are collected later through TransactionProposalSign.
1669 auto const stored = sle->getFieldObject(sfProposedTransaction);
1670 BEAST_EXPECT(!stored.isFieldPresent(sfBatchSigners));
1671 // target owns its own Ticket plus the batch proposal.
1672 BEAST_EXPECT(ownerCount(env, target) == 1 + proposal::kBatchProposalOwnerCount);
1673 }
1674
1675 // A proposed Batch's inner preflight must receive TapProposal, or an
1676 // unsigned account-reserve SponsorshipTransfer is rejected at Create
1677 // (On-Chain Cosigner spec §6.1.1: an inner Sponsor is a collectable
1678 // signature slot). Other inner types that do not key on TapProposal keep
1679 // their existing preflight result.
1680 void
1682 {
1683 testcase("proposed batch inner account-reserve SponsorshipTransfer");
1684
1685 using namespace jtx;
1686 using namespace std::chrono_literals;
1687
1688 Env env{*this, features};
1689
1690 Account const target{"target"};
1691 Account const bob{"bob"}; // named as Sponsor; signature collected later
1692 env.fund(XRP(10000), target, bob);
1693 env.close();
1694
1695 auto const unsignedInnerSponsorship = [&](Account const& account) {
1696 json::Value tx = sponsor::transfer(account, tfSponsorshipCreate);
1697 tx[sfSponsor.getJsonName()] = bob.human();
1698 tx[sfSponsorFlags.getJsonName()] = spfSponsorReserve;
1699 return tx;
1700 };
1701
1702 // Payment (unaffected by TapProposal) plus an unsigned inner
1703 // account-reserve SponsorshipTransfer. Create succeeds only if
1704 // TapProposal reaches the inner.
1705 {
1706 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
1707 auto const seq = env.seq(target);
1708 json::Value const proposedTx = proposal::unsignedBatch(
1709 env,
1710 target,
1711 ticketSeq,
1712 tfAllOrNothing,
1713 {
1714 proposal::innerTx(pay(target, bob, XRP(1)), seq),
1715 proposal::innerTx(unsignedInnerSponsorship(target), seq + 1),
1716 });
1717
1718 env(proposal::create(target, proposedTx, proposal::expiration(env, 100s)),
1720 env.close();
1721 BEAST_EXPECT(proposal::entry(env, target, ticketSeq));
1722 }
1723
1724 // Structural inner failures are unchanged: missing sfSponsor is still
1725 // temMALFORMED in SponsorshipTransfer::preflight, collapsed by Batch
1726 // to temINVALID_INNER_BATCH. TapProposal does not skip that.
1727 {
1728 std::uint32_t const ticketSeq = proposal::createTicket(env, target);
1729 auto const seq = env.seq(target);
1730 json::Value const proposedTx = proposal::unsignedBatch(
1731 env,
1732 target,
1733 ticketSeq,
1734 tfAllOrNothing,
1735 {
1736 proposal::innerTx(pay(target, bob, XRP(1)), seq),
1737 proposal::innerTx(sponsor::transfer(target, tfSponsorshipCreate), seq + 1),
1738 });
1739
1740 env(proposal::create(target, proposedTx, proposal::expiration(env, 100s)),
1743 env.close();
1744 BEAST_EXPECT(!proposal::entry(env, target, ticketSeq));
1745 }
1746 }
1747
1748 void
1749 run() override
1750 {
1751 using namespace jtx;
1752
1753 FeatureBitset const all{testableAmendments()};
1754
1756
1757 // Preflight
1758 testDisabled(all);
1761
1762 // Preclaim
1763 testPreclaim(all);
1769 testPseudoTarget(all);
1770
1771 // Apply
1772 testCreate(all);
1775 testReserve(all);
1776 testTicketedCreate(all);
1779 testFeeSponsored(all);
1780 testBatchReserve(all);
1783 }
1784};
1785
1787
1788} // namespace xrpl::test
T at(T... args)
A generic endpoint for log messages.
Definition Journal.h:44
A testsuite class.
Definition suite.h:52
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
Represents a JSON value.
Definition json_value.h:121
Value removeMember(char const *key)
Remove and return the named member.
bool modify(ModifyType const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:59
void rawReplace(SLE::Ref sle) override
Unconditionally replace a state item.
Definition OpenView.cpp:246
Slice slice() const noexcept
Definition PublicKey.h:115
void push_back(STObject const &object)
Definition STArray.h:79
void setAccountID(SField const &field, AccountID const &)
Definition STObject.cpp:785
static constexpr SeqProxy rawTicket(std::uint32_t v)
Factory function to return a ticket-based SeqProxy.
Definition SeqProxy.h:74
virtual OpenLedger & getOpenLedger()=0
Convenience class to test AMM functionality.
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
std::string const & human() const
Returns the human readable public key.
PublicKey const & pk() const
Return the public key.
Definition jtx/Account.h:84
AccountID id() const
Returns the Account ID.
A transaction testing environment.
Definition Env.h:161
Application & app()
Definition Env.h:300
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:133
SLE::const_pointer le(Account const &account) const
Return an account root.
Definition Env.cpp:311
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:323
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:302
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition Env.cpp:201
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:354
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:377
Set the fee on a JTx.
Definition fee.h:20
Set the regular signature on a JTx.
Definition sig.h:19
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition ter.h:18
Set a ticket sequence on a JTx.
Definition ticket.h:36
@ Object
object value (collection of name/value pairs).
Definition json_value.h:33
Keylet signerList(AccountID const &account) noexcept
A SignerList.
Definition Indexes.cpp:360
Keylet txProposal(AccountID const &target, std::uint32_t ticketSequence) noexcept
A TransactionProposal.
Definition Indexes.cpp:378
Keylet ticket(AccountID const &id, SeqProxy const &ticketSeq)
A ticket belonging to an account.
Definition Indexes.cpp:344
bool isValidProposalTxnType(STObject const &proposedTx)
Whether the proposed transaction is independently submittable through the ordinary multi-sign path: n...
Helpers for constructing Batch test transactions.
Definition batch.h:26
json::Value set(jtx::Account const &account, jtx::Account const &authorize, std::vector< std::string > const &permissions)
Definition delegate.cpp:17
json::Value auth(Account const &account, Account const &auth)
Preauthorize for deposit.
Definition deposit.cpp:16
json::Value set(AccountID const &account, UInt256 const &loanBrokerID, Number principalRequested, std::uint32_t flags)
Create create()
Check the ledger effects a TransactionProposalCreate must have, whatever its outcome: on tesSUCCESS a...
Definition proposal.h:89
json::Value innerTx(json::Value tx, std::uint32_t seq)
Put a transaction into the form an inner transaction of a proposed Batch takes, as batch::Inner does ...
Definition proposal.cpp:80
std::uint32_t createTicket(Env &env, Account const &account, std::uint32_t count)
Create tickets for a proposal to be built against, and close the ledger.
Definition proposal.cpp:128
json::Value unsignedPayload(Env const &env, json::Value tx, std::uint32_t ticketSeq)
Put a transaction of any type into the form a proposal stores it in: unsigned and ticket-based,...
Definition proposal.cpp:61
constexpr std::uint32_t kBatchProposalOwnerCount
Owner-reserve increments held by a proposal of a Batch transaction.
constexpr std::uint32_t kProposalOwnerCount
Owner-reserve increments held by a proposal of an ordinary transaction.
SLE::const_pointer entry(Env const &env, AccountID const &target, std::uint32_t ticketSeq)
The proposal stored against a target account's ticket.
Definition proposal.cpp:145
json::Value create(Account const &proposer, json::Value const &proposedTx, std::uint32_t expiration)
Build a TransactionProposalCreate carrying an unsigned proposed transaction.
Definition proposal.cpp:40
void authorizeProposer(Env &env, Account const &target, Account const &proposer)
Give proposer a place on target's SignerList, so it may create proposals against target.
Definition proposal.cpp:121
json::Value unsignedBatch(Env const &env, Account const &target, std::uint32_t ticketSeq, std::uint32_t flags, std::vector< json::Value > const &inners, std::optional< std::uint32_t > numSigners)
An unsigned outer Batch payload holding inners.
Definition proposal.cpp:86
std::uint32_t expiration(Env &env, NetClock::duration delta)
An absolute expiration delta past the environment's current time.
Definition proposal.cpp:139
json::Value transfer(jtx::Account const &account, uint32_t flags, std::optional< UInt256 > const &index)
Definition sponsor.cpp:52
json::Value mint(jtx::Account const &account, std::uint32_t nfTokenTaxon)
Mint an NFToken.
Definition token.cpp:23
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:14
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
json::Value noop(Account const &account)
The null transaction.
Definition noop.h:14
std::uint32_t ownerCount(Env const &env, Account const &account)
std::uint32_t sponsoringOwnerCount(Env const &env, Account const &account)
FeatureBitset testableAmendments()
Definition Env.h:92
json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
Definition offer.cpp:14
std::uint32_t sponsoredOwnerCount(Env const &env, Account const &account)
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:18
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
json::Value signers(Account const &account, std::uint32_t quorum, std::vector< Signer > const &v)
Definition multisign.cpp:31
json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition flags.cpp:15
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr FlagValue spfSponsorFee
Definition TxFlags.h:467
constexpr FlagValue tfInnerBatchTxn
Definition TxFlags.h:44
ApplyResult apply(ServiceRegistry &registry, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
Definition apply.cpp:181
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:13
@ tefBAD_LEDGER
Definition TER.h:164
@ tefNO_TICKET
Definition TER.h:179
SField const sfGeneric
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition AccountID.cpp:95
BaseUInt< 256 > UInt256
Definition base_uint.h:581
@ temBAD_EXPIRATION
Definition TER.h:79
@ temINVALID
Definition TER.h:98
@ temMALFORMED
Definition TER.h:75
@ temSEQ_AND_TICKET
Definition TER.h:114
@ temDISABLED
Definition TER.h:102
@ temBAD_AMOUNT
Definition TER.h:77
@ temINVALID_INNER_BATCH
Definition TER.h:131
@ temBAD_SIGNER
Definition TER.h:103
TERSubset< CanCvtToTER > TER
Definition TER.h:657
@ tecNO_TARGET
Definition TER.h:315
@ tecEXPIRED
Definition TER.h:325
@ tecINSUFFICIENT_RESERVE
Definition TER.h:318
@ tecNO_PERMISSION
Definition TER.h:316
@ tecDUPLICATE
Definition TER.h:326
constexpr FlagValue spfSponsorReserve
Definition TxFlags.h:468
@ tesSUCCESS
Definition TER.h:253
T size(T... args)
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
UInt256 key
Definition Keylet.h:21