stellar-base 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/generated/stellar-base-generated.rb +56 -102
  3. data/generated/stellar/account_entry.rb +18 -5
  4. data/generated/stellar/account_entry/ext.rb +24 -0
  5. data/generated/stellar/account_flags.rb +2 -2
  6. data/generated/stellar/account_merge_result.rb +2 -2
  7. data/generated/stellar/account_merge_result_code.rb +2 -2
  8. data/generated/stellar/allow_trust_op.rb +2 -2
  9. data/generated/stellar/allow_trust_op/currency.rb +2 -2
  10. data/generated/stellar/allow_trust_result.rb +2 -2
  11. data/generated/stellar/allow_trust_result_code.rb +2 -2
  12. data/generated/stellar/bucket_entry.rb +2 -2
  13. data/generated/stellar/bucket_entry_type.rb +2 -2
  14. data/generated/stellar/change_trust_op.rb +2 -2
  15. data/generated/stellar/change_trust_result.rb +2 -2
  16. data/generated/stellar/change_trust_result_code.rb +2 -2
  17. data/generated/stellar/claim_offer_atom.rb +2 -2
  18. data/generated/stellar/create_account_op.rb +2 -2
  19. data/generated/stellar/create_account_result.rb +2 -2
  20. data/generated/stellar/create_account_result_code.rb +10 -10
  21. data/generated/stellar/create_passive_offer_op.rb +2 -2
  22. data/generated/stellar/crypto_key_type.rb +20 -0
  23. data/generated/stellar/currency.rb +2 -2
  24. data/generated/stellar/currency/alpha_num.rb +2 -2
  25. data/generated/stellar/currency_type.rb +2 -2
  26. data/generated/stellar/decorated_signature.rb +6 -6
  27. data/generated/stellar/dont_have.rb +2 -2
  28. data/generated/stellar/envelope_type.rb +22 -0
  29. data/generated/stellar/error.rb +2 -2
  30. data/generated/stellar/hello.rb +10 -8
  31. data/generated/stellar/inflation_payout.rb +3 -3
  32. data/generated/stellar/inflation_result.rb +3 -3
  33. data/generated/stellar/inflation_result_code.rb +2 -2
  34. data/generated/stellar/ledger_entry.rb +2 -4
  35. data/generated/stellar/ledger_entry_change.rb +2 -2
  36. data/generated/stellar/ledger_entry_change_type.rb +2 -2
  37. data/generated/stellar/ledger_entry_type.rb +2 -2
  38. data/generated/stellar/ledger_header.rb +28 -12
  39. data/generated/stellar/ledger_header/ext.rb +24 -0
  40. data/generated/stellar/ledger_header_history_entry.rb +15 -2
  41. data/generated/stellar/ledger_header_history_entry/ext.rb +24 -0
  42. data/generated/stellar/ledger_key.rb +2 -2
  43. data/generated/stellar/ledger_key/account.rb +2 -2
  44. data/generated/stellar/ledger_key/offer.rb +2 -2
  45. data/generated/stellar/ledger_key/trust_line.rb +2 -2
  46. data/generated/stellar/ledger_upgrade.rb +27 -0
  47. data/generated/stellar/ledger_upgrade_type.rb +22 -0
  48. data/generated/stellar/manage_offer_effect.rb +2 -2
  49. data/generated/stellar/manage_offer_op.rb +2 -2
  50. data/generated/stellar/manage_offer_result.rb +2 -2
  51. data/generated/stellar/manage_offer_result_code.rb +25 -21
  52. data/generated/stellar/manage_offer_success_result.rb +2 -2
  53. data/generated/stellar/manage_offer_success_result/offer.rb +2 -2
  54. data/generated/stellar/memo.rb +2 -2
  55. data/generated/stellar/memo_type.rb +2 -2
  56. data/generated/stellar/message_type.rb +2 -2
  57. data/generated/stellar/offer_entry.rb +15 -2
  58. data/generated/stellar/offer_entry/ext.rb +24 -0
  59. data/generated/stellar/offer_entry_flags.rb +2 -2
  60. data/generated/stellar/operation.rb +4 -4
  61. data/generated/stellar/operation/body.rb +4 -4
  62. data/generated/stellar/operation_result.rb +2 -2
  63. data/generated/stellar/operation_result/tr.rb +2 -2
  64. data/generated/stellar/operation_result_code.rb +2 -2
  65. data/generated/stellar/operation_type.rb +2 -2
  66. data/generated/stellar/path_payment_op.rb +2 -2
  67. data/generated/stellar/path_payment_result.rb +2 -2
  68. data/generated/stellar/path_payment_result/success.rb +2 -2
  69. data/generated/stellar/path_payment_result_code.rb +23 -20
  70. data/generated/stellar/payment_op.rb +2 -2
  71. data/generated/stellar/payment_result.rb +2 -2
  72. data/generated/stellar/payment_result_code.rb +19 -15
  73. data/generated/stellar/peer_address.rb +2 -2
  74. data/generated/stellar/price.rb +2 -2
  75. data/generated/stellar/public_key.rb +23 -0
  76. data/generated/stellar/scp_ballot.rb +2 -2
  77. data/generated/stellar/scp_envelope.rb +2 -4
  78. data/generated/stellar/scp_nomination.rb +22 -0
  79. data/generated/stellar/scp_quorum_set.rb +4 -4
  80. data/generated/stellar/scp_statement.rb +33 -16
  81. data/generated/stellar/scp_statement/pledges.rb +38 -14
  82. data/generated/stellar/scp_statement/pledges/confirm.rb +28 -0
  83. data/generated/stellar/scp_statement/pledges/externalize.rb +28 -0
  84. data/generated/stellar/scp_statement/pledges/prepare.rb +14 -6
  85. data/generated/stellar/scp_statement_type.rb +10 -10
  86. data/generated/stellar/set_options_op.rb +11 -4
  87. data/generated/stellar/set_options_result.rb +2 -2
  88. data/generated/stellar/set_options_result_code.rb +16 -12
  89. data/generated/stellar/signer.rb +4 -4
  90. data/generated/stellar/simple_payment_result.rb +2 -2
  91. data/generated/stellar/stellar_message.rb +2 -2
  92. data/generated/stellar/stellar_value.rb +40 -0
  93. data/generated/stellar/stellar_value/ext.rb +24 -0
  94. data/generated/stellar/threshold_indexes.rb +26 -0
  95. data/generated/stellar/time_bounds.rb +2 -2
  96. data/generated/stellar/transaction.rb +17 -4
  97. data/generated/stellar/transaction/ext.rb +24 -0
  98. data/generated/stellar/transaction_envelope.rb +2 -2
  99. data/generated/stellar/transaction_history_entry.rb +15 -2
  100. data/generated/stellar/transaction_history_entry/ext.rb +24 -0
  101. data/generated/stellar/transaction_history_result_entry.rb +15 -2
  102. data/generated/stellar/transaction_history_result_entry/ext.rb +24 -0
  103. data/generated/stellar/transaction_meta.rb +2 -2
  104. data/generated/stellar/transaction_result.rb +12 -2
  105. data/generated/stellar/transaction_result/ext.rb +24 -0
  106. data/generated/stellar/transaction_result/result.rb +2 -2
  107. data/generated/stellar/transaction_result_code.rb +2 -2
  108. data/generated/stellar/transaction_result_pair.rb +2 -2
  109. data/generated/stellar/transaction_result_set.rb +4 -4
  110. data/generated/stellar/transaction_set.rb +4 -4
  111. data/generated/stellar/trust_line_entry.rb +15 -2
  112. data/generated/stellar/trust_line_entry/ext.rb +24 -0
  113. data/generated/stellar/trust_line_flags.rb +2 -2
  114. data/lib/stellar/base/version.rb +1 -1
  115. data/lib/stellar/currency.rb +1 -1
  116. data/lib/stellar/key_pair.rb +14 -5
  117. data/lib/stellar/operation.rb +7 -7
  118. data/lib/stellar/transaction.rb +15 -3
  119. data/lib/stellar/transaction_envelope.rb +1 -1
  120. data/ruby-stellar-base.gemspec +1 -1
  121. data/spec/lib/stellar/key_pair_spec.rb +40 -9
  122. data/spec/lib/stellar/transaction_envelope_spec.rb +2 -2
  123. data/spec/lib/stellar/transaction_spec.rb +6 -6
  124. data/tasks/xdr.rake +11 -8
  125. data/xdr/Stellar-SCP.x +87 -0
  126. data/xdr/Stellar-ledger-entries.x +80 -6
  127. data/xdr/Stellar-ledger.x +87 -8
  128. data/xdr/Stellar-overlay.x +3 -16
  129. data/xdr/Stellar-transaction.x +66 -39
  130. data/xdr/Stellar-types.x +17 -29
  131. data/xdr/StellarXDR.x +1 -1
  132. metadata +25 -7
  133. data/generated/stellar/stellar_ballot.rb +0 -22
  134. data/generated/stellar/stellar_ballot_value.rb +0 -22
  135. data/xdr/SCPXDR.x +0 -67
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-05-13T15:00:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -9,12 +9,25 @@ require 'xdr'
9
9
  # {
10
10
  # uint32 ledgerSeq;
11
11
  # TransactionResultSet txResultSet;
12
+ #
13
+ # // reserved for future use
14
+ # union switch (int v)
15
+ # {
16
+ # case 0:
17
+ # void;
18
+ # }
19
+ # ext;
12
20
  # };
13
21
  #
14
22
  # ===========================================================================
15
23
  module Stellar
16
24
  class TransactionHistoryResultEntry < XDR::Struct
25
+ include XDR::Namespace
26
+
27
+ autoload :Ext
28
+
17
29
  attribute :ledger_seq, Uint32
18
30
  attribute :tx_result_set, TransactionResultSet
31
+ attribute :ext, Ext
19
32
  end
20
33
  end
@@ -0,0 +1,24 @@
1
+ # This code was automatically generated using xdrgen
2
+ # DO NOT EDIT or your changes may be overwritten
3
+
4
+ require 'xdr'
5
+
6
+ # === xdr source ============================================================
7
+ #
8
+ # union switch (int v)
9
+ # {
10
+ # case 0:
11
+ # void;
12
+ # }
13
+ #
14
+ # ===========================================================================
15
+ module Stellar
16
+ class TransactionHistoryResultEntry
17
+ class Ext < XDR::Union
18
+ switch_on XDR::Int, :v
19
+
20
+ switch 0
21
+
22
+ end
23
+ end
24
+ end
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-05-14T08:36:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-05-13T15:00:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -18,6 +18,14 @@ require 'xdr'
18
18
  # void;
19
19
  # }
20
20
  # result;
21
+ #
22
+ # // reserved for future use
23
+ # union switch (int v)
24
+ # {
25
+ # case 0:
26
+ # void;
27
+ # }
28
+ # ext;
21
29
  # };
22
30
  #
23
31
  # ===========================================================================
@@ -26,8 +34,10 @@ module Stellar
26
34
  include XDR::Namespace
27
35
 
28
36
  autoload :Result
37
+ autoload :Ext
29
38
 
30
39
  attribute :fee_charged, Int64
31
40
  attribute :result, Result
41
+ attribute :ext, Ext
32
42
  end
33
43
  end
@@ -0,0 +1,24 @@
1
+ # This code was automatically generated using xdrgen
2
+ # DO NOT EDIT or your changes may be overwritten
3
+
4
+ require 'xdr'
5
+
6
+ # === xdr source ============================================================
7
+ #
8
+ # union switch (int v)
9
+ # {
10
+ # case 0:
11
+ # void;
12
+ # }
13
+ #
14
+ # ===========================================================================
15
+ module Stellar
16
+ class TransactionResult
17
+ class Ext < XDR::Union
18
+ switch_on XDR::Int, :v
19
+
20
+ switch 0
21
+
22
+ end
23
+ end
24
+ end
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-05-13T15:00:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-05-14T08:36:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-05-13T15:00:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -1,18 +1,18 @@
1
- # Automatically generated on 2015-05-13T15:00:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
7
7
  #
8
8
  # struct TransactionResultSet
9
9
  # {
10
- # TransactionResultPair results<5000>;
10
+ # TransactionResultPair results<MAX_TX_PER_LEDGER>;
11
11
  # };
12
12
  #
13
13
  # ===========================================================================
14
14
  module Stellar
15
15
  class TransactionResultSet < XDR::Struct
16
- attribute :results, XDR::VarArray[TransactionResultPair, 5000]
16
+ attribute :results, XDR::VarArray[TransactionResultPair, MAX_TX_PER_LEDGER]
17
17
  end
18
18
  end
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-05-13T15:00:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -8,13 +8,13 @@ require 'xdr'
8
8
  # struct TransactionSet
9
9
  # {
10
10
  # Hash previousLedgerHash;
11
- # TransactionEnvelope txs<5000>;
11
+ # TransactionEnvelope txs<MAX_TX_PER_LEDGER>;
12
12
  # };
13
13
  #
14
14
  # ===========================================================================
15
15
  module Stellar
16
16
  class TransactionSet < XDR::Struct
17
17
  attribute :previous_ledger_hash, Hash
18
- attribute :txs, XDR::VarArray[TransactionEnvelope, 5000]
18
+ attribute :txs, XDR::VarArray[TransactionEnvelope, MAX_TX_PER_LEDGER]
19
19
  end
20
20
  end
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-05-13T15:00:04-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -14,15 +14,28 @@ require 'xdr'
14
14
  #
15
15
  # int64 limit; // balance cannot be above this
16
16
  # uint32 flags; // see TrustLineFlags
17
+ #
18
+ # // reserved for future use
19
+ # union switch (int v)
20
+ # {
21
+ # case 0:
22
+ # void;
23
+ # }
24
+ # ext;
17
25
  # };
18
26
  #
19
27
  # ===========================================================================
20
28
  module Stellar
21
29
  class TrustLineEntry < XDR::Struct
30
+ include XDR::Namespace
31
+
32
+ autoload :Ext
33
+
22
34
  attribute :account_id, AccountID
23
35
  attribute :currency, Currency
24
36
  attribute :balance, Int64
25
37
  attribute :limit, Int64
26
38
  attribute :flags, Uint32
39
+ attribute :ext, Ext
27
40
  end
28
41
  end
@@ -0,0 +1,24 @@
1
+ # This code was automatically generated using xdrgen
2
+ # DO NOT EDIT or your changes may be overwritten
3
+
4
+ require 'xdr'
5
+
6
+ # === xdr source ============================================================
7
+ #
8
+ # union switch (int v)
9
+ # {
10
+ # case 0:
11
+ # void;
12
+ # }
13
+ #
14
+ # ===========================================================================
15
+ module Stellar
16
+ class TrustLineEntry
17
+ class Ext < XDR::Union
18
+ switch_on XDR::Int, :v
19
+
20
+ switch 0
21
+
22
+ end
23
+ end
24
+ end
@@ -1,6 +1,6 @@
1
- # Automatically generated on 2015-06-08T11:39:14-07:00
1
+ # This code was automatically generated using xdrgen
2
2
  # DO NOT EDIT or your changes may be overwritten
3
-
3
+
4
4
  require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
@@ -1,5 +1,5 @@
1
1
  module Stellar
2
2
  module Base
3
- VERSION = "0.0.18"
3
+ VERSION = "0.0.19"
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@ module Stellar
7
7
  def self.alphanum(code, issuer)
8
8
  raise ArgumentError, "Bad :issuer" unless issuer.is_a?(KeyPair)
9
9
  code = normalize_code(code)
10
- an = AlphaNum.new({currency_code:code, issuer:issuer.public_key})
10
+ an = AlphaNum.new({currency_code:code, issuer:issuer.account_id})
11
11
  new(:currency_type_alphanum, an)
12
12
  end
13
13
 
@@ -32,12 +32,21 @@ module Stellar
32
32
  @secret_key = secret_key
33
33
  end
34
34
 
35
+ def account_id
36
+ Stellar::AccountID.new :key_types_ed25519, raw_public_key
37
+ end
38
+
35
39
  def public_key
40
+ Stellar::PublicKey.new :key_types_ed25519, raw_public_key
41
+ end
42
+
43
+ def raw_public_key
36
44
  @public_key.to_bytes
37
45
  end
38
46
 
39
- def public_key_hint
40
- public_key.slice(0, 4)
47
+ def signature_hint
48
+ # take last 4 bytes
49
+ account_id.to_xdr.slice(-4, 4)
41
50
  end
42
51
 
43
52
  def raw_seed
@@ -53,7 +62,7 @@ module Stellar
53
62
  end
54
63
 
55
64
  def address
56
- pk_bytes = public_key
65
+ pk_bytes = raw_public_key
57
66
  Util::Base58.stellar.check_encode(:account_id, pk_bytes)
58
67
  end
59
68
 
@@ -77,7 +86,7 @@ module Stellar
77
86
  def sign_decorated(message)
78
87
  raw_signature = sign(message)
79
88
  Stellar::DecoratedSignature.new({
80
- hint: public_key_hint,
89
+ hint: signature_hint,
81
90
  signature: raw_signature
82
91
  })
83
92
  end
@@ -91,4 +100,4 @@ module Stellar
91
100
  end
92
101
 
93
102
  end
94
- end
103
+ end
@@ -19,7 +19,7 @@ module Stellar
19
19
 
20
20
  if source_account
21
21
  raise ArgumentError, "Bad :source_account" unless source_account.is_a?(Stellar::KeyPair)
22
- op.source_account = source_account.public_key
22
+ op.source_account = source_account.account_id
23
23
  end
24
24
 
25
25
  return op
@@ -48,7 +48,7 @@ module Stellar
48
48
  op = PaymentOp.new
49
49
  op.currency = currency
50
50
  op.amount = amount
51
- op.destination = destination.public_key
51
+ op.destination = destination.account_id
52
52
 
53
53
  return make(attributes.merge({
54
54
  body:[:payment, op]
@@ -81,7 +81,7 @@ module Stellar
81
81
  op = PathPaymentOp.new
82
82
  op.send_currency = send_currency
83
83
  op.send_max = send_max
84
- op.destination = destination.public_key
84
+ op.destination = destination.account_id
85
85
  op.dest_currency = currency
86
86
  op.dest_amount = amount
87
87
  op.path = path
@@ -98,7 +98,7 @@ module Stellar
98
98
  raise ArgumentError unless destination.is_a?(KeyPair)
99
99
 
100
100
  op = CreateAccountOp.new()
101
- op.destination = destination.public_key
101
+ op.destination = destination.account_id
102
102
  op.starting_balance = starting_balance
103
103
 
104
104
  return make(attributes.merge({
@@ -194,7 +194,7 @@ module Stellar
194
194
  inflation_dest = attributes[:inflation_dest]
195
195
  if inflation_dest
196
196
  raise ArgumentError, "Bad :inflation_dest" unless inflation_dest.is_a?(Stellar::KeyPair)
197
- op.inflation_dest = inflation_dest.public_key
197
+ op.inflation_dest = inflation_dest.account_id
198
198
  end
199
199
 
200
200
 
@@ -227,7 +227,7 @@ module Stellar
227
227
 
228
228
  atc = AllowTrustOp::Currency.new(:currency_type_alphanum, currency.code)
229
229
 
230
- op.trustor = trustor.public_key
230
+ op.trustor = trustor.account_id
231
231
  op.authorize = authorize
232
232
  op.currency = atc
233
233
 
@@ -250,7 +250,7 @@ module Stellar
250
250
 
251
251
  # TODO: add source_account support
252
252
  return make(attributes.merge({
253
- body:[:account_merge, destination.public_key]
253
+ body:[:account_merge, destination.account_id]
254
254
  }))
255
255
  end
256
256
 
@@ -30,7 +30,7 @@ module Stellar
30
30
  def self.manage_offer(attributes={})
31
31
  make :manage_offer, attributes
32
32
  end
33
-
33
+
34
34
  #
35
35
  # @see Stellar::Operation.create_passive_offer
36
36
  def self.create_passive_offer(attributes={})
@@ -101,7 +101,7 @@ module Stellar
101
101
  new.tap do |result|
102
102
  result.seq_num = sequence
103
103
  result.fee = fee
104
- result.source_account = account.public_key
104
+ result.source_account = account.account_id
105
105
  result.apply_defaults
106
106
  end
107
107
  end
@@ -115,7 +115,18 @@ module Stellar
115
115
  end
116
116
 
117
117
  def hash
118
- Digest::SHA256.digest(to_xdr)
118
+ Digest::SHA256.digest(signature_base)
119
+ end
120
+
121
+ # Returns the string of bytes that, when hashed, provide the value which
122
+ # should be signed to create a valid stellar transaciton signature
123
+ def signature_base
124
+ signature_base_prefix + to_xdr
125
+ end
126
+
127
+ def signature_base_prefix
128
+ val = Stellar::EnvelopeType.envelope_type_tx
129
+ Stellar::EnvelopeType.to_xdr(val)
119
130
  end
120
131
 
121
132
  def to_envelope(*key_pairs)
@@ -152,6 +163,7 @@ module Stellar
152
163
  self.operations ||= []
153
164
  self.fee ||= 10
154
165
  self.memo ||= Memo.new(:memo_none)
166
+ self.ext ||= Stellar::Transaction::Ext.new 0
155
167
  end
156
168
  end
157
169
  end