stellar-base 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa23fad0329efcda8cb73f539a3adc91b735d573937b0ba392fd9c992dc3e067
4
- data.tar.gz: 24d04f5f147f3c28cb3bcaed0388b4400746893b1fda8148a1da1eee690bbf80
3
+ metadata.gz: 2062b56ea0a8fd01a7917fe0e602098d9233896c0189bc3551ce594397f394a4
4
+ data.tar.gz: 9dfca2d0f18a86ec0d36c3b7e97fd9c75e61339c39d0f4a7c834129ad48bdf46
5
5
  SHA512:
6
- metadata.gz: a03b5ee1650f1c98d93f014d6d5e3ceabdd0470913a76704e590a770359b3881e0d841ce7da0fd9136affd7b950a3819a3cc7bb5d4f285c83414f43ce408c532
7
- data.tar.gz: f81d001d2cb2da33752e039419d0ae151ab55820f41c8a7e06fbb3b4ac631eb9010aee5bd4252dce0cfa552281cdda986a2f35d862fb9098257d27a057ee57ec
6
+ metadata.gz: fcf5bca3ecc1b9bfc27198bf8d0712a4c0f4780ef851f8894c67a5bdaea13ae82b34696618ba298f31ddec9f726f298d6e6242b8474a29d1a225cbd206bb1bc0
7
+ data.tar.gz: 92f331fdad439135cac96063346ce2e1426efe1766a73e8c2151e87ecd7f7a351b76028569566a84431887ee67e45b8437f8824defb50fd051cbc99f02d75e52
@@ -3,6 +3,7 @@ rvm:
3
3
  - 2.2.6
4
4
  - 2.3.3
5
5
  - 2.4.0
6
+ - 2.5.1
6
7
  script: bundle exec rake travis
7
8
  notifications:
8
9
  slack:
data/README.md CHANGED
@@ -58,15 +58,15 @@ This library also provides an impementation of Stellar's "StrKey" encoding (RFC-
58
58
 
59
59
  ```ruby
60
60
 
61
- Stellar::Util::StrCheck.check_encode(:account_id, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF") # => "GD777777777764TU"
62
- Stellar::Util::StrCheck.check_encode(:seed, "\x00\x00\x00\x00\x00\x00\x39") # => "SAAAAAAAAAADST3H"
61
+ Stellar::Util::StrKey.check_encode(:account_id, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF") # => "GD777777777764TU"
62
+ Stellar::Util::StrKey.check_encode(:seed, "\x00\x00\x00\x00\x00\x00\x39") # => "SAAAAAAAAAADST3H"
63
63
 
64
64
  # To prevent interpretation mistakes, you must pass the expected version byte
65
65
  # when decoding a check_encoded value
66
66
 
67
67
  encoded = Stellar::Util::StrCheck.check_encode(:account_id, "\x61\x6b\x04\xab\x8b\xf6\x1b")
68
- Stellar::Util::StrCheck.check_decode(:account_id, encoded) # => "\x61\x6b\x04\xab\x8b\xf6\x1b"
69
- Stellar::Util::StrCheck.check_decode(:seed, encoded) # => throws ArgumentError: Unexpected version: :account_id
68
+ Stellar::Util::StrKey.check_decode(:account_id, encoded) # => "\x61\x6b\x04\xab\x8b\xf6\x1b"
69
+ Stellar::Util::StrKey.check_decode(:seed, encoded) # => throws ArgumentError: Unexpected version: :account_id
70
70
 
71
71
  ```
72
72
 
@@ -22,6 +22,7 @@ require_relative './stellar/key_pair'
22
22
  require_relative './stellar/operation'
23
23
  require_relative './stellar/path_payment_result'
24
24
  require_relative './stellar/price'
25
+ require_relative './stellar/signer_key'
25
26
  require_relative './stellar/thresholds'
26
27
  require_relative './stellar/transaction'
27
28
  require_relative './stellar/transaction_envelope'
@@ -1,5 +1,5 @@
1
1
  module Stellar
2
2
  module Base
3
- VERSION = "0.15.0"
3
+ VERSION = "0.16.0"
4
4
  end
5
5
  end
@@ -0,0 +1,40 @@
1
+ module Stellar
2
+ class SignerKey
3
+
4
+ def self.ed25519(keypair)
5
+ raise ArgumentError, "Bad keypair" unless keypair.is_a?(KeyPair)
6
+ new(:signer_key_type_ed25519, keypair.raw_public_key)
7
+ end
8
+
9
+
10
+ def self.preauthorized_transaction(tx)
11
+ new(:signer_key_type_pre_auth_tx, tx.hash)
12
+ end
13
+
14
+
15
+ def self.onetime_signer(preimage)
16
+ hash_x = Digest::SHA256.digest(preimage)
17
+ new(:signer_key_type_hash_x, hash_x)
18
+ end
19
+
20
+ def to_s
21
+ case switch
22
+ when SignerKeyType.signer_key_type_ed25519
23
+ address = Stellar::Convert.pk_to_address(self)
24
+ "ed25519: #{address}"
25
+ when SignerKeyType.signer_key_type_pre_auth_tx
26
+ tx = Stellar::Convert.to_hex(pre_auth_tx!)
27
+ "pre_auth_tx: #{tx}"
28
+ when SignerKeyType.signer_key_type_hash_x
29
+ hx = Stellar::Convert.to_hex(hash_x!)
30
+ "hash_x: #{hx}"
31
+ end
32
+ end
33
+
34
+ def inspect
35
+ label = switch.to_s
36
+ "#<Stellar::SignerKey #{to_s}>"
37
+ end
38
+
39
+ end
40
+ end
@@ -169,7 +169,7 @@ module Stellar
169
169
  def to_operations
170
170
  cloned = Marshal.load Marshal.dump(operations)
171
171
  operations.each do |op|
172
- op.source_account = self.source_account
172
+ op.source_account ||= self.source_account
173
173
  end
174
174
  end
175
175
 
@@ -28,5 +28,12 @@ module Stellar
28
28
  def hash
29
29
  Digest::SHA256.digest(to_xdr)
30
30
  end
31
+
32
+ def merge(other)
33
+ merged_tx = tx.merge(other.tx)
34
+ merged_tx.signatures = [signatures, other.signatures]
35
+ merged_tx
36
+ end
37
+
31
38
  end
32
39
  end
@@ -15,12 +15,12 @@ Gem::Specification.new do |spec|
15
15
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
16
  spec.require_paths = ["generated", "lib"]
17
17
 
18
- spec.add_dependency "xdr", "~> 2.0.0"
18
+ spec.add_dependency "xdr", "~> 3.0.0"
19
19
  spec.add_dependency "digest-crc"
20
20
  spec.add_dependency "base32"
21
21
  spec.add_dependency "rbnacl"
22
- spec.add_dependency "rbnacl-libsodium", "~> 1.0.3"
23
- spec.add_dependency "activesupport", ">= 4.2.7"
22
+ spec.add_dependency "rbnacl-libsodium", "~> 1.0.16"
23
+ spec.add_dependency "activesupport", ">= 5.2.0"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.7"
26
26
  spec.add_development_dependency "rake", "~> 12.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xdr
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: digest-crc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.3
75
+ version: 1.0.16
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.3
82
+ version: 1.0.16
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: activesupport
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 4.2.7
89
+ version: 5.2.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 4.2.7
96
+ version: 5.2.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -399,6 +399,7 @@ files:
399
399
  - lib/stellar/operation.rb
400
400
  - lib/stellar/path_payment_result.rb
401
401
  - lib/stellar/price.rb
402
+ - lib/stellar/signer_key.rb
402
403
  - lib/stellar/thresholds.rb
403
404
  - lib/stellar/transaction.rb
404
405
  - lib/stellar/transaction_envelope.rb