bitcoinrb-grpc 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bitcoin/grpc.rb +1 -0
- data/lib/bitcoin/grpc/api.rb +10 -0
- data/lib/bitcoin/grpc/api/list_colored_unspent.rb +28 -0
- data/lib/bitcoin/grpc/api/list_uncolored_unspent.rb +26 -0
- data/lib/bitcoin/grpc/api/list_unspent.rb +27 -0
- data/lib/bitcoin/grpc/grpc_pb.rb +199 -162
- data/lib/bitcoin/grpc/grpc_services_pb.rb +3 -0
- data/lib/bitcoin/grpc/server.rb +24 -0
- data/lib/bitcoin/grpc/version.rb +1 -1
- data/lib/bitcoin/wallet/asset_feature.rb +3 -1
- data/proto/bitcoin/grpc/grpc.proto +38 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 424e2253993bc766b1f087578da27e42998111280126bc699605150708740a7c
|
4
|
+
data.tar.gz: c3248a38a651e57f57b1ae8043b6f112fd7af75fe5ad6a0ce9d03ae837d9673a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2415425f2098278894c025a5451b3d342755ef30cd918ae612f934ad148cc9d622be5d630c532039ab1d9c65414ce44f3ed71159c9120114185f5caf7ce0ebff
|
7
|
+
data.tar.gz: b1ca87670b8bf33b589b895a9cd563cc11dae8d65f18dbbec1900ec50c95f88b25f6146113929667dc47f88ba20485c510559598e80a1b15a97c0a92af30d8d0
|
data/lib/bitcoin/grpc.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
module Bitcoin
|
3
|
+
module Grpc
|
4
|
+
module Api
|
5
|
+
autoload :ListUnspent, 'bitcoin/grpc/api/list_unspent'
|
6
|
+
autoload :ListColoredUnspent, 'bitcoin/grpc/api/list_colored_unspent'
|
7
|
+
autoload :ListUncoloredUnspent, 'bitcoin/grpc/api/list_uncolored_unspent'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bitcoin
|
4
|
+
module Grpc
|
5
|
+
module Api
|
6
|
+
class ListColoredUnspent
|
7
|
+
attr_reader :spv
|
8
|
+
|
9
|
+
def initialize(spv)
|
10
|
+
@spv = spv
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(request)
|
14
|
+
height = spv.chain.latest_block.height
|
15
|
+
assets = spv.wallet.list_unspent_assets_in_account(
|
16
|
+
request.asset_type,
|
17
|
+
request.asset_id,
|
18
|
+
account_name: request.account_name,
|
19
|
+
current_block_height: height,
|
20
|
+
min: request.min,
|
21
|
+
max: request.max
|
22
|
+
)
|
23
|
+
Bitcoin::Grpc::ListColoredUnspentResponse.new(assets: assets)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bitcoin
|
4
|
+
module Grpc
|
5
|
+
module Api
|
6
|
+
class ListUncoloredUnspent
|
7
|
+
attr_reader :spv
|
8
|
+
|
9
|
+
def initialize(spv)
|
10
|
+
@spv = spv
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(request)
|
14
|
+
height = spv.chain.latest_block.height
|
15
|
+
utxos = spv.wallet.list_uncolored_unspent(
|
16
|
+
account_name: request.account_name,
|
17
|
+
current_block_height: height,
|
18
|
+
min: request.min,
|
19
|
+
max: request.max
|
20
|
+
)
|
21
|
+
Bitcoin::Grpc::ListUncoloredUnspentResponse.new(utxos: utxos)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bitcoin
|
4
|
+
module Grpc
|
5
|
+
module Api
|
6
|
+
class ListUnspent
|
7
|
+
attr_reader :spv
|
8
|
+
|
9
|
+
def initialize(spv)
|
10
|
+
@spv = spv
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(request)
|
14
|
+
height = spv.chain.latest_block.height
|
15
|
+
utxos = spv.wallet.list_unspent(
|
16
|
+
account_name: request.account_name,
|
17
|
+
current_block_height: height,
|
18
|
+
min: request.min,
|
19
|
+
max: request.max,
|
20
|
+
addresses: request.addresses
|
21
|
+
)
|
22
|
+
Bitcoin::Grpc::ListUnspentResponse.new(utxos: utxos)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/bitcoin/grpc/grpc_pb.rb
CHANGED
@@ -4,172 +4,203 @@
|
|
4
4
|
require 'google/protobuf'
|
5
5
|
|
6
6
|
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
add_message "bitcoin.grpc.EventsResponse" do
|
12
|
-
oneof :event do
|
13
|
-
optional :connect, :message, 1, "bitcoin.grpc.Connect"
|
14
|
-
optional :disconnect, :message, 2, "bitcoin.grpc.Disconnect"
|
15
|
-
optional :block_created, :message, 3, "bitcoin.grpc.BlockCreated"
|
16
|
-
optional :reorganized, :message, 4, "bitcoin.grpc.Reorganized"
|
17
|
-
optional :tx_received, :message, 5, "bitcoin.grpc.TxReceived"
|
18
|
-
optional :tx_broadcasted, :message, 6, "bitcoin.grpc.TxBroadcasted"
|
19
|
-
optional :utxo_registered, :message, 7, "bitcoin.grpc.UtxoRegistered"
|
20
|
-
optional :utxo_spent, :message, 8, "bitcoin.grpc.UtxoSpent"
|
7
|
+
add_file("bitcoin/grpc/grpc.proto", :syntax => :proto3) do
|
8
|
+
add_message "bitcoin.grpc.EventsRequest" do
|
9
|
+
optional :operation, :enum, 1, "bitcoin.grpc.Operation"
|
10
|
+
optional :event_type, :string, 2
|
21
11
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
add_message "bitcoin.grpc.BlockCreated" do
|
34
|
-
optional :hash, :string, 1
|
35
|
-
optional :height, :uint32, 2
|
36
|
-
end
|
37
|
-
add_message "bitcoin.grpc.Reorganized" do
|
38
|
-
optional :hash, :string, 1
|
39
|
-
optional :height, :uint32, 2
|
40
|
-
optional :orphan_block_hash, :string, 3
|
41
|
-
end
|
42
|
-
add_message "bitcoin.grpc.TxReceived" do
|
43
|
-
optional :tx_hash, :string, 1
|
44
|
-
optional :tx_payload, :string, 2
|
45
|
-
end
|
46
|
-
add_message "bitcoin.grpc.TxBroadcasted" do
|
47
|
-
optional :tx_hash, :string, 1
|
48
|
-
optional :tx_payload, :string, 2
|
49
|
-
end
|
50
|
-
add_message "bitcoin.grpc.UtxoRegistered" do
|
51
|
-
optional :tx_hash, :string, 1
|
52
|
-
optional :tx_payload, :string, 2
|
53
|
-
optional :utxo, :message, 3, "bitcoin.grpc.Utxo"
|
54
|
-
end
|
55
|
-
add_message "bitcoin.grpc.UtxoSpent" do
|
56
|
-
optional :tx_hash, :string, 1
|
57
|
-
optional :tx_payload, :string, 2
|
58
|
-
optional :utxo, :message, 3, "bitcoin.grpc.Utxo"
|
59
|
-
optional :out_point, :message, 4, "bitcoin.grpc.OutPoint"
|
60
|
-
end
|
61
|
-
add_message "bitcoin.grpc.WatchTxConfirmedRequest" do
|
62
|
-
optional :id, :uint32, 1
|
63
|
-
optional :tx_hash, :string, 2
|
64
|
-
optional :confirmations, :uint32, 3
|
65
|
-
end
|
66
|
-
add_message "bitcoin.grpc.WatchTxConfirmedResponse" do
|
67
|
-
optional :id, :uint32, 1
|
68
|
-
oneof :event do
|
69
|
-
optional :confirmed, :message, 2, "bitcoin.grpc.EventTxConfirmed"
|
12
|
+
add_message "bitcoin.grpc.EventsResponse" do
|
13
|
+
oneof :event do
|
14
|
+
optional :connect, :message, 1, "bitcoin.grpc.Connect"
|
15
|
+
optional :disconnect, :message, 2, "bitcoin.grpc.Disconnect"
|
16
|
+
optional :block_created, :message, 3, "bitcoin.grpc.BlockCreated"
|
17
|
+
optional :reorganized, :message, 4, "bitcoin.grpc.Reorganized"
|
18
|
+
optional :tx_received, :message, 5, "bitcoin.grpc.TxReceived"
|
19
|
+
optional :tx_broadcasted, :message, 6, "bitcoin.grpc.TxBroadcasted"
|
20
|
+
optional :utxo_registered, :message, 7, "bitcoin.grpc.UtxoRegistered"
|
21
|
+
optional :utxo_spent, :message, 8, "bitcoin.grpc.UtxoSpent"
|
22
|
+
end
|
70
23
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
optional :id, :uint32, 1
|
77
|
-
oneof :event do
|
78
|
-
optional :registered, :message, 2, "bitcoin.grpc.EventUtxoRegistered"
|
79
|
-
optional :spent, :message, 3, "bitcoin.grpc.EventUtxoSpent"
|
24
|
+
add_message "bitcoin.grpc.Connect" do
|
25
|
+
optional :host, :string, 1
|
26
|
+
optional :port, :uint32, 2
|
27
|
+
optional :local_version, :string, 3
|
28
|
+
optional :remote_version, :string, 4
|
80
29
|
end
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
optional :
|
101
|
-
|
102
|
-
|
30
|
+
add_message "bitcoin.grpc.Disconnect" do
|
31
|
+
optional :host, :string, 1
|
32
|
+
optional :port, :uint32, 2
|
33
|
+
end
|
34
|
+
add_message "bitcoin.grpc.BlockCreated" do
|
35
|
+
optional :hash, :string, 1
|
36
|
+
optional :height, :uint32, 2
|
37
|
+
end
|
38
|
+
add_message "bitcoin.grpc.Reorganized" do
|
39
|
+
optional :hash, :string, 1
|
40
|
+
optional :height, :uint32, 2
|
41
|
+
optional :orphan_block_hash, :string, 3
|
42
|
+
end
|
43
|
+
add_message "bitcoin.grpc.TxReceived" do
|
44
|
+
optional :tx_hash, :string, 1
|
45
|
+
optional :tx_payload, :string, 2
|
46
|
+
end
|
47
|
+
add_message "bitcoin.grpc.TxBroadcasted" do
|
48
|
+
optional :tx_hash, :string, 1
|
49
|
+
optional :tx_payload, :string, 2
|
50
|
+
end
|
51
|
+
add_message "bitcoin.grpc.UtxoRegistered" do
|
52
|
+
optional :tx_hash, :string, 1
|
53
|
+
optional :tx_payload, :string, 2
|
54
|
+
optional :utxo, :message, 3, "bitcoin.grpc.Utxo"
|
55
|
+
end
|
56
|
+
add_message "bitcoin.grpc.UtxoSpent" do
|
57
|
+
optional :tx_hash, :string, 1
|
58
|
+
optional :tx_payload, :string, 2
|
59
|
+
optional :utxo, :message, 3, "bitcoin.grpc.Utxo"
|
60
|
+
optional :out_point, :message, 4, "bitcoin.grpc.OutPoint"
|
61
|
+
end
|
62
|
+
add_message "bitcoin.grpc.WatchTxConfirmedRequest" do
|
63
|
+
optional :id, :uint32, 1
|
64
|
+
optional :tx_hash, :string, 2
|
65
|
+
optional :confirmations, :uint32, 3
|
66
|
+
end
|
67
|
+
add_message "bitcoin.grpc.WatchTxConfirmedResponse" do
|
68
|
+
optional :id, :uint32, 1
|
69
|
+
oneof :event do
|
70
|
+
optional :confirmed, :message, 2, "bitcoin.grpc.EventTxConfirmed"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
add_message "bitcoin.grpc.WatchUtxoRequest" do
|
74
|
+
optional :id, :uint32, 1
|
75
|
+
end
|
76
|
+
add_message "bitcoin.grpc.WatchUtxoResponse" do
|
77
|
+
optional :id, :uint32, 1
|
78
|
+
oneof :event do
|
79
|
+
optional :registered, :message, 2, "bitcoin.grpc.EventUtxoRegistered"
|
80
|
+
optional :spent, :message, 3, "bitcoin.grpc.EventUtxoSpent"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
add_message "bitcoin.grpc.WatchUtxoSpentRequest" do
|
84
|
+
optional :id, :uint32, 1
|
85
|
+
optional :tx_hash, :string, 2
|
86
|
+
optional :output_index, :uint32, 3
|
87
|
+
end
|
88
|
+
add_message "bitcoin.grpc.WatchUtxoSpentResponse" do
|
89
|
+
optional :id, :uint32, 1
|
90
|
+
optional :spent, :message, 2, "bitcoin.grpc.EventUtxoSpent"
|
91
|
+
end
|
92
|
+
add_message "bitcoin.grpc.WatchTokenRequest" do
|
93
|
+
optional :id, :uint32, 1
|
94
|
+
optional :asset_type, :uint32, 2
|
95
|
+
optional :asset_id, :string, 3
|
96
|
+
optional :tx_hash, :string, 4
|
97
|
+
end
|
98
|
+
add_message "bitcoin.grpc.WatchTokenResponse" do
|
99
|
+
optional :id, :uint32, 1
|
100
|
+
oneof :event do
|
101
|
+
optional :issued, :message, 2, "bitcoin.grpc.EventTokenIssued"
|
102
|
+
optional :transfered, :message, 3, "bitcoin.grpc.EventTokenTransfered"
|
103
|
+
optional :burned, :message, 4, "bitcoin.grpc.EventTokenBurned"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
add_message "bitcoin.grpc.WatchAssetIdAssignedRequest" do
|
107
|
+
optional :tx_hash, :string, 1
|
108
|
+
optional :tx_payload, :string, 2
|
109
|
+
end
|
110
|
+
add_message "bitcoin.grpc.GetBlockchainInfoRequest" do
|
111
|
+
end
|
112
|
+
add_message "bitcoin.grpc.GetBlockchainInfoResponse" do
|
113
|
+
optional :chain, :string, 1
|
114
|
+
optional :headers, :uint32, 2
|
115
|
+
optional :bestblockhash, :string, 3
|
116
|
+
optional :chainwork, :uint32, 4
|
117
|
+
optional :mediantime, :uint32, 5
|
118
|
+
end
|
119
|
+
add_message "bitcoin.grpc.ListUnspentRequest" do
|
120
|
+
optional :account_name, :string, 1
|
121
|
+
optional :min, :uint32, 2
|
122
|
+
optional :max, :uint32, 3
|
123
|
+
repeated :addresses, :string, 4
|
124
|
+
end
|
125
|
+
add_message "bitcoin.grpc.ListUnspentResponse" do
|
126
|
+
repeated :utxos, :message, 1, "bitcoin.grpc.Utxo"
|
127
|
+
end
|
128
|
+
add_message "bitcoin.grpc.ListColoredUnspentRequest" do
|
129
|
+
optional :account_name, :string, 1
|
130
|
+
optional :min, :uint32, 2
|
131
|
+
optional :max, :uint32, 3
|
132
|
+
optional :asset_type, :uint32, 4
|
133
|
+
optional :asset_id, :string, 5
|
134
|
+
end
|
135
|
+
add_message "bitcoin.grpc.ListColoredUnspentResponse" do
|
136
|
+
repeated :assets, :message, 1, "bitcoin.grpc.AssetOutput"
|
137
|
+
end
|
138
|
+
add_message "bitcoin.grpc.ListUncoloredUnspentRequest" do
|
139
|
+
optional :account_name, :string, 1
|
140
|
+
optional :min, :uint32, 2
|
141
|
+
optional :max, :uint32, 3
|
142
|
+
end
|
143
|
+
add_message "bitcoin.grpc.ListUncoloredUnspentResponse" do
|
144
|
+
repeated :utxos, :message, 1, "bitcoin.grpc.Utxo"
|
145
|
+
end
|
146
|
+
add_message "bitcoin.grpc.EventTxConfirmed" do
|
147
|
+
optional :request_id, :uint32, 1
|
148
|
+
optional :tx_hash, :string, 2
|
149
|
+
optional :tx_payload, :string, 3
|
150
|
+
optional :block_height, :uint32, 4
|
151
|
+
optional :tx_index, :uint32, 5
|
152
|
+
optional :confirmations, :uint32, 6
|
153
|
+
end
|
154
|
+
add_message "bitcoin.grpc.EventUtxoRegistered" do
|
155
|
+
optional :request_id, :uint32, 1
|
156
|
+
optional :tx_hash, :string, 2
|
157
|
+
optional :tx_payload, :string, 3
|
158
|
+
optional :utxo, :message, 4, "bitcoin.grpc.Utxo"
|
159
|
+
end
|
160
|
+
add_message "bitcoin.grpc.EventUtxoSpent" do
|
161
|
+
optional :request_id, :uint32, 1
|
162
|
+
optional :tx_hash, :string, 2
|
163
|
+
optional :tx_payload, :string, 3
|
164
|
+
optional :utxo, :message, 4, "bitcoin.grpc.Utxo"
|
165
|
+
optional :out_point, :message, 5, "bitcoin.grpc.OutPoint"
|
166
|
+
end
|
167
|
+
add_message "bitcoin.grpc.EventTokenIssued" do
|
168
|
+
optional :request_id, :uint32, 1
|
169
|
+
optional :asset, :message, 2, "bitcoin.grpc.AssetOutput"
|
170
|
+
end
|
171
|
+
add_message "bitcoin.grpc.EventTokenTransfered" do
|
172
|
+
optional :request_id, :uint32, 1
|
173
|
+
optional :asset, :message, 2, "bitcoin.grpc.AssetOutput"
|
174
|
+
end
|
175
|
+
add_message "bitcoin.grpc.EventTokenBurned" do
|
176
|
+
optional :request_id, :uint32, 1
|
177
|
+
optional :asset, :message, 4, "bitcoin.grpc.AssetOutput"
|
178
|
+
end
|
179
|
+
add_message "bitcoin.grpc.OutPoint" do
|
180
|
+
optional :tx_hash, :string, 1
|
181
|
+
optional :index, :uint32, 2
|
182
|
+
end
|
183
|
+
add_message "bitcoin.grpc.Utxo" do
|
184
|
+
optional :tx_hash, :string, 1
|
185
|
+
optional :index, :uint32, 2
|
186
|
+
optional :block_height, :uint32, 3
|
187
|
+
optional :value, :uint64, 4
|
188
|
+
optional :script_pubkey, :string, 5
|
189
|
+
end
|
190
|
+
add_message "bitcoin.grpc.AssetOutput" do
|
191
|
+
optional :asset_type, :uint32, 1
|
192
|
+
optional :asset_id, :string, 2
|
193
|
+
optional :asset_quantity, :uint64, 3
|
194
|
+
optional :tx_hash, :string, 4
|
195
|
+
optional :index, :uint32, 5
|
196
|
+
optional :block_height, :uint32, 6
|
197
|
+
optional :value, :uint64, 7
|
198
|
+
optional :script_pubkey, :string, 8
|
199
|
+
end
|
200
|
+
add_enum "bitcoin.grpc.Operation" do
|
201
|
+
value :SUBSCRIBE, 0
|
202
|
+
value :UNSUBSCRIBE, 1
|
103
203
|
end
|
104
|
-
end
|
105
|
-
add_message "bitcoin.grpc.WatchAssetIdAssignedRequest" do
|
106
|
-
optional :tx_hash, :string, 1
|
107
|
-
optional :tx_payload, :string, 2
|
108
|
-
end
|
109
|
-
add_message "bitcoin.grpc.GetBlockchainInfoRequest" do
|
110
|
-
end
|
111
|
-
add_message "bitcoin.grpc.GetBlockchainInfoResponse" do
|
112
|
-
optional :chain, :string, 1
|
113
|
-
optional :headers, :uint32, 2
|
114
|
-
optional :bestblockhash, :string, 3
|
115
|
-
optional :chainwork, :uint32, 4
|
116
|
-
optional :mediantime, :uint32, 5
|
117
|
-
end
|
118
|
-
add_message "bitcoin.grpc.EventTxConfirmed" do
|
119
|
-
optional :request_id, :uint32, 1
|
120
|
-
optional :tx_hash, :string, 2
|
121
|
-
optional :tx_payload, :string, 3
|
122
|
-
optional :block_height, :uint32, 4
|
123
|
-
optional :tx_index, :uint32, 5
|
124
|
-
optional :confirmations, :uint32, 6
|
125
|
-
end
|
126
|
-
add_message "bitcoin.grpc.EventUtxoRegistered" do
|
127
|
-
optional :request_id, :uint32, 1
|
128
|
-
optional :tx_hash, :string, 2
|
129
|
-
optional :tx_payload, :string, 3
|
130
|
-
optional :utxo, :message, 4, "bitcoin.grpc.Utxo"
|
131
|
-
end
|
132
|
-
add_message "bitcoin.grpc.EventUtxoSpent" do
|
133
|
-
optional :request_id, :uint32, 1
|
134
|
-
optional :tx_hash, :string, 2
|
135
|
-
optional :tx_payload, :string, 3
|
136
|
-
optional :utxo, :message, 4, "bitcoin.grpc.Utxo"
|
137
|
-
optional :out_point, :message, 5, "bitcoin.grpc.OutPoint"
|
138
|
-
end
|
139
|
-
add_message "bitcoin.grpc.EventTokenIssued" do
|
140
|
-
optional :request_id, :uint32, 1
|
141
|
-
optional :asset, :message, 2, "bitcoin.grpc.AssetOutput"
|
142
|
-
end
|
143
|
-
add_message "bitcoin.grpc.EventTokenTransfered" do
|
144
|
-
optional :request_id, :uint32, 1
|
145
|
-
optional :asset, :message, 2, "bitcoin.grpc.AssetOutput"
|
146
|
-
end
|
147
|
-
add_message "bitcoin.grpc.EventTokenBurned" do
|
148
|
-
optional :request_id, :uint32, 1
|
149
|
-
optional :asset, :message, 4, "bitcoin.grpc.AssetOutput"
|
150
|
-
end
|
151
|
-
add_message "bitcoin.grpc.OutPoint" do
|
152
|
-
optional :tx_hash, :string, 1
|
153
|
-
optional :index, :uint32, 2
|
154
|
-
end
|
155
|
-
add_message "bitcoin.grpc.Utxo" do
|
156
|
-
optional :tx_hash, :string, 1
|
157
|
-
optional :index, :uint32, 2
|
158
|
-
optional :block_height, :uint32, 3
|
159
|
-
optional :value, :uint64, 4
|
160
|
-
optional :script_pubkey, :string, 5
|
161
|
-
end
|
162
|
-
add_message "bitcoin.grpc.AssetOutput" do
|
163
|
-
optional :asset_type, :uint32, 1
|
164
|
-
optional :asset_id, :string, 2
|
165
|
-
optional :asset_quantity, :uint64, 3
|
166
|
-
optional :tx_hash, :string, 4
|
167
|
-
optional :index, :uint32, 5
|
168
|
-
optional :block_height, :uint32, 6
|
169
|
-
end
|
170
|
-
add_enum "bitcoin.grpc.Operation" do
|
171
|
-
value :SUBSCRIBE, 0
|
172
|
-
value :UNSUBSCRIBE, 1
|
173
204
|
end
|
174
205
|
end
|
175
206
|
|
@@ -196,6 +227,12 @@ module Bitcoin
|
|
196
227
|
WatchAssetIdAssignedRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.WatchAssetIdAssignedRequest").msgclass
|
197
228
|
GetBlockchainInfoRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.GetBlockchainInfoRequest").msgclass
|
198
229
|
GetBlockchainInfoResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.GetBlockchainInfoResponse").msgclass
|
230
|
+
ListUnspentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.ListUnspentRequest").msgclass
|
231
|
+
ListUnspentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.ListUnspentResponse").msgclass
|
232
|
+
ListColoredUnspentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.ListColoredUnspentRequest").msgclass
|
233
|
+
ListColoredUnspentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.ListColoredUnspentResponse").msgclass
|
234
|
+
ListUncoloredUnspentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.ListUncoloredUnspentRequest").msgclass
|
235
|
+
ListUncoloredUnspentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.ListUncoloredUnspentResponse").msgclass
|
199
236
|
EventTxConfirmed = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.EventTxConfirmed").msgclass
|
200
237
|
EventUtxoRegistered = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.EventUtxoRegistered").msgclass
|
201
238
|
EventUtxoSpent = Google::Protobuf::DescriptorPool.generated_pool.lookup("bitcoin.grpc.EventUtxoSpent").msgclass
|
@@ -21,6 +21,9 @@ module Bitcoin
|
|
21
21
|
rpc :WatchToken, WatchTokenRequest, stream(WatchTokenResponse)
|
22
22
|
rpc :GetBlockchainInfo, GetBlockchainInfoRequest, GetBlockchainInfoResponse
|
23
23
|
rpc :Events, stream(EventsRequest), stream(EventsResponse)
|
24
|
+
rpc :ListUnspent, ListUnspentRequest, ListUnspentResponse
|
25
|
+
rpc :ListColoredUnspent, ListColoredUnspentRequest, ListColoredUnspentResponse
|
26
|
+
rpc :ListUncoloredUnspent, ListUncoloredUnspentRequest, ListUncoloredUnspentResponse
|
24
27
|
end
|
25
28
|
|
26
29
|
Stub = Service.rpc_stub_class
|
data/lib/bitcoin/grpc/server.rb
CHANGED
@@ -96,6 +96,30 @@ module Bitcoin
|
|
96
96
|
logger.error("events: #{e.message}")
|
97
97
|
logger.error("events: #{e.backtrace}")
|
98
98
|
end
|
99
|
+
|
100
|
+
def list_unspent(request, _call)
|
101
|
+
logger.info("list_unspent: #{request}")
|
102
|
+
Bitcoin::Grpc::Api::ListUnspent.new(spv).execute(request)
|
103
|
+
rescue => e
|
104
|
+
logger.error("list_unspent: #{e.message}")
|
105
|
+
logger.error("list_unspent: #{e.backtrace}")
|
106
|
+
end
|
107
|
+
|
108
|
+
def list_colored_unspent(request, _call)
|
109
|
+
logger.info("list_colored_unspent: #{request}")
|
110
|
+
Bitcoin::Grpc::Api::ListColoredUnspent.new(spv).execute(request)
|
111
|
+
rescue => e
|
112
|
+
logger.error("list_colored_unspent: #{e.message}")
|
113
|
+
logger.error("list_colored_unspent: #{e.backtrace}")
|
114
|
+
end
|
115
|
+
|
116
|
+
def list_uncolored_unspent(request, _call)
|
117
|
+
logger.info("list_uncolored_unspent: #{request}")
|
118
|
+
Bitcoin::Grpc::Api::ListUncoloredUnspent.new(spv).execute(request)
|
119
|
+
rescue => e
|
120
|
+
logger.error("list_uncolored_unspent: #{e.message}")
|
121
|
+
logger.error("list_uncolored_unspent: #{e.backtrace}")
|
122
|
+
end
|
99
123
|
end
|
100
124
|
|
101
125
|
class EventsReceiver < Concurrent::Actor::Context
|
data/lib/bitcoin/grpc/version.rb
CHANGED
@@ -20,7 +20,9 @@ module Bitcoin
|
|
20
20
|
asset_quantity: asset_quantity,
|
21
21
|
tx_hash: utxo.tx_hash,
|
22
22
|
index: utxo.index,
|
23
|
-
block_height: utxo.block_height
|
23
|
+
block_height: utxo.block_height,
|
24
|
+
value: utxo.value,
|
25
|
+
script_pubkey: utxo.script_pubkey
|
24
26
|
)
|
25
27
|
out_point = Bitcoin::OutPoint.new(utxo.tx_hash, utxo.index)
|
26
28
|
payload = asset_output.to_proto.bth
|
@@ -10,6 +10,9 @@ service Blockchain {
|
|
10
10
|
rpc WatchToken(WatchTokenRequest) returns (stream WatchTokenResponse);
|
11
11
|
rpc GetBlockchainInfo(GetBlockchainInfoRequest) returns (GetBlockchainInfoResponse);
|
12
12
|
rpc Events(stream EventsRequest) returns (stream EventsResponse);
|
13
|
+
rpc ListUnspent(ListUnspentRequest) returns (ListUnspentResponse);
|
14
|
+
rpc ListColoredUnspent(ListColoredUnspentRequest) returns (ListColoredUnspentResponse);
|
15
|
+
rpc ListUncoloredUnspent(ListUncoloredUnspentRequest) returns (ListUncoloredUnspentResponse);
|
13
16
|
}
|
14
17
|
|
15
18
|
enum Operation {
|
@@ -150,6 +153,39 @@ message GetBlockchainInfoResponse {
|
|
150
153
|
uint32 mediantime = 5;
|
151
154
|
}
|
152
155
|
|
156
|
+
message ListUnspentRequest {
|
157
|
+
string account_name = 1;
|
158
|
+
uint32 min = 2;
|
159
|
+
uint32 max = 3;
|
160
|
+
repeated string addresses = 4;
|
161
|
+
}
|
162
|
+
|
163
|
+
message ListUnspentResponse {
|
164
|
+
repeated Utxo utxos = 1;
|
165
|
+
}
|
166
|
+
|
167
|
+
message ListColoredUnspentRequest {
|
168
|
+
string account_name = 1;
|
169
|
+
uint32 min = 2;
|
170
|
+
uint32 max = 3;
|
171
|
+
uint32 asset_type = 4;
|
172
|
+
string asset_id = 5;
|
173
|
+
}
|
174
|
+
|
175
|
+
message ListColoredUnspentResponse {
|
176
|
+
repeated AssetOutput assets = 1;
|
177
|
+
}
|
178
|
+
|
179
|
+
message ListUncoloredUnspentRequest {
|
180
|
+
string account_name = 1;
|
181
|
+
uint32 min = 2;
|
182
|
+
uint32 max = 3;
|
183
|
+
}
|
184
|
+
|
185
|
+
message ListUncoloredUnspentResponse {
|
186
|
+
repeated Utxo utxos = 1;
|
187
|
+
}
|
188
|
+
|
153
189
|
message EventTxConfirmed {
|
154
190
|
uint32 request_id = 1;
|
155
191
|
string tx_hash = 2;
|
@@ -209,4 +245,6 @@ message AssetOutput {
|
|
209
245
|
string tx_hash = 4;
|
210
246
|
uint32 index = 5;
|
211
247
|
uint32 block_height = 6;
|
248
|
+
uint64 value = 7;
|
249
|
+
string script_pubkey = 8;
|
212
250
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitcoinrb-grpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hajime Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -171,6 +171,10 @@ files:
|
|
171
171
|
- bitcoinrb-grpc.gemspec
|
172
172
|
- config.yml
|
173
173
|
- lib/bitcoin/grpc.rb
|
174
|
+
- lib/bitcoin/grpc/api.rb
|
175
|
+
- lib/bitcoin/grpc/api/list_colored_unspent.rb
|
176
|
+
- lib/bitcoin/grpc/api/list_uncolored_unspent.rb
|
177
|
+
- lib/bitcoin/grpc/api/list_unspent.rb
|
174
178
|
- lib/bitcoin/grpc/grpc_pb.rb
|
175
179
|
- lib/bitcoin/grpc/grpc_services_pb.rb
|
176
180
|
- lib/bitcoin/grpc/oap_service.rb
|