stellar-base 0.0.18 → 0.0.19

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 (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
@@ -15,7 +15,7 @@ module Stellar
15
15
  hash = tx.hash
16
16
  return false if signatures.empty?
17
17
 
18
- key_index = key_pairs.index_by(&:public_key_hint)
18
+ key_index = key_pairs.index_by(&:signature_hint)
19
19
 
20
20
  signatures.all? do |sig|
21
21
  key_pair = key_index[sig.hint]
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["generated", "lib"]
19
19
 
20
- spec.add_dependency "xdr", "~> 0.0.3"
20
+ spec.add_dependency "xdr", "~> 0.0.4"
21
21
  spec.add_dependency "rbnacl"
22
22
  spec.add_dependency "rbnacl-libsodium", "~> 1.0.3"
23
23
  spec.add_dependency "activesupport", "~> 4"
@@ -25,7 +25,7 @@ describe Stellar::KeyPair do
25
25
 
26
26
  describe ".from_raw_seed" do
27
27
  subject{ Stellar::KeyPair.from_raw_seed(raw_seed) }
28
-
28
+
29
29
  context "when the provided value is a 32-byte string" do
30
30
  let(:raw_seed){ "allmylifemyhearthasbeensearching" }
31
31
  it { should be_a(Stellar::KeyPair) }
@@ -101,14 +101,32 @@ describe Stellar::KeyPair do
101
101
  end
102
102
  end
103
103
 
104
- describe "#public_key" do
104
+ describe "#raw_public_key" do
105
105
  let(:key_pair){ Stellar::KeyPair.random }
106
- subject{ key_pair.public_key }
106
+ subject{ key_pair.raw_public_key }
107
107
 
108
108
  it { should be_a(String) }
109
109
  it { should have_length(32) }
110
110
  end
111
111
 
112
+ describe "#public_key" do
113
+ let(:key_pair){ Stellar::KeyPair.random }
114
+ subject{ key_pair.public_key }
115
+
116
+ it { should be_a(Stellar::PublicKey) }
117
+ end
118
+
119
+ describe "#account_id" do
120
+ let(:key_pair){ Stellar::KeyPair.random }
121
+ subject{ key_pair.account_id }
122
+
123
+ it { should be_a(Stellar::AccountID) }
124
+
125
+ it "contains the public key" do
126
+ expect(subject.ed25519!).to eql(key_pair.raw_public_key)
127
+ end
128
+ end
129
+
112
130
  describe "#raw_seed" do
113
131
  let(:key_pair){ Stellar::KeyPair.random }
114
132
  subject{ key_pair.raw_seed }
@@ -117,6 +135,19 @@ describe Stellar::KeyPair do
117
135
  it { should have_length(32) }
118
136
  end
119
137
 
138
+ describe "#signature_hint" do
139
+ let(:key_pair){ Stellar::KeyPair.random }
140
+ subject{ key_pair.signature_hint }
141
+
142
+ it { should be_a(String) }
143
+ it { should have_length(4) }
144
+
145
+ it "is the last 4 bytes of the encoded account_id" do
146
+ expected = key_pair.account_id.to_xdr[-4..-1]
147
+ expect(subject).to eql(expected)
148
+ end
149
+ end
150
+
120
151
  describe "#address" do
121
152
  let(:key_pair){ Stellar::KeyPair.random }
122
153
  subject{ key_pair.address }
@@ -130,7 +161,7 @@ describe Stellar::KeyPair do
130
161
  end
131
162
 
132
163
  describe "#sign" do
133
- let(:message) { "hello" }
164
+ let(:message) { "hello" }
134
165
  subject{ key_pair.sign(message) }
135
166
 
136
167
  context "when the key_pair has no private key" do
@@ -158,26 +189,26 @@ describe Stellar::KeyPair do
158
189
 
159
190
  describe "#verify" do
160
191
  let(:key_pair) { Stellar::KeyPair.random }
161
- let(:message) { "hello" }
192
+ let(:message) { "hello" }
162
193
  subject { key_pair.verify(signature, message) }
163
194
 
164
195
  context "when the signature is correct" do
165
- let(:signature) { key_pair.sign(message) }
196
+ let(:signature) { key_pair.sign(message) }
166
197
  it{ should be_truthy }
167
198
  end
168
199
 
169
200
  context "when the signature is incorrect" do
170
- let(:signature) { key_pair.sign("some other message") }
201
+ let(:signature) { key_pair.sign("some other message") }
171
202
  it{ should be_falsey }
172
203
  end
173
204
 
174
205
  context "when the signature is invalid" do
175
- let(:signature) { "food" }
206
+ let(:signature) { "food" }
176
207
  it{ should be_falsey }
177
208
  end
178
209
 
179
210
  context "when the signature is from a different key" do
180
- let(:signature) { Stellar::KeyPair.random.sign(message) }
211
+ let(:signature) { Stellar::KeyPair.random.sign(message) }
181
212
  it{ should be_falsey }
182
213
  end
183
214
 
@@ -13,7 +13,7 @@ describe Stellar::TransactionEnvelope do
13
13
  end
14
14
 
15
15
  let(:envelope){ transaction.to_envelope(*signers) }
16
-
16
+
17
17
  describe "#signed_correctly?" do
18
18
  subject{ envelope.signed_correctly?(*verifiers) }
19
19
 
@@ -82,7 +82,7 @@ describe Stellar::TransactionEnvelope do
82
82
  it{ should be_falsey }
83
83
  end
84
84
  end
85
-
85
+
86
86
  end
87
87
 
88
88
  describe "#hash" do
@@ -3,23 +3,23 @@ require "spec_helper"
3
3
  describe Stellar::Transaction do
4
4
  subject do
5
5
  Stellar::Transaction.new({
6
- source_account: "\x00" * 32,
6
+ source_account: Stellar::AccountID.new(:key_types_ed25519, "\x00" * 32),
7
7
  fee: 10,
8
8
  seq_num: 1,
9
9
  memo: Stellar::Memo.new(:memo_none),
10
+ ext: Stellar::Transaction::Ext.new(0),
10
11
  operations: [
11
12
  Stellar::Operation.new(body: Stellar::Operation::Body.new(:inflation))
12
13
  ]
13
14
  })
14
15
  end
15
16
  let(:key_pair){ Stellar::KeyPair.random }
16
-
17
+
17
18
  describe "#sign" do
18
19
  let(:result){ subject.sign(key_pair) }
19
20
 
20
- it "returns a signature of SHA256(xdr form of the transaction)" do
21
- xdr = subject.to_xdr
22
- hash = Digest::SHA256.digest(xdr)
21
+ it "returns a signature of SHA256(signature_base of the transaction)" do
22
+ hash = Digest::SHA256.digest(subject.signature_base)
23
23
  expected = key_pair.sign(hash)
24
24
  expect(result).to eq(expected)
25
25
  end
@@ -35,7 +35,7 @@ describe Stellar::Transaction do
35
35
  it "correctly signs the transaction" do
36
36
  expect(result.signatures.length).to eq(1)
37
37
  expect(result.signatures.first).to be_a(Stellar::DecoratedSignature)
38
- expect(result.signatures.first.hint).to eq(key_pair.public_key_hint)
38
+ expect(result.signatures.first.hint).to eq(key_pair.signature_hint)
39
39
  expect(result.signatures.first.signature).to eq(subject.sign(key_pair))
40
40
  end
41
41
  end
@@ -4,21 +4,25 @@ namespace :xdr do
4
4
  # Prior to launch, we should be separating our .x files into a separate
5
5
  # repo, and should be able to improve this integration.
6
6
  HAYASHI_XDR = [
7
+ "src/xdr/Stellar-types.x",
7
8
  "src/xdr/Stellar-ledger-entries.x",
9
+ "src/xdr/Stellar-transaction.x",
8
10
  "src/xdr/Stellar-ledger.x",
9
11
  "src/xdr/Stellar-overlay.x",
10
- "src/xdr/Stellar-transaction.x",
11
- "src/xdr/Stellar-types.x",
12
12
  "src/overlay/StellarXDR.x",
13
- "src/scp/SCPXDR.x",
13
+ "src/scp/Stellar-SCP.x",
14
14
  ]
15
15
 
16
+ LOCAL_XDR_PATHS = HAYASHI_XDR.map{ |src| "xdr/" + File.basename(src) }
17
+
16
18
  task :update => [:download, :generate]
17
19
 
18
20
  task :download do
19
21
  require 'octokit'
20
22
  require 'base64'
21
-
23
+ FileUtils.rm_rf "xdr/"
24
+ FileUtils.mkdir_p "xdr"
25
+
22
26
  client = Octokit::Client.new(:netrc => true)
23
27
 
24
28
  HAYASHI_XDR.each do |src|
@@ -36,13 +40,12 @@ namespace :xdr do
36
40
  require 'fileutils'
37
41
  FileUtils.rm_rf "generated"
38
42
 
39
- paths = Pathname.glob("xdr/**/*.x")
40
43
  compilation = Xdrgen::Compilation.new(
41
- paths,
42
- output_dir: "generated",
44
+ LOCAL_XDR_PATHS,
45
+ output_dir: "generated",
43
46
  namespace: "stellar-base-generated",
44
47
  language: :ruby
45
48
  )
46
49
  compilation.compile
47
50
  end
48
- end
51
+ end
@@ -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 "generated/Stellar-types.h"
6
+
7
+ namespace stellar
8
+ {
9
+
10
+ typedef opaque Value<>;
11
+
12
+ struct SCPBallot
13
+ {
14
+ uint32 counter; // n
15
+ Value value; // x
16
+ };
17
+
18
+ enum SCPStatementType
19
+ {
20
+ SCP_ST_PREPARE = 0,
21
+ SCP_ST_CONFIRM = 1,
22
+ SCP_ST_EXTERNALIZE = 2,
23
+ SCP_ST_NOMINATE = 3
24
+ };
25
+
26
+ struct SCPNomination
27
+ {
28
+ Hash quorumSetHash; // D
29
+ Value votes<>; // X
30
+ Value accepted<>; // Y
31
+ };
32
+
33
+ struct SCPStatement
34
+ {
35
+ NodeID nodeID; // v
36
+ uint64 slotIndex; // i
37
+
38
+ union switch (SCPStatementType type)
39
+ {
40
+ case SCP_ST_PREPARE:
41
+ struct
42
+ {
43
+ Hash quorumSetHash; // D
44
+ SCPBallot ballot; // b
45
+ SCPBallot* prepared; // p
46
+ SCPBallot* preparedPrime; // p'
47
+ uint32 nC; // n_c
48
+ uint32 nP; // n_P
49
+ } prepare;
50
+ case SCP_ST_CONFIRM:
51
+ struct
52
+ {
53
+ Hash quorumSetHash; // D
54
+ uint32 nPrepared; // n_p
55
+ SCPBallot commit; // c
56
+ uint32 nP; // n_P
57
+ } confirm;
58
+ case SCP_ST_EXTERNALIZE:
59
+ struct
60
+ {
61
+ SCPBallot commit; // c
62
+ uint32 nP; // n_P
63
+ // not from the paper, but useful to build tooling to
64
+ // traverse the graph based off only the latest statement
65
+ Hash commitQuorumSetHash; // D used before EXTERNALIZE
66
+ } externalize;
67
+ case SCP_ST_NOMINATE:
68
+ SCPNomination nominate;
69
+ }
70
+ pledges;
71
+ };
72
+
73
+ struct SCPEnvelope
74
+ {
75
+ SCPStatement statement;
76
+ Signature signature;
77
+ };
78
+
79
+ // supports things like: A,B,C,(D,E,F),(G,H,(I,J,K,L))
80
+ // only allows 2 levels of nesting
81
+ struct SCPQuorumSet
82
+ {
83
+ uint32 threshold;
84
+ PublicKey validators<>;
85
+ SCPQuorumSet innerSets<>;
86
+ };
87
+ }
@@ -7,6 +7,49 @@
7
7
  namespace stellar
8
8
  {
9
9
 
10
+ typedef PublicKey AccountID;
11
+ typedef opaque Thresholds[4];
12
+ typedef string string32<32>;
13
+ typedef uint64 SequenceNumber;
14
+
15
+ enum CurrencyType
16
+ {
17
+ CURRENCY_TYPE_NATIVE = 0,
18
+ CURRENCY_TYPE_ALPHANUM = 1
19
+ };
20
+
21
+ union Currency switch (CurrencyType type)
22
+ {
23
+ case CURRENCY_TYPE_NATIVE:
24
+ void;
25
+
26
+ case CURRENCY_TYPE_ALPHANUM:
27
+ struct
28
+ {
29
+ opaque currencyCode[4];
30
+ AccountID issuer;
31
+ } alphaNum;
32
+
33
+ // add other currency types here in the future
34
+ };
35
+
36
+ // price in fractional representation
37
+ struct Price
38
+ {
39
+ int32 n; // numerator
40
+ int32 d; // denominator
41
+ };
42
+
43
+ // the 'Thresholds' type is packed uint8_t values
44
+ // defined by these indexes
45
+ enum ThresholdIndexes
46
+ {
47
+ THRESHOLD_MASTER_WEIGHT = 0,
48
+ THRESHOLD_LOW = 1,
49
+ THRESHOLD_MED = 2,
50
+ THRESHOLD_HIGH = 3
51
+ };
52
+
10
53
  enum LedgerEntryType
11
54
  {
12
55
  ACCOUNT = 0,
@@ -16,7 +59,7 @@ enum LedgerEntryType
16
59
 
17
60
  struct Signer
18
61
  {
19
- uint256 pubKey;
62
+ AccountID pubKey;
20
63
  uint32 weight; // really only need 1byte
21
64
  };
22
65
 
@@ -50,13 +93,21 @@ struct AccountEntry
50
93
  AccountID* inflationDest; // Account to vote during inflation
51
94
  uint32 flags; // see AccountFlags
52
95
 
96
+ string32 homeDomain; // can be used for reverse federation and memo lookup
97
+
53
98
  // fields used for signatures
54
99
  // thresholds stores unsigned bytes: [weight of master|low|medium|high]
55
100
  Thresholds thresholds;
56
101
 
57
- string32 homeDomain; // can be used for reverse federation and memo lookup
58
-
59
102
  Signer signers<20>; // possible signers for this account
103
+
104
+ // reserved for future use
105
+ union switch (int v)
106
+ {
107
+ case 0:
108
+ void;
109
+ }
110
+ ext;
60
111
  };
61
112
 
62
113
  /* TrustLineEntry
@@ -80,8 +131,15 @@ struct TrustLineEntry
80
131
 
81
132
  int64 limit; // balance cannot be above this
82
133
  uint32 flags; // see TrustLineFlags
83
- };
84
134
 
135
+ // reserved for future use
136
+ union switch (int v)
137
+ {
138
+ case 0:
139
+ void;
140
+ }
141
+ ext;
142
+ };
85
143
 
86
144
  enum OfferEntryFlags
87
145
  {
@@ -111,17 +169,33 @@ struct OfferEntry
111
169
  */
112
170
  Price price;
113
171
  uint32 flags; // see OfferEntryFlags
172
+
173
+ // reserved for future use
174
+ union switch (int v)
175
+ {
176
+ case 0:
177
+ void;
178
+ }
179
+ ext;
114
180
  };
115
181
 
116
182
  union LedgerEntry switch (LedgerEntryType type)
117
183
  {
118
184
  case ACCOUNT:
119
185
  AccountEntry account;
120
-
121
186
  case TRUSTLINE:
122
187
  TrustLineEntry trustLine;
123
-
124
188
  case OFFER:
125
189
  OfferEntry offer;
126
190
  };
191
+
192
+ // list of all envelope types used in the application
193
+ // those are prefixes used when building signatures for
194
+ // the respective envelopes
195
+ enum EnvelopeType
196
+ {
197
+ ENVELOPE_TYPE_SCP = 1,
198
+ ENVELOPE_TYPE_TX = 2
199
+ };
200
+
127
201
  }
@@ -7,18 +7,42 @@
7
7
  namespace stellar
8
8
  {
9
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
+ UpgradeType upgrades<4>;
24
+
25
+ // reserved for future use
26
+ union switch (int v)
27
+ {
28
+ case 0:
29
+ void;
30
+ }
31
+ ext;
32
+ };
33
+
10
34
  /* The LedgerHeader is the highest level structure representing the
11
35
  * state of a ledger, cryptographically linked to previous ledgers.
12
36
  */
13
37
  struct LedgerHeader
14
38
  {
39
+ uint32 ledgerVersion; // the protocol version of the ledger
15
40
  Hash previousLedgerHash; // hash of the previous ledger header
16
- Hash txSetHash; // the tx set that was SCP confirmed
41
+ StellarValue scpValue; // what consensus agreed to
17
42
  Hash txSetResultHash; // the TransactionResultSet that led to this ledger
18
43
  Hash bucketListHash; // hash of the ledger state
19
44
 
20
45
  uint32 ledgerSeq; // sequence number of this ledger
21
- uint64 closeTime; // network close time
22
46
 
23
47
  int64 totalCoins; // total number of stroops in existence
24
48
 
@@ -27,11 +51,41 @@ struct LedgerHeader
27
51
 
28
52
  uint64 idPool; // last used global ID, used for generating objects
29
53
 
30
- int32 baseFee; // base fee per operation in stroops
31
- int32 baseReserve; // account base reserve in stroops
54
+ uint32 baseFee; // base fee per operation in stroops
55
+ uint32 baseReserve; // account base reserve in stroops
32
56
 
33
- Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back
34
- // in time without walking the chain back ledger by ledger
57
+ Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back
58
+ // in time without walking the chain back ledger by ledger
59
+ // each slot contains the oldest ledger that is mod of
60
+ // either 50 5000 50000 or 500000 depending on index
61
+ // skipList[0] mod(50), skipList[1] mod(5000), etc
62
+
63
+ // reserved for future use
64
+ union switch (int v)
65
+ {
66
+ case 0:
67
+ void;
68
+ }
69
+ ext;
70
+ };
71
+
72
+ /* Ledger upgrades
73
+ note that the `upgrades` field from StellarValue is normalized such that
74
+ it only contains one entry per LedgerUpgradeType, and entries are sorted
75
+ in ascending order
76
+ */
77
+ enum LedgerUpgradeType
78
+ {
79
+ LEDGER_UPGRADE_VERSION = 1,
80
+ LEDGER_UPGRADE_BASE_FEE = 2
81
+ };
82
+
83
+ union LedgerUpgrade switch (LedgerUpgradeType type)
84
+ {
85
+ case LEDGER_UPGRADE_VERSION:
86
+ uint32 newLedgerVersion; // update ledgerVersion
87
+ case LEDGER_UPGRADE_BASE_FEE:
88
+ uint32 newBaseFee; // update baseFee
35
89
  };
36
90
 
37
91
  /* Entries used to define the bucket list */
@@ -76,10 +130,11 @@ case DEADENTRY:
76
130
 
77
131
  // Transaction sets are the unit used by SCP to decide on transitions
78
132
  // between ledgers
133
+ const MAX_TX_PER_LEDGER = 5000;
79
134
  struct TransactionSet
80
135
  {
81
136
  Hash previousLedgerHash;
82
- TransactionEnvelope txs<5000>;
137
+ TransactionEnvelope txs<MAX_TX_PER_LEDGER>;
83
138
  };
84
139
 
85
140
  struct TransactionResultPair
@@ -91,7 +146,7 @@ struct TransactionResultPair
91
146
  // TransactionResultSet is used to recover results between ledgers
92
147
  struct TransactionResultSet
93
148
  {
94
- TransactionResultPair results<5000>;
149
+ TransactionResultPair results<MAX_TX_PER_LEDGER>;
95
150
  };
96
151
 
97
152
  // Entries below are used in the historical subsystem
@@ -100,18 +155,42 @@ struct TransactionHistoryEntry
100
155
  {
101
156
  uint32 ledgerSeq;
102
157
  TransactionSet txSet;
158
+
159
+ // reserved for future use
160
+ union switch (int v)
161
+ {
162
+ case 0:
163
+ void;
164
+ }
165
+ ext;
103
166
  };
104
167
 
105
168
  struct TransactionHistoryResultEntry
106
169
  {
107
170
  uint32 ledgerSeq;
108
171
  TransactionResultSet txResultSet;
172
+
173
+ // reserved for future use
174
+ union switch (int v)
175
+ {
176
+ case 0:
177
+ void;
178
+ }
179
+ ext;
109
180
  };
110
181
 
111
182
  struct LedgerHeaderHistoryEntry
112
183
  {
113
184
  Hash hash;
114
185
  LedgerHeader header;
186
+
187
+ // reserved for future use
188
+ union switch (int v)
189
+ {
190
+ case 0:
191
+ void;
192
+ }
193
+ ext;
115
194
  };
116
195
 
117
196
  // represents the meta in the transaction table history