rippled
PayChan.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/app/tx/impl/PayChan.h>
21 #include <ripple/basics/Log.h>
22 #include <ripple/basics/XRPAmount.h>
23 #include <ripple/basics/chrono.h>
24 #include <ripple/ledger/ApplyView.h>
25 #include <ripple/ledger/View.h>
26 #include <ripple/protocol/Feature.h>
27 #include <ripple/protocol/Indexes.h>
28 #include <ripple/protocol/PayChan.h>
29 #include <ripple/protocol/PublicKey.h>
30 #include <ripple/protocol/TxFlags.h>
31 #include <ripple/protocol/digest.h>
32 #include <ripple/protocol/st.h>
33 
34 namespace ripple {
35 
36 /*
37  PaymentChannel
38 
39  Payment channels permit off-ledger checkpoints of XRP payments flowing
40  in a single direction. A channel sequesters the owner's XRP in its own
41  ledger entry. The owner can authorize the recipient to claim up to a
42  given balance by giving the receiver a signed message (off-ledger). The
43  recipient can use this signed message to claim any unpaid balance while
44  the channel remains open. The owner can top off the line as needed. If
45  the channel has not paid out all its funds, the owner must wait out a
46  delay to close the channel to give the recipient a chance to supply any
47  claims. The recipient can close the channel at any time. Any transaction
48  that touches the channel after the expiration time will close the
49  channel. The total amount paid increases monotonically as newer claims
50  are issued. When the channel is closed any remaining balance is returned
51  to the owner. Channels are intended to permit intermittent off-ledger
52  settlement of ILP trust lines as balances get substantial. For
53  bidirectional channels, a payment channel can be used in each direction.
54 
55  PaymentChannelCreate
56 
57  Create a unidirectional channel. The parameters are:
58  Destination
59  The recipient at the end of the channel.
60  Amount
61  The amount of XRP to deposit in the channel immediately.
62  SettleDelay
63  The amount of time everyone but the recipient must wait for a
64  superior claim.
65  PublicKey
66  The key that will sign claims against the channel.
67  CancelAfter (optional)
68  Any channel transaction that touches this channel after the
69  `CancelAfter` time will close it.
70  DestinationTag (optional)
71  Destination tags allow the different accounts inside of a Hosted
72  Wallet to be mapped back onto the Ripple ledger. The destination tag
73  tells the server to which account in the Hosted Wallet the funds are
74  intended to go to. Required if the destination has lsfRequireDestTag
75  set.
76  SourceTag (optional)
77  Source tags allow the different accounts inside of a Hosted Wallet
78  to be mapped back onto the Ripple ledger. Source tags are similar to
79  destination tags but are for the channel owner to identify their own
80  transactions.
81 
82  PaymentChannelFund
83 
84  Add additional funds to the payment channel. Only the channel owner may
85  use this transaction. The parameters are:
86  Channel
87  The 256-bit ID of the channel.
88  Amount
89  The amount of XRP to add.
90  Expiration (optional)
91  Time the channel closes. The transaction will fail if the expiration
92  times does not satisfy the SettleDelay constraints.
93 
94  PaymentChannelClaim
95 
96  Place a claim against an existing channel. The parameters are:
97  Channel
98  The 256-bit ID of the channel.
99  Balance (optional)
100  The total amount of XRP delivered after this claim is processed
101  (optional, not needed if just closing). Amount (optional) The amount of XRP
102  the signature is for (not needed if equal to Balance or just closing the
103  line). Signature (optional) Authorization for the balance above, signed by
104  the owner (optional, not needed if closing or owner is performing the
105  transaction). The signature if for the following message: CLM\0 followed by
106  the 256-bit channel ID, and a 64-bit integer drops. PublicKey (optional) The
107  public key that made the signature (optional, required if a signature is
108  present) Flags tfClose Request that the channel be closed tfRenew Request
109  that the channel's expiration be reset. Only the owner may renew a channel.
110 
111 */
112 
113 //------------------------------------------------------------------------------
114 
115 static TER
117  std::shared_ptr<SLE> const& slep,
118  ApplyView& view,
119  uint256 const& key,
120  beast::Journal j)
121 {
122  AccountID const src = (*slep)[sfAccount];
123  // Remove PayChan from owner directory
124  {
125  auto const page = (*slep)[sfOwnerNode];
126  if (!view.dirRemove(keylet::ownerDir(src), page, key, true))
127  {
128  JLOG(j.fatal())
129  << "Could not remove paychan from src owner directory";
130  return tefBAD_LEDGER;
131  }
132  }
133 
134  // Remove PayChan from recipient's owner directory, if present.
135  if (auto const page = (*slep)[~sfDestinationNode];
136  page && view.rules().enabled(fixPayChanRecipientOwnerDir))
137  {
138  auto const dst = (*slep)[sfDestination];
139  if (!view.dirRemove(keylet::ownerDir(dst), *page, key, true))
140  {
141  JLOG(j.fatal())
142  << "Could not remove paychan from dst owner directory";
143  return tefBAD_LEDGER;
144  }
145  }
146 
147  // Transfer amount back to owner, decrement owner count
148  auto const sle = view.peek(keylet::account(src));
149  if (!sle)
150  return tefINTERNAL;
151 
152  assert((*slep)[sfAmount] >= (*slep)[sfBalance]);
153  (*sle)[sfBalance] =
154  (*sle)[sfBalance] + (*slep)[sfAmount] - (*slep)[sfBalance];
155  adjustOwnerCount(view, sle, -1, j);
156  view.update(sle);
157 
158  // Remove PayChan from ledger
159  view.erase(slep);
160  return tesSUCCESS;
161 }
162 
163 //------------------------------------------------------------------------------
164 
165 NotTEC
167 {
168  if (ctx.rules.enabled(fix1543) && ctx.tx.getFlags() & tfUniversalMask)
169  return temINVALID_FLAG;
170 
171  auto const ret = preflight1(ctx);
172  if (!isTesSuccess(ret))
173  return ret;
174 
175  if (!isXRP(ctx.tx[sfAmount]) || (ctx.tx[sfAmount] <= beast::zero))
176  return temBAD_AMOUNT;
177 
178  if (ctx.tx[sfAccount] == ctx.tx[sfDestination])
179  return temDST_IS_SRC;
180 
181  if (!publicKeyType(ctx.tx[sfPublicKey]))
182  return temMALFORMED;
183 
184  return preflight2(ctx);
185 }
186 
187 TER
189 {
190  auto const account = ctx.tx[sfAccount];
191  auto const sle = ctx.view.read(keylet::account(account));
192  if (!sle)
193  return terNO_ACCOUNT;
194 
195  // Check reserve and funds availability
196  {
197  auto const balance = (*sle)[sfBalance];
198  auto const reserve =
199  ctx.view.fees().accountReserve((*sle)[sfOwnerCount] + 1);
200 
201  if (balance < reserve)
203 
204  if (balance < reserve + ctx.tx[sfAmount])
205  return tecUNFUNDED;
206  }
207 
208  auto const dst = ctx.tx[sfDestination];
209 
210  {
211  // Check destination account
212  auto const sled = ctx.view.read(keylet::account(dst));
213  if (!sled)
214  return tecNO_DST;
215  if (((*sled)[sfFlags] & lsfRequireDestTag) &&
216  !ctx.tx[~sfDestinationTag])
217  return tecDST_TAG_NEEDED;
218 
219  // Obeying the lsfDisallowXRP flag was a bug. Piggyback on
220  // featureDepositAuth to remove the bug.
221  if (!ctx.view.rules().enabled(featureDepositAuth) &&
222  ((*sled)[sfFlags] & lsfDisallowXRP))
223  return tecNO_TARGET;
224  }
225 
226  return tesSUCCESS;
227 }
228 
229 TER
231 {
232  auto const account = ctx_.tx[sfAccount];
233  auto const sle = ctx_.view().peek(keylet::account(account));
234  if (!sle)
235  return tefINTERNAL;
236 
237  auto const dst = ctx_.tx[sfDestination];
238 
239  // Create PayChan in ledger
240  auto const slep = std::make_shared<SLE>(
241  keylet::payChan(account, dst, (*sle)[sfSequence] - 1));
242  // Funds held in this channel
243  (*slep)[sfAmount] = ctx_.tx[sfAmount];
244  // Amount channel has already paid
245  (*slep)[sfBalance] = ctx_.tx[sfAmount].zeroed();
246  (*slep)[sfAccount] = account;
247  (*slep)[sfDestination] = dst;
248  (*slep)[sfSettleDelay] = ctx_.tx[sfSettleDelay];
249  (*slep)[sfPublicKey] = ctx_.tx[sfPublicKey];
250  (*slep)[~sfCancelAfter] = ctx_.tx[~sfCancelAfter];
251  (*slep)[~sfSourceTag] = ctx_.tx[~sfSourceTag];
253 
254  ctx_.view().insert(slep);
255 
256  // Add PayChan to owner directory
257  {
258  auto const page = dirAdd(
259  ctx_.view(),
260  keylet::ownerDir(account),
261  slep->key(),
262  false,
263  describeOwnerDir(account),
264  ctx_.app.journal("View"));
265  if (!page)
266  return tecDIR_FULL;
267  (*slep)[sfOwnerNode] = *page;
268  }
269 
270  // Add PayChan to the recipient's owner directory
272  {
273  auto const page = dirAdd(
274  ctx_.view(),
275  keylet::ownerDir(dst),
276  slep->key(),
277  false,
278  describeOwnerDir(dst),
279  ctx_.app.journal("View"));
280  if (!page)
281  return tecDIR_FULL;
282  (*slep)[sfDestinationNode] = *page;
283  }
284 
285  // Deduct owner's balance, increment owner count
286  (*sle)[sfBalance] = (*sle)[sfBalance] - ctx_.tx[sfAmount];
287  adjustOwnerCount(ctx_.view(), sle, 1, ctx_.journal);
288  ctx_.view().update(sle);
289 
290  return tesSUCCESS;
291 }
292 
293 //------------------------------------------------------------------------------
294 
295 NotTEC
297 {
298  if (ctx.rules.enabled(fix1543) && ctx.tx.getFlags() & tfUniversalMask)
299  return temINVALID_FLAG;
300 
301  auto const ret = preflight1(ctx);
302  if (!isTesSuccess(ret))
303  return ret;
304 
305  if (!isXRP(ctx.tx[sfAmount]) || (ctx.tx[sfAmount] <= beast::zero))
306  return temBAD_AMOUNT;
307 
308  return preflight2(ctx);
309 }
310 
311 TER
313 {
314  Keylet const k(ltPAYCHAN, ctx_.tx[sfPayChannel]);
315  auto const slep = ctx_.view().peek(k);
316  if (!slep)
317  return tecNO_ENTRY;
318 
319  AccountID const src = (*slep)[sfAccount];
320  auto const txAccount = ctx_.tx[sfAccount];
321  auto const expiration = (*slep)[~sfExpiration];
322 
323  {
324  auto const cancelAfter = (*slep)[~sfCancelAfter];
325  auto const closeTime =
327  if ((cancelAfter && closeTime >= *cancelAfter) ||
328  (expiration && closeTime >= *expiration))
329  return closeChannel(
330  slep, ctx_.view(), k.key, ctx_.app.journal("View"));
331  }
332 
333  if (src != txAccount)
334  // only the owner can add funds or extend
335  return tecNO_PERMISSION;
336 
337  if (auto extend = ctx_.tx[~sfExpiration])
338  {
339  auto minExpiration =
341  (*slep)[sfSettleDelay];
342  if (expiration && *expiration < minExpiration)
343  minExpiration = *expiration;
344 
345  if (*extend < minExpiration)
346  return temBAD_EXPIRATION;
347  (*slep)[~sfExpiration] = *extend;
348  ctx_.view().update(slep);
349  }
350 
351  auto const sle = ctx_.view().peek(keylet::account(txAccount));
352  if (!sle)
353  return tefINTERNAL;
354 
355  {
356  // Check reserve and funds availability
357  auto const balance = (*sle)[sfBalance];
358  auto const reserve =
360 
361  if (balance < reserve)
363 
364  if (balance < reserve + ctx_.tx[sfAmount])
365  return tecUNFUNDED;
366  }
367 
368  // do not allow adding funds if dst does not exist
369  if (AccountID const dst = (*slep)[sfDestination];
370  !ctx_.view().read(keylet::account(dst)))
371  {
372  return tecNO_DST;
373  }
374 
375  (*slep)[sfAmount] = (*slep)[sfAmount] + ctx_.tx[sfAmount];
376  ctx_.view().update(slep);
377 
378  (*sle)[sfBalance] = (*sle)[sfBalance] - ctx_.tx[sfAmount];
379  ctx_.view().update(sle);
380 
381  return tesSUCCESS;
382 }
383 
384 //------------------------------------------------------------------------------
385 
386 NotTEC
388 {
389  auto const ret = preflight1(ctx);
390  if (!isTesSuccess(ret))
391  return ret;
392 
393  auto const bal = ctx.tx[~sfBalance];
394  if (bal && (!isXRP(*bal) || *bal <= beast::zero))
395  return temBAD_AMOUNT;
396 
397  auto const amt = ctx.tx[~sfAmount];
398  if (amt && (!isXRP(*amt) || *amt <= beast::zero))
399  return temBAD_AMOUNT;
400 
401  if (bal && amt && *bal > *amt)
402  return temBAD_AMOUNT;
403 
404  {
405  auto const flags = ctx.tx.getFlags();
406 
407  if (ctx.rules.enabled(fix1543) && (flags & tfPayChanClaimMask))
408  return temINVALID_FLAG;
409 
410  if ((flags & tfClose) && (flags & tfRenew))
411  return temMALFORMED;
412  }
413 
414  if (auto const sig = ctx.tx[~sfSignature])
415  {
416  if (!(ctx.tx[~sfPublicKey] && bal))
417  return temMALFORMED;
418 
419  // Check the signature
420  // The signature isn't needed if txAccount == src, but if it's
421  // present, check it
422 
423  auto const reqBalance = bal->xrp();
424  auto const authAmt = amt ? amt->xrp() : reqBalance;
425 
426  if (reqBalance > authAmt)
427  return temBAD_AMOUNT;
428 
429  Keylet const k(ltPAYCHAN, ctx.tx[sfPayChannel]);
430  if (!publicKeyType(ctx.tx[sfPublicKey]))
431  return temMALFORMED;
432  PublicKey const pk(ctx.tx[sfPublicKey]);
433  Serializer msg;
434  serializePayChanAuthorization(msg, k.key, authAmt);
435  if (!verify(pk, msg.slice(), *sig, /*canonical*/ true))
436  return temBAD_SIGNATURE;
437  }
438 
439  return preflight2(ctx);
440 }
441 
442 TER
444 {
445  Keylet const k(ltPAYCHAN, ctx_.tx[sfPayChannel]);
446  auto const slep = ctx_.view().peek(k);
447  if (!slep)
448  return tecNO_TARGET;
449 
450  AccountID const src = (*slep)[sfAccount];
451  AccountID const dst = (*slep)[sfDestination];
452  AccountID const txAccount = ctx_.tx[sfAccount];
453 
454  auto const curExpiration = (*slep)[~sfExpiration];
455  {
456  auto const cancelAfter = (*slep)[~sfCancelAfter];
457  auto const closeTime =
459  if ((cancelAfter && closeTime >= *cancelAfter) ||
460  (curExpiration && closeTime >= *curExpiration))
461  return closeChannel(
462  slep, ctx_.view(), k.key, ctx_.app.journal("View"));
463  }
464 
465  if (txAccount != src && txAccount != dst)
466  return tecNO_PERMISSION;
467 
468  if (ctx_.tx[~sfBalance])
469  {
470  auto const chanBalance = slep->getFieldAmount(sfBalance).xrp();
471  auto const chanFunds = slep->getFieldAmount(sfAmount).xrp();
472  auto const reqBalance = ctx_.tx[sfBalance].xrp();
473 
474  if (txAccount == dst && !ctx_.tx[~sfSignature])
475  return temBAD_SIGNATURE;
476 
477  if (ctx_.tx[~sfSignature])
478  {
479  PublicKey const pk((*slep)[sfPublicKey]);
480  if (ctx_.tx[sfPublicKey] != pk)
481  return temBAD_SIGNER;
482  }
483 
484  if (reqBalance > chanFunds)
485  return tecUNFUNDED_PAYMENT;
486 
487  if (reqBalance <= chanBalance)
488  // nothing requested
489  return tecUNFUNDED_PAYMENT;
490 
491  auto const sled = ctx_.view().peek(keylet::account(dst));
492  if (!sled)
493  return tecNO_DST;
494 
495  // Obeying the lsfDisallowXRP flag was a bug. Piggyback on
496  // featureDepositAuth to remove the bug.
497  bool const depositAuth{ctx_.view().rules().enabled(featureDepositAuth)};
498  if (!depositAuth &&
499  (txAccount == src && (sled->getFlags() & lsfDisallowXRP)))
500  return tecNO_TARGET;
501 
502  // Check whether the destination account requires deposit authorization.
503  if (depositAuth && (sled->getFlags() & lsfDepositAuth))
504  {
505  // A destination account that requires authorization has two
506  // ways to get a Payment Channel Claim into the account:
507  // 1. If Account == Destination, or
508  // 2. If Account is deposit preauthorized by destination.
509  if (txAccount != dst)
510  {
511  if (!view().exists(keylet::depositPreauth(dst, txAccount)))
512  return tecNO_PERMISSION;
513  }
514  }
515 
516  (*slep)[sfBalance] = ctx_.tx[sfBalance];
517  XRPAmount const reqDelta = reqBalance - chanBalance;
518  assert(reqDelta >= beast::zero);
519  (*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta;
520  ctx_.view().update(sled);
521  ctx_.view().update(slep);
522  }
523 
524  if (ctx_.tx.getFlags() & tfRenew)
525  {
526  if (src != txAccount)
527  return tecNO_PERMISSION;
528  (*slep)[~sfExpiration] = boost::none;
529  ctx_.view().update(slep);
530  }
531 
532  if (ctx_.tx.getFlags() & tfClose)
533  {
534  // Channel will close immediately if dry or the receiver closes
535  if (dst == txAccount || (*slep)[sfBalance] == (*slep)[sfAmount])
536  return closeChannel(
537  slep, ctx_.view(), k.key, ctx_.app.journal("View"));
538 
539  auto const settleExpiration =
541  (*slep)[sfSettleDelay];
542 
543  if (!curExpiration || *curExpiration > settleExpiration)
544  {
545  (*slep)[~sfExpiration] = settleExpiration;
546  ctx_.view().update(slep);
547  }
548  }
549 
550  return tesSUCCESS;
551 }
552 
553 } // namespace ripple
beast::Journal::fatal
Stream fatal() const
Definition: Journal.h:339
ripple::ReadView::info
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
ripple::keylet::ownerDir
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition: Indexes.cpp:285
ripple::preflight2
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
Definition: Transactor.cpp:90
ripple::PayChanCreate::doApply
TER doApply() override
Definition: PayChan.cpp:230
ripple::Keylet
A pair of SHAMap key and LedgerEntryType.
Definition: Keylet.h:38
ripple::tecNO_TARGET
@ tecNO_TARGET
Definition: TER.h:262
ripple::tefINTERNAL
@ tefINTERNAL
Definition: TER.h:149
std::shared_ptr
STL class.
ripple::PreclaimContext::view
ReadView const & view
Definition: Transactor.h:57
ripple::publicKeyType
boost::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
Definition: PublicKey.cpp:203
ripple::ApplyView::peek
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
ripple::describeOwnerDir
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Definition: View.cpp:713
ripple::isTesSuccess
bool isTesSuccess(TER x)
Definition: TER.h:576
ripple::closeChannel
static TER closeChannel(std::shared_ptr< SLE > const &slep, ApplyView &view, uint256 const &key, beast::Journal j)
Definition: PayChan.cpp:116
ripple::tfClose
const std::uint32_t tfClose
Definition: TxFlags.h:106
ripple::ApplyView::erase
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
ripple::sfSequence
const SF_U32 sfSequence(access, STI_UINT32, 4, "Sequence")
Definition: SField.h:356
ripple::ReadView::fees
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
ripple::PayChanClaim::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: PayChan.cpp:387
ripple::PayChanClaim::doApply
TER doApply() override
Definition: PayChan.cpp:443
ripple::sfAccount
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
Definition: SField.h:480
ripple::sfFlags
const SF_U32 sfFlags(access, STI_UINT32, 2, "Flags")
Definition: SField.h:354
ripple::featureDepositAuth
const uint256 featureDepositAuth
Definition: Feature.cpp:170
ripple::tecDST_TAG_NEEDED
@ tecDST_TAG_NEEDED
Definition: TER.h:267
ripple::ApplyView::update
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
ripple::ApplyContext::journal
const beast::Journal journal
Definition: ApplyContext.h:51
ripple::PayChanFund::doApply
TER doApply() override
Definition: PayChan.cpp:312
ripple::sfOwnerNode
const SF_U64 sfOwnerNode(access, STI_UINT64, 4, "OwnerNode")
Definition: SField.h:398
ripple::sfPayChannel
const SF_U256 sfPayChannel(access, STI_HASH256, 22, "Channel")
Definition: SField.h:434
ripple::serializePayChanAuthorization
void serializePayChanAuthorization(Serializer &msg, uint256 const &key, XRPAmount const &amt)
Definition: protocol/PayChan.h:31
ripple::sfAmount
const SF_Amount sfAmount(access, STI_AMOUNT, 1, "Amount")
Definition: SField.h:440
ripple::sfOwnerCount
const SF_U32 sfOwnerCount(access, STI_UINT32, 13, "OwnerCount")
Definition: SField.h:365
ripple::temDST_IS_SRC
@ temDST_IS_SRC
Definition: TER.h:103
ripple::sfSignature
const SF_Blob sfSignature(access, STI_VL, 6, "Signature", SField::sMD_Default, SField::notSigning)
Definition: SField.h:461
ripple::preflight1
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
Definition: Transactor.cpp:56
ripple::lsfDepositAuth
@ lsfDepositAuth
Definition: LedgerFormats.h:114
ripple::ApplyView
Writeable view to a ledger, for applying a transaction.
Definition: ApplyView.h:140
ripple::ApplyContext::app
Application & app
Definition: ApplyContext.h:47
ripple::sfDestinationTag
const SF_U32 sfDestinationTag(access, STI_UINT32, 14, "DestinationTag")
Definition: SField.h:366
ripple::ApplyView::dirRemove
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
Definition: ApplyView.cpp:189
ripple::verify
bool verify(PublicKey const &publicKey, Slice const &m, Slice const &sig, bool mustBeFullyCanonical)
Verify a signature on a message.
Definition: PublicKey.cpp:268
ripple::Keylet::key
uint256 key
Definition: Keylet.h:41
ripple::base_uint< 256 >
ripple::temINVALID_FLAG
@ temINVALID_FLAG
Definition: TER.h:106
std::chrono::time_point::time_since_epoch
T time_since_epoch(T... args)
ripple::tefBAD_LEDGER
@ tefBAD_LEDGER
Definition: TER.h:146
ripple::adjustOwnerCount
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
Definition: View.cpp:642
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::keylet::account
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition: Indexes.cpp:121
ripple::temBAD_SIGNER
@ temBAD_SIGNER
Definition: TER.h:110
ripple::TERSubset< CanCvtToTER >
ripple::sfDestinationNode
const SF_U64 sfDestinationNode(access, STI_UINT64, 9, "DestinationNode")
Definition: SField.h:403
ripple::tecUNFUNDED
@ tecUNFUNDED
Definition: TER.h:253
ripple::TER
TERSubset< CanCvtToTER > TER
Definition: TER.h:547
ripple::tecUNFUNDED_PAYMENT
@ tecUNFUNDED_PAYMENT
Definition: TER.h:243
ripple::Serializer::slice
Slice slice() const noexcept
Definition: Serializer.h:63
ripple::fixPayChanRecipientOwnerDir
const uint256 fixPayChanRecipientOwnerDir
Definition: Feature.cpp:182
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:454
ripple::isXRP
bool isXRP(AccountID const &c)
Definition: AccountID.h:118
ripple::temBAD_AMOUNT
@ temBAD_AMOUNT
Definition: TER.h:84
ripple::PayChanFund::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: PayChan.cpp:296
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::temBAD_SIGNATURE
@ temBAD_SIGNATURE
Definition: TER.h:100
ripple::Rules::enabled
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
Definition: ReadView.cpp:103
ripple::sfSourceTag
const SF_U32 sfSourceTag(access, STI_UINT32, 3, "SourceTag")
Definition: SField.h:355
ripple::sfExpiration
const SF_U32 sfExpiration(access, STI_UINT32, 10, "Expiration")
Definition: SField.h:362
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
ripple::ApplyContext::view
ApplyView & view()
Definition: ApplyContext.h:54
ripple::tfPayChanClaimMask
const std::uint32_t tfPayChanClaimMask
Definition: TxFlags.h:107
ripple::PreclaimContext::tx
STTx const & tx
Definition: Transactor.h:59
ripple::PayChanCreate::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: PayChan.cpp:166
ripple::lsfRequireDestTag
@ lsfRequireDestTag
Definition: LedgerFormats.h:104
ripple::fix1543
const uint256 fix1543
Definition: Feature.cpp:173
ripple::tecDIR_FULL
@ tecDIR_FULL
Definition: TER.h:245
ripple::dirAdd
boost::optional< std::uint64_t > dirAdd(ApplyView &view, Keylet const &dir, uint256 const &uLedgerIndex, bool strictOrder, std::function< void(SLE::ref)> fDescriber, beast::Journal j)
Definition: View.cpp:721
ripple::terNO_ACCOUNT
@ terNO_ACCOUNT
Definition: TER.h:190
ripple::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition: Transactor.h:53
ripple::Serializer
Definition: Serializer.h:39
ripple::sfPublicKey
const SF_Blob sfPublicKey(access, STI_VL, 1, "PublicKey")
Definition: SField.h:457
ripple::ApplyView::insert
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Application::journal
virtual beast::Journal journal(std::string const &name)=0
ripple::sfBalance
const SF_Amount sfBalance(access, STI_AMOUNT, 2, "Balance")
Definition: SField.h:441
ripple::Transactor::view
ApplyView & view()
Definition: Transactor.h:107
ripple::keylet::payChan
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition: Indexes.cpp:306
ripple::Fees::accountReserve
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
Definition: ReadView.h:65
ripple::ReadView::rules
virtual Rules const & rules() const =0
Returns the tx processing rules.
ripple::tecNO_PERMISSION
@ tecNO_PERMISSION
Definition: TER.h:263
ripple::tfRenew
const std::uint32_t tfRenew
Definition: TxFlags.h:105
ripple::sfSettleDelay
const SF_U32 sfSettleDelay(access, STI_UINT32, 39, "SettleDelay")
Definition: SField.h:392
ripple::tecINSUFFICIENT_RESERVE
@ tecINSUFFICIENT_RESERVE
Definition: TER.h:265
ripple::Transactor::ctx_
ApplyContext & ctx_
Definition: Transactor.h:89
ripple::sfDestination
const SF_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
Definition: SField.h:482
ripple::ltPAYCHAN
@ ltPAYCHAN
Definition: LedgerFormats.h:83
ripple::lsfDisallowXRP
@ lsfDisallowXRP
Definition: LedgerFormats.h:108
ripple::tecNO_ENTRY
@ tecNO_ENTRY
Definition: TER.h:264
ripple::temMALFORMED
@ temMALFORMED
Definition: TER.h:82
ripple::tfUniversalMask
const std::uint32_t tfUniversalMask
Definition: TxFlags.h:50
ripple::PreflightContext::tx
STTx const & tx
Definition: Transactor.h:36
ripple::PreflightContext
State information when preflighting a tx.
Definition: Transactor.h:32
ripple::temBAD_EXPIRATION
@ temBAD_EXPIRATION
Definition: TER.h:86
ripple::PreflightContext::rules
const Rules rules
Definition: Transactor.h:37
ripple::keylet::depositPreauth
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition: Indexes.cpp:269
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:213
ripple::sfCancelAfter
const SF_U32 sfCancelAfter(access, STI_UINT32, 36, "CancelAfter")
Definition: SField.h:389
ripple::ApplyContext::tx
STTx const & tx
Definition: ApplyContext.h:48
ripple::tecNO_DST
@ tecNO_DST
Definition: TER.h:248
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::PayChanCreate::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: PayChan.cpp:188
ripple::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition: TER.h:507
ripple::LedgerInfo::parentCloseTime
NetClock::time_point parentCloseTime
Definition: ReadView.h:89