open-core 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +15 -0
- data/.yardopts +8 -0
- data/CONTRIBUTING.md +48 -0
- data/Gemfile +15 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +202 -0
- data/README.md +83 -0
- data/Rakefile +4 -0
- data/examples/create_account.rb +26 -0
- data/examples/low_level_transaction_post.rb +46 -0
- data/examples/mid_level_transaction_post.rb +33 -0
- data/examples/non_native_payment.rb +60 -0
- data/examples/offer.rb +75 -0
- data/examples/transaction_merge.rb +23 -0
- data/generated/stellar-base-generated.rb +134 -0
- data/generated/stellar/account_entry.rb +53 -0
- data/generated/stellar/account_entry/ext.rb +24 -0
- data/generated/stellar/account_flags.rb +27 -0
- data/generated/stellar/account_merge_result.rb +26 -0
- data/generated/stellar/account_merge_result_code.rb +30 -0
- data/generated/stellar/allow_trust_op.rb +38 -0
- data/generated/stellar/allow_trust_op/asset.rb +33 -0
- data/generated/stellar/allow_trust_result.rb +25 -0
- data/generated/stellar/allow_trust_result_code.rb +31 -0
- data/generated/stellar/asset.rb +47 -0
- data/generated/stellar/asset/alpha_num12.rb +22 -0
- data/generated/stellar/asset/alpha_num4.rb +22 -0
- data/generated/stellar/asset_type.rb +24 -0
- data/generated/stellar/bucket_entry.rb +28 -0
- data/generated/stellar/bucket_entry_type.rb +22 -0
- data/generated/stellar/change_trust_op.rb +22 -0
- data/generated/stellar/change_trust_result.rb +25 -0
- data/generated/stellar/change_trust_result_code.rb +30 -0
- data/generated/stellar/claim_offer_atom.rb +33 -0
- data/generated/stellar/create_account_op.rb +20 -0
- data/generated/stellar/create_account_result.rb +25 -0
- data/generated/stellar/create_account_result_code.rb +32 -0
- data/generated/stellar/create_passive_offer_op.rb +24 -0
- data/generated/stellar/crypto_key_type.rb +20 -0
- data/generated/stellar/decorated_signature.rb +20 -0
- data/generated/stellar/dont_have.rb +20 -0
- data/generated/stellar/envelope_type.rb +22 -0
- data/generated/stellar/error.rb +20 -0
- data/generated/stellar/hello.rb +26 -0
- data/generated/stellar/inflation_payout.rb +20 -0
- data/generated/stellar/inflation_result.rb +26 -0
- data/generated/stellar/inflation_result_code.rb +24 -0
- data/generated/stellar/ledger_entry.rb +44 -0
- data/generated/stellar/ledger_entry/data.rb +33 -0
- data/generated/stellar/ledger_entry/ext.rb +24 -0
- data/generated/stellar/ledger_entry_change.rb +31 -0
- data/generated/stellar/ledger_entry_change_type.rb +24 -0
- data/generated/stellar/ledger_entry_type.rb +24 -0
- data/generated/stellar/ledger_header.rb +65 -0
- data/generated/stellar/ledger_header/ext.rb +24 -0
- data/generated/stellar/ledger_header_history_entry.rb +33 -0
- data/generated/stellar/ledger_header_history_entry/ext.rb +24 -0
- data/generated/stellar/ledger_key.rb +50 -0
- data/generated/stellar/ledger_key/account.rb +20 -0
- data/generated/stellar/ledger_key/offer.rb +22 -0
- data/generated/stellar/ledger_key/trust_line.rb +22 -0
- data/generated/stellar/ledger_upgrade.rb +27 -0
- data/generated/stellar/ledger_upgrade_type.rb +22 -0
- data/generated/stellar/manage_offer_effect.rb +24 -0
- data/generated/stellar/manage_offer_op.rb +28 -0
- data/generated/stellar/manage_offer_result.rb +26 -0
- data/generated/stellar/manage_offer_result_code.rb +48 -0
- data/generated/stellar/manage_offer_success_result.rb +34 -0
- data/generated/stellar/manage_offer_success_result/offer.rb +30 -0
- data/generated/stellar/memo.rb +38 -0
- data/generated/stellar/memo_type.rb +28 -0
- data/generated/stellar/message_type.rb +45 -0
- data/generated/stellar/offer_entry.rb +49 -0
- data/generated/stellar/offer_entry/ext.rb +24 -0
- data/generated/stellar/offer_entry_flags.rb +21 -0
- data/generated/stellar/operation.rb +51 -0
- data/generated/stellar/operation/body.rb +60 -0
- data/generated/stellar/operation_meta.rb +18 -0
- data/generated/stellar/operation_result.rb +53 -0
- data/generated/stellar/operation_result/tr.rb +61 -0
- data/generated/stellar/operation_result_code.rb +25 -0
- data/generated/stellar/operation_type.rb +38 -0
- data/generated/stellar/path_payment_op.rb +32 -0
- data/generated/stellar/path_payment_result.rb +34 -0
- data/generated/stellar/path_payment_result/success.rb +22 -0
- data/generated/stellar/path_payment_result_code.rb +45 -0
- data/generated/stellar/payment_op.rb +22 -0
- data/generated/stellar/payment_result.rb +25 -0
- data/generated/stellar/payment_result_code.rb +39 -0
- data/generated/stellar/peer_address.rb +22 -0
- data/generated/stellar/price.rb +20 -0
- data/generated/stellar/public_key.rb +23 -0
- data/generated/stellar/scp_ballot.rb +20 -0
- data/generated/stellar/scp_envelope.rb +20 -0
- data/generated/stellar/scp_nomination.rb +22 -0
- data/generated/stellar/scp_quorum_set.rb +22 -0
- data/generated/stellar/scp_statement.rb +59 -0
- data/generated/stellar/scp_statement/pledges.rb +64 -0
- data/generated/stellar/scp_statement/pledges/confirm.rb +28 -0
- data/generated/stellar/scp_statement/pledges/externalize.rb +28 -0
- data/generated/stellar/scp_statement/pledges/prepare.rb +32 -0
- data/generated/stellar/scp_statement_type.rb +26 -0
- data/generated/stellar/set_options_op.rb +41 -0
- data/generated/stellar/set_options_result.rb +25 -0
- data/generated/stellar/set_options_result_code.rb +38 -0
- data/generated/stellar/signer.rb +20 -0
- data/generated/stellar/simple_payment_result.rb +22 -0
- data/generated/stellar/stellar_message.rb +66 -0
- data/generated/stellar/stellar_value.rb +40 -0
- data/generated/stellar/stellar_value/ext.rb +24 -0
- data/generated/stellar/threshold_indexes.rb +26 -0
- data/generated/stellar/time_bounds.rb +20 -0
- data/generated/stellar/transaction.rb +50 -0
- data/generated/stellar/transaction/ext.rb +24 -0
- data/generated/stellar/transaction_envelope.rb +20 -0
- data/generated/stellar/transaction_history_entry.rb +33 -0
- data/generated/stellar/transaction_history_entry/ext.rb +24 -0
- data/generated/stellar/transaction_history_result_entry.rb +33 -0
- data/generated/stellar/transaction_history_result_entry/ext.rb +24 -0
- data/generated/stellar/transaction_meta.rb +31 -0
- data/generated/stellar/transaction_meta/v0.rb +22 -0
- data/generated/stellar/transaction_result.rb +43 -0
- data/generated/stellar/transaction_result/ext.rb +24 -0
- data/generated/stellar/transaction_result/result.rb +30 -0
- data/generated/stellar/transaction_result_code.rb +45 -0
- data/generated/stellar/transaction_result_pair.rb +20 -0
- data/generated/stellar/transaction_result_set.rb +18 -0
- data/generated/stellar/transaction_set.rb +20 -0
- data/generated/stellar/trust_line_entry.rb +41 -0
- data/generated/stellar/trust_line_entry/ext.rb +24 -0
- data/generated/stellar/trust_line_flags.rb +21 -0
- data/lib/stellar-base.rb +32 -0
- data/lib/stellar/account_flags.rb +28 -0
- data/lib/stellar/asset.rb +69 -0
- data/lib/stellar/base.rb +1 -0
- data/lib/stellar/base/version.rb +5 -0
- data/lib/stellar/convert.rb +32 -0
- data/lib/stellar/key_pair.rb +112 -0
- data/lib/stellar/networks.rb +45 -0
- data/lib/stellar/operation.rb +304 -0
- data/lib/stellar/path_payment_result.rb +17 -0
- data/lib/stellar/price.rb +32 -0
- data/lib/stellar/thresholds.rb +39 -0
- data/lib/stellar/transaction.rb +170 -0
- data/lib/stellar/transaction_envelope.rb +32 -0
- data/lib/stellar/util/continued_fraction.rb +96 -0
- data/lib/stellar/util/strkey.rb +43 -0
- data/open-core.gemspec +37 -0
- data/spec/lib/stellar/account_flags_spec.rb +19 -0
- data/spec/lib/stellar/asset_spec.rb +45 -0
- data/spec/lib/stellar/convert_spec.rb +61 -0
- data/spec/lib/stellar/key_pair_spec.rb +238 -0
- data/spec/lib/stellar/networks_spec.rb +77 -0
- data/spec/lib/stellar/path_payment_result_spec.rb +95 -0
- data/spec/lib/stellar/price_spec.rb +34 -0
- data/spec/lib/stellar/thresholds_spec.rb +62 -0
- data/spec/lib/stellar/transaction_envelope_spec.rb +93 -0
- data/spec/lib/stellar/transaction_spec.rb +54 -0
- data/spec/lib/stellar/util/strkey_spec.rb +46 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/matchers/be_strkey.rb +9 -0
- data/spec/support/matchers/eq_bytes.rb +5 -0
- data/spec/support/matchers/have_length.rb +5 -0
- data/tasks/rspec.rake +6 -0
- data/tasks/travis.rake +1 -0
- data/tasks/xdr.rake +50 -0
- data/xdr/Stellar-SCP.x +87 -0
- data/xdr/Stellar-ledger-entries.x +222 -0
- data/xdr/Stellar-ledger.x +231 -0
- data/xdr/Stellar-overlay.x +87 -0
- data/xdr/Stellar-transaction.x +670 -0
- data/xdr/Stellar-types.x +34 -0
- metadata +444 -0
@@ -0,0 +1,87 @@
|
|
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
|
+
struct Error
|
11
|
+
{
|
12
|
+
int code;
|
13
|
+
string msg<100>;
|
14
|
+
};
|
15
|
+
|
16
|
+
struct Hello
|
17
|
+
{
|
18
|
+
uint32 ledgerVersion;
|
19
|
+
uint32 overlayVersion;
|
20
|
+
string versionStr<100>;
|
21
|
+
int listeningPort;
|
22
|
+
NodeID peerID;
|
23
|
+
};
|
24
|
+
|
25
|
+
struct PeerAddress
|
26
|
+
{
|
27
|
+
opaque ip[4];
|
28
|
+
uint32 port;
|
29
|
+
uint32 numFailures;
|
30
|
+
};
|
31
|
+
|
32
|
+
enum MessageType
|
33
|
+
{
|
34
|
+
ERROR_MSG = 0,
|
35
|
+
HELLO = 1,
|
36
|
+
DONT_HAVE = 2,
|
37
|
+
|
38
|
+
GET_PEERS = 3, // gets a list of peers this guy knows about
|
39
|
+
PEERS = 4,
|
40
|
+
|
41
|
+
GET_TX_SET = 5, // gets a particular txset by hash
|
42
|
+
TX_SET = 6,
|
43
|
+
|
44
|
+
TRANSACTION = 7, // pass on a tx you have heard about
|
45
|
+
|
46
|
+
// SCP
|
47
|
+
GET_SCP_QUORUMSET = 8,
|
48
|
+
SCP_QUORUMSET = 9,
|
49
|
+
SCP_MESSAGE = 10
|
50
|
+
};
|
51
|
+
|
52
|
+
struct DontHave
|
53
|
+
{
|
54
|
+
MessageType type;
|
55
|
+
uint256 reqHash;
|
56
|
+
};
|
57
|
+
|
58
|
+
union StellarMessage switch (MessageType type)
|
59
|
+
{
|
60
|
+
case ERROR_MSG:
|
61
|
+
Error error;
|
62
|
+
case HELLO:
|
63
|
+
Hello hello;
|
64
|
+
case DONT_HAVE:
|
65
|
+
DontHave dontHave;
|
66
|
+
case GET_PEERS:
|
67
|
+
void;
|
68
|
+
case PEERS:
|
69
|
+
PeerAddress peers<>;
|
70
|
+
|
71
|
+
case GET_TX_SET:
|
72
|
+
uint256 txSetHash;
|
73
|
+
case TX_SET:
|
74
|
+
TransactionSet txSet;
|
75
|
+
|
76
|
+
case TRANSACTION:
|
77
|
+
TransactionEnvelope transaction;
|
78
|
+
|
79
|
+
// SCP
|
80
|
+
case GET_SCP_QUORUMSET:
|
81
|
+
uint256 qSetHash;
|
82
|
+
case SCP_QUORUMSET:
|
83
|
+
SCPQuorumSet qSet;
|
84
|
+
case SCP_MESSAGE:
|
85
|
+
SCPEnvelope envelope;
|
86
|
+
};
|
87
|
+
}
|
@@ -0,0 +1,670 @@
|
|
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; // first 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 = 2,
|
21
|
+
MANAGE_OFFER = 3,
|
22
|
+
CREATE_PASSIVE_OFFER = 4,
|
23
|
+
SET_OPTIONS = 5,
|
24
|
+
CHANGE_TRUST = 6,
|
25
|
+
ALLOW_TRUST = 7,
|
26
|
+
ACCOUNT_MERGE = 8,
|
27
|
+
INFLATION = 9
|
28
|
+
};
|
29
|
+
|
30
|
+
/* CreateAccount
|
31
|
+
Creates and funds a new account with the specified starting balance.
|
32
|
+
|
33
|
+
Threshold: med
|
34
|
+
|
35
|
+
Result: CreateAccountResult
|
36
|
+
|
37
|
+
*/
|
38
|
+
|
39
|
+
struct CreateAccountOp
|
40
|
+
{
|
41
|
+
AccountID destination; // account to create
|
42
|
+
int64 startingBalance; // amount they end up with
|
43
|
+
};
|
44
|
+
|
45
|
+
/* Payment
|
46
|
+
|
47
|
+
Send an amount in specified asset to a destination account.
|
48
|
+
|
49
|
+
Threshold: med
|
50
|
+
|
51
|
+
Result: PaymentResult
|
52
|
+
*/
|
53
|
+
struct PaymentOp
|
54
|
+
{
|
55
|
+
AccountID destination; // recipient of the payment
|
56
|
+
Asset asset; // what they end up with
|
57
|
+
int64 amount; // amount they end up with
|
58
|
+
};
|
59
|
+
|
60
|
+
/* PathPayment
|
61
|
+
|
62
|
+
send an amount to a destination account through a path.
|
63
|
+
(up to sendMax, sendAsset)
|
64
|
+
(X0, Path[0]) .. (Xn, Path[n])
|
65
|
+
(destAmount, destAsset)
|
66
|
+
|
67
|
+
Threshold: med
|
68
|
+
|
69
|
+
Result: PathPaymentResult
|
70
|
+
*/
|
71
|
+
struct PathPaymentOp
|
72
|
+
{
|
73
|
+
Asset sendAsset; // asset we pay with
|
74
|
+
int64 sendMax; // the maximum amount of sendAsset to
|
75
|
+
// send (excluding fees).
|
76
|
+
// The operation will fail if can't be met
|
77
|
+
|
78
|
+
AccountID destination; // recipient of the payment
|
79
|
+
Asset destAsset; // what they end up with
|
80
|
+
int64 destAmount; // amount they end up with
|
81
|
+
|
82
|
+
Asset path<5>; // additional hops it must go through to get there
|
83
|
+
};
|
84
|
+
|
85
|
+
/* Creates, updates or deletes an offer
|
86
|
+
|
87
|
+
Threshold: med
|
88
|
+
|
89
|
+
Result: ManageOfferResult
|
90
|
+
|
91
|
+
*/
|
92
|
+
struct ManageOfferOp
|
93
|
+
{
|
94
|
+
Asset selling;
|
95
|
+
Asset buying;
|
96
|
+
int64 amount; // amount being sold. if set to 0, delete the offer
|
97
|
+
Price price; // price of thing being sold in terms of what you are buying
|
98
|
+
|
99
|
+
// 0=create a new offer, otherwise edit an existing offer
|
100
|
+
uint64 offerID;
|
101
|
+
};
|
102
|
+
|
103
|
+
/* Creates an offer that doesn't take offers of the same price
|
104
|
+
|
105
|
+
Threshold: med
|
106
|
+
|
107
|
+
Result: CreatePassiveOfferResult
|
108
|
+
|
109
|
+
*/
|
110
|
+
struct CreatePassiveOfferOp
|
111
|
+
{
|
112
|
+
Asset selling; // A
|
113
|
+
Asset buying; // B
|
114
|
+
int64 amount; // amount taker gets. if set to 0, delete the offer
|
115
|
+
Price price; // cost of A in terms of B
|
116
|
+
};
|
117
|
+
|
118
|
+
/* Set Account Options
|
119
|
+
|
120
|
+
updates "AccountEntry" fields.
|
121
|
+
note: updating thresholds or signers requires high threshold
|
122
|
+
|
123
|
+
Threshold: med or high
|
124
|
+
|
125
|
+
Result: SetOptionsResult
|
126
|
+
*/
|
127
|
+
|
128
|
+
struct SetOptionsOp
|
129
|
+
{
|
130
|
+
AccountID* inflationDest; // sets the inflation destination
|
131
|
+
|
132
|
+
uint32* clearFlags; // which flags to clear
|
133
|
+
uint32* setFlags; // which flags to set
|
134
|
+
|
135
|
+
// account threshold manipulation
|
136
|
+
uint32* masterWeight; // weight of the master account
|
137
|
+
uint32* lowThreshold;
|
138
|
+
uint32* medThreshold;
|
139
|
+
uint32* highThreshold;
|
140
|
+
|
141
|
+
string32* homeDomain; // sets the home domain
|
142
|
+
|
143
|
+
// Add, update or remove a signer for the account
|
144
|
+
// signer is deleted if the weight is 0
|
145
|
+
Signer* signer;
|
146
|
+
};
|
147
|
+
|
148
|
+
/* Creates, updates or deletes a trust line
|
149
|
+
|
150
|
+
Threshold: med
|
151
|
+
|
152
|
+
Result: ChangeTrustResult
|
153
|
+
|
154
|
+
*/
|
155
|
+
struct ChangeTrustOp
|
156
|
+
{
|
157
|
+
Asset line;
|
158
|
+
|
159
|
+
// if limit is set to 0, deletes the trust line
|
160
|
+
int64 limit;
|
161
|
+
};
|
162
|
+
|
163
|
+
/* Updates the "authorized" flag of an existing trust line
|
164
|
+
this is called by the issuer of the related asset.
|
165
|
+
|
166
|
+
note that authorize can only be set (and not cleared) if
|
167
|
+
the issuer account does not have the AUTH_REVOCABLE_FLAG set
|
168
|
+
Threshold: low
|
169
|
+
|
170
|
+
Result: AllowTrustResult
|
171
|
+
*/
|
172
|
+
struct AllowTrustOp
|
173
|
+
{
|
174
|
+
AccountID trustor;
|
175
|
+
union switch (AssetType type)
|
176
|
+
{
|
177
|
+
// ASSET_TYPE_NATIVE is not allowed
|
178
|
+
case ASSET_TYPE_CREDIT_ALPHANUM4:
|
179
|
+
opaque assetCode4[4];
|
180
|
+
|
181
|
+
case ASSET_TYPE_CREDIT_ALPHANUM12:
|
182
|
+
opaque assetCode12[12];
|
183
|
+
|
184
|
+
// add other asset types here in the future
|
185
|
+
}
|
186
|
+
asset;
|
187
|
+
|
188
|
+
bool authorize;
|
189
|
+
};
|
190
|
+
|
191
|
+
/* Inflation
|
192
|
+
Runs inflation
|
193
|
+
|
194
|
+
Threshold: low
|
195
|
+
|
196
|
+
Result: InflationResult
|
197
|
+
|
198
|
+
*/
|
199
|
+
|
200
|
+
/* AccountMerge
|
201
|
+
Transfers native balance to destination account.
|
202
|
+
|
203
|
+
Threshold: high
|
204
|
+
|
205
|
+
Result : AccountMergeResult
|
206
|
+
*/
|
207
|
+
|
208
|
+
/* An operation is the lowest unit of work that a transaction does */
|
209
|
+
struct Operation
|
210
|
+
{
|
211
|
+
// sourceAccount is the account used to run the operation
|
212
|
+
// if not set, the runtime defaults to "sourceAccount" specified at
|
213
|
+
// the transaction level
|
214
|
+
AccountID* sourceAccount;
|
215
|
+
|
216
|
+
union switch (OperationType type)
|
217
|
+
{
|
218
|
+
case CREATE_ACCOUNT:
|
219
|
+
CreateAccountOp createAccountOp;
|
220
|
+
case PAYMENT:
|
221
|
+
PaymentOp paymentOp;
|
222
|
+
case PATH_PAYMENT:
|
223
|
+
PathPaymentOp pathPaymentOp;
|
224
|
+
case MANAGE_OFFER:
|
225
|
+
ManageOfferOp manageOfferOp;
|
226
|
+
case CREATE_PASSIVE_OFFER:
|
227
|
+
CreatePassiveOfferOp createPassiveOfferOp;
|
228
|
+
case SET_OPTIONS:
|
229
|
+
SetOptionsOp setOptionsOp;
|
230
|
+
case CHANGE_TRUST:
|
231
|
+
ChangeTrustOp changeTrustOp;
|
232
|
+
case ALLOW_TRUST:
|
233
|
+
AllowTrustOp allowTrustOp;
|
234
|
+
case ACCOUNT_MERGE:
|
235
|
+
AccountID destination;
|
236
|
+
case INFLATION:
|
237
|
+
void;
|
238
|
+
}
|
239
|
+
body;
|
240
|
+
};
|
241
|
+
|
242
|
+
enum MemoType
|
243
|
+
{
|
244
|
+
MEMO_NONE = 0,
|
245
|
+
MEMO_TEXT = 1,
|
246
|
+
MEMO_ID = 2,
|
247
|
+
MEMO_HASH = 3,
|
248
|
+
MEMO_RETURN = 4
|
249
|
+
};
|
250
|
+
|
251
|
+
union Memo switch (MemoType type)
|
252
|
+
{
|
253
|
+
case MEMO_NONE:
|
254
|
+
void;
|
255
|
+
case MEMO_TEXT:
|
256
|
+
string text<28>;
|
257
|
+
case MEMO_ID:
|
258
|
+
uint64 id;
|
259
|
+
case MEMO_HASH:
|
260
|
+
Hash hash; // the hash of what to pull from the content server
|
261
|
+
case MEMO_RETURN:
|
262
|
+
Hash retHash; // the hash of the tx you are rejecting
|
263
|
+
};
|
264
|
+
|
265
|
+
struct TimeBounds
|
266
|
+
{
|
267
|
+
uint64 minTime;
|
268
|
+
uint64 maxTime;
|
269
|
+
};
|
270
|
+
|
271
|
+
/* a transaction is a container for a set of operations
|
272
|
+
- is executed by an account
|
273
|
+
- fees are collected from the account
|
274
|
+
- operations are executed in order as one ACID transaction
|
275
|
+
either all operations are applied or none are
|
276
|
+
if any returns a failing code
|
277
|
+
*/
|
278
|
+
|
279
|
+
struct Transaction
|
280
|
+
{
|
281
|
+
// account used to run the transaction
|
282
|
+
AccountID sourceAccount;
|
283
|
+
|
284
|
+
// the fee the sourceAccount will pay
|
285
|
+
uint32 fee;
|
286
|
+
|
287
|
+
// sequence number to consume in the account
|
288
|
+
SequenceNumber seqNum;
|
289
|
+
|
290
|
+
// validity range (inclusive) for the last ledger close time
|
291
|
+
TimeBounds* timeBounds;
|
292
|
+
|
293
|
+
Memo memo;
|
294
|
+
|
295
|
+
Operation operations<100>;
|
296
|
+
|
297
|
+
// reserved for future use
|
298
|
+
union switch (int v)
|
299
|
+
{
|
300
|
+
case 0:
|
301
|
+
void;
|
302
|
+
}
|
303
|
+
ext;
|
304
|
+
};
|
305
|
+
|
306
|
+
/* A TransactionEnvelope wraps a transaction with signatures. */
|
307
|
+
struct TransactionEnvelope
|
308
|
+
{
|
309
|
+
Transaction tx;
|
310
|
+
DecoratedSignature signatures<20>;
|
311
|
+
};
|
312
|
+
|
313
|
+
/* Operation Results section */
|
314
|
+
|
315
|
+
/* This result is used when offers are taken during an operation */
|
316
|
+
struct ClaimOfferAtom
|
317
|
+
{
|
318
|
+
// emited to identify the offer
|
319
|
+
AccountID sellerID; // Account that owns the offer
|
320
|
+
uint64 offerID;
|
321
|
+
|
322
|
+
// amount and asset taken from the owner
|
323
|
+
Asset assetSold;
|
324
|
+
int64 amountSold;
|
325
|
+
|
326
|
+
// amount and asset sent to the owner
|
327
|
+
Asset assetBought;
|
328
|
+
int64 amountBought;
|
329
|
+
};
|
330
|
+
|
331
|
+
/******* CreateAccount Result ********/
|
332
|
+
|
333
|
+
enum CreateAccountResultCode
|
334
|
+
{
|
335
|
+
// codes considered as "success" for the operation
|
336
|
+
CREATE_ACCOUNT_SUCCESS = 0, // account was created
|
337
|
+
|
338
|
+
// codes considered as "failure" for the operation
|
339
|
+
CREATE_ACCOUNT_MALFORMED = -1, // invalid destination
|
340
|
+
CREATE_ACCOUNT_UNDERFUNDED = -2, // not enough funds in source account
|
341
|
+
CREATE_ACCOUNT_LOW_RESERVE =
|
342
|
+
-3, // would create an account below the min reserve
|
343
|
+
CREATE_ACCOUNT_ALREADY_EXIST = -4 // account already exists
|
344
|
+
};
|
345
|
+
|
346
|
+
union CreateAccountResult switch (CreateAccountResultCode code)
|
347
|
+
{
|
348
|
+
case CREATE_ACCOUNT_SUCCESS:
|
349
|
+
void;
|
350
|
+
default:
|
351
|
+
void;
|
352
|
+
};
|
353
|
+
|
354
|
+
/******* Payment Result ********/
|
355
|
+
|
356
|
+
enum PaymentResultCode
|
357
|
+
{
|
358
|
+
// codes considered as "success" for the operation
|
359
|
+
PAYMENT_SUCCESS = 0, // payment successfuly completed
|
360
|
+
|
361
|
+
// codes considered as "failure" for the operation
|
362
|
+
PAYMENT_MALFORMED = -1, // bad input
|
363
|
+
PAYMENT_UNDERFUNDED = -2, // not enough funds in source account
|
364
|
+
PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account
|
365
|
+
PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
|
366
|
+
PAYMENT_NO_DESTINATION = -5, // destination account does not exist
|
367
|
+
PAYMENT_NO_TRUST = -6, // destination missing a trust line for asset
|
368
|
+
PAYMENT_NOT_AUTHORIZED = -7, // destination not authorized to hold asset
|
369
|
+
PAYMENT_LINE_FULL = -8 // destination would go above their limit
|
370
|
+
};
|
371
|
+
|
372
|
+
union PaymentResult switch (PaymentResultCode code)
|
373
|
+
{
|
374
|
+
case PAYMENT_SUCCESS:
|
375
|
+
void;
|
376
|
+
default:
|
377
|
+
void;
|
378
|
+
};
|
379
|
+
|
380
|
+
/******* Payment Result ********/
|
381
|
+
|
382
|
+
enum PathPaymentResultCode
|
383
|
+
{
|
384
|
+
// codes considered as "success" for the operation
|
385
|
+
PATH_PAYMENT_SUCCESS = 0, // success
|
386
|
+
|
387
|
+
// codes considered as "failure" for the operation
|
388
|
+
PATH_PAYMENT_MALFORMED = -1, // bad input
|
389
|
+
PATH_PAYMENT_UNDERFUNDED = -2, // not enough funds in source account
|
390
|
+
PATH_PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account
|
391
|
+
PATH_PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
|
392
|
+
PATH_PAYMENT_NO_DESTINATION = -5, // destination account does not exist
|
393
|
+
PATH_PAYMENT_NO_TRUST = -6, // dest missing a trust line for asset
|
394
|
+
PATH_PAYMENT_NOT_AUTHORIZED = -7, // dest not authorized to hold asset
|
395
|
+
PATH_PAYMENT_LINE_FULL = -8, // dest would go above their limit
|
396
|
+
PATH_PAYMENT_TOO_FEW_OFFERS = -9, // not enough offers to satisfy path
|
397
|
+
PATH_PAYMENT_OFFER_CROSS_SELF = -10, // would cross one of its own offers
|
398
|
+
PATH_PAYMENT_OVER_SENDMAX = -11 // could not satisfy sendmax
|
399
|
+
};
|
400
|
+
|
401
|
+
struct SimplePaymentResult
|
402
|
+
{
|
403
|
+
AccountID destination;
|
404
|
+
Asset asset;
|
405
|
+
int64 amount;
|
406
|
+
};
|
407
|
+
|
408
|
+
union PathPaymentResult switch (PathPaymentResultCode code)
|
409
|
+
{
|
410
|
+
case PATH_PAYMENT_SUCCESS:
|
411
|
+
struct
|
412
|
+
{
|
413
|
+
ClaimOfferAtom offers<>;
|
414
|
+
SimplePaymentResult last;
|
415
|
+
} success;
|
416
|
+
default:
|
417
|
+
void;
|
418
|
+
};
|
419
|
+
|
420
|
+
/******* ManageOffer Result ********/
|
421
|
+
|
422
|
+
enum ManageOfferResultCode
|
423
|
+
{
|
424
|
+
// codes considered as "success" for the operation
|
425
|
+
MANAGE_OFFER_SUCCESS = 0,
|
426
|
+
|
427
|
+
// codes considered as "failure" for the operation
|
428
|
+
MANAGE_OFFER_MALFORMED = -1, // generated offer would be invalid
|
429
|
+
MANAGE_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling
|
430
|
+
MANAGE_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying
|
431
|
+
MANAGE_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell
|
432
|
+
MANAGE_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy
|
433
|
+
MANAGE_OFFER_LINE_FULL = -6, // can't receive more of what it's buying
|
434
|
+
MANAGE_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell
|
435
|
+
MANAGE_OFFER_CROSS_SELF = -8, // would cross an offer from the same user
|
436
|
+
|
437
|
+
// update errors
|
438
|
+
MANAGE_OFFER_NOT_FOUND = -9, // offerID does not match an existing offer
|
439
|
+
MANAGE_OFFER_MISMATCH = -10, // currencies don't match offer
|
440
|
+
|
441
|
+
MANAGE_OFFER_LOW_RESERVE = -11 // not enough funds to create a new Offer
|
442
|
+
};
|
443
|
+
|
444
|
+
enum ManageOfferEffect
|
445
|
+
{
|
446
|
+
MANAGE_OFFER_CREATED = 0,
|
447
|
+
MANAGE_OFFER_UPDATED = 1,
|
448
|
+
MANAGE_OFFER_DELETED = 2
|
449
|
+
};
|
450
|
+
|
451
|
+
struct ManageOfferSuccessResult
|
452
|
+
{
|
453
|
+
// offers that got claimed while creating this offer
|
454
|
+
ClaimOfferAtom offersClaimed<>;
|
455
|
+
|
456
|
+
union switch (ManageOfferEffect effect)
|
457
|
+
{
|
458
|
+
case MANAGE_OFFER_CREATED:
|
459
|
+
case MANAGE_OFFER_UPDATED:
|
460
|
+
OfferEntry offer;
|
461
|
+
default:
|
462
|
+
void;
|
463
|
+
}
|
464
|
+
offer;
|
465
|
+
};
|
466
|
+
|
467
|
+
union ManageOfferResult switch (ManageOfferResultCode code)
|
468
|
+
{
|
469
|
+
case MANAGE_OFFER_SUCCESS:
|
470
|
+
ManageOfferSuccessResult success;
|
471
|
+
default:
|
472
|
+
void;
|
473
|
+
};
|
474
|
+
|
475
|
+
/******* SetOptions Result ********/
|
476
|
+
|
477
|
+
enum SetOptionsResultCode
|
478
|
+
{
|
479
|
+
// codes considered as "success" for the operation
|
480
|
+
SET_OPTIONS_SUCCESS = 0,
|
481
|
+
// codes considered as "failure" for the operation
|
482
|
+
SET_OPTIONS_LOW_RESERVE = -1, // not enough funds to add a signer
|
483
|
+
SET_OPTIONS_TOO_MANY_SIGNERS = -2, // max number of signers already reached
|
484
|
+
SET_OPTIONS_BAD_FLAGS = -3, // invalid combination of clear/set flags
|
485
|
+
SET_OPTIONS_INVALID_INFLATION = -4, // inflation account does not exist
|
486
|
+
SET_OPTIONS_CANT_CHANGE = -5, // can no longer change this option
|
487
|
+
SET_OPTIONS_UNKNOWN_FLAG = -6, // can't set an unknown flag
|
488
|
+
SET_OPTIONS_THRESHOLD_OUT_OF_RANGE = -7, // bad value for weight/threshold
|
489
|
+
SET_OPTIONS_BAD_SIGNER = -8 // signer cannot be masterkey
|
490
|
+
};
|
491
|
+
|
492
|
+
union SetOptionsResult switch (SetOptionsResultCode code)
|
493
|
+
{
|
494
|
+
case SET_OPTIONS_SUCCESS:
|
495
|
+
void;
|
496
|
+
default:
|
497
|
+
void;
|
498
|
+
};
|
499
|
+
|
500
|
+
/******* ChangeTrust Result ********/
|
501
|
+
|
502
|
+
enum ChangeTrustResultCode
|
503
|
+
{
|
504
|
+
// codes considered as "success" for the operation
|
505
|
+
CHANGE_TRUST_SUCCESS = 0,
|
506
|
+
// codes considered as "failure" for the operation
|
507
|
+
CHANGE_TRUST_MALFORMED = -1, // bad input
|
508
|
+
CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer
|
509
|
+
CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance
|
510
|
+
CHANGE_TRUST_LOW_RESERVE = -4 // not enough funds to create a new trust line
|
511
|
+
};
|
512
|
+
|
513
|
+
union ChangeTrustResult switch (ChangeTrustResultCode code)
|
514
|
+
{
|
515
|
+
case CHANGE_TRUST_SUCCESS:
|
516
|
+
void;
|
517
|
+
default:
|
518
|
+
void;
|
519
|
+
};
|
520
|
+
|
521
|
+
/******* AllowTrust Result ********/
|
522
|
+
|
523
|
+
enum AllowTrustResultCode
|
524
|
+
{
|
525
|
+
// codes considered as "success" for the operation
|
526
|
+
ALLOW_TRUST_SUCCESS = 0,
|
527
|
+
// codes considered as "failure" for the operation
|
528
|
+
ALLOW_TRUST_MALFORMED = -1, // asset is not ASSET_TYPE_ALPHANUM
|
529
|
+
ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline
|
530
|
+
// source account does not require trust
|
531
|
+
ALLOW_TRUST_TRUST_NOT_REQUIRED = -3,
|
532
|
+
ALLOW_TRUST_CANT_REVOKE = -4 // source account can't revoke trust
|
533
|
+
};
|
534
|
+
|
535
|
+
union AllowTrustResult switch (AllowTrustResultCode code)
|
536
|
+
{
|
537
|
+
case ALLOW_TRUST_SUCCESS:
|
538
|
+
void;
|
539
|
+
default:
|
540
|
+
void;
|
541
|
+
};
|
542
|
+
|
543
|
+
/******* AccountMerge Result ********/
|
544
|
+
|
545
|
+
enum AccountMergeResultCode
|
546
|
+
{
|
547
|
+
// codes considered as "success" for the operation
|
548
|
+
ACCOUNT_MERGE_SUCCESS = 0,
|
549
|
+
// codes considered as "failure" for the operation
|
550
|
+
ACCOUNT_MERGE_MALFORMED = -1, // can't merge onto itself
|
551
|
+
ACCOUNT_MERGE_NO_ACCOUNT = -2, // destination does not exist
|
552
|
+
ACCOUNT_MERGE_HAS_CREDIT = -3, // account has active trust lines
|
553
|
+
ACCOUNT_MERGE_CREDIT_HELD = -4 // an issuer cannot be merged if used
|
554
|
+
};
|
555
|
+
|
556
|
+
union AccountMergeResult switch (AccountMergeResultCode code)
|
557
|
+
{
|
558
|
+
case ACCOUNT_MERGE_SUCCESS:
|
559
|
+
int64 sourceAccountBalance; // how much got transfered from source account
|
560
|
+
default:
|
561
|
+
void;
|
562
|
+
};
|
563
|
+
|
564
|
+
/******* Inflation Result ********/
|
565
|
+
|
566
|
+
enum InflationResultCode
|
567
|
+
{
|
568
|
+
// codes considered as "success" for the operation
|
569
|
+
INFLATION_SUCCESS = 0,
|
570
|
+
// codes considered as "failure" for the operation
|
571
|
+
INFLATION_NOT_TIME = -1
|
572
|
+
};
|
573
|
+
|
574
|
+
struct InflationPayout // or use PaymentResultAtom to limit types?
|
575
|
+
{
|
576
|
+
AccountID destination;
|
577
|
+
int64 amount;
|
578
|
+
};
|
579
|
+
|
580
|
+
union InflationResult switch (InflationResultCode code)
|
581
|
+
{
|
582
|
+
case INFLATION_SUCCESS:
|
583
|
+
InflationPayout payouts<>;
|
584
|
+
default:
|
585
|
+
void;
|
586
|
+
};
|
587
|
+
|
588
|
+
/* High level Operation Result */
|
589
|
+
|
590
|
+
enum OperationResultCode
|
591
|
+
{
|
592
|
+
opINNER = 0, // inner object result is valid
|
593
|
+
|
594
|
+
opBAD_AUTH = -1, // not enough signatures to perform operation
|
595
|
+
opNO_ACCOUNT = -2 // source account was not found
|
596
|
+
};
|
597
|
+
|
598
|
+
union OperationResult switch (OperationResultCode code)
|
599
|
+
{
|
600
|
+
case opINNER:
|
601
|
+
union switch (OperationType type)
|
602
|
+
{
|
603
|
+
case CREATE_ACCOUNT:
|
604
|
+
CreateAccountResult createAccountResult;
|
605
|
+
case PAYMENT:
|
606
|
+
PaymentResult paymentResult;
|
607
|
+
case PATH_PAYMENT:
|
608
|
+
PathPaymentResult pathPaymentResult;
|
609
|
+
case MANAGE_OFFER:
|
610
|
+
ManageOfferResult manageOfferResult;
|
611
|
+
case CREATE_PASSIVE_OFFER:
|
612
|
+
ManageOfferResult createPassiveOfferResult;
|
613
|
+
case SET_OPTIONS:
|
614
|
+
SetOptionsResult setOptionsResult;
|
615
|
+
case CHANGE_TRUST:
|
616
|
+
ChangeTrustResult changeTrustResult;
|
617
|
+
case ALLOW_TRUST:
|
618
|
+
AllowTrustResult allowTrustResult;
|
619
|
+
case ACCOUNT_MERGE:
|
620
|
+
AccountMergeResult accountMergeResult;
|
621
|
+
case INFLATION:
|
622
|
+
InflationResult inflationResult;
|
623
|
+
}
|
624
|
+
tr;
|
625
|
+
default:
|
626
|
+
void;
|
627
|
+
};
|
628
|
+
|
629
|
+
enum TransactionResultCode
|
630
|
+
{
|
631
|
+
txSUCCESS = 0, // all operations succeeded
|
632
|
+
|
633
|
+
txFAILED = -1, // one of the operations failed (none were applied)
|
634
|
+
|
635
|
+
txTOO_EARLY = -2, // ledger closeTime before minTime
|
636
|
+
txTOO_LATE = -3, // ledger closeTime after maxTime
|
637
|
+
txMISSING_OPERATION = -4, // no operation was specified
|
638
|
+
txBAD_SEQ = -5, // sequence number does not match source account
|
639
|
+
|
640
|
+
txBAD_AUTH = -6, // not enough signatures to perform transaction
|
641
|
+
txINSUFFICIENT_BALANCE = -7, // fee would bring account below reserve
|
642
|
+
txNO_ACCOUNT = -8, // source account not found
|
643
|
+
txINSUFFICIENT_FEE = -9, // fee is too small
|
644
|
+
txBAD_AUTH_EXTRA = -10, // too many signatures on transaction
|
645
|
+
txINTERNAL_ERROR = -11 // an unknown error occured
|
646
|
+
};
|
647
|
+
|
648
|
+
struct TransactionResult
|
649
|
+
{
|
650
|
+
int64 feeCharged; // actual fee charged for the transaction
|
651
|
+
|
652
|
+
union switch (TransactionResultCode code)
|
653
|
+
{
|
654
|
+
case txSUCCESS:
|
655
|
+
case txFAILED:
|
656
|
+
OperationResult results<>;
|
657
|
+
default:
|
658
|
+
void;
|
659
|
+
}
|
660
|
+
result;
|
661
|
+
|
662
|
+
// reserved for future use
|
663
|
+
union switch (int v)
|
664
|
+
{
|
665
|
+
case 0:
|
666
|
+
void;
|
667
|
+
}
|
668
|
+
ext;
|
669
|
+
};
|
670
|
+
}
|