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