forked from stellar/stellar-xdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stellar-transaction.x
2056 lines (1761 loc) · 57.9 KB
/
Stellar-transaction.x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2015 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
%#include "xdr/Stellar-contract.h"
%#include "xdr/Stellar-ledger-entries.h"
namespace stellar
{
// maximum number of operations per transaction
const MAX_OPS_PER_TX = 100;
union LiquidityPoolParameters switch (LiquidityPoolType type)
{
case LIQUIDITY_POOL_CONSTANT_PRODUCT:
LiquidityPoolConstantProductParameters constantProduct;
};
// Source or destination of a payment operation
union MuxedAccount switch (CryptoKeyType type)
{
case KEY_TYPE_ED25519:
uint256 ed25519;
case KEY_TYPE_MUXED_ED25519:
struct
{
uint64 id;
uint256 ed25519;
} med25519;
};
struct DecoratedSignature
{
SignatureHint hint; // last 4 bytes of the public key, used as a hint
Signature signature; // actual signature
};
enum OperationType
{
CREATE_ACCOUNT = 0,
PAYMENT = 1,
PATH_PAYMENT_STRICT_RECEIVE = 2,
MANAGE_SELL_OFFER = 3,
CREATE_PASSIVE_SELL_OFFER = 4,
SET_OPTIONS = 5,
CHANGE_TRUST = 6,
ALLOW_TRUST = 7,
ACCOUNT_MERGE = 8,
INFLATION = 9,
MANAGE_DATA = 10,
BUMP_SEQUENCE = 11,
MANAGE_BUY_OFFER = 12,
PATH_PAYMENT_STRICT_SEND = 13,
CREATE_CLAIMABLE_BALANCE = 14,
CLAIM_CLAIMABLE_BALANCE = 15,
BEGIN_SPONSORING_FUTURE_RESERVES = 16,
END_SPONSORING_FUTURE_RESERVES = 17,
REVOKE_SPONSORSHIP = 18,
CLAWBACK = 19,
CLAWBACK_CLAIMABLE_BALANCE = 20,
SET_TRUST_LINE_FLAGS = 21,
LIQUIDITY_POOL_DEPOSIT = 22,
LIQUIDITY_POOL_WITHDRAW = 23,
INVOKE_HOST_FUNCTION = 24,
EXTEND_FOOTPRINT_TTL = 25,
RESTORE_FOOTPRINT = 26
};
/* CreateAccount
Creates and funds a new account with the specified starting balance.
Threshold: med
Result: CreateAccountResult
*/
struct CreateAccountOp
{
AccountID destination; // account to create
int64 startingBalance; // amount they end up with
};
/* Payment
Send an amount in specified asset to a destination account.
Threshold: med
Result: PaymentResult
*/
struct PaymentOp
{
MuxedAccount destination; // recipient of the payment
Asset asset; // what they end up with
int64 amount; // amount they end up with
};
/* PathPaymentStrictReceive
send an amount to a destination account through a path.
(up to sendMax, sendAsset)
(X0, Path[0]) .. (Xn, Path[n])
(destAmount, destAsset)
Threshold: med
Result: PathPaymentStrictReceiveResult
*/
struct PathPaymentStrictReceiveOp
{
Asset sendAsset; // asset we pay with
int64 sendMax; // the maximum amount of sendAsset to
// send (excluding fees).
// The operation will fail if can't be met
MuxedAccount destination; // recipient of the payment
Asset destAsset; // what they end up with
int64 destAmount; // amount they end up with
Asset path<5>; // additional hops it must go through to get there
};
/* PathPaymentStrictSend
send an amount to a destination account through a path.
(sendMax, sendAsset)
(X0, Path[0]) .. (Xn, Path[n])
(at least destAmount, destAsset)
Threshold: med
Result: PathPaymentStrictSendResult
*/
struct PathPaymentStrictSendOp
{
Asset sendAsset; // asset we pay with
int64 sendAmount; // amount of sendAsset to send (excluding fees)
MuxedAccount destination; // recipient of the payment
Asset destAsset; // what they end up with
int64 destMin; // the minimum amount of dest asset to
// be received
// The operation will fail if it can't be met
Asset path<5>; // additional hops it must go through to get there
};
/* Creates, updates or deletes an offer
Threshold: med
Result: ManageSellOfferResult
*/
struct ManageSellOfferOp
{
Asset selling;
Asset buying;
int64 amount; // amount being sold. if set to 0, delete the offer
Price price; // price of thing being sold in terms of what you are buying
// 0=create a new offer, otherwise edit an existing offer
int64 offerID;
};
/* Creates, updates or deletes an offer with amount in terms of buying asset
Threshold: med
Result: ManageBuyOfferResult
*/
struct ManageBuyOfferOp
{
Asset selling;
Asset buying;
int64 buyAmount; // amount being bought. if set to 0, delete the offer
Price price; // price of thing being bought in terms of what you are
// selling
// 0=create a new offer, otherwise edit an existing offer
int64 offerID;
};
/* Creates an offer that doesn't take offers of the same price
Threshold: med
Result: CreatePassiveSellOfferResult
*/
struct CreatePassiveSellOfferOp
{
Asset selling; // A
Asset buying; // B
int64 amount; // amount taker gets
Price price; // cost of A in terms of B
};
/* Set Account Options
updates "AccountEntry" fields.
note: updating thresholds or signers requires high threshold
Threshold: med or high
Result: SetOptionsResult
*/
struct SetOptionsOp
{
AccountID* inflationDest; // sets the inflation destination
uint32* clearFlags; // which flags to clear
uint32* setFlags; // which flags to set
// account threshold manipulation
uint32* masterWeight; // weight of the master account
uint32* lowThreshold;
uint32* medThreshold;
uint32* highThreshold;
string32* homeDomain; // sets the home domain
// Add, update or remove a signer for the account
// signer is deleted if the weight is 0
Signer* signer;
};
union ChangeTrustAsset switch (AssetType type)
{
case ASSET_TYPE_NATIVE: // Not credit
void;
case ASSET_TYPE_CREDIT_ALPHANUM4:
AlphaNum4 alphaNum4;
case ASSET_TYPE_CREDIT_ALPHANUM12:
AlphaNum12 alphaNum12;
case ASSET_TYPE_POOL_SHARE:
LiquidityPoolParameters liquidityPool;
// add other asset types here in the future
};
/* Creates, updates or deletes a trust line
Threshold: med
Result: ChangeTrustResult
*/
struct ChangeTrustOp
{
ChangeTrustAsset line;
// if limit is set to 0, deletes the trust line
int64 limit;
};
/* Updates the "authorized" flag of an existing trust line
this is called by the issuer of the related asset.
note that authorize can only be set (and not cleared) if
the issuer account does not have the AUTH_REVOCABLE_FLAG set
Threshold: low
Result: AllowTrustResult
*/
struct AllowTrustOp
{
AccountID trustor;
AssetCode asset;
// One of 0, AUTHORIZED_FLAG, or AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG
uint32 authorize;
};
/* Inflation
Runs inflation
Threshold: low
Result: InflationResult
*/
/* AccountMerge
Transfers native balance to destination account.
Threshold: high
Result : AccountMergeResult
*/
/* ManageData
Adds, Updates, or Deletes a key value pair associated with a particular
account.
Threshold: med
Result: ManageDataResult
*/
struct ManageDataOp
{
string64 dataName;
DataValue* dataValue; // set to null to clear
};
/* Bump Sequence
increases the sequence to a given level
Threshold: low
Result: BumpSequenceResult
*/
struct BumpSequenceOp
{
SequenceNumber bumpTo;
};
/* Creates a claimable balance entry
Threshold: med
Result: CreateClaimableBalanceResult
*/
struct CreateClaimableBalanceOp
{
Asset asset;
int64 amount;
Claimant claimants<10>;
};
/* Claims a claimable balance entry
Threshold: low
Result: ClaimClaimableBalanceResult
*/
struct ClaimClaimableBalanceOp
{
ClaimableBalanceID balanceID;
};
/* BeginSponsoringFutureReserves
Establishes the is-sponsoring-future-reserves-for relationship between
the source account and sponsoredID
Threshold: med
Result: BeginSponsoringFutureReservesResult
*/
struct BeginSponsoringFutureReservesOp
{
AccountID sponsoredID;
};
/* EndSponsoringFutureReserves
Terminates the current is-sponsoring-future-reserves-for relationship in
which source account is sponsored
Threshold: med
Result: EndSponsoringFutureReservesResult
*/
// EndSponsoringFutureReserves is empty
/* RevokeSponsorship
If source account is not sponsored or is sponsored by the owner of the
specified entry or sub-entry, then attempt to revoke the sponsorship.
If source account is sponsored, then attempt to transfer the sponsorship
to the sponsor of source account.
Threshold: med
Result: RevokeSponsorshipResult
*/
enum RevokeSponsorshipType
{
REVOKE_SPONSORSHIP_LEDGER_ENTRY = 0,
REVOKE_SPONSORSHIP_SIGNER = 1
};
union RevokeSponsorshipOp switch (RevokeSponsorshipType type)
{
case REVOKE_SPONSORSHIP_LEDGER_ENTRY:
LedgerKey ledgerKey;
case REVOKE_SPONSORSHIP_SIGNER:
struct
{
AccountID accountID;
SignerKey signerKey;
} signer;
};
/* Claws back an amount of an asset from an account
Threshold: med
Result: ClawbackResult
*/
struct ClawbackOp
{
Asset asset;
MuxedAccount from;
int64 amount;
};
/* Claws back a claimable balance
Threshold: med
Result: ClawbackClaimableBalanceResult
*/
struct ClawbackClaimableBalanceOp
{
ClaimableBalanceID balanceID;
};
/* SetTrustLineFlagsOp
Updates the flags of an existing trust line.
This is called by the issuer of the related asset.
Threshold: low
Result: SetTrustLineFlagsResult
*/
struct SetTrustLineFlagsOp
{
AccountID trustor;
Asset asset;
uint32 clearFlags; // which flags to clear
uint32 setFlags; // which flags to set
};
const LIQUIDITY_POOL_FEE_V18 = 30;
/* Deposit assets into a liquidity pool
Threshold: med
Result: LiquidityPoolDepositResult
*/
struct LiquidityPoolDepositOp
{
PoolID liquidityPoolID;
int64 maxAmountA; // maximum amount of first asset to deposit
int64 maxAmountB; // maximum amount of second asset to deposit
Price minPrice; // minimum depositA/depositB
Price maxPrice; // maximum depositA/depositB
};
/* Withdraw assets from a liquidity pool
Threshold: med
Result: LiquidityPoolWithdrawResult
*/
struct LiquidityPoolWithdrawOp
{
PoolID liquidityPoolID;
int64 amount; // amount of pool shares to withdraw
int64 minAmountA; // minimum amount of first asset to withdraw
int64 minAmountB; // minimum amount of second asset to withdraw
};
enum HostFunctionType
{
HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0,
HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1,
HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2
};
enum ContractIDPreimageType
{
CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0,
CONTRACT_ID_PREIMAGE_FROM_ASSET = 1
};
union ContractIDPreimage switch (ContractIDPreimageType type)
{
case CONTRACT_ID_PREIMAGE_FROM_ADDRESS:
struct
{
SCAddress address;
uint256 salt;
} fromAddress;
case CONTRACT_ID_PREIMAGE_FROM_ASSET:
Asset fromAsset;
};
struct CreateContractArgs
{
ContractIDPreimage contractIDPreimage;
ContractExecutable executable;
};
struct InvokeContractArgs {
SCAddress contractAddress;
SCSymbol functionName;
SCVal args<>;
};
union HostFunction switch (HostFunctionType type)
{
case HOST_FUNCTION_TYPE_INVOKE_CONTRACT:
InvokeContractArgs invokeContract;
case HOST_FUNCTION_TYPE_CREATE_CONTRACT:
CreateContractArgs createContract;
case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM:
opaque wasm<>;
};
enum SorobanAuthorizedFunctionType
{
SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0,
SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1
};
union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type)
{
case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN:
InvokeContractArgs contractFn;
case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN:
CreateContractArgs createContractHostFn;
};
struct SorobanAuthorizedInvocation
{
SorobanAuthorizedFunction function;
SorobanAuthorizedInvocation subInvocations<>;
};
struct SorobanAddressCredentials
{
SCAddress address;
int64 nonce;
uint32 signatureExpirationLedger;
SCVal signature;
};
enum SorobanCredentialsType
{
SOROBAN_CREDENTIALS_SOURCE_ACCOUNT = 0,
SOROBAN_CREDENTIALS_ADDRESS = 1
};
union SorobanCredentials switch (SorobanCredentialsType type)
{
case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT:
void;
case SOROBAN_CREDENTIALS_ADDRESS:
SorobanAddressCredentials address;
};
/* Unit of authorization data for Soroban.
Represents an authorization for executing the tree of authorized contract
and/or host function calls by the user defined by `credentials`.
*/
struct SorobanAuthorizationEntry
{
SorobanCredentials credentials;
SorobanAuthorizedInvocation rootInvocation;
};
/* Upload Wasm, create, and invoke contracts in Soroban.
Threshold: med
Result: InvokeHostFunctionResult
*/
struct InvokeHostFunctionOp
{
// Host function to invoke.
HostFunction hostFunction;
// Per-address authorizations for this host function.
SorobanAuthorizationEntry auth<>;
};
/* Extend the TTL of the entries specified in the readOnly footprint
so they will live at least extendTo ledgers from lcl.
Threshold: low
Result: ExtendFootprintTTLResult
*/
struct ExtendFootprintTTLOp
{
ExtensionPoint ext;
uint32 extendTo;
};
/* Restore the archived entries specified in the readWrite footprint.
Threshold: low
Result: RestoreFootprintOp
*/
struct RestoreFootprintOp
{
ExtensionPoint ext;
};
/* An operation is the lowest unit of work that a transaction does */
struct Operation
{
// sourceAccount is the account used to run the operation
// if not set, the runtime defaults to "sourceAccount" specified at
// the transaction level
MuxedAccount* sourceAccount;
union switch (OperationType type)
{
case CREATE_ACCOUNT:
CreateAccountOp createAccountOp;
case PAYMENT:
PaymentOp paymentOp;
case PATH_PAYMENT_STRICT_RECEIVE:
PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp;
case MANAGE_SELL_OFFER:
ManageSellOfferOp manageSellOfferOp;
case CREATE_PASSIVE_SELL_OFFER:
CreatePassiveSellOfferOp createPassiveSellOfferOp;
case SET_OPTIONS:
SetOptionsOp setOptionsOp;
case CHANGE_TRUST:
ChangeTrustOp changeTrustOp;
case ALLOW_TRUST:
AllowTrustOp allowTrustOp;
case ACCOUNT_MERGE:
MuxedAccount destination;
case INFLATION:
void;
case MANAGE_DATA:
ManageDataOp manageDataOp;
case BUMP_SEQUENCE:
BumpSequenceOp bumpSequenceOp;
case MANAGE_BUY_OFFER:
ManageBuyOfferOp manageBuyOfferOp;
case PATH_PAYMENT_STRICT_SEND:
PathPaymentStrictSendOp pathPaymentStrictSendOp;
case CREATE_CLAIMABLE_BALANCE:
CreateClaimableBalanceOp createClaimableBalanceOp;
case CLAIM_CLAIMABLE_BALANCE:
ClaimClaimableBalanceOp claimClaimableBalanceOp;
case BEGIN_SPONSORING_FUTURE_RESERVES:
BeginSponsoringFutureReservesOp beginSponsoringFutureReservesOp;
case END_SPONSORING_FUTURE_RESERVES:
void;
case REVOKE_SPONSORSHIP:
RevokeSponsorshipOp revokeSponsorshipOp;
case CLAWBACK:
ClawbackOp clawbackOp;
case CLAWBACK_CLAIMABLE_BALANCE:
ClawbackClaimableBalanceOp clawbackClaimableBalanceOp;
case SET_TRUST_LINE_FLAGS:
SetTrustLineFlagsOp setTrustLineFlagsOp;
case LIQUIDITY_POOL_DEPOSIT:
LiquidityPoolDepositOp liquidityPoolDepositOp;
case LIQUIDITY_POOL_WITHDRAW:
LiquidityPoolWithdrawOp liquidityPoolWithdrawOp;
case INVOKE_HOST_FUNCTION:
InvokeHostFunctionOp invokeHostFunctionOp;
case EXTEND_FOOTPRINT_TTL:
ExtendFootprintTTLOp extendFootprintTTLOp;
case RESTORE_FOOTPRINT:
RestoreFootprintOp restoreFootprintOp;
}
body;
};
union HashIDPreimage switch (EnvelopeType type)
{
case ENVELOPE_TYPE_OP_ID:
struct
{
AccountID sourceAccount;
SequenceNumber seqNum;
uint32 opNum;
} operationID;
case ENVELOPE_TYPE_POOL_REVOKE_OP_ID:
struct
{
AccountID sourceAccount;
SequenceNumber seqNum;
uint32 opNum;
PoolID liquidityPoolID;
Asset asset;
} revokeID;
case ENVELOPE_TYPE_CONTRACT_ID:
struct
{
Hash networkID;
ContractIDPreimage contractIDPreimage;
} contractID;
case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION:
struct
{
Hash networkID;
int64 nonce;
uint32 signatureExpirationLedger;
SorobanAuthorizedInvocation invocation;
} sorobanAuthorization;
};
enum MemoType
{
MEMO_NONE = 0,
MEMO_TEXT = 1,
MEMO_ID = 2,
MEMO_HASH = 3,
MEMO_RETURN = 4
};
union Memo switch (MemoType type)
{
case MEMO_NONE:
void;
case MEMO_TEXT:
string text<28>;
case MEMO_ID:
uint64 id;
case MEMO_HASH:
Hash hash; // the hash of what to pull from the content server
case MEMO_RETURN:
Hash retHash; // the hash of the tx you are rejecting
};
struct TimeBounds
{
TimePoint minTime;
TimePoint maxTime; // 0 here means no maxTime
};
struct LedgerBounds
{
uint32 minLedger;
uint32 maxLedger; // 0 here means no maxLedger
};
struct PreconditionsV2
{
TimeBounds* timeBounds;
// Transaction only valid for ledger numbers n such that
// minLedger <= n < maxLedger (if maxLedger == 0, then
// only minLedger is checked)
LedgerBounds* ledgerBounds;
// If NULL, only valid when sourceAccount's sequence number
// is seqNum - 1. Otherwise, valid when sourceAccount's
// sequence number n satisfies minSeqNum <= n < tx.seqNum.
// Note that after execution the account's sequence number
// is always raised to tx.seqNum, and a transaction is not
// valid if tx.seqNum is too high to ensure replay protection.
SequenceNumber* minSeqNum;
// For the transaction to be valid, the current ledger time must
// be at least minSeqAge greater than sourceAccount's seqTime.
Duration minSeqAge;
// For the transaction to be valid, the current ledger number
// must be at least minSeqLedgerGap greater than sourceAccount's
// seqLedger.
uint32 minSeqLedgerGap;
// For the transaction to be valid, there must be a signature
// corresponding to every Signer in this array, even if the
// signature is not otherwise required by the sourceAccount or
// operations.
SignerKey extraSigners<2>;
};
enum PreconditionType
{
PRECOND_NONE = 0,
PRECOND_TIME = 1,
PRECOND_V2 = 2
};
union Preconditions switch (PreconditionType type)
{
case PRECOND_NONE:
void;
case PRECOND_TIME:
TimeBounds timeBounds;
case PRECOND_V2:
PreconditionsV2 v2;
};
// Ledger key sets touched by a smart contract transaction.
struct LedgerFootprint
{
LedgerKey readOnly<>;
LedgerKey readWrite<>;
};
// Resource limits for a Soroban transaction.
// The transaction will fail if it exceeds any of these limits.
struct SorobanResources
{
// The ledger footprint of the transaction.
LedgerFootprint footprint;
// The maximum number of instructions this transaction can use
uint32 instructions;
// The maximum number of bytes this transaction can read from ledger
uint32 readBytes;
// The maximum number of bytes this transaction can write to ledger
uint32 writeBytes;
};
// The transaction extension for Soroban.
struct SorobanTransactionData
{
ExtensionPoint ext;
SorobanResources resources;
// Amount of the transaction `fee` allocated to the Soroban resource fees.
// The fraction of `resourceFee` corresponding to `resources` specified
// above is *not* refundable (i.e. fees for instructions, ledger I/O), as
// well as fees for the transaction size.
// The remaining part of the fee is refundable and the charged value is
// based on the actual consumption of refundable resources (events, ledger
// rent bumps).
// The `inclusionFee` used for prioritization of the transaction is defined
// as `tx.fee - resourceFee`.
int64 resourceFee;
};
// TransactionV0 is a transaction with the AccountID discriminant stripped off,
// leaving a raw ed25519 public key to identify the source account. This is used
// for backwards compatibility starting from the protocol 12/13 boundary. If an
// "old-style" TransactionEnvelope containing a Transaction is parsed with this
// XDR definition, it will be parsed as a "new-style" TransactionEnvelope
// containing a TransactionV0.
struct TransactionV0
{
uint256 sourceAccountEd25519;
uint32 fee;
SequenceNumber seqNum;
TimeBounds* timeBounds;
Memo memo;
Operation operations<MAX_OPS_PER_TX>;
union switch (int v)
{
case 0:
void;
}
ext;
};
struct TransactionV0Envelope
{
TransactionV0 tx;
/* Each decorated signature is a signature over the SHA256 hash of
* a TransactionSignaturePayload */
DecoratedSignature signatures<20>;
};
/* a transaction is a container for a set of operations
- is executed by an account
- fees are collected from the account
- operations are executed in order as one ACID transaction
either all operations are applied or none are
if any returns a failing code
*/
struct Transaction
{
// account used to run the transaction
MuxedAccount sourceAccount;
// the fee the sourceAccount will pay
uint32 fee;
// sequence number to consume in the account
SequenceNumber seqNum;
// validity conditions
Preconditions cond;
Memo memo;
Operation operations<MAX_OPS_PER_TX>;
// reserved for future use
union switch (int v)
{
case 0:
void;
case 1:
SorobanTransactionData sorobanData;
}
ext;
};
struct TransactionV1Envelope
{
Transaction tx;
/* Each decorated signature is a signature over the SHA256 hash of
* a TransactionSignaturePayload */
DecoratedSignature signatures<20>;
};
struct FeeBumpTransaction
{
MuxedAccount feeSource;
int64 fee;
union switch (EnvelopeType type)
{
case ENVELOPE_TYPE_TX:
TransactionV1Envelope v1;
}
innerTx;
union switch (int v)
{
case 0:
void;
}
ext;
};
struct FeeBumpTransactionEnvelope
{
FeeBumpTransaction tx;
/* Each decorated signature is a signature over the SHA256 hash of
* a TransactionSignaturePayload */
DecoratedSignature signatures<20>;
};
/* A TransactionEnvelope wraps a transaction with signatures. */
union TransactionEnvelope switch (EnvelopeType type)
{
case ENVELOPE_TYPE_TX_V0:
TransactionV0Envelope v0;
case ENVELOPE_TYPE_TX:
TransactionV1Envelope v1;
case ENVELOPE_TYPE_TX_FEE_BUMP:
FeeBumpTransactionEnvelope feeBump;
};
struct TransactionSignaturePayload
{
Hash networkId;
union switch (EnvelopeType type)
{
// Backwards Compatibility: Use ENVELOPE_TYPE_TX to sign ENVELOPE_TYPE_TX_V0
case ENVELOPE_TYPE_TX:
Transaction tx;
case ENVELOPE_TYPE_TX_FEE_BUMP:
FeeBumpTransaction feeBump;
}
taggedTransaction;
};
/* Operation Results section */
enum ClaimAtomType
{
CLAIM_ATOM_TYPE_V0 = 0,
CLAIM_ATOM_TYPE_ORDER_BOOK = 1,
CLAIM_ATOM_TYPE_LIQUIDITY_POOL = 2
};
// ClaimOfferAtomV0 is a ClaimOfferAtom with the AccountID discriminant stripped
// off, leaving a raw ed25519 public key to identify the source account. This is
// used for backwards compatibility starting from the protocol 17/18 boundary.
// If an "old-style" ClaimOfferAtom is parsed with this XDR definition, it will
// be parsed as a "new-style" ClaimAtom containing a ClaimOfferAtomV0.
struct ClaimOfferAtomV0
{
// emitted to identify the offer
uint256 sellerEd25519; // Account that owns the offer
int64 offerID;
// amount and asset taken from the owner
Asset assetSold;
int64 amountSold;
// amount and asset sent to the owner
Asset assetBought;
int64 amountBought;
};
struct ClaimOfferAtom
{
// emitted to identify the offer
AccountID sellerID; // Account that owns the offer
int64 offerID;
// amount and asset taken from the owner
Asset assetSold;
int64 amountSold;
// amount and asset sent to the owner