auction-ruby-base 0.1.1
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/CHANGELOG.md +58 -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/auction-ruby-base.gemspec +35 -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 +174 -0
- data/generated/stellar/account_entry.rb +55 -0
- data/generated/stellar/account_entry/ext.rb +24 -0
- data/generated/stellar/account_flags.rb +31 -0
- data/generated/stellar/account_merge_result.rb +26 -0
- data/generated/stellar/account_merge_result_code.rb +30 -0
- data/generated/stellar/affirm_fail_op.rb +22 -0
- data/generated/stellar/affirm_fail_result.rb +25 -0
- data/generated/stellar/affirm_fail_result_code.rb +22 -0
- data/generated/stellar/affirm_pass_op.rb +24 -0
- data/generated/stellar/affirm_pass_result.rb +25 -0
- data/generated/stellar/affirm_pass_result_code.rb +22 -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/auth.rb +20 -0
- data/generated/stellar/auth_cert.rb +22 -0
- data/generated/stellar/authenticated_message.rb +32 -0
- data/generated/stellar/authenticated_message/v0.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 +31 -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_bid_op.rb +20 -0
- data/generated/stellar/create_bid_result.rb +25 -0
- data/generated/stellar/create_bid_result_code.rb +22 -0
- data/generated/stellar/create_lot_op.rb +46 -0
- data/generated/stellar/create_lot_result.rb +25 -0
- data/generated/stellar/create_lot_result_code.rb +22 -0
- data/generated/stellar/create_passive_offer_op.rb +24 -0
- data/generated/stellar/crypto_key_type.rb +20 -0
- data/generated/stellar/curve25519_public.rb +18 -0
- data/generated/stellar/curve25519_secret.rb +18 -0
- data/generated/stellar/decorated_signature.rb +20 -0
- data/generated/stellar/dont_have.rb +20 -0
- data/generated/stellar/envelope_type.rb +24 -0
- data/generated/stellar/error.rb +20 -0
- data/generated/stellar/error_code.rb +28 -0
- data/generated/stellar/hello.rb +34 -0
- data/generated/stellar/hmac_sha256_key.rb +18 -0
- data/generated/stellar/hmac_sha256_mac.rb +18 -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/ip_addr_type.rb +22 -0
- data/generated/stellar/ledger_entry.rb +52 -0
- data/generated/stellar/ledger_entry/data.rb +49 -0
- data/generated/stellar/ledger_entry/ext.rb +24 -0
- data/generated/stellar/ledger_entry_change.rb +35 -0
- data/generated/stellar/ledger_entry_change_type.rb +26 -0
- data/generated/stellar/ledger_entry_type.rb +32 -0
- data/generated/stellar/ledger_header.rb +69 -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 +87 -0
- data/generated/stellar/ledger_key/account.rb +20 -0
- data/generated/stellar/ledger_key/lot.rb +22 -0
- data/generated/stellar/ledger_key/message.rb +22 -0
- data/generated/stellar/ledger_key/offer.rb +22 -0
- data/generated/stellar/ledger_key/participant.rb +22 -0
- data/generated/stellar/ledger_key/proof.rb +22 -0
- data/generated/stellar/ledger_key/trust_line.rb +22 -0
- data/generated/stellar/ledger_scp_messages.rb +20 -0
- data/generated/stellar/ledger_upgrade.rb +31 -0
- data/generated/stellar/ledger_upgrade_type.rb +24 -0
- data/generated/stellar/lot_branch.rb +21 -0
- data/generated/stellar/lot_entry.rb +64 -0
- data/generated/stellar/lot_entry/ext.rb +24 -0
- data/generated/stellar/lot_type.rb +21 -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 +50 -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_entry.rb +38 -0
- data/generated/stellar/message_entry/ext.rb +24 -0
- data/generated/stellar/message_type.rb +51 -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 +65 -0
- data/generated/stellar/operation/body.rb +88 -0
- data/generated/stellar/operation_meta.rb +18 -0
- data/generated/stellar/operation_result.rb +67 -0
- data/generated/stellar/operation_result/tr.rb +89 -0
- data/generated/stellar/operation_result_code.rb +25 -0
- data/generated/stellar/operation_type.rb +52 -0
- data/generated/stellar/participant_entry.rb +39 -0
- data/generated/stellar/participant_entry/ext.rb +24 -0
- data/generated/stellar/participant_state.rb +25 -0
- data/generated/stellar/path_payment_op.rb +32 -0
- data/generated/stellar/path_payment_result.rb +38 -0
- data/generated/stellar/path_payment_result/success.rb +22 -0
- data/generated/stellar/path_payment_result_code.rb +47 -0
- data/generated/stellar/payment_op.rb +22 -0
- data/generated/stellar/payment_result.rb +25 -0
- data/generated/stellar/payment_result_code.rb +41 -0
- data/generated/stellar/peer_address.rb +33 -0
- data/generated/stellar/peer_address/ip.rb +29 -0
- data/generated/stellar/price.rb +20 -0
- data/generated/stellar/proof_entry.rb +42 -0
- data/generated/stellar/proof_entry/ext.rb +24 -0
- data/generated/stellar/provide_proof_op.rb +24 -0
- data/generated/stellar/provide_proof_result.rb +25 -0
- data/generated/stellar/provide_proof_result_code.rb +22 -0
- data/generated/stellar/public_key.rb +23 -0
- data/generated/stellar/register_participant_op.rb +22 -0
- data/generated/stellar/register_participant_result.rb +25 -0
- data/generated/stellar/register_participant_result_code.rb +22 -0
- data/generated/stellar/scp_ballot.rb +20 -0
- data/generated/stellar/scp_envelope.rb +20 -0
- data/generated/stellar/scp_history_entry.rb +23 -0
- data/generated/stellar/scp_history_entry_v0.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 +58 -0
- data/generated/stellar/scp_statement/pledges.rb +63 -0
- data/generated/stellar/scp_statement/pledges/confirm.rb +30 -0
- data/generated/stellar/scp_statement/pledges/externalize.rb +26 -0
- data/generated/stellar/scp_statement/pledges/prepare.rb +32 -0
- data/generated/stellar/scp_statement_type.rb +26 -0
- data/generated/stellar/send_message_op.rb +22 -0
- data/generated/stellar/send_message_result.rb +25 -0
- data/generated/stellar/send_message_result_code.rb +22 -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 +40 -0
- data/generated/stellar/signer.rb +20 -0
- data/generated/stellar/simple_payment_result.rb +22 -0
- data/generated/stellar/stellar_message.rb +74 -0
- data/generated/stellar/stellar_value.rb +41 -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 +23 -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 +33 -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 +384 -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 +205 -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/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/operation_spec.rb +13 -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 +83 -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 +86 -0
- data/xdr/Stellar-ledger-entries.x +351 -0
- data/xdr/Stellar-ledger.x +288 -0
- data/xdr/Stellar-overlay.x +146 -0
- data/xdr/Stellar-transaction.x +936 -0
- data/xdr/Stellar-types.x +55 -0
- metadata +495 -0
@@ -0,0 +1,351 @@
|
|
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-types.h"
|
6
|
+
|
7
|
+
namespace stellar
|
8
|
+
{
|
9
|
+
|
10
|
+
typedef PublicKey AccountID;
|
11
|
+
typedef opaque Thresholds[4];
|
12
|
+
typedef string string32<32>;
|
13
|
+
typedef uint64 SequenceNumber;
|
14
|
+
|
15
|
+
enum AssetType
|
16
|
+
{
|
17
|
+
ASSET_TYPE_NATIVE = 0,
|
18
|
+
ASSET_TYPE_CREDIT_ALPHANUM4 = 1,
|
19
|
+
ASSET_TYPE_CREDIT_ALPHANUM12 = 2
|
20
|
+
};
|
21
|
+
|
22
|
+
union Asset switch (AssetType type)
|
23
|
+
{
|
24
|
+
case ASSET_TYPE_NATIVE: // Not credit
|
25
|
+
void;
|
26
|
+
|
27
|
+
case ASSET_TYPE_CREDIT_ALPHANUM4:
|
28
|
+
struct
|
29
|
+
{
|
30
|
+
opaque assetCode[4]; // 1 to 4 characters
|
31
|
+
AccountID issuer;
|
32
|
+
} alphaNum4;
|
33
|
+
|
34
|
+
case ASSET_TYPE_CREDIT_ALPHANUM12:
|
35
|
+
struct
|
36
|
+
{
|
37
|
+
opaque assetCode[12]; // 5 to 12 characters
|
38
|
+
AccountID issuer;
|
39
|
+
} alphaNum12;
|
40
|
+
|
41
|
+
// add other asset types here in the future
|
42
|
+
};
|
43
|
+
|
44
|
+
// price in fractional representation
|
45
|
+
struct Price
|
46
|
+
{
|
47
|
+
int32 n; // numerator
|
48
|
+
int32 d; // denominator
|
49
|
+
};
|
50
|
+
|
51
|
+
// the 'Thresholds' type is packed uint8_t values
|
52
|
+
// defined by these indexes
|
53
|
+
enum ThresholdIndexes
|
54
|
+
{
|
55
|
+
THRESHOLD_MASTER_WEIGHT = 0,
|
56
|
+
THRESHOLD_LOW = 1,
|
57
|
+
THRESHOLD_MED = 2,
|
58
|
+
THRESHOLD_HIGH = 3
|
59
|
+
};
|
60
|
+
|
61
|
+
enum LedgerEntryType
|
62
|
+
{
|
63
|
+
ACCOUNT = 0,
|
64
|
+
TRUSTLINE = 1,
|
65
|
+
OFFER = 2,
|
66
|
+
LOT = 3,
|
67
|
+
PARTICIPANT = 4,
|
68
|
+
MESSAGE = 5,
|
69
|
+
PROOF = 6
|
70
|
+
};
|
71
|
+
|
72
|
+
struct Signer
|
73
|
+
{
|
74
|
+
AccountID pubKey;
|
75
|
+
uint32 weight; // really only need 1byte
|
76
|
+
};
|
77
|
+
|
78
|
+
enum AccountFlags
|
79
|
+
{ // masks for each flag
|
80
|
+
|
81
|
+
// Flags set on issuer accounts
|
82
|
+
// TrustLines are created with authorized set to "false" requiring
|
83
|
+
// the issuer to set it for each TrustLine
|
84
|
+
AUTH_REQUIRED_FLAG = 0x1,
|
85
|
+
// If set, the authorized flag in TrustLines can be cleared
|
86
|
+
// otherwise, authorization cannot be revoked
|
87
|
+
AUTH_REVOCABLE_FLAG = 0x2,
|
88
|
+
// Once set, causes all AUTH_* flags to be read-only
|
89
|
+
AUTH_IMMUTABLE_FLAG = 0x4
|
90
|
+
};
|
91
|
+
|
92
|
+
/* AccountEntry
|
93
|
+
|
94
|
+
Main entry representing a user in Stellar. All transactions are
|
95
|
+
performed using an account.
|
96
|
+
|
97
|
+
Other ledger entries created require an account.
|
98
|
+
|
99
|
+
*/
|
100
|
+
|
101
|
+
struct AccountEntry
|
102
|
+
{
|
103
|
+
AccountID accountID; // master public key for this account
|
104
|
+
int64 balance; // in stroops
|
105
|
+
SequenceNumber seqNum; // last sequence number used for this account
|
106
|
+
uint32 numSubEntries; // number of sub-entries this account has
|
107
|
+
// drives the reserve
|
108
|
+
AccountID* inflationDest; // Account to vote for during inflation
|
109
|
+
uint32 flags; // see AccountFlags
|
110
|
+
|
111
|
+
string32 homeDomain; // can be used for reverse federation and memo lookup
|
112
|
+
|
113
|
+
// fields used for signatures
|
114
|
+
// thresholds stores unsigned bytes: [weight of master|low|medium|high]
|
115
|
+
Thresholds thresholds;
|
116
|
+
|
117
|
+
Signer signers<20>; // possible signers for this account
|
118
|
+
|
119
|
+
string32 codeKYC;
|
120
|
+
// reserved for future use
|
121
|
+
union switch (int v)
|
122
|
+
{
|
123
|
+
case 0:
|
124
|
+
void;
|
125
|
+
}
|
126
|
+
ext;
|
127
|
+
};
|
128
|
+
|
129
|
+
/* ProofEntry
|
130
|
+
|
131
|
+
*/
|
132
|
+
|
133
|
+
struct ProofEntry
|
134
|
+
{
|
135
|
+
AccountID accountID;
|
136
|
+
uint64 lotID;
|
137
|
+
uint64 proofID;
|
138
|
+
uint64 bankID;
|
139
|
+
uint32 quantity;
|
140
|
+
|
141
|
+
string proof<1000>;
|
142
|
+
|
143
|
+
// reserved for future use
|
144
|
+
union switch (int v)
|
145
|
+
{
|
146
|
+
case 0:
|
147
|
+
void;
|
148
|
+
}
|
149
|
+
ext;
|
150
|
+
};
|
151
|
+
|
152
|
+
/* TrustLineEntry
|
153
|
+
A trust line represents a specific trust relationship with
|
154
|
+
a credit/issuer (limit, authorization)
|
155
|
+
as well as the balance.
|
156
|
+
*/
|
157
|
+
|
158
|
+
enum TrustLineFlags
|
159
|
+
{
|
160
|
+
// issuer has authorized account to perform transactions with its credit
|
161
|
+
AUTHORIZED_FLAG = 1
|
162
|
+
};
|
163
|
+
|
164
|
+
struct TrustLineEntry
|
165
|
+
{
|
166
|
+
AccountID accountID; // account this trustline belongs to
|
167
|
+
Asset asset; // type of asset (with issuer)
|
168
|
+
int64 balance; // how much of this asset the user has.
|
169
|
+
// Asset defines the unit for this;
|
170
|
+
|
171
|
+
int64 limit; // balance cannot be above this
|
172
|
+
uint32 flags; // see TrustLineFlags
|
173
|
+
|
174
|
+
// reserved for future use
|
175
|
+
union switch (int v)
|
176
|
+
{
|
177
|
+
case 0:
|
178
|
+
void;
|
179
|
+
}
|
180
|
+
ext;
|
181
|
+
};
|
182
|
+
|
183
|
+
enum OfferEntryFlags
|
184
|
+
{
|
185
|
+
// issuer has authorized account to perform transactions with its credit
|
186
|
+
PASSIVE_FLAG = 1
|
187
|
+
};
|
188
|
+
|
189
|
+
/* OfferEntry
|
190
|
+
An offer is the building block of the offer book, they are automatically
|
191
|
+
claimed by payments when the price set by the owner is met.
|
192
|
+
|
193
|
+
For example an Offer is selling 10A where 1A is priced at 1.5B
|
194
|
+
|
195
|
+
*/
|
196
|
+
struct OfferEntry
|
197
|
+
{
|
198
|
+
AccountID sellerID;
|
199
|
+
uint64 offerID;
|
200
|
+
Asset selling; // A
|
201
|
+
Asset buying; // B
|
202
|
+
int64 amount; // amount of A
|
203
|
+
|
204
|
+
/* price for this offer:
|
205
|
+
price of A in terms of B
|
206
|
+
price=AmountB/AmountA=priceNumerator/priceDenominator
|
207
|
+
price is after fees
|
208
|
+
*/
|
209
|
+
Price price;
|
210
|
+
uint32 flags; // see OfferEntryFlags
|
211
|
+
|
212
|
+
// reserved for future use
|
213
|
+
union switch (int v)
|
214
|
+
{
|
215
|
+
case 0:
|
216
|
+
void;
|
217
|
+
}
|
218
|
+
ext;
|
219
|
+
};
|
220
|
+
|
221
|
+
|
222
|
+
/* LotEntry
|
223
|
+
|
224
|
+
*/
|
225
|
+
|
226
|
+
enum LotType {
|
227
|
+
TERRITORY = 1,
|
228
|
+
FACILITY = 2
|
229
|
+
};
|
230
|
+
|
231
|
+
enum LotBranch {
|
232
|
+
AGRICULTURE = 1,
|
233
|
+
LIVESTOCK = 2
|
234
|
+
};
|
235
|
+
|
236
|
+
struct LotEntry
|
237
|
+
{
|
238
|
+
AccountID organizerID;
|
239
|
+
uint64 lotID;
|
240
|
+
string lotName<1000>;
|
241
|
+
uint32 type;
|
242
|
+
string32 lotCode;
|
243
|
+
string lotAddress<1000>;
|
244
|
+
uint32 lotBranch;
|
245
|
+
string lotLocation<1000>;
|
246
|
+
uint64 startPrice;
|
247
|
+
uint64 bestPrice;
|
248
|
+
uint32 minStep;
|
249
|
+
uint32 maxStep;
|
250
|
+
uint64 published;
|
251
|
+
uint64 aucStarted;
|
252
|
+
uint64 duration;
|
253
|
+
uint64 pledge;
|
254
|
+
AccountID publisherID;
|
255
|
+
string details<1000>;
|
256
|
+
// reserved for future use
|
257
|
+
union switch (int v)
|
258
|
+
{
|
259
|
+
case 0:
|
260
|
+
void;
|
261
|
+
}
|
262
|
+
ext;
|
263
|
+
};
|
264
|
+
|
265
|
+
enum ParticipantState {
|
266
|
+
APPROVED = 0,
|
267
|
+
PENDING = 1,
|
268
|
+
PASS = 2,
|
269
|
+
FAIL = 3
|
270
|
+
};
|
271
|
+
/* ParticipantEntry
|
272
|
+
|
273
|
+
*/
|
274
|
+
struct ParticipantEntry
|
275
|
+
{
|
276
|
+
AccountID accountID;
|
277
|
+
uint64 lotID;
|
278
|
+
uint32 state;
|
279
|
+
uint64 bestBid;
|
280
|
+
uint32 bestBidSeq;
|
281
|
+
|
282
|
+
// reserved for future use
|
283
|
+
union switch (int v)
|
284
|
+
{
|
285
|
+
case 0:
|
286
|
+
void;
|
287
|
+
}
|
288
|
+
ext;
|
289
|
+
};
|
290
|
+
|
291
|
+
/* MessageEntry
|
292
|
+
|
293
|
+
*/
|
294
|
+
struct MessageEntry
|
295
|
+
{
|
296
|
+
uint64 messageID;
|
297
|
+
AccountID accountID;
|
298
|
+
string text<1000>;
|
299
|
+
uint64 lotID;
|
300
|
+
uint64 refMessageID;
|
301
|
+
// reserved for future use
|
302
|
+
union switch (int v)
|
303
|
+
{
|
304
|
+
case 0:
|
305
|
+
void;
|
306
|
+
}
|
307
|
+
ext;
|
308
|
+
};
|
309
|
+
|
310
|
+
struct LedgerEntry
|
311
|
+
{
|
312
|
+
uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed
|
313
|
+
|
314
|
+
union switch (LedgerEntryType type)
|
315
|
+
{
|
316
|
+
case ACCOUNT:
|
317
|
+
AccountEntry account;
|
318
|
+
case TRUSTLINE:
|
319
|
+
TrustLineEntry trustLine;
|
320
|
+
case OFFER:
|
321
|
+
OfferEntry offer;
|
322
|
+
case LOT:
|
323
|
+
LotEntry lot;
|
324
|
+
case PARTICIPANT:
|
325
|
+
ParticipantEntry participant;
|
326
|
+
case MESSAGE:
|
327
|
+
MessageEntry message;
|
328
|
+
case PROOF:
|
329
|
+
ProofEntry proof;
|
330
|
+
}
|
331
|
+
data;
|
332
|
+
|
333
|
+
// reserved for future use
|
334
|
+
union switch (int v)
|
335
|
+
{
|
336
|
+
case 0:
|
337
|
+
void;
|
338
|
+
}
|
339
|
+
ext;
|
340
|
+
};
|
341
|
+
|
342
|
+
// list of all envelope types used in the application
|
343
|
+
// those are prefixes used when building signatures for
|
344
|
+
// the respective envelopes
|
345
|
+
enum EnvelopeType
|
346
|
+
{
|
347
|
+
ENVELOPE_TYPE_SCP = 1,
|
348
|
+
ENVELOPE_TYPE_TX = 2,
|
349
|
+
ENVELOPE_TYPE_AUTH = 3
|
350
|
+
};
|
351
|
+
}
|
@@ -0,0 +1,288 @@
|
|
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-transaction.h"
|
6
|
+
|
7
|
+
namespace stellar
|
8
|
+
{
|
9
|
+
|
10
|
+
typedef opaque UpgradeType<128>;
|
11
|
+
|
12
|
+
/* StellarValue is the value used by SCP to reach consensus on a given ledger
|
13
|
+
*/
|
14
|
+
struct StellarValue
|
15
|
+
{
|
16
|
+
Hash txSetHash; // transaction set to apply to previous ledger
|
17
|
+
uint64 closeTime; // network close time
|
18
|
+
|
19
|
+
// upgrades to apply to the previous ledger (usually empty)
|
20
|
+
// this is a vector of encoded 'LedgerUpgrade' so that nodes can drop
|
21
|
+
// unknown steps during consensus if needed.
|
22
|
+
// see notes below on 'LedgerUpgrade' for more detail
|
23
|
+
// max size is dictated by number of upgrade types (+ room for future)
|
24
|
+
UpgradeType upgrades<6>;
|
25
|
+
|
26
|
+
// reserved for future use
|
27
|
+
union switch (int v)
|
28
|
+
{
|
29
|
+
case 0:
|
30
|
+
void;
|
31
|
+
}
|
32
|
+
ext;
|
33
|
+
};
|
34
|
+
|
35
|
+
/* The LedgerHeader is the highest level structure representing the
|
36
|
+
* state of a ledger, cryptographically linked to previous ledgers.
|
37
|
+
*/
|
38
|
+
struct LedgerHeader
|
39
|
+
{
|
40
|
+
uint32 ledgerVersion; // the protocol version of the ledger
|
41
|
+
Hash previousLedgerHash; // hash of the previous ledger header
|
42
|
+
StellarValue scpValue; // what consensus agreed to
|
43
|
+
Hash txSetResultHash; // the TransactionResultSet that led to this ledger
|
44
|
+
Hash bucketListHash; // hash of the ledger state
|
45
|
+
|
46
|
+
uint32 ledgerSeq; // sequence number of this ledger
|
47
|
+
|
48
|
+
int64 totalCoins; // total number of stroops in existence.
|
49
|
+
// 10,000,000 stroops in 1 XLM
|
50
|
+
|
51
|
+
int64 feePool; // fees burned since last inflation run
|
52
|
+
uint32 inflationSeq; // inflation sequence number
|
53
|
+
|
54
|
+
uint64 idPool; // last used global ID, used for generating objects
|
55
|
+
|
56
|
+
uint32 baseFee; // base fee per operation in stroops
|
57
|
+
uint32 baseReserve; // account base reserve in stroops
|
58
|
+
|
59
|
+
uint32 maxTxSetSize; // maximum size a transaction set can be
|
60
|
+
|
61
|
+
Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back
|
62
|
+
// in time without walking the chain back ledger by ledger
|
63
|
+
// each slot contains the oldest ledger that is mod of
|
64
|
+
// either 50 5000 50000 or 500000 depending on index
|
65
|
+
// skipList[0] mod(50), skipList[1] mod(5000), etc
|
66
|
+
|
67
|
+
// reserved for future use
|
68
|
+
union switch (int v)
|
69
|
+
{
|
70
|
+
case 0:
|
71
|
+
void;
|
72
|
+
}
|
73
|
+
ext;
|
74
|
+
};
|
75
|
+
|
76
|
+
/* Ledger upgrades
|
77
|
+
note that the `upgrades` field from StellarValue is normalized such that
|
78
|
+
it only contains one entry per LedgerUpgradeType, and entries are sorted
|
79
|
+
in ascending order
|
80
|
+
*/
|
81
|
+
enum LedgerUpgradeType
|
82
|
+
{
|
83
|
+
LEDGER_UPGRADE_VERSION = 1,
|
84
|
+
LEDGER_UPGRADE_BASE_FEE = 2,
|
85
|
+
LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3
|
86
|
+
};
|
87
|
+
|
88
|
+
union LedgerUpgrade switch (LedgerUpgradeType type)
|
89
|
+
{
|
90
|
+
case LEDGER_UPGRADE_VERSION:
|
91
|
+
uint32 newLedgerVersion; // update ledgerVersion
|
92
|
+
case LEDGER_UPGRADE_BASE_FEE:
|
93
|
+
uint32 newBaseFee; // update baseFee
|
94
|
+
case LEDGER_UPGRADE_MAX_TX_SET_SIZE:
|
95
|
+
uint32 newMaxTxSetSize; // update maxTxSetSize
|
96
|
+
};
|
97
|
+
|
98
|
+
/* Entries used to define the bucket list */
|
99
|
+
|
100
|
+
union LedgerKey switch (LedgerEntryType type)
|
101
|
+
{
|
102
|
+
case ACCOUNT:
|
103
|
+
struct
|
104
|
+
{
|
105
|
+
AccountID accountID;
|
106
|
+
} account;
|
107
|
+
|
108
|
+
case TRUSTLINE:
|
109
|
+
struct
|
110
|
+
{
|
111
|
+
AccountID accountID;
|
112
|
+
Asset asset;
|
113
|
+
} trustLine;
|
114
|
+
|
115
|
+
case OFFER:
|
116
|
+
struct
|
117
|
+
{
|
118
|
+
AccountID sellerID;
|
119
|
+
uint64 offerID;
|
120
|
+
} offer;
|
121
|
+
case LOT:
|
122
|
+
struct
|
123
|
+
{
|
124
|
+
AccountID organizerID;
|
125
|
+
uint64 lotID;
|
126
|
+
} lot;
|
127
|
+
case PARTICIPANT:
|
128
|
+
struct
|
129
|
+
{
|
130
|
+
AccountID accountID;
|
131
|
+
uint64 lotID;
|
132
|
+
} participant;
|
133
|
+
case MESSAGE:
|
134
|
+
struct
|
135
|
+
{
|
136
|
+
AccountID accountID;
|
137
|
+
uint64 messageID;
|
138
|
+
} message;
|
139
|
+
case PROOF:
|
140
|
+
struct
|
141
|
+
{
|
142
|
+
AccountID accountID;
|
143
|
+
uint64 proofID;
|
144
|
+
} proof;
|
145
|
+
|
146
|
+
};
|
147
|
+
|
148
|
+
enum BucketEntryType
|
149
|
+
{
|
150
|
+
LIVEENTRY = 0,
|
151
|
+
DEADENTRY = 1
|
152
|
+
};
|
153
|
+
|
154
|
+
union BucketEntry switch (BucketEntryType type)
|
155
|
+
{
|
156
|
+
case LIVEENTRY:
|
157
|
+
LedgerEntry liveEntry;
|
158
|
+
|
159
|
+
case DEADENTRY:
|
160
|
+
LedgerKey deadEntry;
|
161
|
+
};
|
162
|
+
|
163
|
+
// Transaction sets are the unit used by SCP to decide on transitions
|
164
|
+
// between ledgers
|
165
|
+
const MAX_TX_PER_LEDGER = 5000;
|
166
|
+
struct TransactionSet
|
167
|
+
{
|
168
|
+
Hash previousLedgerHash;
|
169
|
+
TransactionEnvelope txs<MAX_TX_PER_LEDGER>;
|
170
|
+
};
|
171
|
+
|
172
|
+
struct TransactionResultPair
|
173
|
+
{
|
174
|
+
Hash transactionHash;
|
175
|
+
TransactionResult result; // result for the transaction
|
176
|
+
};
|
177
|
+
|
178
|
+
// TransactionResultSet is used to recover results between ledgers
|
179
|
+
struct TransactionResultSet
|
180
|
+
{
|
181
|
+
TransactionResultPair results<MAX_TX_PER_LEDGER>;
|
182
|
+
};
|
183
|
+
|
184
|
+
// Entries below are used in the historical subsystem
|
185
|
+
|
186
|
+
struct TransactionHistoryEntry
|
187
|
+
{
|
188
|
+
uint32 ledgerSeq;
|
189
|
+
TransactionSet txSet;
|
190
|
+
|
191
|
+
// reserved for future use
|
192
|
+
union switch (int v)
|
193
|
+
{
|
194
|
+
case 0:
|
195
|
+
void;
|
196
|
+
}
|
197
|
+
ext;
|
198
|
+
};
|
199
|
+
|
200
|
+
struct TransactionHistoryResultEntry
|
201
|
+
{
|
202
|
+
uint32 ledgerSeq;
|
203
|
+
TransactionResultSet txResultSet;
|
204
|
+
|
205
|
+
// reserved for future use
|
206
|
+
union switch (int v)
|
207
|
+
{
|
208
|
+
case 0:
|
209
|
+
void;
|
210
|
+
}
|
211
|
+
ext;
|
212
|
+
};
|
213
|
+
|
214
|
+
struct LedgerHeaderHistoryEntry
|
215
|
+
{
|
216
|
+
Hash hash;
|
217
|
+
LedgerHeader header;
|
218
|
+
|
219
|
+
// reserved for future use
|
220
|
+
union switch (int v)
|
221
|
+
{
|
222
|
+
case 0:
|
223
|
+
void;
|
224
|
+
}
|
225
|
+
ext;
|
226
|
+
};
|
227
|
+
|
228
|
+
// historical SCP messages
|
229
|
+
|
230
|
+
struct LedgerSCPMessages
|
231
|
+
{
|
232
|
+
uint32 ledgerSeq;
|
233
|
+
SCPEnvelope messages<>;
|
234
|
+
};
|
235
|
+
|
236
|
+
// note: ledgerMessages may refer to any quorumSets encountered
|
237
|
+
// in the file so far, not just the one from this entry
|
238
|
+
struct SCPHistoryEntryV0
|
239
|
+
{
|
240
|
+
SCPQuorumSet quorumSets<>; // additional quorum sets used by ledgerMessages
|
241
|
+
LedgerSCPMessages ledgerMessages;
|
242
|
+
};
|
243
|
+
|
244
|
+
// SCP history file is an array of these
|
245
|
+
union SCPHistoryEntry switch (int v)
|
246
|
+
{
|
247
|
+
case 0:
|
248
|
+
SCPHistoryEntryV0 v0;
|
249
|
+
};
|
250
|
+
|
251
|
+
// represents the meta in the transaction table history
|
252
|
+
|
253
|
+
// STATE is emitted every time a ledger entry is modified/deleted
|
254
|
+
// and the entry was not already modified in the current ledger
|
255
|
+
|
256
|
+
enum LedgerEntryChangeType
|
257
|
+
{
|
258
|
+
LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger
|
259
|
+
LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger
|
260
|
+
LEDGER_ENTRY_REMOVED = 2, // entry was removed from the ledger
|
261
|
+
LEDGER_ENTRY_STATE = 3 // value of the entry
|
262
|
+
};
|
263
|
+
|
264
|
+
union LedgerEntryChange switch (LedgerEntryChangeType type)
|
265
|
+
{
|
266
|
+
case LEDGER_ENTRY_CREATED:
|
267
|
+
LedgerEntry created;
|
268
|
+
case LEDGER_ENTRY_UPDATED:
|
269
|
+
LedgerEntry updated;
|
270
|
+
case LEDGER_ENTRY_REMOVED:
|
271
|
+
LedgerKey removed;
|
272
|
+
case LEDGER_ENTRY_STATE:
|
273
|
+
LedgerEntry state;
|
274
|
+
};
|
275
|
+
|
276
|
+
typedef LedgerEntryChange LedgerEntryChanges<>;
|
277
|
+
|
278
|
+
struct OperationMeta
|
279
|
+
{
|
280
|
+
LedgerEntryChanges changes;
|
281
|
+
};
|
282
|
+
|
283
|
+
union TransactionMeta switch (int v)
|
284
|
+
{
|
285
|
+
case 0:
|
286
|
+
OperationMeta operations<>;
|
287
|
+
};
|
288
|
+
}
|