stellar-base 0.0.20 → 0.1.0

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -14
  3. data/examples/low_level_transaction_post.rb +1 -1
  4. data/examples/non_native_payment.rb +2 -2
  5. data/examples/offer.rb +5 -5
  6. data/generated/stellar-base-generated.rb +4 -5
  7. data/generated/stellar/account_flags.rb +1 -1
  8. data/generated/stellar/allow_trust_op.rb +11 -8
  9. data/generated/stellar/allow_trust_op/asset.rb +33 -0
  10. data/generated/stellar/allow_trust_result_code.rb +1 -1
  11. data/generated/stellar/asset.rb +47 -0
  12. data/generated/stellar/{currency/alpha_num.rb → asset/alpha_num12.rb} +5 -5
  13. data/generated/stellar/asset/alpha_num4.rb +22 -0
  14. data/generated/stellar/asset_type.rb +24 -0
  15. data/generated/stellar/change_trust_op.rb +2 -2
  16. data/generated/stellar/claim_offer_atom.rb +10 -10
  17. data/generated/stellar/create_passive_offer_op.rb +8 -8
  18. data/generated/stellar/crypto_key_type.rb +2 -2
  19. data/generated/stellar/ledger_key.rb +2 -2
  20. data/generated/stellar/ledger_key/offer.rb +3 -3
  21. data/generated/stellar/ledger_key/trust_line.rb +2 -2
  22. data/generated/stellar/manage_offer_op.rb +9 -9
  23. data/generated/stellar/offer_entry.rb +11 -11
  24. data/generated/stellar/{currency_type.rb → operation_meta.rb} +4 -8
  25. data/generated/stellar/path_payment_op.rb +10 -10
  26. data/generated/stellar/path_payment_result_code.rb +2 -2
  27. data/generated/stellar/payment_op.rb +2 -2
  28. data/generated/stellar/payment_result_code.rb +2 -2
  29. data/generated/stellar/public_key.rb +2 -2
  30. data/generated/stellar/simple_payment_result.rb +2 -2
  31. data/generated/stellar/transaction_meta.rb +17 -4
  32. data/generated/stellar/transaction_meta/v0.rb +22 -0
  33. data/generated/stellar/trust_line_entry.rb +4 -4
  34. data/lib/stellar-base.rb +2 -2
  35. data/lib/stellar/asset.rb +38 -0
  36. data/lib/stellar/base/version.rb +1 -1
  37. data/lib/stellar/convert.rb +1 -5
  38. data/lib/stellar/key_pair.rb +6 -6
  39. data/lib/stellar/operation.rb +24 -24
  40. data/lib/stellar/path_payment_result.rb +2 -2
  41. data/lib/stellar/util/strkey.rb +43 -0
  42. data/ruby-stellar-base.gemspec +2 -0
  43. data/spec/lib/stellar/key_pair_spec.rb +12 -12
  44. data/spec/lib/stellar/path_payment_result_spec.rb +7 -7
  45. data/spec/lib/stellar/transaction_spec.rb +1 -1
  46. data/spec/lib/stellar/util/strkey_spec.rb +46 -0
  47. data/spec/support/matchers/be_strkey.rb +9 -0
  48. data/tasks/xdr.rake +7 -8
  49. data/xdr/Stellar-SCP.x +1 -1
  50. data/xdr/Stellar-ledger-entries.x +26 -18
  51. data/xdr/Stellar-ledger.x +17 -5
  52. data/xdr/Stellar-overlay.x +1 -1
  53. data/xdr/Stellar-transaction.x +39 -36
  54. data/xdr/Stellar-types.x +2 -3
  55. metadata +43 -13
  56. data/generated/stellar/allow_trust_op/currency.rb +0 -28
  57. data/generated/stellar/currency.rb +0 -37
  58. data/lib/stellar/currency.rb +0 -39
  59. data/lib/stellar/util/base58.rb +0 -127
  60. data/spec/lib/stellar/util/base58_spec.rb +0 -74
  61. data/spec/support/matchers/be_base58_check.rb +0 -9
  62. data/xdr/StellarXDR.x +0 -11
@@ -31,7 +31,7 @@ module Stellar
31
31
  # in the necessary XDR structs to be included within a
32
32
  # transactions `operations` array.
33
33
  #
34
- # @see Stellar::Currency
34
+ # @see Stellar::Asset
35
35
  #
36
36
  # @param [Hash] attributes the attributes to create the operation with
37
37
  # @option attributes [Stellar::KeyPair] :destination the receiver of the payment
@@ -40,13 +40,13 @@ module Stellar
40
40
  # Stellar::PaymentOp body
41
41
  def self.payment(attributes={})
42
42
  destination = attributes[:destination]
43
- currency, amount = extract_amount(attributes[:amount])
43
+ asset, amount = extract_amount(attributes[:amount])
44
44
 
45
45
  raise ArgumentError unless destination.is_a?(KeyPair)
46
46
 
47
47
 
48
48
  op = PaymentOp.new
49
- op.currency = currency
49
+ op.asset = asset
50
50
  op.amount = amount
51
51
  op.destination = destination.account_id
52
52
 
@@ -60,29 +60,29 @@ module Stellar
60
60
  # in the necessary XDR structs to be included within a
61
61
  # transactions `operations` array.
62
62
  #
63
- # @see Stellar::Currency
63
+ # @see Stellar::Asset
64
64
  #
65
65
  # @param [Hash] attributes the attributes to create the operation with
66
66
  # @option attributes [Stellar::KeyPair] :destination the receiver of the payment
67
67
  # @option attributes [Array] :amount the amount to pay
68
- # @option attributes [Array] :with the source currency and maximum allowed source amount to pay with
69
- # @option attributes [Array<Stellar::Currency>] :path the payment path to use
68
+ # @option attributes [Array] :with the source asset and maximum allowed source amount to pay with
69
+ # @option attributes [Array<Stellar::Asset>] :path the payment path to use
70
70
  #
71
71
  # @return [Stellar::Operation] the built operation, containing a
72
72
  # Stellar::PaymentOp body
73
73
  def self.path_payment(attributes={})
74
74
  destination = attributes[:destination]
75
- currency, amount = extract_amount(attributes[:amount])
76
- send_currency, send_max = extract_amount(attributes[:with])
77
- path = (attributes[:path] || []).map{|p| Stellar::Currency.send(*p)}
75
+ asset, amount = extract_amount(attributes[:amount])
76
+ send_asset, send_max = extract_amount(attributes[:with])
77
+ path = (attributes[:path] || []).map{|p| Stellar::Asset.send(*p)}
78
78
 
79
79
  raise ArgumentError unless destination.is_a?(KeyPair)
80
80
 
81
81
  op = PathPaymentOp.new
82
- op.send_currency = send_currency
82
+ op.send_asset = send_asset
83
83
  op.send_max = send_max
84
84
  op.destination = destination.account_id
85
- op.dest_currency = currency
85
+ op.dest_asset = asset
86
86
  op.dest_amount = amount
87
87
  op.path = path
88
88
 
@@ -112,13 +112,13 @@ module Stellar
112
112
  # transactions `operations` array.
113
113
  #
114
114
  # @param [Hash] attributes the attributes to create the operation with
115
- # @option attributes [Stellar::Currrency] :line the currency to trust
115
+ # @option attributes [Stellar::Currrency] :line the asset to trust
116
116
  # @option attributes [Fixnum] :limit the maximum amount to trust
117
117
  #
118
118
  # @return [Stellar::Operation] the built operation, containing a
119
119
  # Stellar::ChangeTrustOp body
120
120
  def self.change_trust(attributes={})
121
- line = Currency.send(*attributes[:line])
121
+ line = Asset.send(*attributes[:line])
122
122
  limit = attributes[:limit]
123
123
 
124
124
  raise ArgumentError, "Bad :limit #{limit}" unless limit.is_a?(Integer)
@@ -131,8 +131,8 @@ module Stellar
131
131
  end
132
132
 
133
133
  def self.manage_offer(attributes={})
134
- taker_pays = Currency.send(*attributes[:taker_pays])
135
- taker_gets = Currency.send(*attributes[:taker_gets])
134
+ taker_pays = Asset.send(*attributes[:taker_pays])
135
+ taker_gets = Asset.send(*attributes[:taker_gets])
136
136
  amount = attributes[:amount]
137
137
  offer_id = attributes[:offer_id] || 0
138
138
  price = Price.from_f(attributes[:price])
@@ -151,8 +151,8 @@ module Stellar
151
151
  end
152
152
 
153
153
  def self.create_passive_offer(attributes={})
154
- taker_pays = Currency.send(*attributes[:taker_pays])
155
- taker_gets = Currency.send(*attributes[:taker_gets])
154
+ taker_pays = Asset.send(*attributes[:taker_pays])
155
+ taker_gets = Asset.send(*attributes[:taker_gets])
156
156
  amount = attributes[:amount]
157
157
  price = Price.from_f(attributes[:price])
158
158
 
@@ -214,7 +214,7 @@ module Stellar
214
214
  #
215
215
  # @param [Hash] attributes the attributes to create the operation with
216
216
  # @option attributes [Stellar::KeyPair] :trustor
217
- # @option attributes [Stellar::Currency] :currency
217
+ # @option attributes [Stellar::Asset] :asset
218
218
  #
219
219
  # @return [Stellar::Operation] the built operation, containing a
220
220
  # Stellar::AllowTrustOp body
@@ -223,17 +223,17 @@ module Stellar
223
223
 
224
224
  trustor = attributes[:trustor]
225
225
  authorize = attributes[:authorize]
226
- currency = Currency.send(*attributes[:currency])
226
+ asset = Asset.send(*attributes[:asset])
227
227
 
228
228
  raise ArgumentError, "Bad :trustor" unless trustor.is_a?(Stellar::KeyPair)
229
229
  raise ArgumentError, "Bad :authorize" unless authorize == !!authorize # check boolean
230
- raise ArgumentError, "Bad :currency" unless currency.type == Stellar::CurrencyType.currency_type_alphanum
230
+ raise ArgumentError, "Bad :asset" unless asset.type == Stellar::AssetType.asset_type_credit_alphanum4
231
231
 
232
- atc = AllowTrustOp::Currency.new(:currency_type_alphanum, currency.code)
232
+ atc = AllowTrustOp::Asset.new(:asset_type_credit_alphanum4, asset.code)
233
233
 
234
234
  op.trustor = trustor.account_id
235
235
  op.authorize = authorize
236
- op.currency = atc
236
+ op.asset = atc
237
237
 
238
238
  return make(attributes.merge({
239
239
  body:[:allow_trust, op]
@@ -279,9 +279,9 @@ module Stellar
279
279
  private
280
280
  def self.extract_amount(a)
281
281
  amount = a.last
282
- currency = Stellar::Currency.send(*a[0...-1])
282
+ asset = Stellar::Asset.send(*a[0...-1])
283
283
 
284
- return currency, amount
284
+ return asset, amount
285
285
  end
286
286
  end
287
287
  end
@@ -7,8 +7,8 @@ module Stellar
7
7
  s = success!
8
8
  return s.last.amount if s.offers.blank?
9
9
 
10
- source_currency = s.offers.first.currency_send
11
- source_offers = s.offers.take_while{|o| o.currency_send == source_currency}
10
+ source_asset = s.offers.first.asset_send
11
+ source_offers = s.offers.take_while{|o| o.asset_send == source_asset}
12
12
 
13
13
  source_offers.map(&:amount_send).sum
14
14
  end
@@ -0,0 +1,43 @@
1
+ module Stellar
2
+ module Util
3
+
4
+ require 'base32'
5
+ require 'digest/crc16_xmodem'
6
+
7
+ class StrKey
8
+
9
+ VERSION_BYTES = {
10
+ account_id: [ 6 << 3].pack("C"), # Base32-encodes to 'G...'
11
+ seed: [18 << 3].pack("C"), # Base32-encodes to 'S...'
12
+ }
13
+
14
+ def self.check_encode(version, byte_str)
15
+ version_byte = VERSION_BYTES[version]
16
+ raise ArgumentError, "Invalid version: #{version}" if version_byte.blank?
17
+ payload = version_byte + byte_str.dup.force_encoding("BINARY")
18
+ check = checksum(payload)
19
+ Base32.encode(payload + check)
20
+ end
21
+
22
+ def self.check_decode(expected_version, str)
23
+ decoded = Base32.decode(str) rescue (raise ArgumentError, "Invalid base32 string")
24
+ version_byte = decoded[0]
25
+ payload = decoded[1...-2]
26
+ check = decoded[-2..-1]
27
+ version = VERSION_BYTES.key(version_byte)
28
+
29
+ raise ArgumentError, "Unexpected version: #{version.inspect}" if version != expected_version
30
+ raise ArgumentError, "Invalid checksum" if check != checksum(decoded[0...-2])
31
+ payload
32
+ end
33
+
34
+ # return the "XModem CRC16" (CCITT-like, but with 0-init and MSB first)
35
+ # packed into a string in little-endian order
36
+ def self.checksum(bytes)
37
+ crc = Digest::CRC16XModem.checksum(bytes)
38
+ [crc].pack("S<")
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["generated", "lib"]
19
19
 
20
20
  spec.add_dependency "xdr", "~> 0.0.4"
21
+ spec.add_dependency "digest-crc"
22
+ spec.add_dependency "base32"
21
23
  spec.add_dependency "rbnacl"
22
24
  spec.add_dependency "rbnacl-libsodium", "~> 1.0.3"
23
25
  spec.add_dependency "activesupport", "~> 4"
@@ -6,19 +6,19 @@ describe Stellar::KeyPair do
6
6
  describe ".from_seed" do
7
7
  subject{ Stellar::KeyPair.from_seed(seed) }
8
8
 
9
- context "when provided a base58check encoded seed" do
10
- let(:seed){ "s9aaUNPaT9t1x7vCeDzQYvLZDm5XxSUKkwnqQowV6D3kMr678uZ" }
9
+ context "when provided a strkey encoded seed" do
10
+ let(:seed){ "SBDA4J4PYZJEXWDTHFZBIGFVF2745BTKDKADWDQF72QXP55BP6XOV3B6" }
11
11
  it { should be_a(Stellar::KeyPair) }
12
12
  end
13
13
 
14
- context "provided value is not base58 encoded" do
14
+ context "provided value is not strkey encoded" do
15
15
  let(:seed){ "allmylifemyhearthasbeensearching" }
16
16
  it { expect{ subject }.to raise_error(ArgumentError) }
17
17
  end
18
18
 
19
- context "provided value is not base58 encoded as a seed" do
19
+ context "provided value is not strkey encoded as a seed" do
20
20
  let(:raw_seed){ "allmylifemyhearthasbeensearching" }
21
- let(:seed){ Stellar::Util::Base58.stellar.check_encode(:account_id, raw_seed) }
21
+ let(:seed){ Stellar::Util::StrKey.check_encode(:account_id, raw_seed) }
22
22
  it { expect{ subject }.to raise_error(ArgumentError) }
23
23
  end
24
24
  end
@@ -74,19 +74,19 @@ describe Stellar::KeyPair do
74
74
  describe ".from_address" do
75
75
  subject{ Stellar::KeyPair.from_address(address) }
76
76
 
77
- context "when provided a base58check encoded account_id" do
78
- let(:address){ "gsYRSEQhTffqA9opPepAENCr2WG6z5iBHHubxxbRzWaHf8FBWcu" }
77
+ context "when provided a strkey encoded account_id" do
78
+ let(:address){ "GBRAINV4XDXEINVTNN53GOIGTN4B3BK65N6Q2ZBOMXHGHT347OQVNYZQ" }
79
79
  it { should be_a(Stellar::KeyPair) }
80
80
  end
81
81
 
82
- context "provided value is not base58 encoded" do
82
+ context "provided value is not strkey encoded" do
83
83
  let(:address){ "some address" }
84
84
  it { expect{ subject }.to raise_error(ArgumentError) }
85
85
  end
86
86
 
87
- context "provided value is not base58 encoded as an account_id" do
87
+ context "provided value is not strkey encoded as an account_id" do
88
88
  let(:public_key){ "\xFF" * 32 }
89
- let(:address){ Stellar::Util::Base58.stellar.check_encode(:seed, public_key) }
89
+ let(:address){ Stellar::Util::StrKey.check_encode(:seed, public_key) }
90
90
  it { expect{ subject }.to raise_error(ArgumentError) }
91
91
  end
92
92
 
@@ -151,13 +151,13 @@ describe Stellar::KeyPair do
151
151
  describe "#address" do
152
152
  let(:key_pair){ Stellar::KeyPair.random }
153
153
  subject{ key_pair.address }
154
- it{ should be_base58_check(:account_id)}
154
+ it{ should be_strkey(:account_id)}
155
155
  end
156
156
 
157
157
  describe "#seed" do
158
158
  let(:key_pair){ Stellar::KeyPair.random }
159
159
  subject{ key_pair.seed }
160
- it{ should be_base58_check(:seed)}
160
+ it{ should be_strkey(:seed)}
161
161
  end
162
162
 
163
163
  describe "#sign" do
@@ -26,7 +26,7 @@ describe Stellar::PathPaymentResult, "#send_amount" do
26
26
  context "with simple 1-hop result" do
27
27
  let(:simple_success){ Stellar::SimplePaymentResult.new(amount: 100) }
28
28
  let(:offers) do
29
- [Stellar::ClaimOfferAtom.new(currency_send: Stellar::Currency.native, amount_send: 200)]
29
+ [Stellar::ClaimOfferAtom.new(asset_send: Stellar::Asset.native, amount_send: 200)]
30
30
  end
31
31
 
32
32
  let(:path_success) do
@@ -47,8 +47,8 @@ describe Stellar::PathPaymentResult, "#send_amount" do
47
47
  let(:simple_success){ Stellar::SimplePaymentResult.new(amount: 100) }
48
48
  let(:offers) do
49
49
  [
50
- Stellar::ClaimOfferAtom.new(currency_send: Stellar::Currency.native, amount_send: 200),
51
- Stellar::ClaimOfferAtom.new(currency_send: Stellar::Currency.native, amount_send: 200),
50
+ Stellar::ClaimOfferAtom.new(asset_send: Stellar::Asset.native, amount_send: 200),
51
+ Stellar::ClaimOfferAtom.new(asset_send: Stellar::Asset.native, amount_send: 200),
52
52
  ]
53
53
  end
54
54
 
@@ -69,12 +69,12 @@ describe Stellar::PathPaymentResult, "#send_amount" do
69
69
 
70
70
  context "with multi-hop result that claimed multiple offers" do
71
71
  let(:simple_success){ Stellar::SimplePaymentResult.new(amount: 100) }
72
- let(:otherCurrency){ Stellar::Currency.alphanum("USD", Stellar::KeyPair.random) }
72
+ let(:otherAsset){ Stellar::Asset.alphanum4("USD", Stellar::KeyPair.random) }
73
73
  let(:offers) do
74
74
  [
75
- Stellar::ClaimOfferAtom.new(currency_send: Stellar::Currency.native, amount_send: 200),
76
- Stellar::ClaimOfferAtom.new(currency_send: Stellar::Currency.native, amount_send: 200),
77
- Stellar::ClaimOfferAtom.new(currency_send: otherCurrency, amount_send: 200),
75
+ Stellar::ClaimOfferAtom.new(asset_send: Stellar::Asset.native, amount_send: 200),
76
+ Stellar::ClaimOfferAtom.new(asset_send: Stellar::Asset.native, amount_send: 200),
77
+ Stellar::ClaimOfferAtom.new(asset_send: otherAsset, amount_send: 200),
78
78
  ]
79
79
  end
80
80
 
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe Stellar::Transaction do
4
4
  subject do
5
5
  Stellar::Transaction.new({
6
- source_account: Stellar::AccountID.new(:key_types_ed25519, "\x00" * 32),
6
+ source_account: Stellar::AccountID.new(:key_type_ed25519, "\x00" * 32),
7
7
  fee: 10,
8
8
  seq_num: 1,
9
9
  memo: Stellar::Memo.new(:memo_none),
@@ -0,0 +1,46 @@
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
+ end
13
+
14
+ it "raises an ArgumentError if the decoded version byte does not match the expected value" do
15
+ expect{ decode :seed, "GD777777777764TU" }.to raise_error(ArgumentError)
16
+ expect{ decode :account_id, "SAAAAAAAAAADST3M" }.to raise_error(ArgumentError)
17
+ end
18
+
19
+ it "raises an ArgumentError if the decoded value cannot be validated by the checksum" do
20
+ expect{decode :seed, "SAAAAAAAAAADST3M"}.to raise_error(ArgumentError)
21
+ end
22
+
23
+ def decode(version, bytes)
24
+ subject.check_decode(version, bytes)
25
+ end
26
+ end
27
+
28
+ describe"#check_encode" do
29
+ it "properly encodes" do
30
+ expect(encode :seed, "\x00\x00\x00\x00\x00\x00\x39").to eq("SAAAAAAAAAADST3H")
31
+ expect(encode :account_id, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF").to eq("GD777777777764TU")
32
+ expect(encode :account_id, "\x61\x6b\x04\xab\x8b\xf6\x1b").to eq("GBQWWBFLRP3BXZD5")
33
+ end
34
+
35
+ it "raises an ArgumentError when an invalid version is provided" do
36
+ expect{ encode :floob, "\x39" }.to raise_error(ArgumentError)
37
+ end
38
+
39
+ def encode(version, bytes)
40
+ subject.check_encode(version, bytes)
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+
@@ -0,0 +1,9 @@
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
@@ -4,14 +4,13 @@ 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",
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/overlay/StellarXDR.x",
13
- "src/scp/Stellar-SCP.x",
14
- ]
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
+ ]
15
14
 
16
15
  LOCAL_XDR_PATHS = HAYASHI_XDR.map{ |src| "xdr/" + File.basename(src) }
17
16
 
@@ -2,7 +2,7 @@
2
2
  // under the Apache License, Version 2.0. See the COPYING file at the root
3
3
  // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
4
4
 
5
- %#include "generated/Stellar-types.h"
5
+ %#include "xdr/Stellar-types.h"
6
6
 
7
7
  namespace stellar
8
8
  {
@@ -2,7 +2,7 @@
2
2
  // under the Apache License, Version 2.0. See the COPYING file at the root
3
3
  // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
4
4
 
5
- %#include "generated/Stellar-types.h"
5
+ %#include "xdr/Stellar-types.h"
6
6
 
7
7
  namespace stellar
8
8
  {
@@ -12,25 +12,33 @@ typedef opaque Thresholds[4];
12
12
  typedef string string32<32>;
13
13
  typedef uint64 SequenceNumber;
14
14
 
15
- enum CurrencyType
15
+ enum AssetType
16
16
  {
17
- CURRENCY_TYPE_NATIVE = 0,
18
- CURRENCY_TYPE_ALPHANUM = 1
17
+ ASSET_TYPE_NATIVE = 0,
18
+ ASSET_TYPE_CREDIT_ALPHANUM4 = 1,
19
+ ASSET_TYPE_CREDIT_ALPHANUM12 = 2
19
20
  };
20
21
 
21
- union Currency switch (CurrencyType type)
22
+ union Asset switch (AssetType type)
22
23
  {
23
- case CURRENCY_TYPE_NATIVE:
24
+ case ASSET_TYPE_NATIVE: // Not credit
24
25
  void;
25
26
 
26
- case CURRENCY_TYPE_ALPHANUM:
27
+ case ASSET_TYPE_CREDIT_ALPHANUM4:
27
28
  struct
28
29
  {
29
- opaque currencyCode[4];
30
+ opaque assetCode[4];
30
31
  AccountID issuer;
31
- } alphaNum;
32
+ } alphaNum4;
32
33
 
33
- // add other currency types here in the future
34
+ case ASSET_TYPE_CREDIT_ALPHANUM12:
35
+ struct
36
+ {
37
+ opaque assetCode[12];
38
+ AccountID issuer;
39
+ } alphaNum12;
40
+
41
+ // add other asset types here in the future
34
42
  };
35
43
 
36
44
  // price in fractional representation
@@ -69,7 +77,7 @@ enum AccountFlags
69
77
  // if set, TrustLines are created with authorized set to "false"
70
78
  // requiring the issuer to set it for each TrustLine
71
79
  AUTH_REQUIRED_FLAG = 0x1,
72
- // if set, the authorized flag in TrustTines can be cleared
80
+ // if set, the authorized flag in TrustLines can be cleared
73
81
  // otherwise, authorization cannot be revoked
74
82
  AUTH_REVOCABLE_FLAG = 0x2
75
83
  };
@@ -112,7 +120,7 @@ struct AccountEntry
112
120
 
113
121
  /* TrustLineEntry
114
122
  A trust line represents a specific trust relationship with
115
- a currency/issuer (limit, authorization)
123
+ a credit/issuer (limit, authorization)
116
124
  as well as the balance.
117
125
  */
118
126
 
@@ -125,9 +133,9 @@ enum TrustLineFlags
125
133
  struct TrustLineEntry
126
134
  {
127
135
  AccountID accountID; // account this trustline belongs to
128
- Currency currency; // currency (with issuer)
129
- int64 balance; // how much of this currency the user has.
130
- // Currency defines the unit for this;
136
+ Asset asset; // type of asset (with issuer)
137
+ int64 balance; // how much of this asset the user has.
138
+ // Asset defines the unit for this;
131
139
 
132
140
  int64 limit; // balance cannot be above this
133
141
  uint32 flags; // see TrustLineFlags
@@ -156,10 +164,10 @@ enum OfferEntryFlags
156
164
  */
157
165
  struct OfferEntry
158
166
  {
159
- AccountID accountID;
167
+ AccountID sellerID;
160
168
  uint64 offerID;
161
- Currency takerGets; // A
162
- Currency takerPays; // B
169
+ Asset selling; // A
170
+ Asset buying; // B
163
171
  int64 amount; // amount of A
164
172
 
165
173
  /* price for this offer: