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