glueby 1.1.1 → 1.1.2
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf5bddcac51622b30df3af390b3755b5f98509cb890a4d7505b60bc08b44f896
|
4
|
+
data.tar.gz: 7e456329486fe6f1bef94899827c59a56ae9f6e327fc6149170cb84adb104965
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0849f5053fe790bbdbeb4e81829ced6597af38c9dea55c94ab07c2d1e7ce767f064a607451b575d30f5fd2cad8e2155d9de300dfdca9f72abaf0f62f446831a1'
|
7
|
+
data.tar.gz: e1513b7c30d6a3b1c807b3150d4b22c46615fa41167cc2b0e33a14489599811b71cfef5c875e2fdf98ed4ec6f73c360e41b4250787be66371e74bfc2de843c39
|
data/.github/workflows/ruby.yml
CHANGED
@@ -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
|
data/lib/glueby/version.rb
CHANGED