stellar-base 0.18.0 → 0.23.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +5 -5
  2. data/{LICENSE.txt → LICENSE} +0 -0
  3. data/README.md +2 -3
  4. data/generated/stellar-base-generated.rb +45 -8
  5. data/generated/stellar/allow_trust_op.rb +5 -4
  6. data/generated/stellar/allow_trust_op/asset.rb +4 -4
  7. data/generated/stellar/asset.rb +2 -2
  8. data/generated/stellar/asset/alpha_num12.rb +2 -2
  9. data/generated/stellar/asset/alpha_num4.rb +2 -2
  10. data/generated/stellar/authenticated_message.rb +4 -4
  11. data/generated/stellar/authenticated_message/v0.rb +4 -4
  12. data/generated/stellar/bucket_entry.rb +6 -0
  13. data/generated/stellar/bucket_entry_type.rb +8 -2
  14. data/generated/stellar/bucket_metadata.rb +32 -0
  15. data/generated/stellar/bucket_metadata/ext.rb +24 -0
  16. data/generated/stellar/claim_offer_atom.rb +2 -2
  17. data/generated/stellar/{create_passive_offer_op.rb → create_passive_sell_offer_op.rb} +2 -2
  18. data/generated/stellar/crypto_key_type.rb +8 -4
  19. data/generated/stellar/curve25519_public.rb +1 -1
  20. data/generated/stellar/curve25519_secret.rb +1 -1
  21. data/generated/stellar/envelope_type.rb +10 -4
  22. data/generated/stellar/fee_bump_transaction.rb +39 -0
  23. data/generated/stellar/fee_bump_transaction/ext.rb +24 -0
  24. data/generated/stellar/fee_bump_transaction/inner_tx.rb +25 -0
  25. data/generated/stellar/fee_bump_transaction_envelope.rb +22 -0
  26. data/generated/stellar/hmac_sha256_key.rb +1 -1
  27. data/generated/stellar/hmac_sha256_mac.rb +1 -1
  28. data/generated/stellar/inner_transaction_result.rb +56 -0
  29. data/generated/stellar/inner_transaction_result/ext.rb +24 -0
  30. data/generated/stellar/inner_transaction_result/result.rb +52 -0
  31. data/generated/stellar/inner_transaction_result_pair.rb +20 -0
  32. data/generated/stellar/ledger_close_meta.rb +23 -0
  33. data/generated/stellar/ledger_close_meta_v0.rb +35 -0
  34. data/generated/stellar/ledger_close_value_signature.rb +20 -0
  35. data/generated/stellar/ledger_key.rb +1 -1
  36. data/generated/stellar/ledger_key/offer.rb +2 -2
  37. data/generated/stellar/manage_buy_offer_op.rb +29 -0
  38. data/generated/stellar/{manage_offer_result.rb → manage_buy_offer_result.rb} +5 -5
  39. data/generated/stellar/manage_buy_offer_result_code.rb +51 -0
  40. data/generated/stellar/{manage_offer_op.rb → manage_sell_offer_op.rb} +4 -4
  41. data/generated/stellar/manage_sell_offer_result.rb +26 -0
  42. data/generated/stellar/manage_sell_offer_result_code.rb +54 -0
  43. data/generated/stellar/message_type.rb +6 -1
  44. data/generated/stellar/muxed_account.rb +35 -0
  45. data/generated/stellar/muxed_account/med25519.rb +22 -0
  46. data/generated/stellar/offer_entry.rb +2 -2
  47. data/generated/stellar/operation.rb +13 -9
  48. data/generated/stellar/operation/body.rb +37 -29
  49. data/generated/stellar/operation_result.rb +10 -6
  50. data/generated/stellar/operation_result/tr.rb +38 -30
  51. data/generated/stellar/operation_result_code.rb +11 -7
  52. data/generated/stellar/operation_type.rb +20 -16
  53. data/generated/stellar/{path_payment_op.rb → path_payment_strict_receive_op.rb} +6 -6
  54. data/generated/stellar/path_payment_strict_receive_result.rb +38 -0
  55. data/generated/stellar/path_payment_strict_receive_result/success.rb +22 -0
  56. data/generated/stellar/path_payment_strict_receive_result_code.rb +56 -0
  57. data/generated/stellar/path_payment_strict_send_op.rb +32 -0
  58. data/generated/stellar/{path_payment_result.rb → path_payment_strict_send_result.rb} +7 -7
  59. data/generated/stellar/{path_payment_result → path_payment_strict_send_result}/success.rb +1 -1
  60. data/generated/stellar/path_payment_strict_send_result_code.rb +55 -0
  61. data/generated/stellar/payment_op.rb +4 -4
  62. data/generated/stellar/peer_stats.rb +48 -0
  63. data/generated/stellar/signed_survey_request_message.rb +20 -0
  64. data/generated/stellar/signed_survey_response_message.rb +20 -0
  65. data/generated/stellar/signer.rb +1 -1
  66. data/generated/stellar/stellar_message.rb +22 -12
  67. data/generated/stellar/stellar_value.rb +7 -5
  68. data/generated/stellar/stellar_value/ext.rb +8 -4
  69. data/generated/stellar/stellar_value_type.rb +22 -0
  70. data/generated/stellar/survey_message_command_type.rb +20 -0
  71. data/generated/stellar/survey_request_message.rb +26 -0
  72. data/generated/stellar/survey_response_body.rb +23 -0
  73. data/generated/stellar/survey_response_message.rb +26 -0
  74. data/generated/stellar/time_bounds.rb +4 -4
  75. data/generated/stellar/topology_response_body.rb +25 -0
  76. data/generated/stellar/transaction.rb +4 -4
  77. data/generated/stellar/transaction_envelope.rb +17 -8
  78. data/generated/stellar/transaction_meta.rb +4 -0
  79. data/generated/stellar/transaction_meta_v1.rb +1 -1
  80. data/generated/stellar/transaction_meta_v2.rb +24 -0
  81. data/generated/stellar/transaction_result.rb +3 -0
  82. data/generated/stellar/transaction_result/result.rb +9 -3
  83. data/generated/stellar/transaction_result_code.rb +21 -14
  84. data/generated/stellar/transaction_result_meta.rb +22 -0
  85. data/generated/stellar/transaction_signature_payload.rb +3 -1
  86. data/generated/stellar/transaction_signature_payload/tagged_transaction.rb +7 -3
  87. data/generated/stellar/transaction_v0.rb +39 -0
  88. data/generated/stellar/transaction_v0/ext.rb +24 -0
  89. data/generated/stellar/transaction_v0_envelope.rb +22 -0
  90. data/generated/stellar/transaction_v1_envelope.rb +22 -0
  91. data/generated/stellar/trust_line_flags.rb +6 -2
  92. data/generated/stellar/upgrade_entry_meta.rb +20 -0
  93. data/lib/stellar-base.rb +28 -23
  94. data/lib/stellar/account_flags.rb +2 -4
  95. data/lib/stellar/asset.rb +6 -6
  96. data/lib/stellar/base.rb +1 -1
  97. data/lib/stellar/compat.rb +21 -0
  98. data/lib/stellar/concerns/transaction.rb +49 -0
  99. data/lib/stellar/convert.rb +2 -2
  100. data/lib/stellar/factories.rb +1 -3
  101. data/lib/stellar/fee_bump_transaction.rb +21 -0
  102. data/lib/stellar/key_pair.rb +9 -6
  103. data/lib/stellar/networks.rb +5 -7
  104. data/lib/stellar/operation.rb +428 -317
  105. data/lib/stellar/{path_payment_result.rb → path_payment_strict_receive_result.rb} +2 -3
  106. data/lib/stellar/price.rb +2 -4
  107. data/lib/stellar/signer_key.rb +4 -8
  108. data/lib/stellar/thresholds.rb +5 -7
  109. data/lib/stellar/transaction.rb +154 -169
  110. data/lib/stellar/transaction_builder.rb +149 -0
  111. data/lib/stellar/transaction_envelope.rb +40 -8
  112. data/lib/stellar/transaction_v0.rb +39 -0
  113. data/lib/stellar/util/continued_fraction.rb +19 -19
  114. data/lib/stellar/util/strkey.rb +39 -14
  115. data/lib/stellar/{base/version.rb → version.rb} +1 -1
  116. metadata +69 -211
  117. data/.gitignore +0 -17
  118. data/.travis.yml +0 -14
  119. data/.yardopts +0 -8
  120. data/CHANGELOG.md +0 -120
  121. data/CONTRIBUTING.md +0 -48
  122. data/Gemfile +0 -15
  123. data/Guardfile +0 -5
  124. data/Rakefile +0 -4
  125. data/examples/create_account.rb +0 -26
  126. data/examples/low_level_transaction_post.rb +0 -46
  127. data/examples/mid_level_transaction_post.rb +0 -33
  128. data/examples/non_native_payment.rb +0 -60
  129. data/examples/offer.rb +0 -75
  130. data/examples/transaction_merge.rb +0 -23
  131. data/generated/stellar/manage_offer_result_code.rb +0 -50
  132. data/generated/stellar/path_payment_result_code.rb +0 -47
  133. data/ruby-stellar-base.gemspec +0 -34
  134. data/spec/lib/stellar/account_flags_spec.rb +0 -19
  135. data/spec/lib/stellar/asset_spec.rb +0 -45
  136. data/spec/lib/stellar/convert_spec.rb +0 -61
  137. data/spec/lib/stellar/key_pair_spec.rb +0 -251
  138. data/spec/lib/stellar/networks_spec.rb +0 -77
  139. data/spec/lib/stellar/operation_spec.rb +0 -71
  140. data/spec/lib/stellar/path_payment_result_spec.rb +0 -95
  141. data/spec/lib/stellar/price_spec.rb +0 -34
  142. data/spec/lib/stellar/signer_key_spec.rb +0 -26
  143. data/spec/lib/stellar/thresholds_spec.rb +0 -62
  144. data/spec/lib/stellar/transaction_envelope_spec.rb +0 -93
  145. data/spec/lib/stellar/transaction_spec.rb +0 -100
  146. data/spec/lib/stellar/util/strkey_spec.rb +0 -54
  147. data/spec/spec_helper.rb +0 -16
  148. data/spec/support/matchers/be_strkey.rb +0 -9
  149. data/spec/support/matchers/eq_bytes.rb +0 -5
  150. data/spec/support/matchers/have_length.rb +0 -5
  151. data/tasks/rspec.rake +0 -6
  152. data/tasks/travis.rake +0 -1
  153. data/tasks/xdr.rake +0 -50
  154. data/xdr/Stellar-SCP.x +0 -86
  155. data/xdr/Stellar-ledger-entries.x +0 -288
  156. data/xdr/Stellar-ledger.x +0 -283
  157. data/xdr/Stellar-overlay.x +0 -146
  158. data/xdr/Stellar-transaction.x +0 -777
  159. 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
-
@@ -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
@@ -1,9 +0,0 @@
1
- RSpec::Matchers.define :be_strkey do |version_byte|
2
- match do |actual|
3
- begin
4
- Stellar::Util::StrKey.check_decode(version_byte, actual)
5
- rescue ArgumentError
6
- false
7
- end
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :eq_bytes do |expected|
2
- match do |actual|
3
- expected.force_encoding("ASCII-8BIT") == actual.force_encoding("ASCII-8BIT")
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :have_length do |length|
2
- match do |actual|
3
- actual.length == length
4
- end
5
- end
@@ -1,6 +0,0 @@
1
- begin
2
- require 'rspec/core/rake_task'
3
- RSpec::Core::RakeTask.new(:spec)
4
- task :default => :spec
5
- rescue LoadError
6
- end
@@ -1 +0,0 @@
1
- task :travis => %w(spec)
@@ -1,50 +0,0 @@
1
- namespace :xdr do
2
-
3
- # As Hayashi adds more .x files, we'll need to update this array
4
- # Prior to launch, we should be separating our .x files into a separate
5
- # repo, and should be able to improve this integration.
6
- HAYASHI_XDR = [
7
- "src/xdr/Stellar-types.x",
8
- "src/xdr/Stellar-ledger-entries.x",
9
- "src/xdr/Stellar-transaction.x",
10
- "src/xdr/Stellar-ledger.x",
11
- "src/xdr/Stellar-overlay.x",
12
- "src/xdr/Stellar-SCP.x",
13
- ]
14
-
15
- LOCAL_XDR_PATHS = HAYASHI_XDR.map{ |src| "xdr/" + File.basename(src) }
16
-
17
- task :update => [:download, :generate]
18
-
19
- task :download do
20
- require 'octokit'
21
- require 'base64'
22
- FileUtils.rm_rf "xdr/"
23
- FileUtils.mkdir_p "xdr"
24
-
25
- client = Octokit::Client.new(:netrc => true)
26
-
27
- HAYASHI_XDR.each do |src|
28
- local_path = "xdr/" + File.basename(src)
29
- encoded = client.contents("stellar/stellar-core", path: src).content
30
- decoded = Base64.decode64 encoded
31
-
32
- IO.write(local_path, decoded)
33
- end
34
- end
35
-
36
- task :generate do
37
- require "pathname"
38
- require "xdrgen"
39
- require 'fileutils'
40
- FileUtils.rm_rf "generated"
41
-
42
- compilation = Xdrgen::Compilation.new(
43
- LOCAL_XDR_PATHS,
44
- output_dir: "generated",
45
- namespace: "stellar-base-generated",
46
- language: :ruby
47
- )
48
- compilation.compile
49
- end
50
- end
@@ -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,288 +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 opaque DataValue<64>;
16
-
17
- enum AssetType
18
- {
19
- ASSET_TYPE_NATIVE = 0,
20
- ASSET_TYPE_CREDIT_ALPHANUM4 = 1,
21
- ASSET_TYPE_CREDIT_ALPHANUM12 = 2
22
- };
23
-
24
- union Asset switch (AssetType type)
25
- {
26
- case ASSET_TYPE_NATIVE: // Not credit
27
- void;
28
-
29
- case ASSET_TYPE_CREDIT_ALPHANUM4:
30
- struct
31
- {
32
- opaque assetCode[4]; // 1 to 4 characters
33
- AccountID issuer;
34
- } alphaNum4;
35
-
36
- case ASSET_TYPE_CREDIT_ALPHANUM12:
37
- struct
38
- {
39
- opaque assetCode[12]; // 5 to 12 characters
40
- AccountID issuer;
41
- } alphaNum12;
42
-
43
- // add other asset types here in the future
44
- };
45
-
46
- // price in fractional representation
47
- struct Price
48
- {
49
- int32 n; // numerator
50
- int32 d; // denominator
51
- };
52
-
53
- struct Liabilities
54
- {
55
- int64 buying;
56
- int64 selling;
57
- };
58
-
59
- // the 'Thresholds' type is packed uint8_t values
60
- // defined by these indexes
61
- enum ThresholdIndexes
62
- {
63
- THRESHOLD_MASTER_WEIGHT = 0,
64
- THRESHOLD_LOW = 1,
65
- THRESHOLD_MED = 2,
66
- THRESHOLD_HIGH = 3
67
- };
68
-
69
- enum LedgerEntryType
70
- {
71
- ACCOUNT = 0,
72
- TRUSTLINE = 1,
73
- OFFER = 2,
74
- DATA = 3
75
- };
76
-
77
- struct Signer
78
- {
79
- SignerKey key;
80
- uint32 weight; // really only need 1byte
81
- };
82
-
83
- enum AccountFlags
84
- { // masks for each flag
85
-
86
- // Flags set on issuer accounts
87
- // TrustLines are created with authorized set to "false" requiring
88
- // the issuer to set it for each TrustLine
89
- AUTH_REQUIRED_FLAG = 0x1,
90
- // If set, the authorized flag in TrustLines can be cleared
91
- // otherwise, authorization cannot be revoked
92
- AUTH_REVOCABLE_FLAG = 0x2,
93
- // Once set, causes all AUTH_* flags to be read-only
94
- AUTH_IMMUTABLE_FLAG = 0x4
95
- };
96
-
97
- // mask for all valid flags
98
- const MASK_ACCOUNT_FLAGS = 0x7;
99
-
100
- /* AccountEntry
101
-
102
- Main entry representing a user in Stellar. All transactions are
103
- performed using an account.
104
-
105
- Other ledger entries created require an account.
106
-
107
- */
108
-
109
- struct AccountEntry
110
- {
111
- AccountID accountID; // master public key for this account
112
- int64 balance; // in stroops
113
- SequenceNumber seqNum; // last sequence number used for this account
114
- uint32 numSubEntries; // number of sub-entries this account has
115
- // drives the reserve
116
- AccountID* inflationDest; // Account to vote for during inflation
117
- uint32 flags; // see AccountFlags
118
-
119
- string32 homeDomain; // can be used for reverse federation and memo lookup
120
-
121
- // fields used for signatures
122
- // thresholds stores unsigned bytes: [weight of master|low|medium|high]
123
- Thresholds thresholds;
124
-
125
- Signer signers<20>; // possible signers for this account
126
-
127
- // reserved for future use
128
- union switch (int v)
129
- {
130
- case 0:
131
- void;
132
- case 1:
133
- struct
134
- {
135
- Liabilities liabilities;
136
-
137
- union switch (int v)
138
- {
139
- case 0:
140
- void;
141
- }
142
- ext;
143
- } v1;
144
- }
145
- ext;
146
- };
147
-
148
- /* TrustLineEntry
149
- A trust line represents a specific trust relationship with
150
- a credit/issuer (limit, authorization)
151
- as well as the balance.
152
- */
153
-
154
- enum TrustLineFlags
155
- {
156
- // issuer has authorized account to perform transactions with its credit
157
- AUTHORIZED_FLAG = 1
158
- };
159
-
160
- // mask for all trustline flags
161
- const MASK_TRUSTLINE_FLAGS = 1;
162
-
163
- struct TrustLineEntry
164
- {
165
- AccountID accountID; // account this trustline belongs to
166
- Asset asset; // type of asset (with issuer)
167
- int64 balance; // how much of this asset the user has.
168
- // Asset defines the unit for this;
169
-
170
- int64 limit; // balance cannot be above this
171
- uint32 flags; // see TrustLineFlags
172
-
173
- // reserved for future use
174
- union switch (int v)
175
- {
176
- case 0:
177
- void;
178
- case 1:
179
- struct
180
- {
181
- Liabilities liabilities;
182
-
183
- union switch (int v)
184
- {
185
- case 0:
186
- void;
187
- }
188
- ext;
189
- } v1;
190
- }
191
- ext;
192
- };
193
-
194
- enum OfferEntryFlags
195
- {
196
- // issuer has authorized account to perform transactions with its credit
197
- PASSIVE_FLAG = 1
198
- };
199
-
200
- // Mask for OfferEntry flags
201
- const MASK_OFFERENTRY_FLAGS = 1;
202
-
203
- /* OfferEntry
204
- An offer is the building block of the offer book, they are automatically
205
- claimed by payments when the price set by the owner is met.
206
-
207
- For example an Offer is selling 10A where 1A is priced at 1.5B
208
-
209
- */
210
- struct OfferEntry
211
- {
212
- AccountID sellerID;
213
- uint64 offerID;
214
- Asset selling; // A
215
- Asset buying; // B
216
- int64 amount; // amount of A
217
-
218
- /* price for this offer:
219
- price of A in terms of B
220
- price=AmountB/AmountA=priceNumerator/priceDenominator
221
- price is after fees
222
- */
223
- Price price;
224
- uint32 flags; // see OfferEntryFlags
225
-
226
- // reserved for future use
227
- union switch (int v)
228
- {
229
- case 0:
230
- void;
231
- }
232
- ext;
233
- };
234
-
235
- /* DataEntry
236
- Data can be attached to accounts.
237
- */
238
- struct DataEntry
239
- {
240
- AccountID accountID; // account this data belongs to
241
- string64 dataName;
242
- DataValue dataValue;
243
-
244
- // reserved for future use
245
- union switch (int v)
246
- {
247
- case 0:
248
- void;
249
- }
250
- ext;
251
- };
252
-
253
- struct LedgerEntry
254
- {
255
- uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed
256
-
257
- union switch (LedgerEntryType type)
258
- {
259
- case ACCOUNT:
260
- AccountEntry account;
261
- case TRUSTLINE:
262
- TrustLineEntry trustLine;
263
- case OFFER:
264
- OfferEntry offer;
265
- case DATA:
266
- DataEntry data;
267
- }
268
- data;
269
-
270
- // reserved for future use
271
- union switch (int v)
272
- {
273
- case 0:
274
- void;
275
- }
276
- ext;
277
- };
278
-
279
- // list of all envelope types used in the application
280
- // those are prefixes used when building signatures for
281
- // the respective envelopes
282
- enum EnvelopeType
283
- {
284
- ENVELOPE_TYPE_SCP = 1,
285
- ENVELOPE_TYPE_TX = 2,
286
- ENVELOPE_TYPE_AUTH = 3
287
- };
288
- }