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/chrono.h>
22 #include <ripple/basics/Log.h>
23 #include <ripple/basics/XRPAmount.h>
24 #include <ripple/ledger/ApplyView.h>
25 #include <ripple/ledger/View.h>
26 #include <ripple/protocol/digest.h>
27 #include <ripple/protocol/Feature.h>
28 #include <ripple/protocol/Indexes.h>
29 #include <ripple/protocol/PayChan.h>
30 #include <ripple/protocol/PublicKey.h>
31 #include <ripple/protocol/st.h>
32 #include <ripple/protocol/TxFlags.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 (optional, not
101  needed if just closing).
102  Amount (optional)
103  The amount of XRP the signature is for (not needed if equal to Balance or just
104  closing the line).
105  Signature (optional)
106  Authorization for the balance above, signed by the owner (optional,
107  not needed if closing or owner is performing the transaction). The
108  signature if for the following message: CLM\0 followed by the
109  256-bit channel ID, and a 64-bit integer drops.
110  PublicKey (optional)
111  The public key that made the signature (optional, required if a signature
112  is present)
113  Flags
114  tfClose
115  Request that the channel be closed
116  tfRenew
117  Request that the channel's expiration be reset. Only the owner
118  may renew a channel.
119 
120 */
121 
122 //------------------------------------------------------------------------------
123 
124 static
125 TER
127  std::shared_ptr<SLE> const& slep,
128  ApplyView& view,
129  uint256 const& key,
130  beast::Journal j)
131 {
132  AccountID const src = (*slep)[sfAccount];
133  // Remove PayChan from owner directory
134  {
135  auto const page = (*slep)[sfOwnerNode];
136  if (! view.dirRemove(keylet::ownerDir(src), page, key, true))
137  {
138  JLOG (j.fatal()) << "Could not remove paychan from src owner directory";
139  return tefBAD_LEDGER;
140  }
141  }
142 
143  // Remove PayChan from recipient's owner directory, if present.
144  if (auto const page = (*slep)[~sfDestinationNode];
145  page && view.rules().enabled(fixPayChanRecipientOwnerDir))
146  {
147  auto const dst = (*slep)[sfDestination];
148  if (!view.dirRemove(keylet::ownerDir(dst), *page, key, true))
149  {
150  JLOG (j.fatal()) << "Could not remove paychan from dst owner directory";
151  return tefBAD_LEDGER;
152  }
153  }
154 
155  // Transfer amount back to owner, decrement owner count
156  auto const sle = view.peek (keylet::account (src));
157  if (! sle)
158  return tefINTERNAL;
159 
160  assert ((*slep)[sfAmount] >= (*slep)[sfBalance]);
161  (*sle)[sfBalance] =
162  (*sle)[sfBalance] + (*slep)[sfAmount] - (*slep)[sfBalance];
163  adjustOwnerCount(view, sle, -1, j);
164  view.update (sle);
165 
166  // Remove PayChan from ledger
167  view.erase (slep);
168  return tesSUCCESS;
169 }
170 
171 //------------------------------------------------------------------------------
172 
173 NotTEC
175 {
176  if (ctx.rules.enabled(fix1543) && ctx.tx.getFlags() & tfUniversalMask)
177  return temINVALID_FLAG;
178 
179  auto const ret = preflight1 (ctx);
180  if (!isTesSuccess (ret))
181  return ret;
182 
183  if (!isXRP (ctx.tx[sfAmount]) || (ctx.tx[sfAmount] <= beast::zero))
184  return temBAD_AMOUNT;
185 
186  if (ctx.tx[sfAccount] == ctx.tx[sfDestination])
187  return temDST_IS_SRC;
188 
189  if (!publicKeyType(ctx.tx[sfPublicKey]))
190  return temMALFORMED;
191 
192  return preflight2 (ctx);
193 }
194 
195 TER
197 {
198  auto const account = ctx.tx[sfAccount];
199  auto const sle = ctx.view.read (keylet::account (account));
200  if (! sle)
201  return terNO_ACCOUNT;
202 
203  // Check reserve and funds availability
204  {
205  auto const balance = (*sle)[sfBalance];
206  auto const reserve =
207  ctx.view.fees ().accountReserve ((*sle)[sfOwnerCount] + 1);
208 
209  if (balance < reserve)
211 
212  if (balance < reserve + ctx.tx[sfAmount])
213  return tecUNFUNDED;
214  }
215 
216  auto const dst = ctx.tx[sfDestination];
217 
218  {
219  // Check destination account
220  auto const sled = ctx.view.read (keylet::account (dst));
221  if (!sled)
222  return tecNO_DST;
223  if (((*sled)[sfFlags] & lsfRequireDestTag) &&
224  !ctx.tx[~sfDestinationTag])
225  return tecDST_TAG_NEEDED;
226 
227  // Obeying the lsfDisallowXRP flag was a bug. Piggyback on
228  // featureDepositAuth to remove the bug.
229  if (!ctx.view.rules().enabled(featureDepositAuth) &&
230  ((*sled)[sfFlags] & lsfDisallowXRP))
231  return tecNO_TARGET;
232  }
233 
234  return tesSUCCESS;
235 }
236 
237 TER
239 {
240  auto const account = ctx_.tx[sfAccount];
241  auto const sle = ctx_.view ().peek (keylet::account (account));
242  if (!sle)
243  return tefINTERNAL;
244 
245  auto const dst = ctx_.tx[sfDestination];
246 
247  // Create PayChan in ledger
248  auto const slep = std::make_shared<SLE> (
249  keylet::payChan (account, dst, (*sle)[sfSequence] - 1));
250  // Funds held in this channel
251  (*slep)[sfAmount] = ctx_.tx[sfAmount];
252  // Amount channel has already paid
253  (*slep)[sfBalance] = ctx_.tx[sfAmount].zeroed ();
254  (*slep)[sfAccount] = account;
255  (*slep)[sfDestination] = dst;
256  (*slep)[sfSettleDelay] = ctx_.tx[sfSettleDelay];
257  (*slep)[sfPublicKey] = ctx_.tx[sfPublicKey];
258  (*slep)[~sfCancelAfter] = ctx_.tx[~sfCancelAfter];
259  (*slep)[~sfSourceTag] = ctx_.tx[~sfSourceTag];
261 
262  ctx_.view ().insert (slep);
263 
264  // Add PayChan to owner directory
265  {
266  auto const page = dirAdd (ctx_.view(), keylet::ownerDir(account), slep->key(),
267  false, describeOwnerDir (account), ctx_.app.journal ("View"));
268  if (!page)
269  return tecDIR_FULL;
270  (*slep)[sfOwnerNode] = *page;
271  }
272 
273  // Add PayChan to the recipient's owner directory
275  {
276  auto const page = dirAdd(ctx_.view(), keylet::ownerDir(dst), slep->key(),
277  false, describeOwnerDir(dst), ctx_.app.journal("View"));
278  if (!page)
279  return tecDIR_FULL;
280  (*slep)[sfDestinationNode] = *page;
281  }
282 
283  // Deduct owner's balance, increment owner count
284  (*sle)[sfBalance] = (*sle)[sfBalance] - ctx_.tx[sfAmount];
285  adjustOwnerCount(ctx_.view(), sle, 1, ctx_.journal);
286  ctx_.view ().update (sle);
287 
288  return tesSUCCESS;
289 }
290 
291 //------------------------------------------------------------------------------
292 
293 NotTEC
295 {
296  if (ctx.rules.enabled(fix1543) && ctx.tx.getFlags() & tfUniversalMask)
297  return temINVALID_FLAG;
298 
299  auto const ret = preflight1 (ctx);
300  if (!isTesSuccess (ret))
301  return ret;
302 
303  if (!isXRP (ctx.tx[sfAmount]) || (ctx.tx[sfAmount] <= beast::zero))
304  return temBAD_AMOUNT;
305 
306  return preflight2 (ctx);
307 }
308 
309 TER
311 {
312  Keylet const k (ltPAYCHAN, ctx_.tx[sfPayChannel]);
313  auto const slep = ctx_.view ().peek (k);
314  if (!slep)
315  return tecNO_ENTRY;
316 
317  AccountID const src = (*slep)[sfAccount];
318  auto const txAccount = ctx_.tx[sfAccount];
319  auto const expiration = (*slep)[~sfExpiration];
320 
321  {
322  auto const cancelAfter = (*slep)[~sfCancelAfter];
323  auto const closeTime =
324  ctx_.view ().info ().parentCloseTime.time_since_epoch ().count ();
325  if ((cancelAfter && closeTime >= *cancelAfter) ||
326  (expiration && closeTime >= *expiration))
327  return closeChannel (
328  slep, ctx_.view (), k.key, ctx_.app.journal ("View"));
329  }
330 
331  if (src != txAccount)
332  // only the owner can add funds or extend
333  return tecNO_PERMISSION;
334 
335  if (auto extend = ctx_.tx[~sfExpiration])
336  {
337  auto minExpiration =
338  ctx_.view ().info ().parentCloseTime.time_since_epoch ().count () +
339  (*slep)[sfSettleDelay];
340  if (expiration && *expiration < minExpiration)
341  minExpiration = *expiration;
342 
343  if (*extend < minExpiration)
344  return temBAD_EXPIRATION;
345  (*slep)[~sfExpiration] = *extend;
346  ctx_.view ().update (slep);
347  }
348 
349  auto const sle = ctx_.view ().peek (keylet::account (txAccount));
350  if (! sle)
351  return tefINTERNAL;
352 
353  {
354  // Check reserve and funds availability
355  auto const balance = (*sle)[sfBalance];
356  auto const reserve =
357  ctx_.view ().fees ().accountReserve ((*sle)[sfOwnerCount]);
358 
359  if (balance < reserve)
361 
362  if (balance < reserve + ctx_.tx[sfAmount])
363  return tecUNFUNDED;
364  }
365 
366  // do not allow adding funds if dst does not exist
367  if (AccountID const dst = (*slep)[sfDestination];
368  !ctx_.view().read(keylet::account(dst)))
369  {
370  return tecNO_DST;
371  }
372 
373  (*slep)[sfAmount] = (*slep)[sfAmount] + ctx_.tx[sfAmount];
374  ctx_.view ().update (slep);
375 
376  (*sle)[sfBalance] = (*sle)[sfBalance] - ctx_.tx[sfAmount];
377  ctx_.view ().update (sle);
378 
379  return tesSUCCESS;
380 }
381 
382 //------------------------------------------------------------------------------
383 
384 NotTEC
386 {
387  auto const ret = preflight1 (ctx);
388  if (!isTesSuccess (ret))
389  return ret;
390 
391  auto const bal = ctx.tx[~sfBalance];
392  if (bal && (!isXRP (*bal) || *bal <= beast::zero))
393  return temBAD_AMOUNT;
394 
395  auto const amt = ctx.tx[~sfAmount];
396  if (amt && (!isXRP (*amt) || *amt <= beast::zero))
397  return temBAD_AMOUNT;
398 
399  if (bal && amt && *bal > *amt)
400  return temBAD_AMOUNT;
401 
402  {
403  auto const flags = ctx.tx.getFlags();
404 
405  if (ctx.rules.enabled(fix1543) && (flags & tfPayChanClaimMask))
406  return temINVALID_FLAG;
407 
408  if ((flags & tfClose) && (flags & tfRenew))
409  return temMALFORMED;
410  }
411 
412  if (auto const sig = ctx.tx[~sfSignature])
413  {
414  if (!(ctx.tx[~sfPublicKey] && bal))
415  return temMALFORMED;
416 
417  // Check the signature
418  // The signature isn't needed if txAccount == src, but if it's
419  // present, check it
420 
421  auto const reqBalance = bal->xrp ();
422  auto const authAmt = amt ? amt->xrp() : reqBalance;
423 
424  if (reqBalance > authAmt)
425  return temBAD_AMOUNT;
426 
427  Keylet const k (ltPAYCHAN, ctx.tx[sfPayChannel]);
428  if (!publicKeyType(ctx.tx[sfPublicKey]))
429  return temMALFORMED;
430  PublicKey const pk (ctx.tx[sfPublicKey]);
431  Serializer msg;
432  serializePayChanAuthorization (msg, k.key, authAmt);
433  if (!verify (pk, msg.slice (), *sig, /*canonical*/ true))
434  return temBAD_SIGNATURE;
435  }
436 
437  return preflight2 (ctx);
438 }
439 
440 TER
442 {
443  Keylet const k (ltPAYCHAN, ctx_.tx[sfPayChannel]);
444  auto const slep = ctx_.view ().peek (k);
445  if (!slep)
446  return tecNO_TARGET;
447 
448  AccountID const src = (*slep)[sfAccount];
449  AccountID const dst = (*slep)[sfDestination];
450  AccountID const txAccount = ctx_.tx[sfAccount];
451 
452  auto const curExpiration = (*slep)[~sfExpiration];
453  {
454  auto const cancelAfter = (*slep)[~sfCancelAfter];
455  auto const closeTime =
456  ctx_.view ().info ().parentCloseTime.time_since_epoch ().count ();
457  if ((cancelAfter && closeTime >= *cancelAfter) ||
458  (curExpiration && closeTime >= *curExpiration))
459  return closeChannel (
460  slep, ctx_.view (), k.key, ctx_.app.journal ("View"));
461  }
462 
463  if (txAccount != src && txAccount != dst)
464  return tecNO_PERMISSION;
465 
466  if (ctx_.tx[~sfBalance])
467  {
468  auto const chanBalance = slep->getFieldAmount (sfBalance).xrp ();
469  auto const chanFunds = slep->getFieldAmount (sfAmount).xrp ();
470  auto const reqBalance = ctx_.tx[sfBalance].xrp ();
471 
472  if (txAccount == dst && !ctx_.tx[~sfSignature])
473  return temBAD_SIGNATURE;
474 
475  if (ctx_.tx[~sfSignature])
476  {
477  PublicKey const pk ((*slep)[sfPublicKey]);
478  if (ctx_.tx[sfPublicKey] != pk)
479  return temBAD_SIGNER;
480  }
481 
482  if (reqBalance > chanFunds)
483  return tecUNFUNDED_PAYMENT;
484 
485  if (reqBalance <= chanBalance)
486  // nothing requested
487  return tecUNFUNDED_PAYMENT;
488 
489  auto const sled = ctx_.view ().peek (keylet::account (dst));
490  if (!sled)
491  return tecNO_DST;
492 
493  // Obeying the lsfDisallowXRP flag was a bug. Piggyback on
494  // featureDepositAuth to remove the bug.
495  bool const depositAuth {ctx_.view().rules().enabled(featureDepositAuth)};
496  if (!depositAuth &&
497  (txAccount == src && (sled->getFlags() & lsfDisallowXRP)))
498  return tecNO_TARGET;
499 
500  // Check whether the destination account requires deposit authorization.
501  if (depositAuth && (sled->getFlags() & lsfDepositAuth))
502  {
503  // A destination account that requires authorization has two
504  // ways to get a Payment Channel Claim into the account:
505  // 1. If Account == Destination, or
506  // 2. If Account is deposit preauthorized by destination.
507  if (txAccount != dst)
508  {
509  if (! view().exists (keylet::depositPreauth (dst, txAccount)))
510  return tecNO_PERMISSION;
511  }
512  }
513 
514  (*slep)[sfBalance] = ctx_.tx[sfBalance];
515  XRPAmount const reqDelta = reqBalance - chanBalance;
516  assert (reqDelta >= beast::zero);
517  (*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta;
518  ctx_.view ().update (sled);
519  ctx_.view ().update (slep);
520  }
521 
522  if (ctx_.tx.getFlags () & tfRenew)
523  {
524  if (src != txAccount)
525  return tecNO_PERMISSION;
526  (*slep)[~sfExpiration] = boost::none;
527  ctx_.view ().update (slep);
528  }
529 
530  if (ctx_.tx.getFlags () & tfClose)
531  {
532  // Channel will close immediately if dry or the receiver closes
533  if (dst == txAccount || (*slep)[sfBalance] == (*slep)[sfAmount])
534  return closeChannel (
535  slep, ctx_.view (), k.key, ctx_.app.journal ("View"));
536 
537  auto const settleExpiration =
538  ctx_.view ().info ().parentCloseTime.time_since_epoch ().count () +
539  (*slep)[sfSettleDelay];
540 
541  if (!curExpiration || *curExpiration > settleExpiration)
542  {
543  (*slep)[~sfExpiration] = settleExpiration;
544  ctx_.view ().update (slep);
545  }
546  }
547 
548  return tesSUCCESS;
549 }
550 
551 } // ripple
552 
beast::Journal::fatal
Stream fatal() const
Definition: Journal.h:312
ripple::ReadView::info
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
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:238
ripple::Keylet
A pair of SHAMap key and LedgerEntryType.
Definition: Keylet.h:38
ripple::tecNO_TARGET
@ tecNO_TARGET
Definition: TER.h:269
ripple::tefINTERNAL
@ tefINTERNAL
Definition: TER.h:153
std::shared_ptr
STL class.
ripple::PreclaimContext::view
ReadView const & view
Definition: Transactor.h:53
ripple::publicKeyType
boost::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
Definition: PublicKey.cpp:207
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:700
ripple::isTesSuccess
bool isTesSuccess(TER x)
Definition: TER.h:501
ripple::closeChannel
static TER closeChannel(std::shared_ptr< SLE > const &slep, ApplyView &view, uint256 const &key, beast::Journal j)
Definition: PayChan.cpp:126
ripple::tfClose
const std::uint32_t tfClose
Definition: TxFlags.h:103
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:340
ripple::ReadView::fees
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
ripple::keylet::payChan
Keylet payChan(AccountID const &source, AccountID const &dst, std::uint32_t seq)
A PaymentChannel.
Definition: Indexes.cpp:350
ripple::PayChanClaim::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: PayChan.cpp:385
ripple::PayChanClaim::doApply
TER doApply() override
Definition: PayChan.cpp:441
ripple::sfAccount
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
Definition: SField.h:460
ripple::sfFlags
const SF_U32 sfFlags(access, STI_UINT32, 2, "Flags")
Definition: SField.h:338
ripple::featureDepositAuth
const uint256 featureDepositAuth
Definition: Feature.cpp:164
ripple::tecDST_TAG_NEEDED
@ tecDST_TAG_NEEDED
Definition: TER.h:274
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:48
ripple::PayChanFund::doApply
TER doApply() override
Definition: PayChan.cpp:310
ripple::sfOwnerNode
const SF_U64 sfOwnerNode(access, STI_UINT64, 4, "OwnerNode")
Definition: SField.h:382
ripple::sfPayChannel
const SF_U256 sfPayChannel(access, STI_HASH256, 22, "Channel")
Definition: SField.h:418
ripple::serializePayChanAuthorization
void serializePayChanAuthorization(Serializer &msg, uint256 const &key, XRPAmount const &amt)
Definition: protocol/PayChan.h:32
ripple::sfAmount
const SF_Amount sfAmount(access, STI_AMOUNT, 1, "Amount")
Definition: SField.h:423
ripple::sfOwnerCount
const SF_U32 sfOwnerCount(access, STI_UINT32, 13, "OwnerCount")
Definition: SField.h:349
ripple::temDST_IS_SRC
@ temDST_IS_SRC
Definition: TER.h:106
ripple::sfSignature
const SF_Blob sfSignature(access, STI_VL, 6, "Signature", SField::sMD_Default, SField::notSigning)
Definition: SField.h:444
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:140
ripple::ApplyView
Writeable view to a ledger, for applying a transaction.
Definition: ApplyView.h:150
ripple::ApplyContext::app
Application & app
Definition: ApplyContext.h:44
ripple::keylet::depositPreauth
static const depositPreauth_t depositPreauth
Definition: Indexes.h:269
ripple::sfDestinationTag
const SF_U32 sfDestinationTag(access, STI_UINT32, 14, "DestinationTag")
Definition: SField.h:350
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:277
ripple::Keylet::key
uint256 key
Definition: Keylet.h:41
ripple::base_uint< 256 >
ripple::temINVALID_FLAG
@ temINVALID_FLAG
Definition: TER.h:109
std::chrono::time_point::time_since_epoch
T time_since_epoch(T... args)
ripple::tefBAD_LEDGER
@ tefBAD_LEDGER
Definition: TER.h:150
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:629
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::keylet::account
static const account_t account
Definition: Indexes.h:116
ripple::temBAD_SIGNER
@ temBAD_SIGNER
Definition: TER.h:113
ripple::TERSubset< CanCvtToTER >
ripple::sfDestinationNode
const SF_U64 sfDestinationNode(access, STI_UINT64, 9, "DestinationNode")
Definition: SField.h:387
ripple::keylet::ownerDir
Keylet ownerDir(AccountID const &id)
The root page of an account's directory.
Definition: Indexes.cpp:318
ripple::tecUNFUNDED
@ tecUNFUNDED
Definition: TER.h:260
ripple::TER
TERSubset< CanCvtToTER > TER
Definition: TER.h:477
ripple::tecUNFUNDED_PAYMENT
@ tecUNFUNDED_PAYMENT
Definition: TER.h:250
ripple::Serializer::slice
Slice slice() const noexcept
Definition: Serializer.h:67
ripple::fixPayChanRecipientOwnerDir
const uint256 fixPayChanRecipientOwnerDir
Definition: Feature.cpp:176
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:439
ripple::isXRP
bool isXRP(AccountID const &c)
Definition: AccountID.h:121
ripple::temBAD_AMOUNT
@ temBAD_AMOUNT
Definition: TER.h:87
ripple::PayChanFund::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: PayChan.cpp:294
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
ripple::temBAD_SIGNATURE
@ temBAD_SIGNATURE
Definition: TER.h:103
ripple::Rules::enabled
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
Definition: ReadView.cpp:107
ripple::sfSourceTag
const SF_U32 sfSourceTag(access, STI_UINT32, 3, "SourceTag")
Definition: SField.h:339
ripple::sfExpiration
const SF_U32 sfExpiration(access, STI_UINT32, 10, "Expiration")
Definition: SField.h:346
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:51
ripple::tfPayChanClaimMask
const std::uint32_t tfPayChanClaimMask
Definition: TxFlags.h:104
ripple::PreclaimContext::tx
STTx const & tx
Definition: Transactor.h:55
ripple::PayChanCreate::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: PayChan.cpp:174
ripple::lsfRequireDestTag
@ lsfRequireDestTag
Definition: LedgerFormats.h:133
ripple::fix1543
const uint256 fix1543
Definition: Feature.cpp:167
ripple::tecDIR_FULL
@ tecDIR_FULL
Definition: TER.h:252
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:709
ripple::terNO_ACCOUNT
@ terNO_ACCOUNT
Definition: TER.h:195
ripple::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition: Transactor.h:49
ripple::Serializer
Definition: Serializer.h:43
ripple::sfPublicKey
const SF_Blob sfPublicKey(access, STI_VL, 1, "PublicKey")
Definition: SField.h:440
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:424
ripple::Transactor::view
ApplyView & view()
Definition: Transactor.h:98
ripple::Fees::accountReserve
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
Definition: ReadView.h:64
ripple::ReadView::rules
virtual Rules const & rules() const =0
Returns the tx processing rules.
ripple::tecNO_PERMISSION
@ tecNO_PERMISSION
Definition: TER.h:270
ripple::tfRenew
const std::uint32_t tfRenew
Definition: TxFlags.h:102
ripple::sfSettleDelay
const SF_U32 sfSettleDelay(access, STI_UINT32, 39, "SettleDelay")
Definition: SField.h:376
ripple::tecINSUFFICIENT_RESERVE
@ tecINSUFFICIENT_RESERVE
Definition: TER.h:272
ripple::Transactor::ctx_
ApplyContext & ctx_
Definition: Transactor.h:81
ripple::sfDestination
const SF_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
Definition: SField.h:462
ripple::ltPAYCHAN
@ ltPAYCHAN
Definition: LedgerFormats.h:84
ripple::lsfDisallowXRP
@ lsfDisallowXRP
Definition: LedgerFormats.h:135
ripple::tecNO_ENTRY
@ tecNO_ENTRY
Definition: TER.h:271
ripple::temMALFORMED
@ temMALFORMED
Definition: TER.h:85
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:89
ripple::PreflightContext::rules
const Rules rules
Definition: Transactor.h:37
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:219
ripple::sfCancelAfter
const SF_U32 sfCancelAfter(access, STI_UINT32, 36, "CancelAfter")
Definition: SField.h:373
ripple::ApplyContext::tx
STTx const & tx
Definition: ApplyContext.h:45
ripple::tecNO_DST
@ tecNO_DST
Definition: TER.h:255
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::PayChanCreate::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: PayChan.cpp:196
ripple::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition: TER.h:461
ripple::LedgerInfo::parentCloseTime
NetClock::time_point parentCloseTime
Definition: ReadView.h:88