rippled
Loading...
Searching...
No Matches
XChainBridge.h
1#ifndef XRPL_TX_XCHAINBRIDGE_H_INCLUDED
2#define XRPL_TX_XCHAINBRIDGE_H_INCLUDED
3
4#include <xrpld/app/tx/detail/Transactor.h>
5
6#include <xrpl/protocol/XChainAttestations.h>
7
8namespace ripple {
9
10constexpr size_t xbridgeMaxAccountCreateClaims = 128;
11
12// Attach a new bridge to a door account. Once this is done, the cross-chain
13// transfer transactions may be used to transfer funds from this account.
15{
16public:
18
20 {
21 }
22
23 static NotTEC
24 preflight(PreflightContext const& ctx);
25
26 static TER
27 preclaim(PreclaimContext const& ctx);
28
29 TER
30 doApply() override;
31};
32
34{
35public:
37
38 explicit BridgeModify(ApplyContext& ctx) : Transactor(ctx)
39 {
40 }
41
42 static std::uint32_t
44
45 static NotTEC
46 preflight(PreflightContext const& ctx);
47
48 static TER
49 preclaim(PreclaimContext const& ctx);
50
51 TER
52 doApply() override;
53};
54
56
57//------------------------------------------------------------------------------
58
59// Claim funds from a `XChainCommit` transaction. This is normally not needed,
60// but may be used to handle transaction failures or if the destination account
61// was not specified in the `XChainCommit` transaction. It may only be used
62// after a quorum of signatures have been sent from the witness servers.
63//
64// If the transaction succeeds in moving funds, the referenced `XChainClaimID`
65// ledger object will be destroyed. This prevents transaction replay. If the
66// transaction fails, the `XChainClaimID` will not be destroyed and the
67// transaction may be re-run with different parameters.
68class XChainClaim : public Transactor
69{
70public:
71 // Blocker since we cannot accurately calculate the consequences
73
74 explicit XChainClaim(ApplyContext& ctx) : Transactor(ctx)
75 {
76 }
77
78 static NotTEC
79 preflight(PreflightContext const& ctx);
80
81 static TER
82 preclaim(PreclaimContext const& ctx);
83
84 TER
85 doApply() override;
86};
87
88//------------------------------------------------------------------------------
89
90// Put assets into trust on the locking-chain so they may be wrapped on the
91// issuing-chain, or return wrapped assets on the issuing-chain so they can be
92// unlocked on the locking-chain. The second step in a cross-chain transfer.
94{
95public:
97
98 static TxConsequences
100
102 {
103 }
104
105 static NotTEC
106 preflight(PreflightContext const& ctx);
107
108 static TER
109 preclaim(PreclaimContext const& ctx);
110
111 TER
112 doApply() override;
113};
114
115//------------------------------------------------------------------------------
116
117// Create a new claim id owned by the account. This is the first step in a
118// cross-chain transfer. The claim id must be created on the destination chain
119// before the `XChainCommit` transaction (which must reference this number) can
120// be sent on the source chain. The account that will send the `XChainCommit` on
121// the source chain must be specified in this transaction (see note on the
122// `SourceAccount` field in the `XChainClaimID` ledger object for
123// justification). The actual sequence number must be retrieved from a validated
124// ledger.
126{
127public:
129
131 {
132 }
133
134 static NotTEC
135 preflight(PreflightContext const& ctx);
136
137 static TER
138 preclaim(PreclaimContext const& ctx);
139
140 TER
141 doApply() override;
142};
143
144//------------------------------------------------------------------------------
145
146// Provide attestations from a witness server attesting to events on
147// the other chain. The signatures must be from one of the keys on the door's
148// signer's list at the time the signature was provided. However, if the
149// signature list changes between the time the signature was submitted and the
150// quorum is reached, the new signature set is used and some of the currently
151// collected signatures may be removed. Also note the reward is only sent to
152// accounts that have keys on the current list.
154{
155public:
156 // Blocker since we cannot accurately calculate the consequences
158
160 {
161 }
162
163 static NotTEC
164 preflight(PreflightContext const& ctx);
165
166 static TER
167 preclaim(PreclaimContext const& ctx);
168
169 TER
170 doApply() override;
171};
172
174{
175public:
176 // Blocker since we cannot accurately calculate the consequences
178
180 : Transactor(ctx)
181 {
182 }
183
184 static NotTEC
185 preflight(PreflightContext const& ctx);
186
187 static TER
188 preclaim(PreclaimContext const& ctx);
189
190 TER
191 doApply() override;
192};
193
194//------------------------------------------------------------------------------
195
196// This is a special transaction used for creating accounts through a
197// cross-chain transfer. A normal cross-chain transfer requires a "chain claim
198// id" (which requires an existing account on the destination chain). One
199// purpose of the "chain claim id" is to prevent transaction replay. For this
200// transaction, we use a different mechanism: the accounts must be claimed on
201// the destination chain in the same order that the `XChainCreateAccountCommit`
202// transactions occurred on the source chain.
203//
204// This transaction can only be used for XRP to XRP bridges.
205//
206// IMPORTANT: This transaction should only be enabled if the witness
207// attestations will be reliably delivered to the destination chain. If the
208// signatures are not delivered (for example, the chain relies on user wallets
209// to collect signatures) then account creation would be blocked for all
210// transactions that happened after the one waiting on attestations. This could
211// be used maliciously. To disable this transaction on XRP to XRP bridges, the
212// bridge's `MinAccountCreateAmount` should not be present.
213//
214// Note: If this account already exists, the XRP is transferred to the existing
215// account. However, note that unlike the `XChainCommit` transaction, there is
216// no error handling mechanism. If the claim transaction fails, there is no
217// mechanism for refunds. The funds are permanently lost. This transaction
218// should still only be used for account creation.
220{
221public:
223
225 {
226 }
227
228 static NotTEC
229 preflight(PreflightContext const& ctx);
230
231 static TER
232 preclaim(PreclaimContext const& ctx);
233
234 TER
235 doApply() override;
236};
237
239
240//------------------------------------------------------------------------------
241
242} // namespace ripple
243
244#endif
State information when applying a tx.
BridgeModify(ApplyContext &ctx)
static constexpr ConsequencesFactoryType ConsequencesFactory
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:39
static constexpr ConsequencesFactoryType ConsequencesFactory
static TER preclaim(PreclaimContext const &ctx)
XChainAddAccountCreateAttestation(ApplyContext &ctx)
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
XChainAddClaimAttestation(ApplyContext &ctx)
static constexpr ConsequencesFactoryType ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
static TER preclaim(PreclaimContext const &ctx)
XChainClaim(ApplyContext &ctx)
static NotTEC preflight(PreflightContext const &ctx)
TER doApply() override
XChainCommit(ApplyContext &ctx)
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
static constexpr ConsequencesFactoryType ConsequencesFactory
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
static constexpr ConsequencesFactoryType ConsequencesFactory
static TER preclaim(PreclaimContext const &ctx)
XChainCreateAccountCommit(ApplyContext &ctx)
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static constexpr ConsequencesFactoryType ConsequencesFactory
static NotTEC preflight(PreflightContext const &ctx)
XChainCreateBridge(ApplyContext &ctx)
static constexpr ConsequencesFactoryType ConsequencesFactory
XChainCreateClaimID(ApplyContext &ctx)
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
constexpr size_t xbridgeMaxAccountCreateClaims
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:61
State information when preflighting a tx.
Definition Transactor.h:16