glueby 1.1.1 → 1.1.2

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: 4a8f1227734487ffe7cfec63f102badd602e5d37688534aa46889eee5ba666b3
4
- data.tar.gz: 67012970c3960b835e122f1d4e29dc231bcbb8ab9dc0b76045ba8827f73174da
3
+ metadata.gz: cf5bddcac51622b30df3af390b3755b5f98509cb890a4d7505b60bc08b44f896
4
+ data.tar.gz: 7e456329486fe6f1bef94899827c59a56ae9f6e327fc6149170cb84adb104965
5
5
  SHA512:
6
- metadata.gz: c8db5d47bfb94b58d23e1cb64dae9058ce04d063b1cdba6064ad3e881b68a3a7701d5eb3ccec26c1ce8d6df2619672366912bd0e7395ef86d4d2981ce28b85ff
7
- data.tar.gz: cf939bae1b6d2850cda5e461b30ed3998d1b0c0e167ce5da4135d4afcab3a2d82728350dfaf4fb2fac9eb95d29f9f1868001b1694a9eefacc7cc339b00fd58b9
6
+ metadata.gz: '0849f5053fe790bbdbeb4e81829ced6597af38c9dea55c94ab07c2d1e7ce767f064a607451b575d30f5fd2cad8e2155d9de300dfdca9f72abaf0f62f446831a1'
7
+ data.tar.gz: e1513b7c30d6a3b1c807b3150d4b22c46615fa41167cc2b0e33a14489599811b71cfef5c875e2fdf98ed4ec6f73c360e41b4250787be66371e74bfc2de843c39
@@ -9,9 +9,9 @@ name: Ruby
9
9
 
10
10
  on:
11
11
  push:
12
- branches: [master]
12
+ branches: [master, v1.1]
13
13
  pull_request:
14
- branches: [master]
14
+ branches: [master, v1.1]
15
15
 
16
16
  jobs:
17
17
  test:
@@ -135,6 +135,15 @@ module Glueby
135
135
  raise NotImplementedError, "You must implement #{self.class}##{__method__}"
136
136
  end
137
137
 
138
+ # Returns information for the addresses
139
+ #
140
+ # @param [String] address - The p2pkh address to get information about
141
+ # @return [Array<Hash>] The array of hash instance which has keys wallet_id, label and purpose.
142
+ # Returns blank array if the key correspond with the address is not exist.
143
+ def get_addresses_info(addresses)
144
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
145
+ end
146
+
138
147
  # Returns a new public key.
139
148
  #
140
149
  # This method is expected to returns a new public key. The key would generate internally. This key is provided
@@ -153,6 +153,36 @@ module Glueby
153
153
  keys.map(&:address)
154
154
  end
155
155
 
156
+ def get_addresses_info(addresses)
157
+ unless addresses.is_a?(Array)
158
+ addresses = [addresses]
159
+ end
160
+
161
+ script_pubkeys = addresses.map do |address|
162
+ Tapyrus::Script.parse_from_addr(address).to_hex
163
+ rescue ::ArgumentError => e
164
+ raise Glueby::ArgumentError, "\"#{address}\" is invalid address. #{e.message}"
165
+ rescue RuntimeError => e
166
+ if e.message == 'Invalid version bytes.' || e.message == 'Invalid address.'
167
+ raise Glueby::ArgumentError, "\"#{address}\" is invalid address. #{e.message}"
168
+ else
169
+ raise e
170
+ end
171
+ end
172
+
173
+ keys = AR::Key.where(script_pubkey: script_pubkeys)
174
+ keys.map do |key|
175
+ {
176
+ address: key.address,
177
+ public_key: key.public_key,
178
+ wallet_id: key.wallet.wallet_id,
179
+ label: key.label,
180
+ purpose: key.purpose,
181
+ script_pubkey: key.script_pubkey
182
+ }
183
+ end
184
+ end
185
+
156
186
  def create_pay_to_contract_address(wallet_id, contents)
157
187
  pubkey = create_pubkey(wallet_id)
158
188
  [pay_to_contract_key(wallet_id, pubkey, contents).to_p2pkh, pubkey.pubkey]
@@ -73,6 +73,10 @@ module Glueby
73
73
  @wallet_adapter or
74
74
  raise Errors::ShouldInitializeWalletAdapter, 'You should initialize wallet adapter using `Glueby::Internal::Wallet.wallet_adapter = some wallet adapter instance`.'
75
75
  end
76
+
77
+ def get_addresses_info(addresses)
78
+ @wallet_adapter.get_addresses_info(addresses)
79
+ end
76
80
  end
77
81
 
78
82
  attr_reader :id
@@ -1,3 +1,3 @@
1
1
  module Glueby
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glueby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi