xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
tx
paths
detail
StepChecks.h
1
#pragma once
2
3
#include <xrpl/basics/Log.h>
4
#include <xrpl/beast/utility/Journal.h>
5
#include <xrpl/beast/utility/instrumentation.h>
6
#include <xrpl/ledger/ReadView.h>
7
#include <xrpl/ledger/View.h>
8
#include <xrpl/protocol/AccountID.h>
9
#include <xrpl/protocol/Feature.h>
10
#include <xrpl/protocol/Indexes.h>
11
#include <xrpl/protocol/LedgerFormats.h>
12
#include <xrpl/protocol/SField.h>
13
#include <xrpl/protocol/TER.h>
14
#include <xrpl/protocol/UintTypes.h>
15
16
namespace
xrpl
{
17
18
inline
TER
19
checkFreeze
(
20
ReadView
const
& view,
21
AccountID
const
& src,
22
AccountID
const
& dst,
23
Currency
const
& currency)
24
{
25
XRPL_ASSERT(src != dst,
"xrpl::checkFreeze : unequal input accounts"
);
26
27
// check freeze
28
if
(
auto
sle = view.
read
(
keylet::account
(dst)))
29
{
30
if
(sle->isFlag(lsfGlobalFreeze))
31
{
32
return
terNO_LINE
;
33
}
34
}
35
36
if
(
auto
sle = view.
read
(
keylet::trustLine
(src, dst, currency)))
37
{
38
if
(sle->isFlag((dst > src) ? lsfHighFreeze : lsfLowFreeze))
39
{
40
return
terNO_LINE
;
41
}
42
// Unlike normal freeze, a deep frozen trust line acts the same
43
// regardless of which side froze it
44
if
(sle->isFlag(lsfHighDeepFreeze) || sle->isFlag(lsfLowDeepFreeze))
45
{
46
return
terNO_LINE
;
47
}
48
}
49
50
if
(view.
rules
().
enabled
(fixFrozenLPTokenTransfer))
51
{
52
if
(
auto
const
sleDst = view.
read
(
keylet::account
(dst));
53
sleDst && sleDst->isFieldPresent(sfAMMID))
54
{
55
auto
const
sleAmm = view.
read
(
keylet::amm
((*sleDst)[sfAMMID]));
56
if
(!sleAmm)
57
return
tecINTERNAL
;
// LCOV_EXCL_LINE
58
59
if
(
isLPTokenFrozen
(view, src, (*sleAmm)[sfAsset], (*sleAmm)[sfAsset2]))
60
{
61
return
terNO_LINE
;
62
}
63
}
64
}
65
66
return
tesSUCCESS
;
67
}
68
69
inline
TER
70
checkNoRipple
(
71
ReadView
const
& view,
72
AccountID
const
& prev,
73
AccountID
const
& cur,
74
// This is the account whose constraints we are checking
75
AccountID
const
& next,
76
Currency
const
& currency,
77
beast::Journal
j)
78
{
79
// fetch the ripple lines into and out of this node
80
auto
sleIn = view.
read
(
keylet::trustLine
(prev, cur, currency));
81
auto
sleOut = view.
read
(
keylet::trustLine
(cur, next, currency));
82
83
if
(!sleIn || !sleOut)
84
return
terNO_LINE
;
85
86
if
(sleIn->isFlag((cur > prev) ? lsfHighNoRipple : lsfLowNoRipple) &&
87
sleOut->isFlag((cur > next) ? lsfHighNoRipple : lsfLowNoRipple))
88
{
89
JLOG(j.
info
()) <<
"Path violates noRipple constraint between "
<< prev <<
", "
<< cur
90
<<
" and "
<< next;
91
92
return
terNO_RIPPLE
;
93
}
94
return
tesSUCCESS
;
95
}
96
97
}
// namespace xrpl
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::Journal::info
Stream info() const
Definition
Journal.h:350
xrpl::ReadView
A view into a ledger.
Definition
ReadView.h:41
xrpl::ReadView::rules
virtual Rules const & rules() const =0
Returns the tx processing rules.
xrpl::ReadView::read
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
xrpl::Rules::enabled
bool enabled(UInt256 const &feature) const
Returns true if a feature is enabled.
Definition
Rules.cpp:182
xrpl::keylet::amm
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition
Indexes.cpp:471
xrpl::keylet::account
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition
Indexes.cpp:220
xrpl::keylet::trustLine
Keylet trustLine(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
Definition
Indexes.cpp:275
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::terNO_LINE
@ terNO_LINE
Definition
TER.h:220
xrpl::terNO_RIPPLE
@ terNO_RIPPLE
Definition
TER.h:225
xrpl::Currency
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition
UintTypes.h:42
xrpl::checkFreeze
TER checkFreeze(ReadView const &view, AccountID const &src, AccountID const &dst, Currency const ¤cy)
Definition
StepChecks.h:19
xrpl::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
xrpl::TER
TERSubset< CanCvtToTER > TER
Definition
TER.h:654
xrpl::isLPTokenFrozen
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Asset const &asset, Asset const &asset2)
Definition
View.cpp:176
xrpl::tecINTERNAL
@ tecINTERNAL
Definition
TER.h:318
xrpl::checkNoRipple
TER checkNoRipple(ReadView const &view, AccountID const &prev, AccountID const &cur, AccountID const &next, Currency const ¤cy, beast::Journal j)
Definition
StepChecks.h:70
xrpl::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:250
Generated by
1.17.0