stellar-base 0.20.0 → 0.23.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -21
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +2 -3
- data/generated/stellar-base-generated.rb +31 -4
- 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 +23 -0
- data/generated/stellar/ledger_close_meta_v0.rb +35 -0
- 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/message_type.rb +6 -1
- data/generated/stellar/muxed_account.rb +35 -0
- data/generated/stellar/muxed_account/med25519.rb +22 -0
- data/generated/stellar/operation.rb +7 -5
- data/generated/stellar/operation/body.rb +31 -27
- data/generated/stellar/operation_result.rb +5 -3
- data/generated/stellar/operation_result/tr.rb +33 -29
- data/generated/stellar/operation_result_code.rb +3 -3
- data/generated/stellar/operation_type.rb +17 -15
- data/generated/stellar/{path_payment_op.rb → path_payment_strict_receive_op.rb} +6 -6
- data/generated/stellar/path_payment_strict_receive_result.rb +38 -0
- data/generated/stellar/path_payment_strict_receive_result/success.rb +22 -0
- data/generated/stellar/path_payment_strict_receive_result_code.rb +56 -0
- data/generated/stellar/path_payment_strict_send_op.rb +32 -0
- data/generated/stellar/{path_payment_result.rb → path_payment_strict_send_result.rb} +7 -7
- data/generated/stellar/{path_payment_result → path_payment_strict_send_result}/success.rb +1 -1
- data/generated/stellar/path_payment_strict_send_result_code.rb +55 -0
- data/generated/stellar/payment_op.rb +4 -4
- data/generated/stellar/peer_stats.rb +48 -0
- data/generated/stellar/signed_survey_request_message.rb +20 -0
- data/generated/stellar/signed_survey_response_message.rb +20 -0
- data/generated/stellar/stellar_message.rb +22 -12
- data/generated/stellar/survey_message_command_type.rb +20 -0
- data/generated/stellar/survey_request_message.rb +26 -0
- data/generated/stellar/survey_response_body.rb +23 -0
- data/generated/stellar/survey_response_message.rb +26 -0
- data/generated/stellar/topology_response_body.rb +25 -0
- data/generated/stellar/transaction.rb +2 -2
- data/generated/stellar/transaction_envelope.rb +17 -8
- data/generated/stellar/transaction_meta.rb +4 -0
- data/generated/stellar/transaction_meta_v2.rb +24 -0
- 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_result_meta.rb +22 -0
- 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/generated/stellar/upgrade_entry_meta.rb +20 -0
- data/lib/stellar-base.rb +27 -24
- 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 +427 -336
- data/lib/stellar/{path_payment_result.rb → path_payment_strict_receive_result.rb} +2 -3
- 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 -175
- data/lib/stellar/transaction_builder.rb +149 -0
- 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 +61 -211
- data/.gitignore +0 -17
- data/.travis.yml +0 -16
- data/.yardopts +0 -8
- data/CONTRIBUTING.md +0 -48
- data/Gemfile +0 -15
- 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/generated/stellar/path_payment_result_code.rb +0 -47
- 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 -71
- data/spec/lib/stellar/path_payment_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_envelope_spec.rb +0 -93
- data/spec/lib/stellar/transaction_spec.rb +0 -100
- 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 -318
- data/xdr/Stellar-overlay.x +0 -146
- data/xdr/Stellar-transaction.x +0 -834
- data/xdr/Stellar-types.x +0 -81
@@ -1,100 +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 "#sign" do
|
19
|
-
let(:result){ subject.sign(key_pair) }
|
20
|
-
|
21
|
-
it "returns a signature of SHA256(signature_base of the transaction)" do
|
22
|
-
hash = Digest::SHA256.digest(subject.signature_base)
|
23
|
-
expected = key_pair.sign(hash)
|
24
|
-
expect(result).to eq(expected)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#to_envelope" do
|
29
|
-
let(:result){ subject.to_envelope(*key_pairs) }
|
30
|
-
|
31
|
-
|
32
|
-
context "with a single key pair as a parameter" do
|
33
|
-
let(:key_pairs){ [key_pair] }
|
34
|
-
|
35
|
-
it "return a Stellar::TransactionEnvelope" do
|
36
|
-
expect(result).to be_a(Stellar::TransactionEnvelope)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "correctly signs the transaction" do
|
40
|
-
expect(result.signatures.length).to eq(1)
|
41
|
-
expect(result.signatures.first).to be_a(Stellar::DecoratedSignature)
|
42
|
-
expect(result.signatures.first.hint).to eq(key_pair.signature_hint)
|
43
|
-
expect(result.signatures.first.signature).to eq(subject.sign(key_pair))
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "with no keypairs provided as parameters" do
|
48
|
-
let(:key_pairs){ [] }
|
49
|
-
|
50
|
-
it "return a Stellar::TransactionEnvelope" do
|
51
|
-
expect(result).to be_a(Stellar::TransactionEnvelope)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "adds no signatures" do
|
55
|
-
expect(result.signatures.length).to eq(0)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#signature_base" do
|
61
|
-
|
62
|
-
it "is prefixed with the current network id" do
|
63
|
-
expect(subject.signature_base).to start_with(Stellar.current_network_id)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "includes the envelope type" do
|
67
|
-
expect(subject.signature_base[32...36]).to eql("\x00\x00\x00\x02")
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
describe ".for_account's memo assignment" do
|
73
|
-
let(:attrs){{account: Stellar::KeyPair.random, sequence: 1}}
|
74
|
-
|
75
|
-
def make(memo)
|
76
|
-
tx = Stellar::Transaction.for_account(attrs.merge(memo: memo))
|
77
|
-
tx.memo
|
78
|
-
end
|
79
|
-
|
80
|
-
it "sets to an ID memo when a number is provided" do
|
81
|
-
expect(make(3)).to eql(Stellar::Memo.new(:memo_id, 3))
|
82
|
-
end
|
83
|
-
|
84
|
-
it "sets to an text memo when a number is provided" do
|
85
|
-
expect(make("hello")).to eql(Stellar::Memo.new(:memo_text, "hello"))
|
86
|
-
end
|
87
|
-
|
88
|
-
it "uses the provided value directly if already a memo" do
|
89
|
-
expect(make(Stellar::Memo.new(:memo_text, "hello"))).to eql(Stellar::Memo.new(:memo_text, "hello"))
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
it "allows a 2-element array as shorthand" do
|
94
|
-
expect(make([:id, 3])).to eql(Stellar::Memo.new(:memo_id, 3))
|
95
|
-
expect(make([:text, "h"])).to eql(Stellar::Memo.new(:memo_text, "h"))
|
96
|
-
expect(make([:hash, "h"])).to eql(Stellar::Memo.new(:memo_hash, "h"))
|
97
|
-
expect(make([:return, "h"])).to eql(Stellar::Memo.new(:memo_return, "h"))
|
98
|
-
end
|
99
|
-
end
|
100
|
-
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
|
-
}
|
@@ -1,295 +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 PublicKey AccountID;
|
11
|
-
typedef opaque Thresholds[4];
|
12
|
-
typedef string string32<32>;
|
13
|
-
typedef string string64<64>;
|
14
|
-
typedef int64 SequenceNumber;
|
15
|
-
typedef uint64 TimePoint;
|
16
|
-
typedef opaque DataValue<64>;
|
17
|
-
|
18
|
-
// 1-4 alphanumeric characters right-padded with 0 bytes
|
19
|
-
typedef opaque AssetCode4[4];
|
20
|
-
|
21
|
-
// 5-12 alphanumeric characters right-padded with 0 bytes
|
22
|
-
typedef opaque AssetCode12[12];
|
23
|
-
|
24
|
-
enum AssetType
|
25
|
-
{
|
26
|
-
ASSET_TYPE_NATIVE = 0,
|
27
|
-
ASSET_TYPE_CREDIT_ALPHANUM4 = 1,
|
28
|
-
ASSET_TYPE_CREDIT_ALPHANUM12 = 2
|
29
|
-
};
|
30
|
-
|
31
|
-
union Asset switch (AssetType type)
|
32
|
-
{
|
33
|
-
case ASSET_TYPE_NATIVE: // Not credit
|
34
|
-
void;
|
35
|
-
|
36
|
-
case ASSET_TYPE_CREDIT_ALPHANUM4:
|
37
|
-
struct
|
38
|
-
{
|
39
|
-
AssetCode4 assetCode;
|
40
|
-
AccountID issuer;
|
41
|
-
} alphaNum4;
|
42
|
-
|
43
|
-
case ASSET_TYPE_CREDIT_ALPHANUM12:
|
44
|
-
struct
|
45
|
-
{
|
46
|
-
AssetCode12 assetCode;
|
47
|
-
AccountID issuer;
|
48
|
-
} alphaNum12;
|
49
|
-
|
50
|
-
// add other asset types here in the future
|
51
|
-
};
|
52
|
-
|
53
|
-
// price in fractional representation
|
54
|
-
struct Price
|
55
|
-
{
|
56
|
-
int32 n; // numerator
|
57
|
-
int32 d; // denominator
|
58
|
-
};
|
59
|
-
|
60
|
-
struct Liabilities
|
61
|
-
{
|
62
|
-
int64 buying;
|
63
|
-
int64 selling;
|
64
|
-
};
|
65
|
-
|
66
|
-
// the 'Thresholds' type is packed uint8_t values
|
67
|
-
// defined by these indexes
|
68
|
-
enum ThresholdIndexes
|
69
|
-
{
|
70
|
-
THRESHOLD_MASTER_WEIGHT = 0,
|
71
|
-
THRESHOLD_LOW = 1,
|
72
|
-
THRESHOLD_MED = 2,
|
73
|
-
THRESHOLD_HIGH = 3
|
74
|
-
};
|
75
|
-
|
76
|
-
enum LedgerEntryType
|
77
|
-
{
|
78
|
-
ACCOUNT = 0,
|
79
|
-
TRUSTLINE = 1,
|
80
|
-
OFFER = 2,
|
81
|
-
DATA = 3
|
82
|
-
};
|
83
|
-
|
84
|
-
struct Signer
|
85
|
-
{
|
86
|
-
SignerKey key;
|
87
|
-
uint32 weight; // really only need 1 byte
|
88
|
-
};
|
89
|
-
|
90
|
-
enum AccountFlags
|
91
|
-
{ // masks for each flag
|
92
|
-
|
93
|
-
// Flags set on issuer accounts
|
94
|
-
// TrustLines are created with authorized set to "false" requiring
|
95
|
-
// the issuer to set it for each TrustLine
|
96
|
-
AUTH_REQUIRED_FLAG = 0x1,
|
97
|
-
// If set, the authorized flag in TrustLines can be cleared
|
98
|
-
// otherwise, authorization cannot be revoked
|
99
|
-
AUTH_REVOCABLE_FLAG = 0x2,
|
100
|
-
// Once set, causes all AUTH_* flags to be read-only
|
101
|
-
AUTH_IMMUTABLE_FLAG = 0x4
|
102
|
-
};
|
103
|
-
|
104
|
-
// mask for all valid flags
|
105
|
-
const MASK_ACCOUNT_FLAGS = 0x7;
|
106
|
-
|
107
|
-
/* AccountEntry
|
108
|
-
|
109
|
-
Main entry representing a user in Stellar. All transactions are
|
110
|
-
performed using an account.
|
111
|
-
|
112
|
-
Other ledger entries created require an account.
|
113
|
-
|
114
|
-
*/
|
115
|
-
struct AccountEntry
|
116
|
-
{
|
117
|
-
AccountID accountID; // master public key for this account
|
118
|
-
int64 balance; // in stroops
|
119
|
-
SequenceNumber seqNum; // last sequence number used for this account
|
120
|
-
uint32 numSubEntries; // number of sub-entries this account has
|
121
|
-
// drives the reserve
|
122
|
-
AccountID* inflationDest; // Account to vote for during inflation
|
123
|
-
uint32 flags; // see AccountFlags
|
124
|
-
|
125
|
-
string32 homeDomain; // can be used for reverse federation and memo lookup
|
126
|
-
|
127
|
-
// fields used for signatures
|
128
|
-
// thresholds stores unsigned bytes: [weight of master|low|medium|high]
|
129
|
-
Thresholds thresholds;
|
130
|
-
|
131
|
-
Signer signers<20>; // possible signers for this account
|
132
|
-
|
133
|
-
// reserved for future use
|
134
|
-
union switch (int v)
|
135
|
-
{
|
136
|
-
case 0:
|
137
|
-
void;
|
138
|
-
case 1:
|
139
|
-
struct
|
140
|
-
{
|
141
|
-
Liabilities liabilities;
|
142
|
-
|
143
|
-
union switch (int v)
|
144
|
-
{
|
145
|
-
case 0:
|
146
|
-
void;
|
147
|
-
}
|
148
|
-
ext;
|
149
|
-
} v1;
|
150
|
-
}
|
151
|
-
ext;
|
152
|
-
};
|
153
|
-
|
154
|
-
/* TrustLineEntry
|
155
|
-
A trust line represents a specific trust relationship with
|
156
|
-
a credit/issuer (limit, authorization)
|
157
|
-
as well as the balance.
|
158
|
-
*/
|
159
|
-
|
160
|
-
enum TrustLineFlags
|
161
|
-
{
|
162
|
-
// issuer has authorized account to perform transactions with its credit
|
163
|
-
AUTHORIZED_FLAG = 1
|
164
|
-
};
|
165
|
-
|
166
|
-
// mask for all trustline flags
|
167
|
-
const MASK_TRUSTLINE_FLAGS = 1;
|
168
|
-
|
169
|
-
struct TrustLineEntry
|
170
|
-
{
|
171
|
-
AccountID accountID; // account this trustline belongs to
|
172
|
-
Asset asset; // type of asset (with issuer)
|
173
|
-
int64 balance; // how much of this asset the user has.
|
174
|
-
// Asset defines the unit for this;
|
175
|
-
|
176
|
-
int64 limit; // balance cannot be above this
|
177
|
-
uint32 flags; // see TrustLineFlags
|
178
|
-
|
179
|
-
// reserved for future use
|
180
|
-
union switch (int v)
|
181
|
-
{
|
182
|
-
case 0:
|
183
|
-
void;
|
184
|
-
case 1:
|
185
|
-
struct
|
186
|
-
{
|
187
|
-
Liabilities liabilities;
|
188
|
-
|
189
|
-
union switch (int v)
|
190
|
-
{
|
191
|
-
case 0:
|
192
|
-
void;
|
193
|
-
}
|
194
|
-
ext;
|
195
|
-
} v1;
|
196
|
-
}
|
197
|
-
ext;
|
198
|
-
};
|
199
|
-
|
200
|
-
enum OfferEntryFlags
|
201
|
-
{
|
202
|
-
// issuer has authorized account to perform transactions with its credit
|
203
|
-
PASSIVE_FLAG = 1
|
204
|
-
};
|
205
|
-
|
206
|
-
// Mask for OfferEntry flags
|
207
|
-
const MASK_OFFERENTRY_FLAGS = 1;
|
208
|
-
|
209
|
-
/* OfferEntry
|
210
|
-
An offer is the building block of the offer book, they are automatically
|
211
|
-
claimed by payments when the price set by the owner is met.
|
212
|
-
|
213
|
-
For example an Offer is selling 10A where 1A is priced at 1.5B
|
214
|
-
|
215
|
-
*/
|
216
|
-
struct OfferEntry
|
217
|
-
{
|
218
|
-
AccountID sellerID;
|
219
|
-
int64 offerID;
|
220
|
-
Asset selling; // A
|
221
|
-
Asset buying; // B
|
222
|
-
int64 amount; // amount of A
|
223
|
-
|
224
|
-
/* price for this offer:
|
225
|
-
price of A in terms of B
|
226
|
-
price=AmountB/AmountA=priceNumerator/priceDenominator
|
227
|
-
price is after fees
|
228
|
-
*/
|
229
|
-
Price price;
|
230
|
-
uint32 flags; // see OfferEntryFlags
|
231
|
-
|
232
|
-
// reserved for future use
|
233
|
-
union switch (int v)
|
234
|
-
{
|
235
|
-
case 0:
|
236
|
-
void;
|
237
|
-
}
|
238
|
-
ext;
|
239
|
-
};
|
240
|
-
|
241
|
-
/* DataEntry
|
242
|
-
Data can be attached to accounts.
|
243
|
-
*/
|
244
|
-
struct DataEntry
|
245
|
-
{
|
246
|
-
AccountID accountID; // account this data belongs to
|
247
|
-
string64 dataName;
|
248
|
-
DataValue dataValue;
|
249
|
-
|
250
|
-
// reserved for future use
|
251
|
-
union switch (int v)
|
252
|
-
{
|
253
|
-
case 0:
|
254
|
-
void;
|
255
|
-
}
|
256
|
-
ext;
|
257
|
-
};
|
258
|
-
|
259
|
-
struct LedgerEntry
|
260
|
-
{
|
261
|
-
uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed
|
262
|
-
|
263
|
-
union switch (LedgerEntryType type)
|
264
|
-
{
|
265
|
-
case ACCOUNT:
|
266
|
-
AccountEntry account;
|
267
|
-
case TRUSTLINE:
|
268
|
-
TrustLineEntry trustLine;
|
269
|
-
case OFFER:
|
270
|
-
OfferEntry offer;
|
271
|
-
case DATA:
|
272
|
-
DataEntry data;
|
273
|
-
}
|
274
|
-
data;
|
275
|
-
|
276
|
-
// reserved for future use
|
277
|
-
union switch (int v)
|
278
|
-
{
|
279
|
-
case 0:
|
280
|
-
void;
|
281
|
-
}
|
282
|
-
ext;
|
283
|
-
};
|
284
|
-
|
285
|
-
// list of all envelope types used in the application
|
286
|
-
// those are prefixes used when building signatures for
|
287
|
-
// the respective envelopes
|
288
|
-
enum EnvelopeType
|
289
|
-
{
|
290
|
-
ENVELOPE_TYPE_SCP = 1,
|
291
|
-
ENVELOPE_TYPE_TX = 2,
|
292
|
-
ENVELOPE_TYPE_AUTH = 3,
|
293
|
-
ENVELOPE_TYPE_SCPVALUE = 4
|
294
|
-
};
|
295
|
-
}
|