stellar-base 0.22.0 → 0.23.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSE.txt → LICENSE} +0 -0
  3. data/README.md +2 -3
  4. data/generated/stellar-base-generated.rb +10 -1
  5. data/generated/stellar/allow_trust_op.rb +3 -2
  6. data/generated/stellar/authenticated_message.rb +4 -4
  7. data/generated/stellar/authenticated_message/v0.rb +4 -4
  8. data/generated/stellar/change_trust_result_code.rb +1 -1
  9. data/generated/stellar/crypto_key_type.rb +8 -4
  10. data/generated/stellar/curve25519_public.rb +1 -1
  11. data/generated/stellar/curve25519_secret.rb +1 -1
  12. data/generated/stellar/envelope_type.rb +9 -5
  13. data/generated/stellar/fee_bump_transaction.rb +39 -0
  14. data/generated/stellar/fee_bump_transaction/ext.rb +24 -0
  15. data/generated/stellar/fee_bump_transaction/inner_tx.rb +25 -0
  16. data/generated/stellar/fee_bump_transaction_envelope.rb +22 -0
  17. data/generated/stellar/hmac_sha256_key.rb +1 -1
  18. data/generated/stellar/hmac_sha256_mac.rb +1 -1
  19. data/generated/stellar/inner_transaction_result.rb +56 -0
  20. data/generated/stellar/inner_transaction_result/ext.rb +24 -0
  21. data/generated/stellar/inner_transaction_result/result.rb +52 -0
  22. data/generated/stellar/inner_transaction_result_pair.rb +20 -0
  23. data/generated/stellar/ledger_close_meta.rb +1 -1
  24. data/generated/stellar/manage_buy_offer_result_code.rb +5 -4
  25. data/generated/stellar/manage_sell_offer_result_code.rb +12 -8
  26. data/generated/stellar/muxed_account.rb +35 -0
  27. data/generated/stellar/muxed_account/med25519.rb +22 -0
  28. data/generated/stellar/operation.rb +3 -3
  29. data/generated/stellar/operation/body.rb +2 -2
  30. data/generated/stellar/operation_result.rb +1 -1
  31. data/generated/stellar/operation_result/tr.rb +1 -1
  32. data/generated/stellar/operation_result_code.rb +3 -3
  33. data/generated/stellar/path_payment_strict_receive_op.rb +4 -4
  34. data/generated/stellar/path_payment_strict_receive_result_code.rb +21 -12
  35. data/generated/stellar/path_payment_strict_send_op.rb +6 -6
  36. data/generated/stellar/path_payment_strict_send_result_code.rb +20 -12
  37. data/generated/stellar/payment_op.rb +4 -4
  38. data/generated/stellar/survey_response_body.rb +2 -2
  39. data/generated/stellar/transaction.rb +2 -2
  40. data/generated/stellar/transaction_envelope.rb +17 -8
  41. data/generated/stellar/transaction_result.rb +3 -0
  42. data/generated/stellar/transaction_result/result.rb +9 -3
  43. data/generated/stellar/transaction_result_code.rb +21 -14
  44. data/generated/stellar/transaction_signature_payload.rb +3 -1
  45. data/generated/stellar/transaction_signature_payload/tagged_transaction.rb +7 -3
  46. data/generated/stellar/transaction_v0.rb +39 -0
  47. data/generated/stellar/transaction_v0/ext.rb +24 -0
  48. data/generated/stellar/transaction_v0_envelope.rb +22 -0
  49. data/generated/stellar/transaction_v1_envelope.rb +22 -0
  50. data/generated/stellar/trust_line_flags.rb +6 -2
  51. data/lib/stellar-base.rb +27 -25
  52. data/lib/stellar/account_flags.rb +2 -4
  53. data/lib/stellar/asset.rb +6 -6
  54. data/lib/stellar/base.rb +1 -1
  55. data/lib/stellar/{base/compat.rb → compat.rb} +6 -7
  56. data/lib/stellar/concerns/transaction.rb +49 -0
  57. data/lib/stellar/convert.rb +2 -2
  58. data/lib/stellar/factories.rb +1 -3
  59. data/lib/stellar/fee_bump_transaction.rb +21 -0
  60. data/lib/stellar/key_pair.rb +9 -6
  61. data/lib/stellar/networks.rb +5 -7
  62. data/lib/stellar/operation.rb +421 -416
  63. data/lib/stellar/path_payment_strict_receive_result.rb +1 -2
  64. data/lib/stellar/price.rb +2 -4
  65. data/lib/stellar/signer_key.rb +4 -8
  66. data/lib/stellar/thresholds.rb +5 -7
  67. data/lib/stellar/transaction.rb +154 -198
  68. data/lib/stellar/transaction_builder.rb +66 -23
  69. data/lib/stellar/transaction_envelope.rb +40 -8
  70. data/lib/stellar/transaction_v0.rb +39 -0
  71. data/lib/stellar/util/continued_fraction.rb +19 -19
  72. data/lib/stellar/util/strkey.rb +39 -14
  73. data/lib/stellar/{base/version.rb → version.rb} +1 -1
  74. metadata +33 -203
  75. data/.gitignore +0 -17
  76. data/.travis.yml +0 -16
  77. data/.yardopts +0 -8
  78. data/CHANGELOG.md +0 -149
  79. data/CONTRIBUTING.md +0 -48
  80. data/Gemfile +0 -9
  81. data/Guardfile +0 -5
  82. data/Rakefile +0 -4
  83. data/examples/allow_trust.rb +0 -51
  84. data/examples/create_account.rb +0 -26
  85. data/examples/low_level_transaction_post.rb +0 -46
  86. data/examples/mid_level_transaction_post.rb +0 -33
  87. data/examples/non_native_payment.rb +0 -60
  88. data/examples/offer.rb +0 -75
  89. data/examples/transaction_merge.rb +0 -23
  90. data/ruby-stellar-base.gemspec +0 -34
  91. data/spec/lib/stellar/account_flags_spec.rb +0 -19
  92. data/spec/lib/stellar/asset_spec.rb +0 -45
  93. data/spec/lib/stellar/convert_spec.rb +0 -61
  94. data/spec/lib/stellar/key_pair_spec.rb +0 -251
  95. data/spec/lib/stellar/networks_spec.rb +0 -77
  96. data/spec/lib/stellar/operation_spec.rb +0 -131
  97. data/spec/lib/stellar/path_payment_strict_receive_result_spec.rb +0 -95
  98. data/spec/lib/stellar/price_spec.rb +0 -34
  99. data/spec/lib/stellar/signer_key_spec.rb +0 -26
  100. data/spec/lib/stellar/thresholds_spec.rb +0 -62
  101. data/spec/lib/stellar/transaction_builder_spec.rb +0 -263
  102. data/spec/lib/stellar/transaction_envelope_spec.rb +0 -93
  103. data/spec/lib/stellar/transaction_spec.rb +0 -132
  104. data/spec/lib/stellar/util/strkey_spec.rb +0 -54
  105. data/spec/spec_helper.rb +0 -16
  106. data/spec/support/matchers/be_strkey.rb +0 -9
  107. data/spec/support/matchers/eq_bytes.rb +0 -5
  108. data/spec/support/matchers/have_length.rb +0 -5
  109. data/tasks/rspec.rake +0 -6
  110. data/tasks/travis.rake +0 -1
  111. data/tasks/xdr.rake +0 -45
  112. data/xdr/Stellar-SCP.x +0 -86
  113. data/xdr/Stellar-ledger-entries.x +0 -295
  114. data/xdr/Stellar-ledger.x +0 -372
  115. data/xdr/Stellar-overlay.x +0 -229
  116. data/xdr/Stellar-transaction.x +0 -901
  117. data/xdr/Stellar-types.x +0 -81
@@ -1,229 +0,0 @@
1
- // Copyright 2015 Stellar Development Foundation and contributors. Licensed
2
- // under the Apache License, Version 2.0. See the COPYING file at the root
3
- // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
4
-
5
- %#include "xdr/Stellar-ledger.h"
6
-
7
- namespace stellar
8
- {
9
-
10
- enum ErrorCode
11
- {
12
- ERR_MISC = 0, // Unspecific error
13
- ERR_DATA = 1, // Malformed data
14
- ERR_CONF = 2, // Misconfiguration error
15
- ERR_AUTH = 3, // Authentication failure
16
- ERR_LOAD = 4 // System overloaded
17
- };
18
-
19
- struct Error
20
- {
21
- ErrorCode code;
22
- string msg<100>;
23
- };
24
-
25
- struct AuthCert
26
- {
27
- Curve25519Public pubkey;
28
- uint64 expiration;
29
- Signature sig;
30
- };
31
-
32
- struct Hello
33
- {
34
- uint32 ledgerVersion;
35
- uint32 overlayVersion;
36
- uint32 overlayMinVersion;
37
- Hash networkID;
38
- string versionStr<100>;
39
- int listeningPort;
40
- NodeID peerID;
41
- AuthCert cert;
42
- uint256 nonce;
43
- };
44
-
45
- struct Auth
46
- {
47
- // Empty message, just to confirm
48
- // establishment of MAC keys.
49
- int unused;
50
- };
51
-
52
- enum IPAddrType
53
- {
54
- IPv4 = 0,
55
- IPv6 = 1
56
- };
57
-
58
- struct PeerAddress
59
- {
60
- union switch (IPAddrType type)
61
- {
62
- case IPv4:
63
- opaque ipv4[4];
64
- case IPv6:
65
- opaque ipv6[16];
66
- }
67
- ip;
68
- uint32 port;
69
- uint32 numFailures;
70
- };
71
-
72
- enum MessageType
73
- {
74
- ERROR_MSG = 0,
75
- AUTH = 2,
76
- DONT_HAVE = 3,
77
-
78
- GET_PEERS = 4, // gets a list of peers this guy knows about
79
- PEERS = 5,
80
-
81
- GET_TX_SET = 6, // gets a particular txset by hash
82
- TX_SET = 7,
83
-
84
- TRANSACTION = 8, // pass on a tx you have heard about
85
-
86
- // SCP
87
- GET_SCP_QUORUMSET = 9,
88
- SCP_QUORUMSET = 10,
89
- SCP_MESSAGE = 11,
90
- GET_SCP_STATE = 12,
91
-
92
- // new messages
93
- HELLO = 13,
94
-
95
- SURVEY_REQUEST = 14,
96
- SURVEY_RESPONSE = 15
97
- };
98
-
99
- struct DontHave
100
- {
101
- MessageType type;
102
- uint256 reqHash;
103
- };
104
-
105
- enum SurveyMessageCommandType
106
- {
107
- SURVEY_TOPOLOGY = 0
108
- };
109
-
110
- struct SurveyRequestMessage
111
- {
112
- NodeID surveyorPeerID;
113
- NodeID surveyedPeerID;
114
- uint32 ledgerNum;
115
- Curve25519Public encryptionKey;
116
- SurveyMessageCommandType commandType;
117
- };
118
-
119
- struct SignedSurveyRequestMessage
120
- {
121
- Signature requestSignature;
122
- SurveyRequestMessage request;
123
- };
124
-
125
- typedef opaque EncryptedBody<64000>;
126
- struct SurveyResponseMessage
127
- {
128
- NodeID surveyorPeerID;
129
- NodeID surveyedPeerID;
130
- uint32 ledgerNum;
131
- SurveyMessageCommandType commandType;
132
- EncryptedBody encryptedBody;
133
- };
134
-
135
- struct SignedSurveyResponseMessage
136
- {
137
- Signature responseSignature;
138
- SurveyResponseMessage response;
139
- };
140
-
141
- struct PeerStats
142
- {
143
- NodeID id;
144
- string versionStr<100>;
145
- uint64 messagesRead;
146
- uint64 messagesWritten;
147
- uint64 bytesRead;
148
- uint64 bytesWritten;
149
- uint64 secondsConnected;
150
-
151
- uint64 uniqueFloodBytesRecv;
152
- uint64 duplicateFloodBytesRecv;
153
- uint64 uniqueFetchBytesRecv;
154
- uint64 duplicateFetchBytesRecv;
155
-
156
- uint64 uniqueFloodMessageRecv;
157
- uint64 duplicateFloodMessageRecv;
158
- uint64 uniqueFetchMessageRecv;
159
- uint64 duplicateFetchMessageRecv;
160
- };
161
-
162
- typedef PeerStats PeerStatList<25>;
163
-
164
- struct TopologyResponseBody
165
- {
166
- PeerStatList inboundPeers;
167
- PeerStatList outboundPeers;
168
-
169
- uint32 totalInboundPeerCount;
170
- uint32 totalOutboundPeerCount;
171
- };
172
-
173
- union SurveyResponseBody switch (SurveyMessageCommandType type)
174
- {
175
- case SURVEY_TOPOLOGY:
176
- TopologyResponseBody topologyResponseBody;
177
- };
178
-
179
- union StellarMessage switch (MessageType type)
180
- {
181
- case ERROR_MSG:
182
- Error error;
183
- case HELLO:
184
- Hello hello;
185
- case AUTH:
186
- Auth auth;
187
- case DONT_HAVE:
188
- DontHave dontHave;
189
- case GET_PEERS:
190
- void;
191
- case PEERS:
192
- PeerAddress peers<100>;
193
-
194
- case GET_TX_SET:
195
- uint256 txSetHash;
196
- case TX_SET:
197
- TransactionSet txSet;
198
-
199
- case TRANSACTION:
200
- TransactionEnvelope transaction;
201
-
202
- case SURVEY_REQUEST:
203
- SignedSurveyRequestMessage signedSurveyRequestMessage;
204
-
205
- case SURVEY_RESPONSE:
206
- SignedSurveyResponseMessage signedSurveyResponseMessage;
207
-
208
- // SCP
209
- case GET_SCP_QUORUMSET:
210
- uint256 qSetHash;
211
- case SCP_QUORUMSET:
212
- SCPQuorumSet qSet;
213
- case SCP_MESSAGE:
214
- SCPEnvelope envelope;
215
- case GET_SCP_STATE:
216
- uint32 getSCPLedgerSeq; // ledger seq requested ; if 0, requests the latest
217
- };
218
-
219
- union AuthenticatedMessage switch (uint32 v)
220
- {
221
- case 0:
222
- struct
223
- {
224
- uint64 sequence;
225
- StellarMessage message;
226
- HmacSha256Mac mac;
227
- } v0;
228
- };
229
- }
@@ -1,901 +0,0 @@
1
- // Copyright 2015 Stellar Development Foundation and contributors. Licensed
2
- // under the Apache License, Version 2.0. See the COPYING file at the root
3
- // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
4
-
5
- %#include "xdr/Stellar-ledger-entries.h"
6
-
7
- namespace stellar
8
- {
9
-
10
- struct DecoratedSignature
11
- {
12
- SignatureHint hint; // last 4 bytes of the public key, used as a hint
13
- Signature signature; // actual signature
14
- };
15
-
16
- enum OperationType
17
- {
18
- CREATE_ACCOUNT = 0,
19
- PAYMENT = 1,
20
- PATH_PAYMENT_STRICT_RECEIVE = 2,
21
- MANAGE_SELL_OFFER = 3,
22
- CREATE_PASSIVE_SELL_OFFER = 4,
23
- SET_OPTIONS = 5,
24
- CHANGE_TRUST = 6,
25
- ALLOW_TRUST = 7,
26
- ACCOUNT_MERGE = 8,
27
- INFLATION = 9,
28
- MANAGE_DATA = 10,
29
- BUMP_SEQUENCE = 11,
30
- MANAGE_BUY_OFFER = 12,
31
- PATH_PAYMENT_STRICT_SEND = 13
32
- };
33
-
34
- /* CreateAccount
35
- Creates and funds a new account with the specified starting balance.
36
-
37
- Threshold: med
38
-
39
- Result: CreateAccountResult
40
-
41
- */
42
- struct CreateAccountOp
43
- {
44
- AccountID destination; // account to create
45
- int64 startingBalance; // amount they end up with
46
- };
47
-
48
- /* Payment
49
-
50
- Send an amount in specified asset to a destination account.
51
-
52
- Threshold: med
53
-
54
- Result: PaymentResult
55
- */
56
- struct PaymentOp
57
- {
58
- AccountID destination; // recipient of the payment
59
- Asset asset; // what they end up with
60
- int64 amount; // amount they end up with
61
- };
62
-
63
- /* PathPaymentStrictReceive
64
-
65
- send an amount to a destination account through a path.
66
- (up to sendMax, sendAsset)
67
- (X0, Path[0]) .. (Xn, Path[n])
68
- (destAmount, destAsset)
69
-
70
- Threshold: med
71
-
72
- Result: PathPaymentStrictReceiveResult
73
- */
74
- struct PathPaymentStrictReceiveOp
75
- {
76
- Asset sendAsset; // asset we pay with
77
- int64 sendMax; // the maximum amount of sendAsset to
78
- // send (excluding fees).
79
- // The operation will fail if can't be met
80
-
81
- AccountID destination; // recipient of the payment
82
- Asset destAsset; // what they end up with
83
- int64 destAmount; // amount they end up with
84
-
85
- Asset path<5>; // additional hops it must go through to get there
86
- };
87
-
88
- /* PathPaymentStrictSend
89
-
90
- send an amount to a destination account through a path.
91
- (sendMax, sendAsset)
92
- (X0, Path[0]) .. (Xn, Path[n])
93
- (at least destAmount, destAsset)
94
-
95
- Threshold: med
96
-
97
- Result: PathPaymentStrictSendResult
98
- */
99
- struct PathPaymentStrictSendOp
100
- {
101
- Asset sendAsset; // asset we pay with
102
- int64 sendAmount; // amount of sendAsset to send (excluding fees)
103
-
104
- AccountID destination; // recipient of the payment
105
- Asset destAsset; // what they end up with
106
- int64 destMin; // the minimum amount of dest asset to
107
- // be received
108
- // The operation will fail if it can't be met
109
-
110
- Asset path<5>; // additional hops it must go through to get there
111
- };
112
-
113
-
114
- /* Creates, updates or deletes an offer
115
-
116
- Threshold: med
117
-
118
- Result: ManageSellOfferResult
119
-
120
- */
121
- struct ManageSellOfferOp
122
- {
123
- Asset selling;
124
- Asset buying;
125
- int64 amount; // amount being sold. if set to 0, delete the offer
126
- Price price; // price of thing being sold in terms of what you are buying
127
-
128
- // 0=create a new offer, otherwise edit an existing offer
129
- int64 offerID;
130
- };
131
-
132
- /* Creates, updates or deletes an offer with amount in terms of buying asset
133
-
134
- Threshold: med
135
-
136
- Result: ManageBuyOfferResult
137
-
138
- */
139
- struct ManageBuyOfferOp
140
- {
141
- Asset selling;
142
- Asset buying;
143
- int64 buyAmount; // amount being bought. if set to 0, delete the offer
144
- Price price; // price of thing being bought in terms of what you are
145
- // selling
146
-
147
- // 0=create a new offer, otherwise edit an existing offer
148
- int64 offerID;
149
- };
150
-
151
- /* Creates an offer that doesn't take offers of the same price
152
-
153
- Threshold: med
154
-
155
- Result: CreatePassiveSellOfferResult
156
-
157
- */
158
- struct CreatePassiveSellOfferOp
159
- {
160
- Asset selling; // A
161
- Asset buying; // B
162
- int64 amount; // amount taker gets. if set to 0, delete the offer
163
- Price price; // cost of A in terms of B
164
- };
165
-
166
- /* Set Account Options
167
-
168
- updates "AccountEntry" fields.
169
- note: updating thresholds or signers requires high threshold
170
-
171
- Threshold: med or high
172
-
173
- Result: SetOptionsResult
174
- */
175
- struct SetOptionsOp
176
- {
177
- AccountID* inflationDest; // sets the inflation destination
178
-
179
- uint32* clearFlags; // which flags to clear
180
- uint32* setFlags; // which flags to set
181
-
182
- // account threshold manipulation
183
- uint32* masterWeight; // weight of the master account
184
- uint32* lowThreshold;
185
- uint32* medThreshold;
186
- uint32* highThreshold;
187
-
188
- string32* homeDomain; // sets the home domain
189
-
190
- // Add, update or remove a signer for the account
191
- // signer is deleted if the weight is 0
192
- Signer* signer;
193
- };
194
-
195
- /* Creates, updates or deletes a trust line
196
-
197
- Threshold: med
198
-
199
- Result: ChangeTrustResult
200
-
201
- */
202
- struct ChangeTrustOp
203
- {
204
- Asset line;
205
-
206
- // if limit is set to 0, deletes the trust line
207
- int64 limit;
208
- };
209
-
210
- /* Updates the "authorized" flag of an existing trust line
211
- this is called by the issuer of the related asset.
212
-
213
- note that authorize can only be set (and not cleared) if
214
- the issuer account does not have the AUTH_REVOCABLE_FLAG set
215
- Threshold: low
216
-
217
- Result: AllowTrustResult
218
- */
219
- struct AllowTrustOp
220
- {
221
- AccountID trustor;
222
- union switch (AssetType type)
223
- {
224
- // ASSET_TYPE_NATIVE is not allowed
225
- case ASSET_TYPE_CREDIT_ALPHANUM4:
226
- AssetCode4 assetCode4;
227
-
228
- case ASSET_TYPE_CREDIT_ALPHANUM12:
229
- AssetCode12 assetCode12;
230
-
231
- // add other asset types here in the future
232
- }
233
- asset;
234
-
235
- bool authorize;
236
- };
237
-
238
- /* Inflation
239
- Runs inflation
240
-
241
- Threshold: low
242
-
243
- Result: InflationResult
244
-
245
- */
246
-
247
- /* AccountMerge
248
- Transfers native balance to destination account.
249
-
250
- Threshold: high
251
-
252
- Result : AccountMergeResult
253
- */
254
-
255
- /* ManageData
256
- Adds, Updates, or Deletes a key value pair associated with a particular
257
- account.
258
-
259
- Threshold: med
260
-
261
- Result: ManageDataResult
262
- */
263
- struct ManageDataOp
264
- {
265
- string64 dataName;
266
- DataValue* dataValue; // set to null to clear
267
- };
268
-
269
- /* Bump Sequence
270
-
271
- increases the sequence to a given level
272
-
273
- Threshold: low
274
-
275
- Result: BumpSequenceResult
276
- */
277
- struct BumpSequenceOp
278
- {
279
- SequenceNumber bumpTo;
280
- };
281
-
282
- /* An operation is the lowest unit of work that a transaction does */
283
- struct Operation
284
- {
285
- // sourceAccount is the account used to run the operation
286
- // if not set, the runtime defaults to "sourceAccount" specified at
287
- // the transaction level
288
- AccountID* sourceAccount;
289
-
290
- union switch (OperationType type)
291
- {
292
- case CREATE_ACCOUNT:
293
- CreateAccountOp createAccountOp;
294
- case PAYMENT:
295
- PaymentOp paymentOp;
296
- case PATH_PAYMENT_STRICT_RECEIVE:
297
- PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp;
298
- case MANAGE_SELL_OFFER:
299
- ManageSellOfferOp manageSellOfferOp;
300
- case CREATE_PASSIVE_SELL_OFFER:
301
- CreatePassiveSellOfferOp createPassiveSellOfferOp;
302
- case SET_OPTIONS:
303
- SetOptionsOp setOptionsOp;
304
- case CHANGE_TRUST:
305
- ChangeTrustOp changeTrustOp;
306
- case ALLOW_TRUST:
307
- AllowTrustOp allowTrustOp;
308
- case ACCOUNT_MERGE:
309
- AccountID destination;
310
- case INFLATION:
311
- void;
312
- case MANAGE_DATA:
313
- ManageDataOp manageDataOp;
314
- case BUMP_SEQUENCE:
315
- BumpSequenceOp bumpSequenceOp;
316
- case MANAGE_BUY_OFFER:
317
- ManageBuyOfferOp manageBuyOfferOp;
318
- case PATH_PAYMENT_STRICT_SEND:
319
- PathPaymentStrictSendOp pathPaymentStrictSendOp;
320
- }
321
- body;
322
- };
323
-
324
- enum MemoType
325
- {
326
- MEMO_NONE = 0,
327
- MEMO_TEXT = 1,
328
- MEMO_ID = 2,
329
- MEMO_HASH = 3,
330
- MEMO_RETURN = 4
331
- };
332
-
333
- union Memo switch (MemoType type)
334
- {
335
- case MEMO_NONE:
336
- void;
337
- case MEMO_TEXT:
338
- string text<28>;
339
- case MEMO_ID:
340
- uint64 id;
341
- case MEMO_HASH:
342
- Hash hash; // the hash of what to pull from the content server
343
- case MEMO_RETURN:
344
- Hash retHash; // the hash of the tx you are rejecting
345
- };
346
-
347
- struct TimeBounds
348
- {
349
- TimePoint minTime;
350
- TimePoint maxTime; // 0 here means no maxTime
351
- };
352
-
353
- // maximum number of operations per transaction
354
- const MAX_OPS_PER_TX = 100;
355
-
356
- /* a transaction is a container for a set of operations
357
- - is executed by an account
358
- - fees are collected from the account
359
- - operations are executed in order as one ACID transaction
360
- either all operations are applied or none are
361
- if any returns a failing code
362
- */
363
- struct Transaction
364
- {
365
- // account used to run the transaction
366
- AccountID sourceAccount;
367
-
368
- // the fee the sourceAccount will pay
369
- uint32 fee;
370
-
371
- // sequence number to consume in the account
372
- SequenceNumber seqNum;
373
-
374
- // validity range (inclusive) for the last ledger close time
375
- TimeBounds* timeBounds;
376
-
377
- Memo memo;
378
-
379
- Operation operations<MAX_OPS_PER_TX>;
380
-
381
- // reserved for future use
382
- union switch (int v)
383
- {
384
- case 0:
385
- void;
386
- }
387
- ext;
388
- };
389
-
390
- struct TransactionSignaturePayload
391
- {
392
- Hash networkId;
393
- union switch (EnvelopeType type)
394
- {
395
- case ENVELOPE_TYPE_TX:
396
- Transaction tx;
397
- /* All other values of type are invalid */
398
- }
399
- taggedTransaction;
400
- };
401
-
402
- /* A TransactionEnvelope wraps a transaction with signatures. */
403
- struct TransactionEnvelope
404
- {
405
- Transaction tx;
406
- /* Each decorated signature is a signature over the SHA256 hash of
407
- * a TransactionSignaturePayload */
408
- DecoratedSignature signatures<20>;
409
- };
410
-
411
- /* Operation Results section */
412
-
413
- /* This result is used when offers are taken during an operation */
414
- struct ClaimOfferAtom
415
- {
416
- // emitted to identify the offer
417
- AccountID sellerID; // Account that owns the offer
418
- int64 offerID;
419
-
420
- // amount and asset taken from the owner
421
- Asset assetSold;
422
- int64 amountSold;
423
-
424
- // amount and asset sent to the owner
425
- Asset assetBought;
426
- int64 amountBought;
427
- };
428
-
429
- /******* CreateAccount Result ********/
430
-
431
- enum CreateAccountResultCode
432
- {
433
- // codes considered as "success" for the operation
434
- CREATE_ACCOUNT_SUCCESS = 0, // account was created
435
-
436
- // codes considered as "failure" for the operation
437
- CREATE_ACCOUNT_MALFORMED = -1, // invalid destination
438
- CREATE_ACCOUNT_UNDERFUNDED = -2, // not enough funds in source account
439
- CREATE_ACCOUNT_LOW_RESERVE =
440
- -3, // would create an account below the min reserve
441
- CREATE_ACCOUNT_ALREADY_EXIST = -4 // account already exists
442
- };
443
-
444
- union CreateAccountResult switch (CreateAccountResultCode code)
445
- {
446
- case CREATE_ACCOUNT_SUCCESS:
447
- void;
448
- default:
449
- void;
450
- };
451
-
452
- /******* Payment Result ********/
453
-
454
- enum PaymentResultCode
455
- {
456
- // codes considered as "success" for the operation
457
- PAYMENT_SUCCESS = 0, // payment successfuly completed
458
-
459
- // codes considered as "failure" for the operation
460
- PAYMENT_MALFORMED = -1, // bad input
461
- PAYMENT_UNDERFUNDED = -2, // not enough funds in source account
462
- PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account
463
- PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
464
- PAYMENT_NO_DESTINATION = -5, // destination account does not exist
465
- PAYMENT_NO_TRUST = -6, // destination missing a trust line for asset
466
- PAYMENT_NOT_AUTHORIZED = -7, // destination not authorized to hold asset
467
- PAYMENT_LINE_FULL = -8, // destination would go above their limit
468
- PAYMENT_NO_ISSUER = -9 // missing issuer on asset
469
- };
470
-
471
- union PaymentResult switch (PaymentResultCode code)
472
- {
473
- case PAYMENT_SUCCESS:
474
- void;
475
- default:
476
- void;
477
- };
478
-
479
- /******* PathPaymentStrictReceive Result ********/
480
-
481
- enum PathPaymentStrictReceiveResultCode
482
- {
483
- // codes considered as "success" for the operation
484
- PATH_PAYMENT_STRICT_RECEIVE_SUCCESS = 0, // success
485
-
486
- // codes considered as "failure" for the operation
487
- PATH_PAYMENT_STRICT_RECEIVE_MALFORMED = -1, // bad input
488
- PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED = -2, // not enough funds in source account
489
- PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST = -3, // no trust line on source account
490
- PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
491
- PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION = -5, // destination account does not exist
492
- PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST = -6, // dest missing a trust line for asset
493
- PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED = -7, // dest not authorized to hold asset
494
- PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL = -8, // dest would go above their limit
495
- PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER = -9, // missing issuer on one asset
496
- PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS = -10, // not enough offers to satisfy path
497
- PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF = -11, // would cross one of its own offers
498
- PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX = -12 // could not satisfy sendmax
499
- };
500
-
501
- struct SimplePaymentResult
502
- {
503
- AccountID destination;
504
- Asset asset;
505
- int64 amount;
506
- };
507
-
508
- union PathPaymentStrictReceiveResult switch (PathPaymentStrictReceiveResultCode code)
509
- {
510
- case PATH_PAYMENT_STRICT_RECEIVE_SUCCESS:
511
- struct
512
- {
513
- ClaimOfferAtom offers<>;
514
- SimplePaymentResult last;
515
- } success;
516
- case PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER:
517
- Asset noIssuer; // the asset that caused the error
518
- default:
519
- void;
520
- };
521
-
522
- /******* PathPaymentStrictSend Result ********/
523
-
524
- enum PathPaymentStrictSendResultCode
525
- {
526
- // codes considered as "success" for the operation
527
- PATH_PAYMENT_STRICT_SEND_SUCCESS = 0, // success
528
-
529
- // codes considered as "failure" for the operation
530
- PATH_PAYMENT_STRICT_SEND_MALFORMED = -1, // bad input
531
- PATH_PAYMENT_STRICT_SEND_UNDERFUNDED = -2, // not enough funds in source account
532
- PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST = -3, // no trust line on source account
533
- PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
534
- PATH_PAYMENT_STRICT_SEND_NO_DESTINATION = -5, // destination account does not exist
535
- PATH_PAYMENT_STRICT_SEND_NO_TRUST = -6, // dest missing a trust line for asset
536
- PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED = -7, // dest not authorized to hold asset
537
- PATH_PAYMENT_STRICT_SEND_LINE_FULL = -8, // dest would go above their limit
538
- PATH_PAYMENT_STRICT_SEND_NO_ISSUER = -9, // missing issuer on one asset
539
- PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS = -10, // not enough offers to satisfy path
540
- PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF = -11, // would cross one of its own offers
541
- PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN = -12 // could not satisfy destMin
542
- };
543
-
544
- union PathPaymentStrictSendResult switch (PathPaymentStrictSendResultCode code)
545
- {
546
- case PATH_PAYMENT_STRICT_SEND_SUCCESS:
547
- struct
548
- {
549
- ClaimOfferAtom offers<>;
550
- SimplePaymentResult last;
551
- } success;
552
- case PATH_PAYMENT_STRICT_SEND_NO_ISSUER:
553
- Asset noIssuer; // the asset that caused the error
554
- default:
555
- void;
556
- };
557
-
558
- /******* ManageSellOffer Result ********/
559
-
560
- enum ManageSellOfferResultCode
561
- {
562
- // codes considered as "success" for the operation
563
- MANAGE_SELL_OFFER_SUCCESS = 0,
564
-
565
- // codes considered as "failure" for the operation
566
- MANAGE_SELL_OFFER_MALFORMED = -1, // generated offer would be invalid
567
- MANAGE_SELL_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling
568
- MANAGE_SELL_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying
569
- MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell
570
- MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy
571
- MANAGE_SELL_OFFER_LINE_FULL = -6, // can't receive more of what it's buying
572
- MANAGE_SELL_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell
573
- MANAGE_SELL_OFFER_CROSS_SELF = -8, // would cross an offer from the same user
574
- MANAGE_SELL_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling
575
- MANAGE_SELL_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying
576
-
577
- // update errors
578
- MANAGE_SELL_OFFER_NOT_FOUND = -11, // offerID does not match an existing offer
579
-
580
- MANAGE_SELL_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer
581
- };
582
-
583
- enum ManageOfferEffect
584
- {
585
- MANAGE_OFFER_CREATED = 0,
586
- MANAGE_OFFER_UPDATED = 1,
587
- MANAGE_OFFER_DELETED = 2
588
- };
589
-
590
- struct ManageOfferSuccessResult
591
- {
592
- // offers that got claimed while creating this offer
593
- ClaimOfferAtom offersClaimed<>;
594
-
595
- union switch (ManageOfferEffect effect)
596
- {
597
- case MANAGE_OFFER_CREATED:
598
- case MANAGE_OFFER_UPDATED:
599
- OfferEntry offer;
600
- default:
601
- void;
602
- }
603
- offer;
604
- };
605
-
606
- union ManageSellOfferResult switch (ManageSellOfferResultCode code)
607
- {
608
- case MANAGE_SELL_OFFER_SUCCESS:
609
- ManageOfferSuccessResult success;
610
- default:
611
- void;
612
- };
613
-
614
- /******* ManageBuyOffer Result ********/
615
-
616
- enum ManageBuyOfferResultCode
617
- {
618
- // codes considered as "success" for the operation
619
- MANAGE_BUY_OFFER_SUCCESS = 0,
620
-
621
- // codes considered as "failure" for the operation
622
- MANAGE_BUY_OFFER_MALFORMED = -1, // generated offer would be invalid
623
- MANAGE_BUY_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling
624
- MANAGE_BUY_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying
625
- MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell
626
- MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy
627
- MANAGE_BUY_OFFER_LINE_FULL = -6, // can't receive more of what it's buying
628
- MANAGE_BUY_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell
629
- MANAGE_BUY_OFFER_CROSS_SELF = -8, // would cross an offer from the same user
630
- MANAGE_BUY_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling
631
- MANAGE_BUY_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying
632
-
633
- // update errors
634
- MANAGE_BUY_OFFER_NOT_FOUND = -11, // offerID does not match an existing offer
635
-
636
- MANAGE_BUY_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer
637
- };
638
-
639
- union ManageBuyOfferResult switch (ManageBuyOfferResultCode code)
640
- {
641
- case MANAGE_BUY_OFFER_SUCCESS:
642
- ManageOfferSuccessResult success;
643
- default:
644
- void;
645
- };
646
-
647
- /******* SetOptions Result ********/
648
-
649
- enum SetOptionsResultCode
650
- {
651
- // codes considered as "success" for the operation
652
- SET_OPTIONS_SUCCESS = 0,
653
- // codes considered as "failure" for the operation
654
- SET_OPTIONS_LOW_RESERVE = -1, // not enough funds to add a signer
655
- SET_OPTIONS_TOO_MANY_SIGNERS = -2, // max number of signers already reached
656
- SET_OPTIONS_BAD_FLAGS = -3, // invalid combination of clear/set flags
657
- SET_OPTIONS_INVALID_INFLATION = -4, // inflation account does not exist
658
- SET_OPTIONS_CANT_CHANGE = -5, // can no longer change this option
659
- SET_OPTIONS_UNKNOWN_FLAG = -6, // can't set an unknown flag
660
- SET_OPTIONS_THRESHOLD_OUT_OF_RANGE = -7, // bad value for weight/threshold
661
- SET_OPTIONS_BAD_SIGNER = -8, // signer cannot be masterkey
662
- SET_OPTIONS_INVALID_HOME_DOMAIN = -9 // malformed home domain
663
- };
664
-
665
- union SetOptionsResult switch (SetOptionsResultCode code)
666
- {
667
- case SET_OPTIONS_SUCCESS:
668
- void;
669
- default:
670
- void;
671
- };
672
-
673
- /******* ChangeTrust Result ********/
674
-
675
- enum ChangeTrustResultCode
676
- {
677
- // codes considered as "success" for the operation
678
- CHANGE_TRUST_SUCCESS = 0,
679
- // codes considered as "failure" for the operation
680
- CHANGE_TRUST_MALFORMED = -1, // bad input
681
- CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer
682
- CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance
683
- // cannot create with a limit of 0
684
- CHANGE_TRUST_LOW_RESERVE =
685
- -4, // not enough funds to create a new trust line,
686
- CHANGE_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed
687
- };
688
-
689
- union ChangeTrustResult switch (ChangeTrustResultCode code)
690
- {
691
- case CHANGE_TRUST_SUCCESS:
692
- void;
693
- default:
694
- void;
695
- };
696
-
697
- /******* AllowTrust Result ********/
698
-
699
- enum AllowTrustResultCode
700
- {
701
- // codes considered as "success" for the operation
702
- ALLOW_TRUST_SUCCESS = 0,
703
- // codes considered as "failure" for the operation
704
- ALLOW_TRUST_MALFORMED = -1, // asset is not ASSET_TYPE_ALPHANUM
705
- ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline
706
- // source account does not require trust
707
- ALLOW_TRUST_TRUST_NOT_REQUIRED = -3,
708
- ALLOW_TRUST_CANT_REVOKE = -4, // source account can't revoke trust,
709
- ALLOW_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed
710
- };
711
-
712
- union AllowTrustResult switch (AllowTrustResultCode code)
713
- {
714
- case ALLOW_TRUST_SUCCESS:
715
- void;
716
- default:
717
- void;
718
- };
719
-
720
- /******* AccountMerge Result ********/
721
-
722
- enum AccountMergeResultCode
723
- {
724
- // codes considered as "success" for the operation
725
- ACCOUNT_MERGE_SUCCESS = 0,
726
- // codes considered as "failure" for the operation
727
- ACCOUNT_MERGE_MALFORMED = -1, // can't merge onto itself
728
- ACCOUNT_MERGE_NO_ACCOUNT = -2, // destination does not exist
729
- ACCOUNT_MERGE_IMMUTABLE_SET = -3, // source account has AUTH_IMMUTABLE set
730
- ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4, // account has trust lines/offers
731
- ACCOUNT_MERGE_SEQNUM_TOO_FAR = -5, // sequence number is over max allowed
732
- ACCOUNT_MERGE_DEST_FULL = -6 // can't add source balance to
733
- // destination balance
734
- };
735
-
736
- union AccountMergeResult switch (AccountMergeResultCode code)
737
- {
738
- case ACCOUNT_MERGE_SUCCESS:
739
- int64 sourceAccountBalance; // how much got transfered from source account
740
- default:
741
- void;
742
- };
743
-
744
- /******* Inflation Result ********/
745
-
746
- enum InflationResultCode
747
- {
748
- // codes considered as "success" for the operation
749
- INFLATION_SUCCESS = 0,
750
- // codes considered as "failure" for the operation
751
- INFLATION_NOT_TIME = -1
752
- };
753
-
754
- struct InflationPayout // or use PaymentResultAtom to limit types?
755
- {
756
- AccountID destination;
757
- int64 amount;
758
- };
759
-
760
- union InflationResult switch (InflationResultCode code)
761
- {
762
- case INFLATION_SUCCESS:
763
- InflationPayout payouts<>;
764
- default:
765
- void;
766
- };
767
-
768
- /******* ManageData Result ********/
769
-
770
- enum ManageDataResultCode
771
- {
772
- // codes considered as "success" for the operation
773
- MANAGE_DATA_SUCCESS = 0,
774
- // codes considered as "failure" for the operation
775
- MANAGE_DATA_NOT_SUPPORTED_YET =
776
- -1, // The network hasn't moved to this protocol change yet
777
- MANAGE_DATA_NAME_NOT_FOUND =
778
- -2, // Trying to remove a Data Entry that isn't there
779
- MANAGE_DATA_LOW_RESERVE = -3, // not enough funds to create a new Data Entry
780
- MANAGE_DATA_INVALID_NAME = -4 // Name not a valid string
781
- };
782
-
783
- union ManageDataResult switch (ManageDataResultCode code)
784
- {
785
- case MANAGE_DATA_SUCCESS:
786
- void;
787
- default:
788
- void;
789
- };
790
-
791
- /******* BumpSequence Result ********/
792
-
793
- enum BumpSequenceResultCode
794
- {
795
- // codes considered as "success" for the operation
796
- BUMP_SEQUENCE_SUCCESS = 0,
797
- // codes considered as "failure" for the operation
798
- BUMP_SEQUENCE_BAD_SEQ = -1 // `bumpTo` is not within bounds
799
- };
800
-
801
- union BumpSequenceResult switch (BumpSequenceResultCode code)
802
- {
803
- case BUMP_SEQUENCE_SUCCESS:
804
- void;
805
- default:
806
- void;
807
- };
808
- /* High level Operation Result */
809
-
810
- enum OperationResultCode
811
- {
812
- opINNER = 0, // inner object result is valid
813
-
814
- opBAD_AUTH = -1, // too few valid signatures / wrong network
815
- opNO_ACCOUNT = -2, // source account was not found
816
- opNOT_SUPPORTED = -3, // operation not supported at this time
817
- opTOO_MANY_SUBENTRIES = -4, // max number of subentries already reached
818
- opEXCEEDED_WORK_LIMIT = -5 // operation did too much work
819
- };
820
-
821
- union OperationResult switch (OperationResultCode code)
822
- {
823
- case opINNER:
824
- union switch (OperationType type)
825
- {
826
- case CREATE_ACCOUNT:
827
- CreateAccountResult createAccountResult;
828
- case PAYMENT:
829
- PaymentResult paymentResult;
830
- case PATH_PAYMENT_STRICT_RECEIVE:
831
- PathPaymentStrictReceiveResult pathPaymentStrictReceiveResult;
832
- case MANAGE_SELL_OFFER:
833
- ManageSellOfferResult manageSellOfferResult;
834
- case CREATE_PASSIVE_SELL_OFFER:
835
- ManageSellOfferResult createPassiveSellOfferResult;
836
- case SET_OPTIONS:
837
- SetOptionsResult setOptionsResult;
838
- case CHANGE_TRUST:
839
- ChangeTrustResult changeTrustResult;
840
- case ALLOW_TRUST:
841
- AllowTrustResult allowTrustResult;
842
- case ACCOUNT_MERGE:
843
- AccountMergeResult accountMergeResult;
844
- case INFLATION:
845
- InflationResult inflationResult;
846
- case MANAGE_DATA:
847
- ManageDataResult manageDataResult;
848
- case BUMP_SEQUENCE:
849
- BumpSequenceResult bumpSeqResult;
850
- case MANAGE_BUY_OFFER:
851
- ManageBuyOfferResult manageBuyOfferResult;
852
- case PATH_PAYMENT_STRICT_SEND:
853
- PathPaymentStrictSendResult pathPaymentStrictSendResult;
854
- }
855
- tr;
856
- default:
857
- void;
858
- };
859
-
860
- enum TransactionResultCode
861
- {
862
- txSUCCESS = 0, // all operations succeeded
863
-
864
- txFAILED = -1, // one of the operations failed (none were applied)
865
-
866
- txTOO_EARLY = -2, // ledger closeTime before minTime
867
- txTOO_LATE = -3, // ledger closeTime after maxTime
868
- txMISSING_OPERATION = -4, // no operation was specified
869
- txBAD_SEQ = -5, // sequence number does not match source account
870
-
871
- txBAD_AUTH = -6, // too few valid signatures / wrong network
872
- txINSUFFICIENT_BALANCE = -7, // fee would bring account below reserve
873
- txNO_ACCOUNT = -8, // source account not found
874
- txINSUFFICIENT_FEE = -9, // fee is too small
875
- txBAD_AUTH_EXTRA = -10, // unused signatures attached to transaction
876
- txINTERNAL_ERROR = -11 // an unknown error occured
877
- };
878
-
879
- struct TransactionResult
880
- {
881
- int64 feeCharged; // actual fee charged for the transaction
882
-
883
- union switch (TransactionResultCode code)
884
- {
885
- case txSUCCESS:
886
- case txFAILED:
887
- OperationResult results<>;
888
- default:
889
- void;
890
- }
891
- result;
892
-
893
- // reserved for future use
894
- union switch (int v)
895
- {
896
- case 0:
897
- void;
898
- }
899
- ext;
900
- };
901
- }