stellar-base 0.22.0 → 0.23.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +2 -3
- data/generated/stellar-base-generated.rb +10 -1
- data/generated/stellar/allow_trust_op.rb +3 -2
- data/generated/stellar/authenticated_message.rb +4 -4
- data/generated/stellar/authenticated_message/v0.rb +4 -4
- data/generated/stellar/change_trust_result_code.rb +1 -1
- data/generated/stellar/crypto_key_type.rb +8 -4
- data/generated/stellar/curve25519_public.rb +1 -1
- data/generated/stellar/curve25519_secret.rb +1 -1
- data/generated/stellar/envelope_type.rb +9 -5
- data/generated/stellar/fee_bump_transaction.rb +39 -0
- data/generated/stellar/fee_bump_transaction/ext.rb +24 -0
- data/generated/stellar/fee_bump_transaction/inner_tx.rb +25 -0
- data/generated/stellar/fee_bump_transaction_envelope.rb +22 -0
- data/generated/stellar/hmac_sha256_key.rb +1 -1
- data/generated/stellar/hmac_sha256_mac.rb +1 -1
- data/generated/stellar/inner_transaction_result.rb +56 -0
- data/generated/stellar/inner_transaction_result/ext.rb +24 -0
- data/generated/stellar/inner_transaction_result/result.rb +52 -0
- data/generated/stellar/inner_transaction_result_pair.rb +20 -0
- data/generated/stellar/ledger_close_meta.rb +1 -1
- data/generated/stellar/manage_buy_offer_result_code.rb +5 -4
- data/generated/stellar/manage_sell_offer_result_code.rb +12 -8
- data/generated/stellar/muxed_account.rb +35 -0
- data/generated/stellar/muxed_account/med25519.rb +22 -0
- data/generated/stellar/operation.rb +3 -3
- data/generated/stellar/operation/body.rb +2 -2
- data/generated/stellar/operation_result.rb +1 -1
- data/generated/stellar/operation_result/tr.rb +1 -1
- data/generated/stellar/operation_result_code.rb +3 -3
- data/generated/stellar/path_payment_strict_receive_op.rb +4 -4
- data/generated/stellar/path_payment_strict_receive_result_code.rb +21 -12
- data/generated/stellar/path_payment_strict_send_op.rb +6 -6
- data/generated/stellar/path_payment_strict_send_result_code.rb +20 -12
- data/generated/stellar/payment_op.rb +4 -4
- data/generated/stellar/survey_response_body.rb +2 -2
- data/generated/stellar/transaction.rb +2 -2
- data/generated/stellar/transaction_envelope.rb +17 -8
- data/generated/stellar/transaction_result.rb +3 -0
- data/generated/stellar/transaction_result/result.rb +9 -3
- data/generated/stellar/transaction_result_code.rb +21 -14
- data/generated/stellar/transaction_signature_payload.rb +3 -1
- data/generated/stellar/transaction_signature_payload/tagged_transaction.rb +7 -3
- data/generated/stellar/transaction_v0.rb +39 -0
- data/generated/stellar/transaction_v0/ext.rb +24 -0
- data/generated/stellar/transaction_v0_envelope.rb +22 -0
- data/generated/stellar/transaction_v1_envelope.rb +22 -0
- data/generated/stellar/trust_line_flags.rb +6 -2
- data/lib/stellar-base.rb +27 -25
- data/lib/stellar/account_flags.rb +2 -4
- data/lib/stellar/asset.rb +6 -6
- data/lib/stellar/base.rb +1 -1
- data/lib/stellar/{base/compat.rb → compat.rb} +6 -7
- data/lib/stellar/concerns/transaction.rb +49 -0
- data/lib/stellar/convert.rb +2 -2
- data/lib/stellar/factories.rb +1 -3
- data/lib/stellar/fee_bump_transaction.rb +21 -0
- data/lib/stellar/key_pair.rb +9 -6
- data/lib/stellar/networks.rb +5 -7
- data/lib/stellar/operation.rb +421 -416
- data/lib/stellar/path_payment_strict_receive_result.rb +1 -2
- data/lib/stellar/price.rb +2 -4
- data/lib/stellar/signer_key.rb +4 -8
- data/lib/stellar/thresholds.rb +5 -7
- data/lib/stellar/transaction.rb +154 -198
- data/lib/stellar/transaction_builder.rb +66 -23
- data/lib/stellar/transaction_envelope.rb +40 -8
- data/lib/stellar/transaction_v0.rb +39 -0
- data/lib/stellar/util/continued_fraction.rb +19 -19
- data/lib/stellar/util/strkey.rb +39 -14
- data/lib/stellar/{base/version.rb → version.rb} +1 -1
- metadata +33 -203
- data/.gitignore +0 -17
- data/.travis.yml +0 -16
- data/.yardopts +0 -8
- data/CHANGELOG.md +0 -149
- data/CONTRIBUTING.md +0 -48
- data/Gemfile +0 -9
- data/Guardfile +0 -5
- data/Rakefile +0 -4
- data/examples/allow_trust.rb +0 -51
- data/examples/create_account.rb +0 -26
- data/examples/low_level_transaction_post.rb +0 -46
- data/examples/mid_level_transaction_post.rb +0 -33
- data/examples/non_native_payment.rb +0 -60
- data/examples/offer.rb +0 -75
- data/examples/transaction_merge.rb +0 -23
- data/ruby-stellar-base.gemspec +0 -34
- data/spec/lib/stellar/account_flags_spec.rb +0 -19
- data/spec/lib/stellar/asset_spec.rb +0 -45
- data/spec/lib/stellar/convert_spec.rb +0 -61
- data/spec/lib/stellar/key_pair_spec.rb +0 -251
- data/spec/lib/stellar/networks_spec.rb +0 -77
- data/spec/lib/stellar/operation_spec.rb +0 -131
- data/spec/lib/stellar/path_payment_strict_receive_result_spec.rb +0 -95
- data/spec/lib/stellar/price_spec.rb +0 -34
- data/spec/lib/stellar/signer_key_spec.rb +0 -26
- data/spec/lib/stellar/thresholds_spec.rb +0 -62
- data/spec/lib/stellar/transaction_builder_spec.rb +0 -263
- data/spec/lib/stellar/transaction_envelope_spec.rb +0 -93
- data/spec/lib/stellar/transaction_spec.rb +0 -132
- data/spec/lib/stellar/util/strkey_spec.rb +0 -54
- data/spec/spec_helper.rb +0 -16
- data/spec/support/matchers/be_strkey.rb +0 -9
- data/spec/support/matchers/eq_bytes.rb +0 -5
- data/spec/support/matchers/have_length.rb +0 -5
- data/tasks/rspec.rake +0 -6
- data/tasks/travis.rake +0 -1
- data/tasks/xdr.rake +0 -45
- data/xdr/Stellar-SCP.x +0 -86
- data/xdr/Stellar-ledger-entries.x +0 -295
- data/xdr/Stellar-ledger.x +0 -372
- data/xdr/Stellar-overlay.x +0 -229
- data/xdr/Stellar-transaction.x +0 -901
- data/xdr/Stellar-types.x +0 -81
@@ -1,93 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Stellar::TransactionEnvelope do
|
4
|
-
let(:sender) { Stellar::KeyPair.random }
|
5
|
-
let(:receiver){ Stellar::KeyPair.random }
|
6
|
-
let(:transaction) do
|
7
|
-
Stellar::Transaction.payment({
|
8
|
-
account: sender,
|
9
|
-
destination: receiver,
|
10
|
-
sequence: 1,
|
11
|
-
amount: [:native, 20000000]
|
12
|
-
})
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:envelope){ transaction.to_envelope(*signers) }
|
16
|
-
|
17
|
-
describe "#signed_correctly?" do
|
18
|
-
subject{ envelope.signed_correctly?(*verifiers) }
|
19
|
-
|
20
|
-
context "when unsigned" do
|
21
|
-
let(:signers) { [] }
|
22
|
-
let(:verifiers){ [sender] }
|
23
|
-
|
24
|
-
it{ should be_falsey }
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when signed by a single account" do
|
28
|
-
let(:signers) { [sender] }
|
29
|
-
let(:verifiers){ signers }
|
30
|
-
|
31
|
-
context "and signed correctly" do
|
32
|
-
it{ should be_truthy }
|
33
|
-
end
|
34
|
-
|
35
|
-
context "and the signature is corrupted" do
|
36
|
-
before(:each){ envelope.signatures.first.signature = "\xFF" * 32}
|
37
|
-
it{ should be_falsey }
|
38
|
-
end
|
39
|
-
|
40
|
-
context "and the signature is from a different message" do
|
41
|
-
before(:each){ envelope.signatures = [sender.sign_decorated("hello")]}
|
42
|
-
it{ should be_falsey }
|
43
|
-
end
|
44
|
-
|
45
|
-
context "and the key for the signing account is not provided" do
|
46
|
-
let(:verifiers){ [] }
|
47
|
-
it{ should be_falsey }
|
48
|
-
end
|
49
|
-
|
50
|
-
context "and the key for the signing account is wrong" do
|
51
|
-
let(:verifiers){ [receiver] }
|
52
|
-
it{ should be_falsey }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "when signed by a multiple accounts" do
|
57
|
-
let(:alternate_signer){ Stellar::KeyPair.random }
|
58
|
-
let(:signers) { [sender, alternate_signer] }
|
59
|
-
let(:verifiers){ signers }
|
60
|
-
|
61
|
-
context "and all public keys are provided" do
|
62
|
-
it{ should be_truthy }
|
63
|
-
end
|
64
|
-
|
65
|
-
context "and all public keys are provided, with additional unused keys provided" do
|
66
|
-
let(:verifiers){ signers + [Stellar::KeyPair.random] }
|
67
|
-
it{ should be_truthy }
|
68
|
-
end
|
69
|
-
|
70
|
-
context "and not all public keys for the signers are provided" do
|
71
|
-
let(:verifiers){ [alternate_signer] }
|
72
|
-
it{ should be_falsey }
|
73
|
-
end
|
74
|
-
|
75
|
-
context "and one of the signatures is corrupted" do
|
76
|
-
before(:each){ envelope.signatures.last.signature = "\xFF" * 32}
|
77
|
-
it{ should be_falsey }
|
78
|
-
end
|
79
|
-
|
80
|
-
context "and the signature is from a different message" do
|
81
|
-
before(:each){ envelope.signatures = signers.map{|s| s.sign_decorated("hello")}}
|
82
|
-
it{ should be_falsey }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "#hash" do
|
89
|
-
let(:signers) { [sender] }
|
90
|
-
subject{ envelope.hash }
|
91
|
-
it{ should eq(Digest::SHA256.digest envelope.to_xdr)}
|
92
|
-
end
|
93
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Stellar::Transaction do
|
4
|
-
subject do
|
5
|
-
Stellar::Transaction.new({
|
6
|
-
source_account: Stellar::AccountID.new(:public_key_type_ed25519, "\x00" * 32),
|
7
|
-
fee: 10,
|
8
|
-
seq_num: 1,
|
9
|
-
memo: Stellar::Memo.new(:memo_none),
|
10
|
-
ext: Stellar::Transaction::Ext.new(0),
|
11
|
-
operations: [
|
12
|
-
Stellar::Operation.new(body: Stellar::Operation::Body.new(:inflation))
|
13
|
-
]
|
14
|
-
})
|
15
|
-
end
|
16
|
-
let(:key_pair){ Stellar::KeyPair.random }
|
17
|
-
|
18
|
-
describe ".path_payment_strict_receive" do
|
19
|
-
it 'works' do
|
20
|
-
tx = Stellar::Transaction.path_payment_strict_receive({
|
21
|
-
account: Stellar::KeyPair.random,
|
22
|
-
sequence: 1,
|
23
|
-
fee: 100,
|
24
|
-
destination: Stellar::KeyPair.random,
|
25
|
-
with: [:alphanum4, "USD", Stellar::KeyPair.master, 10],
|
26
|
-
amount: [:alphanum4, "EUR", Stellar::KeyPair.master, 9.2],
|
27
|
-
})
|
28
|
-
|
29
|
-
expect(tx.operations.size).to eq(1)
|
30
|
-
expect(tx.operations.first.body.arm).to eql(:path_payment_strict_receive_op)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe ".path_payment_strict_send" do
|
35
|
-
it 'works' do
|
36
|
-
tx = Stellar::Transaction.path_payment_strict_send({
|
37
|
-
account: Stellar::KeyPair.random,
|
38
|
-
sequence: 1,
|
39
|
-
fee: 100,
|
40
|
-
destination: Stellar::KeyPair.random,
|
41
|
-
with: [:alphanum4, "USD", Stellar::KeyPair.master, 10],
|
42
|
-
amount: [:alphanum4, "EUR", Stellar::KeyPair.master, 9.2],
|
43
|
-
})
|
44
|
-
|
45
|
-
expect(tx.operations.size).to eq(1)
|
46
|
-
expect(tx.operations.first.body.arm).to eql(:path_payment_strict_send_op)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#sign" do
|
51
|
-
let(:result){ subject.sign(key_pair) }
|
52
|
-
|
53
|
-
it "returns a signature of SHA256(signature_base of the transaction)" do
|
54
|
-
hash = Digest::SHA256.digest(subject.signature_base)
|
55
|
-
expected = key_pair.sign(hash)
|
56
|
-
expect(result).to eq(expected)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#to_envelope" do
|
61
|
-
let(:result){ subject.to_envelope(*key_pairs) }
|
62
|
-
|
63
|
-
|
64
|
-
context "with a single key pair as a parameter" do
|
65
|
-
let(:key_pairs){ [key_pair] }
|
66
|
-
|
67
|
-
it "return a Stellar::TransactionEnvelope" do
|
68
|
-
expect(result).to be_a(Stellar::TransactionEnvelope)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "correctly signs the transaction" do
|
72
|
-
expect(result.signatures.length).to eq(1)
|
73
|
-
expect(result.signatures.first).to be_a(Stellar::DecoratedSignature)
|
74
|
-
expect(result.signatures.first.hint).to eq(key_pair.signature_hint)
|
75
|
-
expect(result.signatures.first.signature).to eq(subject.sign(key_pair))
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "with no keypairs provided as parameters" do
|
80
|
-
let(:key_pairs){ [] }
|
81
|
-
|
82
|
-
it "return a Stellar::TransactionEnvelope" do
|
83
|
-
expect(result).to be_a(Stellar::TransactionEnvelope)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "adds no signatures" do
|
87
|
-
expect(result.signatures.length).to eq(0)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "#signature_base" do
|
93
|
-
|
94
|
-
it "is prefixed with the current network id" do
|
95
|
-
expect(subject.signature_base).to start_with(Stellar.current_network_id)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "includes the envelope type" do
|
99
|
-
expect(subject.signature_base[32...36]).to eql("\x00\x00\x00\x02")
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
describe ".for_account's memo assignment" do
|
105
|
-
let(:attrs){{account: Stellar::KeyPair.random, sequence: 1}}
|
106
|
-
|
107
|
-
def make(memo)
|
108
|
-
tx = Stellar::Transaction.for_account(attrs.merge(memo: memo))
|
109
|
-
tx.memo
|
110
|
-
end
|
111
|
-
|
112
|
-
it "sets to an ID memo when a number is provided" do
|
113
|
-
expect(make(3)).to eql(Stellar::Memo.new(:memo_id, 3))
|
114
|
-
end
|
115
|
-
|
116
|
-
it "sets to an text memo when a number is provided" do
|
117
|
-
expect(make("hello")).to eql(Stellar::Memo.new(:memo_text, "hello"))
|
118
|
-
end
|
119
|
-
|
120
|
-
it "uses the provided value directly if already a memo" do
|
121
|
-
expect(make(Stellar::Memo.new(:memo_text, "hello"))).to eql(Stellar::Memo.new(:memo_text, "hello"))
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
it "allows a 2-element array as shorthand" do
|
126
|
-
expect(make([:id, 3])).to eql(Stellar::Memo.new(:memo_id, 3))
|
127
|
-
expect(make([:text, "h"])).to eql(Stellar::Memo.new(:memo_text, "h"))
|
128
|
-
expect(make([:hash, "h"])).to eql(Stellar::Memo.new(:memo_hash, "h"))
|
129
|
-
expect(make([:return, "h"])).to eql(Stellar::Memo.new(:memo_return, "h"))
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Stellar::Util::StrKey do
|
4
|
-
|
5
|
-
subject{ Stellar::Util::StrKey }
|
6
|
-
|
7
|
-
describe "#check_decode" do
|
8
|
-
it "properly decodes" do
|
9
|
-
expect(decode :seed, "SAAAAAAAAAADST3H").to eq_bytes("\x00\x00\x00\x00\x00\x00\x39")
|
10
|
-
expect(decode :account_id, "GD777777777764TU").to eq_bytes("\xFF\xFF\xFF\xFF\xFF\xFF\xFF")
|
11
|
-
expect(decode :account_id, "GBQWWBFLRP3BXZD5").to eq_bytes("\x61\x6b\x04\xab\x8b\xf6\x1b")
|
12
|
-
expect(decode :pre_auth_tx, "TBU2RRGLXH3E4VON").to eq_bytes("\x69\xa8\xc4\xcb\xb9\xf6\x4e")
|
13
|
-
expect(decode :hash_x, "XBU2RRGLXH3E4PNW").to eq_bytes("\x69\xa8\xc4\xcb\xb9\xf6\x4e")
|
14
|
-
end
|
15
|
-
|
16
|
-
it "raises an ArgumentError when an invalid version is provided" do
|
17
|
-
expect{ decode :floob, "SAAAAAAAAAADST3M" }.to raise_error(ArgumentError)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "raises an ArgumentError if the decoded version byte does not match the expected value" do
|
21
|
-
expect{ decode :seed, "GD777777777764TU" }.to raise_error(ArgumentError)
|
22
|
-
expect{ decode :account_id, "SAAAAAAAAAADST3M" }.to raise_error(ArgumentError)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "raises an ArgumentError if the decoded value cannot be validated by the checksum" do
|
26
|
-
expect{ decode :seed, "SAAAAAAAAAADST3M" }.to raise_error(ArgumentError)
|
27
|
-
end
|
28
|
-
|
29
|
-
def decode(version, bytes)
|
30
|
-
subject.check_decode(version, bytes)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#check_encode" do
|
35
|
-
it "properly encodes" do
|
36
|
-
expect(encode :seed, "\x00\x00\x00\x00\x00\x00\x39").to eq("SAAAAAAAAAADST3H")
|
37
|
-
expect(encode :account_id, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF").to eq("GD777777777764TU")
|
38
|
-
expect(encode :account_id, "\x61\x6b\x04\xab\x8b\xf6\x1b").to eq("GBQWWBFLRP3BXZD5")
|
39
|
-
expect(encode :pre_auth_tx, "\x69\xa8\xc4\xcb\xb9\xf6\x4e").to eq_bytes("TBU2RRGLXH3E4VON")
|
40
|
-
expect(encode :hash_x, "\x69\xa8\xc4\xcb\xb9\xf6\x4e").to eq_bytes("XBU2RRGLXH3E4PNW")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "raises an ArgumentError when an invalid version is provided" do
|
44
|
-
expect{ encode :floob, "\x39" }.to raise_error(ArgumentError)
|
45
|
-
end
|
46
|
-
|
47
|
-
def encode(version, bytes)
|
48
|
-
subject.check_encode(version, bytes)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
|
data/spec/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
Bundler.setup
|
3
|
-
|
4
|
-
require 'simplecov'
|
5
|
-
SimpleCov.start
|
6
|
-
|
7
|
-
require 'pry'
|
8
|
-
require 'stellar-base'
|
9
|
-
|
10
|
-
SPEC_ROOT = File.dirname(__FILE__)
|
11
|
-
|
12
|
-
Dir["#{SPEC_ROOT}/support/**/*.rb"].each { |f| require f }
|
13
|
-
|
14
|
-
RSpec.configure do |config|
|
15
|
-
|
16
|
-
end
|
data/tasks/rspec.rake
DELETED
data/tasks/travis.rake
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
task :travis => %w(spec)
|
data/tasks/xdr.rake
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
namespace :xdr do
|
2
|
-
xdr_defs = FileList[
|
3
|
-
'xdr/Stellar-types.x',
|
4
|
-
'xdr/Stellar-ledger-entries.x',
|
5
|
-
'xdr/Stellar-transaction.x',
|
6
|
-
'xdr/Stellar-ledger.x',
|
7
|
-
'xdr/Stellar-overlay.x',
|
8
|
-
'xdr/Stellar-SCP.x',
|
9
|
-
]
|
10
|
-
|
11
|
-
task :update, [:ref] => [:clean, :generate]
|
12
|
-
task :generate => 'generated/stellar-base-generated.rb'
|
13
|
-
|
14
|
-
directory 'xdr'
|
15
|
-
directory 'generated'
|
16
|
-
|
17
|
-
file 'generated/stellar-base-generated.rb' => xdr_defs do |t|
|
18
|
-
require "xdrgen"
|
19
|
-
|
20
|
-
compilation = Xdrgen::Compilation.new(
|
21
|
-
t.sources,
|
22
|
-
output_dir: "generated",
|
23
|
-
namespace: "stellar-base-generated",
|
24
|
-
language: :ruby
|
25
|
-
)
|
26
|
-
compilation.compile
|
27
|
-
end
|
28
|
-
|
29
|
-
rule '.x', [:ref] => ['xdr'] do |t, args|
|
30
|
-
args.with_defaults(ref: :master)
|
31
|
-
core_file = github_client.contents("stellar/stellar-core", path: "src/#{t.name}", ref: args.ref)
|
32
|
-
IO.write(t.name, core_file.rels[:download].get.data)
|
33
|
-
end
|
34
|
-
|
35
|
-
task :clean do
|
36
|
-
rm_rf 'xdr'
|
37
|
-
rm_rf 'generated'
|
38
|
-
end
|
39
|
-
|
40
|
-
def github_client
|
41
|
-
return @github_client if defined?(@github_client)
|
42
|
-
require 'octokit'
|
43
|
-
@github_client = Octokit::Client.new(netrc: true)
|
44
|
-
end
|
45
|
-
end
|
data/xdr/Stellar-SCP.x
DELETED
@@ -1,86 +0,0 @@
|
|
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 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; // c.n
|
48
|
-
uint32 nH; // h.n
|
49
|
-
} prepare;
|
50
|
-
case SCP_ST_CONFIRM:
|
51
|
-
struct
|
52
|
-
{
|
53
|
-
SCPBallot ballot; // b
|
54
|
-
uint32 nPrepared; // p.n
|
55
|
-
uint32 nCommit; // c.n
|
56
|
-
uint32 nH; // h.n
|
57
|
-
Hash quorumSetHash; // D
|
58
|
-
} confirm;
|
59
|
-
case SCP_ST_EXTERNALIZE:
|
60
|
-
struct
|
61
|
-
{
|
62
|
-
SCPBallot commit; // c
|
63
|
-
uint32 nH; // h.n
|
64
|
-
Hash commitQuorumSetHash; // D used before EXTERNALIZE
|
65
|
-
} externalize;
|
66
|
-
case SCP_ST_NOMINATE:
|
67
|
-
SCPNomination nominate;
|
68
|
-
}
|
69
|
-
pledges;
|
70
|
-
};
|
71
|
-
|
72
|
-
struct SCPEnvelope
|
73
|
-
{
|
74
|
-
SCPStatement statement;
|
75
|
-
Signature signature;
|
76
|
-
};
|
77
|
-
|
78
|
-
// supports things like: A,B,C,(D,E,F),(G,H,(I,J,K,L))
|
79
|
-
// only allows 2 levels of nesting
|
80
|
-
struct SCPQuorumSet
|
81
|
-
{
|
82
|
-
uint32 threshold;
|
83
|
-
PublicKey validators<>;
|
84
|
-
SCPQuorumSet innerSets<>;
|
85
|
-
};
|
86
|
-
}
|