stellar-base 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/examples/create_account.rb +28 -0
  3. data/examples/low_level_transaction_post.rb +0 -6
  4. data/generated/stellar-base-generated.rb +13 -3
  5. data/generated/stellar/account_entry.rb +1 -1
  6. data/generated/stellar/account_flags.rb +1 -1
  7. data/generated/stellar/account_merge_result.rb +1 -1
  8. data/generated/stellar/account_merge_result_code.rb +1 -1
  9. data/generated/stellar/allow_trust_op.rb +1 -1
  10. data/generated/stellar/allow_trust_op/currency.rb +1 -1
  11. data/generated/stellar/allow_trust_result.rb +1 -1
  12. data/generated/stellar/allow_trust_result_code.rb +1 -1
  13. data/generated/stellar/bucket_entry.rb +1 -1
  14. data/generated/stellar/bucket_entry_type.rb +1 -1
  15. data/generated/stellar/change_trust_op.rb +1 -1
  16. data/generated/stellar/change_trust_result.rb +1 -1
  17. data/generated/stellar/change_trust_result_code.rb +1 -1
  18. data/generated/stellar/claim_offer_atom.rb +1 -1
  19. data/generated/stellar/create_account_op.rb +20 -0
  20. data/generated/stellar/create_account_result.rb +25 -0
  21. data/generated/stellar/create_account_result_code.rb +32 -0
  22. data/generated/stellar/create_offer_effect.rb +1 -1
  23. data/generated/stellar/create_offer_op.rb +1 -1
  24. data/generated/stellar/create_offer_result.rb +1 -1
  25. data/generated/stellar/create_offer_result_code.rb +1 -1
  26. data/generated/stellar/create_offer_success_result.rb +1 -1
  27. data/generated/stellar/create_offer_success_result/offer.rb +1 -1
  28. data/generated/stellar/currency.rb +1 -1
  29. data/generated/stellar/currency/alpha_num.rb +1 -1
  30. data/generated/stellar/currency_type.rb +1 -1
  31. data/generated/stellar/decorated_signature.rb +1 -1
  32. data/generated/stellar/dont_have.rb +1 -1
  33. data/generated/stellar/error.rb +1 -1
  34. data/generated/stellar/hello.rb +1 -1
  35. data/generated/stellar/inflation_payout.rb +1 -1
  36. data/generated/stellar/inflation_result.rb +1 -1
  37. data/generated/stellar/inflation_result_code.rb +1 -1
  38. data/generated/stellar/ledger_entry.rb +1 -1
  39. data/generated/stellar/ledger_entry_type.rb +1 -1
  40. data/generated/stellar/ledger_header.rb +1 -1
  41. data/generated/stellar/ledger_header_history_entry.rb +1 -1
  42. data/generated/stellar/ledger_key.rb +1 -1
  43. data/generated/stellar/ledger_key/account.rb +1 -1
  44. data/generated/stellar/ledger_key/offer.rb +1 -1
  45. data/generated/stellar/ledger_key/trust_line.rb +1 -1
  46. data/generated/stellar/memo.rb +11 -11
  47. data/generated/stellar/memo_type.rb +11 -11
  48. data/generated/stellar/message_type.rb +1 -1
  49. data/generated/stellar/offer_entry.rb +1 -1
  50. data/generated/stellar/operation.rb +5 -1
  51. data/generated/stellar/operation/body.rb +21 -13
  52. data/generated/stellar/operation_result.rb +5 -1
  53. data/generated/stellar/operation_result/tr.rb +23 -15
  54. data/generated/stellar/operation_result_code.rb +1 -1
  55. data/generated/stellar/operation_type.rb +19 -15
  56. data/generated/stellar/path_payment_op.rb +32 -0
  57. data/generated/stellar/path_payment_result.rb +34 -0
  58. data/generated/stellar/path_payment_result/success.rb +22 -0
  59. data/generated/stellar/path_payment_result_code.rb +40 -0
  60. data/generated/stellar/payment_op.rb +1 -9
  61. data/generated/stellar/payment_result.rb +1 -5
  62. data/generated/stellar/payment_result_code.rb +3 -11
  63. data/generated/stellar/peer_address.rb +1 -1
  64. data/generated/stellar/price.rb +1 -1
  65. data/generated/stellar/scp_ballot.rb +1 -1
  66. data/generated/stellar/scp_envelope.rb +1 -1
  67. data/generated/stellar/scp_quorum_set.rb +1 -1
  68. data/generated/stellar/scp_statement.rb +1 -1
  69. data/generated/stellar/scp_statement/pledges.rb +1 -1
  70. data/generated/stellar/scp_statement/pledges/prepare.rb +1 -1
  71. data/generated/stellar/scp_statement_type.rb +1 -1
  72. data/generated/stellar/set_options_op.rb +1 -1
  73. data/generated/stellar/set_options_result.rb +1 -1
  74. data/generated/stellar/set_options_result_code.rb +1 -1
  75. data/generated/stellar/signer.rb +1 -1
  76. data/generated/stellar/simple_payment_result.rb +1 -1
  77. data/generated/stellar/stellar_ballot.rb +1 -1
  78. data/generated/stellar/stellar_ballot_value.rb +1 -1
  79. data/generated/stellar/stellar_message.rb +1 -1
  80. data/generated/stellar/time_bounds.rb +20 -0
  81. data/generated/stellar/transaction.rb +5 -7
  82. data/generated/stellar/transaction_envelope.rb +1 -1
  83. data/generated/stellar/transaction_history_entry.rb +1 -1
  84. data/generated/stellar/transaction_history_result_entry.rb +1 -1
  85. data/generated/stellar/transaction_meta.rb +1 -1
  86. data/generated/stellar/transaction_result.rb +1 -1
  87. data/generated/stellar/transaction_result/result.rb +1 -1
  88. data/generated/stellar/transaction_result_code.rb +21 -19
  89. data/generated/stellar/transaction_result_pair.rb +1 -1
  90. data/generated/stellar/transaction_result_set.rb +1 -1
  91. data/generated/stellar/transaction_set.rb +1 -1
  92. data/generated/stellar/trust_line_entry.rb +1 -1
  93. data/generated/stellar/trust_line_flags.rb +1 -1
  94. data/lib/stellar/base/version.rb +1 -1
  95. data/lib/stellar/operation.rb +18 -3
  96. data/lib/stellar/payment_op.rb +0 -3
  97. data/lib/stellar/transaction.rb +7 -3
  98. data/spec/lib/stellar/transaction_spec.rb +1 -3
  99. data/xdr/Stellar-transaction.x +146 -55
  100. metadata +11 -3
  101. data/generated/stellar/payment_success_multi_result.rb +0 -20
@@ -7,6 +7,12 @@ module Stellar
7
7
  make :payment, attributes
8
8
  end
9
9
 
10
+ #
11
+ # @see Stellar::Operation.create_account
12
+ def self.create_account(attributes={})
13
+ make :create_account, attributes
14
+ end
15
+
10
16
  #
11
17
  # @see Stellar::Operation.change_trust
12
18
  def self.change_trust(attributes={})
@@ -133,9 +139,7 @@ module Stellar
133
139
  def apply_defaults
134
140
  self.operations ||= []
135
141
  self.fee ||= 10
136
- self.min_ledger ||= 0
137
- self.max_ledger ||= 2**32 - 1
138
- self.memo ||= Memo.new(:memo_type_none)
142
+ self.memo ||= Memo.new(:memo_none)
139
143
  end
140
144
  end
141
145
  end
@@ -6,9 +6,7 @@ describe Stellar::Transaction do
6
6
  source_account: "\x00" * 32,
7
7
  fee: 10,
8
8
  seq_num: 1,
9
- max_ledger: 10,
10
- min_ledger: 0,
11
- memo: Stellar::Memo.new(:memo_type_none),
9
+ memo: Stellar::Memo.new(:memo_none),
12
10
  operations: [
13
11
  Stellar::Operation.new(body: Stellar::Operation::Body.new(:inflation))
14
12
  ]
@@ -15,19 +15,35 @@ struct DecoratedSignature
15
15
 
16
16
  enum OperationType
17
17
  {
18
- PAYMENT = 0,
19
- CREATE_OFFER = 1,
20
- SET_OPTIONS = 2,
21
- CHANGE_TRUST = 3,
22
- ALLOW_TRUST = 4,
23
- ACCOUNT_MERGE = 5,
24
- INFLATION = 6
18
+ CREATE_ACCOUNT = 0,
19
+ PAYMENT = 1,
20
+ PATH_PAYMENT = 2,
21
+ CREATE_OFFER = 3,
22
+ SET_OPTIONS = 4,
23
+ CHANGE_TRUST = 5,
24
+ ALLOW_TRUST = 6,
25
+ ACCOUNT_MERGE = 7,
26
+ INFLATION = 8
27
+ };
28
+
29
+ /* CreateAccount
30
+ Funds a new account with the specified starting balance
31
+
32
+ Threshold: med
33
+
34
+ Result: CreateAccountResult
35
+
36
+ */
37
+
38
+ struct CreateAccountOp
39
+ {
40
+ AccountID destination; // account to create
41
+ int64 startingBalance; // amount they end up with
25
42
  };
26
43
 
27
44
  /* Payment
28
45
 
29
- send an amount to a destination account, optionally through a path.
30
- XLM payments create the destination account if it does not exist
46
+ send an amount to a destination account.
31
47
 
32
48
  Threshold: med
33
49
 
@@ -38,12 +54,31 @@ struct PaymentOp
38
54
  AccountID destination; // recipient of the payment
39
55
  Currency currency; // what they end up with
40
56
  int64 amount; // amount they end up with
57
+ };
58
+
59
+ /* PathPayment
60
+
61
+ send an amount to a destination account through a path.
62
+ (up to sendMax, sendCurrency)
63
+ (X0, Path[0]) .. (Xn, Path[n])
64
+ (destAmount, destCurrency)
65
+
66
+ Threshold: med
67
+
68
+ Result: PathPaymentResult
69
+ */
70
+ struct PathPaymentOp
71
+ {
72
+ Currency sendCurrency; // currency we pay with
73
+ int64 sendMax; // the maximum amount of sendCurrency to
74
+ // send (excluding fees).
75
+ // The operation will fail if can't be met
76
+
77
+ AccountID destination; // recipient of the payment
78
+ Currency destCurrency; // what they end up with
79
+ int64 destAmount; // amount they end up with
41
80
 
42
- // payment over path
43
- Currency path<5>; // what hops it must go through to get there
44
- int64 sendMax; // the maximum amount of the source currency (==path[0]) to
45
- // send (excluding fees).
46
- // The operation will fail if can't be met
81
+ Currency path<5>; // additional hops it must go through to get there
47
82
  };
48
83
 
49
84
  /* Creates, updates or deletes an offer
@@ -155,8 +190,12 @@ struct Operation
155
190
 
156
191
  union switch (OperationType type)
157
192
  {
193
+ case CREATE_ACCOUNT:
194
+ CreateAccountOp createAccountOp;
158
195
  case PAYMENT:
159
196
  PaymentOp paymentOp;
197
+ case PATH_PAYMENT:
198
+ PathPaymentOp pathPaymentOp;
160
199
  case CREATE_OFFER:
161
200
  CreateOfferOp createOfferOp;
162
201
  case SET_OPTIONS:
@@ -175,27 +214,33 @@ struct Operation
175
214
 
176
215
  enum MemoType
177
216
  {
178
- MEMO_TYPE_NONE = 0,
179
- MEMO_TYPE_TEXT = 1,
180
- MEMO_TYPE_ID = 2,
181
- MEMO_TYPE_HASH = 3,
182
- MEMO_TYPE_RETURN = 4
217
+ MEMO_NONE = 0,
218
+ MEMO_TEXT = 1,
219
+ MEMO_ID = 2,
220
+ MEMO_HASH = 3,
221
+ MEMO_RETURN = 4
183
222
  };
184
223
 
185
224
  union Memo switch (MemoType type)
186
225
  {
187
- case MEMO_TYPE_NONE:
226
+ case MEMO_NONE:
188
227
  void;
189
- case MEMO_TYPE_TEXT:
228
+ case MEMO_TEXT:
190
229
  string text<28>;
191
- case MEMO_TYPE_ID:
230
+ case MEMO_ID:
192
231
  uint64 id;
193
- case MEMO_TYPE_HASH:
232
+ case MEMO_HASH:
194
233
  Hash hash; // the hash of what to pull from the content server
195
- case MEMO_TYPE_RETURN:
234
+ case MEMO_RETURN:
196
235
  Hash retHash; // the hash of the tx you are rejecting
197
236
  };
198
237
 
238
+ struct TimeBounds
239
+ {
240
+ uint64 minTime;
241
+ uint64 maxTime;
242
+ };
243
+
199
244
  /* a transaction is a container for a set of operations
200
245
  - is executed by an account
201
246
  - fees are collected from the account
@@ -209,15 +254,14 @@ struct Transaction
209
254
  // account used to run the transaction
210
255
  AccountID sourceAccount;
211
256
 
212
- // the fee the sourceAccount will pay
257
+ // the fee the sourceAccount will pay
213
258
  int32 fee;
214
259
 
215
260
  // sequence number to consume in the account
216
261
  SequenceNumber seqNum;
217
262
 
218
- // validity range (inclusive) for the ledger sequence number
219
- uint32 minLedger;
220
- uint32 maxLedger;
263
+ // validity range (inclusive) for the last ledger close time
264
+ TimeBounds* timeBounds;
221
265
 
222
266
  Memo memo;
223
267
 
@@ -247,13 +291,35 @@ struct ClaimOfferAtom
247
291
  // should we also include the amount that the owner gets in return?
248
292
  };
249
293
 
294
+ /******* CreateAccount Result ********/
295
+
296
+ enum CreateAccountResultCode
297
+ {
298
+ // codes considered as "success" for the operation
299
+ CREATE_ACCOUNT_SUCCESS = 0, // account was created
300
+
301
+ // codes considered as "failure" for the operation
302
+ CREATE_ACCOUNT_MALFORMED = 1, // invalid destination
303
+ CREATE_ACCOUNT_UNDERFUNDED = 2, // not enough funds in source account
304
+ CREATE_ACCOUNT_LOW_RESERVE =
305
+ 3, // would create an account below the min reserve
306
+ CREATE_ACCOUNT_ALREADY_EXIST = 4 // account already exists
307
+ };
308
+
309
+ union CreateAccountResult switch (CreateAccountResultCode code)
310
+ {
311
+ case CREATE_ACCOUNT_SUCCESS:
312
+ void;
313
+ default:
314
+ void;
315
+ };
316
+
250
317
  /******* Payment Result ********/
251
318
 
252
319
  enum PaymentResultCode
253
320
  {
254
321
  // codes considered as "success" for the operation
255
- PAYMENT_SUCCESS = 0, // simple payment success
256
- PAYMENT_SUCCESS_MULTI = 1, // multi-path payment success
322
+ PAYMENT_SUCCESS = 0, // payment successfuly completed
257
323
 
258
324
  // codes considered as "failure" for the operation
259
325
  PAYMENT_MALFORMED = -1, // bad input
@@ -261,10 +327,34 @@ enum PaymentResultCode
261
327
  PAYMENT_NO_DESTINATION = -3, // destination account does not exist
262
328
  PAYMENT_NO_TRUST = -4, // destination missing a trust line for currency
263
329
  PAYMENT_NOT_AUTHORIZED = -5, // destination not authorized to hold currency
264
- PAYMENT_LINE_FULL = -6, // destination would go above their limit
265
- PAYMENT_TOO_FEW_OFFERS = -7, // not enough offers to satisfy path payment
266
- PAYMENT_OVER_SENDMAX = -8, // multi-path payment could not satisfy sendmax
267
- PAYMENT_LOW_RESERVE = -9 // would create an account below the min reserve
330
+ PAYMENT_LINE_FULL = -6 // destination would go above their limit
331
+ };
332
+
333
+ union PaymentResult switch (PaymentResultCode code)
334
+ {
335
+ case PAYMENT_SUCCESS:
336
+ void;
337
+ default:
338
+ void;
339
+ };
340
+
341
+ /******* Payment Result ********/
342
+
343
+ enum PathPaymentResultCode
344
+ {
345
+ // codes considered as "success" for the operation
346
+ PATH_PAYMENT_SUCCESS = 0, // success
347
+
348
+ // codes considered as "failure" for the operation
349
+ PATH_PAYMENT_MALFORMED = -1, // bad input
350
+ PATH_PAYMENT_UNDERFUNDED = -2, // not enough funds in source account
351
+ PATH_PAYMENT_NO_DESTINATION = -3, // destination account does not exist
352
+ PATH_PAYMENT_NO_TRUST = -4, // destination missing a trust line for currency
353
+ PATH_PAYMENT_NOT_AUTHORIZED =
354
+ -5, // destination not authorized to hold currency
355
+ PATH_PAYMENT_LINE_FULL = -6, // destination would go above their limit
356
+ PATH_PAYMENT_TOO_FEW_OFFERS = -7, // not enough offers to satisfy path
357
+ PATH_PAYMENT_OVER_SENDMAX = -8 // could not satisfy sendmax
268
358
  };
269
359
 
270
360
  struct SimplePaymentResult
@@ -274,18 +364,14 @@ struct SimplePaymentResult
274
364
  int64 amount;
275
365
  };
276
366
 
277
- struct PaymentSuccessMultiResult
278
- {
279
- ClaimOfferAtom offers<>;
280
- SimplePaymentResult last;
281
- };
282
-
283
- union PaymentResult switch (PaymentResultCode code)
367
+ union PathPaymentResult switch (PathPaymentResultCode code)
284
368
  {
285
- case PAYMENT_SUCCESS:
286
- void;
287
- case PAYMENT_SUCCESS_MULTI:
288
- PaymentSuccessMultiResult multi;
369
+ case PATH_PAYMENT_SUCCESS:
370
+ struct
371
+ {
372
+ ClaimOfferAtom offers<>;
373
+ SimplePaymentResult last;
374
+ } success;
289
375
  default:
290
376
  void;
291
377
  };
@@ -468,8 +554,12 @@ union OperationResult switch (OperationResultCode code)
468
554
  case opINNER:
469
555
  union switch (OperationType type)
470
556
  {
557
+ case CREATE_ACCOUNT:
558
+ CreateAccountResult createAccountResult;
471
559
  case PAYMENT:
472
560
  PaymentResult paymentResult;
561
+ case PATH_PAYMENT:
562
+ PathPaymentResult pathPaymentResult;
473
563
  case CREATE_OFFER:
474
564
  CreateOfferResult createOfferResult;
475
565
  case SET_OPTIONS:
@@ -496,16 +586,17 @@ enum TransactionResultCode
496
586
 
497
587
  txFAILED = -2, // one of the operations failed (but none were applied)
498
588
 
499
- txBAD_LEDGER = -3, // ledger is not in range [minLeder; maxLedger]
500
- txMISSING_OPERATION = -4, // no operation was specified
501
- txBAD_SEQ = -5, // sequence number does not match source account
502
-
503
- txBAD_AUTH = -6, // not enough signatures to perform transaction
504
- txINSUFFICIENT_BALANCE = -7, // fee would bring account below reserve
505
- txNO_ACCOUNT = -8, // source account not found
506
- txINSUFFICIENT_FEE = -9, // max fee is too small
507
- txBAD_AUTH_EXTRA = -10, // too many signatures on transaction
508
- txINTERNAL_ERROR = -11 // an unknown error occured
589
+ txTOO_EARLY = -3, // ledger closeTime before minTime
590
+ txTOO_LATE = -4, // ledger closeTime after maxTime
591
+ txMISSING_OPERATION = -5, // no operation was specified
592
+ txBAD_SEQ = -6, // sequence number does not match source account
593
+
594
+ txBAD_AUTH = -7, // not enough signatures to perform transaction
595
+ txINSUFFICIENT_BALANCE = -8, // fee would bring account below reserve
596
+ txNO_ACCOUNT = -9, // source account not found
597
+ txINSUFFICIENT_FEE = -10, // fee is too small
598
+ txBAD_AUTH_EXTRA = -11, // too many signatures on transaction
599
+ txINTERNAL_ERROR = -12 // an unknown error occured
509
600
  };
510
601
 
511
602
  struct TransactionResult
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xdr
@@ -194,6 +194,7 @@ files:
194
194
  - LICENSE.txt
195
195
  - README.md
196
196
  - Rakefile
197
+ - examples/create_account.rb
197
198
  - examples/low_level_transaction_post.rb
198
199
  - examples/mid_level_transaction_post.rb
199
200
  - examples/non_native_payment.rb
@@ -214,6 +215,9 @@ files:
214
215
  - generated/stellar/change_trust_result.rb
215
216
  - generated/stellar/change_trust_result_code.rb
216
217
  - generated/stellar/claim_offer_atom.rb
218
+ - generated/stellar/create_account_op.rb
219
+ - generated/stellar/create_account_result.rb
220
+ - generated/stellar/create_account_result_code.rb
217
221
  - generated/stellar/create_offer_effect.rb
218
222
  - generated/stellar/create_offer_op.rb
219
223
  - generated/stellar/create_offer_result.rb
@@ -248,10 +252,13 @@ files:
248
252
  - generated/stellar/operation_result/tr.rb
249
253
  - generated/stellar/operation_result_code.rb
250
254
  - generated/stellar/operation_type.rb
255
+ - generated/stellar/path_payment_op.rb
256
+ - generated/stellar/path_payment_result.rb
257
+ - generated/stellar/path_payment_result/success.rb
258
+ - generated/stellar/path_payment_result_code.rb
251
259
  - generated/stellar/payment_op.rb
252
260
  - generated/stellar/payment_result.rb
253
261
  - generated/stellar/payment_result_code.rb
254
- - generated/stellar/payment_success_multi_result.rb
255
262
  - generated/stellar/peer_address.rb
256
263
  - generated/stellar/price.rb
257
264
  - generated/stellar/scp_ballot.rb
@@ -269,6 +276,7 @@ files:
269
276
  - generated/stellar/stellar_ballot.rb
270
277
  - generated/stellar/stellar_ballot_value.rb
271
278
  - generated/stellar/stellar_message.rb
279
+ - generated/stellar/time_bounds.rb
272
280
  - generated/stellar/transaction.rb
273
281
  - generated/stellar/transaction_envelope.rb
274
282
  - generated/stellar/transaction_history_entry.rb
@@ -1,20 +0,0 @@
1
- # Automatically generated on 2015-05-12T09:08:23-07:00
2
- # DO NOT EDIT or your changes may be overwritten
3
-
4
- require 'xdr'
5
-
6
- # === xdr source ============================================================
7
- #
8
- # struct PaymentSuccessMultiResult
9
- # {
10
- # ClaimOfferAtom offers<>;
11
- # SimplePaymentResult last;
12
- # };
13
- #
14
- # ===========================================================================
15
- module Stellar
16
- class PaymentSuccessMultiResult < XDR::Struct
17
- attribute :offers, XDR::VarArray[ClaimOfferAtom]
18
- attribute :last, SimplePaymentResult
19
- end
20
- end