glueby 0.4.0 → 0.4.1
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 +4 -4
- data/README.md +1 -1
- data/glueby.gemspec +1 -1
- data/lib/generators/glueby/contract/templates/key_table.rb.erb +1 -0
- data/lib/generators/glueby/contract/templates/utxo_table.rb.erb +1 -0
- data/lib/glueby/contract/token.rb +1 -0
- data/lib/glueby/internal/wallet.rb +8 -8
- data/lib/glueby/internal/wallet/abstract_wallet_adapter.rb +8 -4
- data/lib/glueby/internal/wallet/active_record/utxo.rb +1 -0
- data/lib/glueby/internal/wallet/active_record_wallet_adapter.rb +8 -5
- data/lib/glueby/internal/wallet/tapyrus_core_wallet_adapter.rb +5 -3
- data/lib/glueby/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d128fa095b1dacb936a8a9ff3306b750d3cf258133f6fa469ccaf9d4d830c08
|
4
|
+
data.tar.gz: 0a0496a04b1a6b86d3f2790555ac832094cb2a809ea10262f0641520dc7cb96b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '07178bc49443f227073442e2d5e767e2350a1b363f72b1041b6f2feb2a6a7a413399617c97017acf73537d49e57f10d0aecb7439a8524a7c80691ccaf0620ce6'
|
7
|
+
data.tar.gz: 86d4f463995f258d3ab3496206eabc97af77f16554705f61db69c339efc146d876375cda34bf8a17425954bf51ad6c1699eb19f37676e54401c57e5026bec597
|
data/README.md
CHANGED
@@ -183,7 +183,7 @@ In the second Fee Provider mode, the Fee Provider module pays a fee instead of t
|
|
183
183
|
1. Set like below
|
184
184
|
|
185
185
|
```ruby
|
186
|
-
|
186
|
+
Glueby.configure do |config|
|
187
187
|
# Use FeeProvider to supply inputs for fees on each transaction that is created on Glueby.
|
188
188
|
config.fee_provider_bears!
|
189
189
|
config.fee_provider_config = {
|
data/glueby.gemspec
CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
spec.add_runtime_dependency 'tapyrus', '>= 0.2.9'
|
30
|
-
spec.
|
30
|
+
spec.add_runtime_dependency 'activerecord'
|
31
31
|
spec.add_development_dependency 'sqlite3'
|
32
32
|
end
|
@@ -74,8 +74,8 @@ module Glueby
|
|
74
74
|
wallet_adapter.balance(id, only_finalized)
|
75
75
|
end
|
76
76
|
|
77
|
-
def list_unspent(only_finalized = true)
|
78
|
-
wallet_adapter.list_unspent(id, only_finalized)
|
77
|
+
def list_unspent(only_finalized = true, label = nil)
|
78
|
+
wallet_adapter.list_unspent(id, only_finalized, label)
|
79
79
|
end
|
80
80
|
|
81
81
|
def delete
|
@@ -105,8 +105,8 @@ module Glueby
|
|
105
105
|
tx
|
106
106
|
end
|
107
107
|
|
108
|
-
def receive_address
|
109
|
-
wallet_adapter.receive_address(id)
|
108
|
+
def receive_address(label = nil)
|
109
|
+
wallet_adapter.receive_address(id, label)
|
110
110
|
end
|
111
111
|
|
112
112
|
def change_address
|
@@ -117,8 +117,8 @@ module Glueby
|
|
117
117
|
wallet_adapter.create_pubkey(id)
|
118
118
|
end
|
119
119
|
|
120
|
-
def collect_uncolored_outputs(amount)
|
121
|
-
utxos = list_unspent
|
120
|
+
def collect_uncolored_outputs(amount, label = nil)
|
121
|
+
utxos = list_unspent(true, label)
|
122
122
|
|
123
123
|
utxos.inject([0, []]) do |sum, output|
|
124
124
|
next sum if output[:color_id]
|
@@ -132,8 +132,8 @@ module Glueby
|
|
132
132
|
raise Glueby::Contract::Errors::InsufficientFunds
|
133
133
|
end
|
134
134
|
|
135
|
-
def get_addresses
|
136
|
-
wallet_adapter.get_addresses(id)
|
135
|
+
def get_addresses(label = nil)
|
136
|
+
wallet_adapter.get_addresses(id, label)
|
137
137
|
end
|
138
138
|
|
139
139
|
private
|
@@ -65,11 +65,13 @@ module Glueby
|
|
65
65
|
raise NotImplementedError, "You must implement #{self.class}##{__method__}"
|
66
66
|
end
|
67
67
|
|
68
|
-
# Returns
|
68
|
+
# Returns the UTXOs that the wallet has.
|
69
|
+
# If label is specified, return UTXOs filtered with label
|
69
70
|
#
|
70
71
|
# @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
|
71
72
|
# @param [Boolean] only_finalized - The UTXOs includes only finalized UTXO value if it
|
72
73
|
# is true. Default is true.
|
74
|
+
# @param [String] label - Label for filtering UTXOs
|
73
75
|
# @return [Array of UTXO]
|
74
76
|
#
|
75
77
|
# ## The UTXO structure
|
@@ -78,7 +80,7 @@ module Glueby
|
|
78
80
|
# - vout: [Integer] Output index
|
79
81
|
# - amount: [Integer] Amount of the UTXO as tapyrus unit
|
80
82
|
# - finalized: [Boolean] Whether the UTXO is finalized
|
81
|
-
def list_unspent(wallet_id, only_finalized = true)
|
83
|
+
def list_unspent(wallet_id, only_finalized = true, label = nil)
|
82
84
|
raise NotImplementedError, "You must implement #{self.class}##{__method__}"
|
83
85
|
end
|
84
86
|
|
@@ -107,8 +109,9 @@ module Glueby
|
|
107
109
|
# Returns an address to receive coin.
|
108
110
|
#
|
109
111
|
# @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
|
112
|
+
# @param [String] label The label associated with this address.
|
110
113
|
# @return [String] P2PKH address
|
111
|
-
def receive_address(wallet_id)
|
114
|
+
def receive_address(wallet_id, label = nil)
|
112
115
|
raise NotImplementedError, "You must implement #{self.class}##{__method__}"
|
113
116
|
end
|
114
117
|
|
@@ -136,8 +139,9 @@ module Glueby
|
|
136
139
|
# This method is expected to return the list of addresses that wallet has.
|
137
140
|
#
|
138
141
|
# @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
|
142
|
+
# @param [String] label The label to filter the addresses.
|
139
143
|
# @return [Array<String>] array of P2PKH address
|
140
|
-
def get_addresses(wallet_id)
|
144
|
+
def get_addresses(wallet_id, label = nil)
|
141
145
|
raise NotImplementedError, "You must implement #{self.class}##{__method__}"
|
142
146
|
end
|
143
147
|
end
|
@@ -86,10 +86,11 @@ module Glueby
|
|
86
86
|
utxos.sum(&:value)
|
87
87
|
end
|
88
88
|
|
89
|
-
def list_unspent(wallet_id, only_finalized = true)
|
89
|
+
def list_unspent(wallet_id, only_finalized = true, label = nil)
|
90
90
|
wallet = AR::Wallet.find_by(wallet_id: wallet_id)
|
91
91
|
utxos = wallet.utxos
|
92
92
|
utxos = utxos.where(status: :finalized) if only_finalized
|
93
|
+
utxos = utxos.where(label: label) if label
|
93
94
|
utxos.map do |utxo|
|
94
95
|
{
|
95
96
|
txid: utxo.txid,
|
@@ -115,9 +116,9 @@ module Glueby
|
|
115
116
|
end
|
116
117
|
end
|
117
118
|
|
118
|
-
def receive_address(wallet_id)
|
119
|
+
def receive_address(wallet_id, label = nil)
|
119
120
|
wallet = AR::Wallet.find_by(wallet_id: wallet_id)
|
120
|
-
key = wallet.keys.create(purpose: :receive)
|
121
|
+
key = wallet.keys.create(purpose: :receive, label: label || '')
|
121
122
|
key.address
|
122
123
|
end
|
123
124
|
|
@@ -133,9 +134,11 @@ module Glueby
|
|
133
134
|
Tapyrus::Key.new(pubkey: key.public_key)
|
134
135
|
end
|
135
136
|
|
136
|
-
def get_addresses(wallet_id)
|
137
|
+
def get_addresses(wallet_id, label = nil)
|
137
138
|
wallet = AR::Wallet.find_by(wallet_id: wallet_id)
|
138
|
-
wallet.keys
|
139
|
+
keys = wallet.keys
|
140
|
+
keys = keys.where(label: label) if label
|
141
|
+
keys.map(&:address)
|
139
142
|
end
|
140
143
|
end
|
141
144
|
end
|
@@ -83,11 +83,13 @@ module Glueby
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
def list_unspent(wallet_id, only_finalized = true)
|
86
|
+
def list_unspent(wallet_id, only_finalized = true, label = nil)
|
87
87
|
perform_as(wallet_id) do |client|
|
88
88
|
min_conf = only_finalized ? 1 : 0
|
89
89
|
res = client.listunspent(min_conf)
|
90
90
|
|
91
|
+
res = res.filter { |i| i['label'] == label } if label
|
92
|
+
|
91
93
|
res.map do |i|
|
92
94
|
script = Tapyrus::Script.parse_from_payload(i['scriptPubKey'].htb)
|
93
95
|
color_id = if script.cp2pkh? || script.cp2sh?
|
@@ -122,9 +124,9 @@ module Glueby
|
|
122
124
|
end
|
123
125
|
end
|
124
126
|
|
125
|
-
def receive_address(wallet_id)
|
127
|
+
def receive_address(wallet_id, label = nil)
|
126
128
|
perform_as(wallet_id) do |client|
|
127
|
-
client.getnewaddress('', ADDRESS_TYPE)
|
129
|
+
client.getnewaddress(label || '', ADDRESS_TYPE)
|
128
130
|
end
|
129
131
|
end
|
130
132
|
|
data/lib/glueby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glueby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tapyrus
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|