huginn_lnd_node_info_agent 0.1.10
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 +7 -0
- data/LICENSE.txt +7 -0
- data/lib/huginn_lnd_node_info_agent/lnd_node_info_agent.rb +230 -0
- data/lib/huginn_lnd_node_info_agent.rb +4 -0
- data/spec/lnd_node_info_agent_spec.rb +13 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c7c3b5b8bc6e490358c405e3044794c0533c685d12fdb566025d82d6daf990b0
|
4
|
+
data.tar.gz: 79d71cdce5c4d77a5023c28c6de380f7190cf597a98be323f524329c7128cd50
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 07060472cf084aea28c7bcd7f7471652f629b0a62c8845d0873359c5b7fc775486149a5504ea6a9d5f6c9abdccaa49f8ebf6d55dadcfdb3355156ab83936bb45
|
7
|
+
data.tar.gz: a18c604f5721fadc34a6bec4085c3d51618c9362045ef442e4d5952e616db6f3858817f7428a843866f94c98154c7fc183353e2d0f7fd0ddedd7abfcfefaf3fa
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2020 Nicolas Germain
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,230 @@
|
|
1
|
+
module Agents
|
2
|
+
class LndNodeInfoAgent < Agent
|
3
|
+
include FormConfigurable
|
4
|
+
can_dry_run!
|
5
|
+
no_bulk_receive!
|
6
|
+
default_schedule 'every_1h'
|
7
|
+
|
8
|
+
description do
|
9
|
+
<<-MD
|
10
|
+
The Github notification agent fetches notifications and creates an event by notification.
|
11
|
+
|
12
|
+
`mark_as_read` is used to post request for mark as read notification.
|
13
|
+
|
14
|
+
`result_limit` is used when you want to limit result per page.
|
15
|
+
|
16
|
+
`real_value` is used for calculating token value with the tokenDecimal applied.
|
17
|
+
|
18
|
+
`debug` is used for verbose mode.
|
19
|
+
|
20
|
+
`with_confirmations` is used to avoid an event as soon as it increases.
|
21
|
+
|
22
|
+
`type` can be tokentx type (you can see api documentation).
|
23
|
+
Get a list of "ERC20 - Token Transfer Events" by Address
|
24
|
+
|
25
|
+
`expected_receive_period_in_days` is used to determine if the Agent is working. Set it to the maximum number of days
|
26
|
+
that you anticipate passing without this Agent receiving an incoming Event.
|
27
|
+
MD
|
28
|
+
end
|
29
|
+
|
30
|
+
event_description <<-MD
|
31
|
+
Events look like this:
|
32
|
+
|
33
|
+
{
|
34
|
+
"version": {
|
35
|
+
"version": "0.11.0-beta commit=",
|
36
|
+
"commit_hash": "",
|
37
|
+
"identity_pubkey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
38
|
+
"alias": "XXXXXXXXXXX",
|
39
|
+
"color": "XXXXXXX",
|
40
|
+
"num_pending_channels": 0,
|
41
|
+
"num_active_channels": 5,
|
42
|
+
"num_inactive_channels": 0,
|
43
|
+
"num_peers": 5,
|
44
|
+
"block_height": 644844,
|
45
|
+
"block_hash": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
46
|
+
"best_header_timestamp": "1598100386",
|
47
|
+
"synced_to_chain": true,
|
48
|
+
"synced_to_graph": true,
|
49
|
+
"testnet": false,
|
50
|
+
"chains": [
|
51
|
+
{
|
52
|
+
"chain": "bitcoin",
|
53
|
+
"network": "mainnet"
|
54
|
+
}
|
55
|
+
],
|
56
|
+
"uris": [
|
57
|
+
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
58
|
+
],
|
59
|
+
"features": {
|
60
|
+
"0": {
|
61
|
+
"name": "data-loss-protect",
|
62
|
+
"is_required": true,
|
63
|
+
"is_known": true
|
64
|
+
},
|
65
|
+
"5": {
|
66
|
+
"name": "upfront-shutdown-script",
|
67
|
+
"is_required": false,
|
68
|
+
"is_known": true
|
69
|
+
},
|
70
|
+
"7": {
|
71
|
+
"name": "gossip-queries",
|
72
|
+
"is_required": false,
|
73
|
+
"is_known": true
|
74
|
+
},
|
75
|
+
"9": {
|
76
|
+
"name": "tlv-onion",
|
77
|
+
"is_required": false,
|
78
|
+
"is_known": true
|
79
|
+
},
|
80
|
+
"13": {
|
81
|
+
"name": "static-remote-key",
|
82
|
+
"is_required": false,
|
83
|
+
"is_known": true
|
84
|
+
},
|
85
|
+
"15": {
|
86
|
+
"name": "payment-addr",
|
87
|
+
"is_required": false,
|
88
|
+
"is_known": true
|
89
|
+
},
|
90
|
+
"17": {
|
91
|
+
"name": "multi-path-payments",
|
92
|
+
"is_required": false,
|
93
|
+
"is_known": true
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
MD
|
99
|
+
|
100
|
+
def default_options
|
101
|
+
{
|
102
|
+
'url' => '',
|
103
|
+
'changes_only' => 'true',
|
104
|
+
'expected_receive_period_in_days' => '2',
|
105
|
+
'debug' => 'false',
|
106
|
+
'macaroon' => '',
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
form_configurable :url, type: :string
|
111
|
+
form_configurable :changes_only, type: :boolean
|
112
|
+
form_configurable :macaroon, type: :string
|
113
|
+
form_configurable :debug, type: :boolean
|
114
|
+
form_configurable :expected_receive_period_in_days, type: :string
|
115
|
+
|
116
|
+
def validate_options
|
117
|
+
unless options['url'].present?
|
118
|
+
errors.add(:base, "url is a required field")
|
119
|
+
end
|
120
|
+
|
121
|
+
if options.has_key?('changes_only') && boolify(options['changes_only']).nil?
|
122
|
+
errors.add(:base, "if provided, changes_only must be true or false")
|
123
|
+
end
|
124
|
+
|
125
|
+
if options.has_key?('debug') && boolify(options['debug']).nil?
|
126
|
+
errors.add(:base, "if provided, debug must be true or false")
|
127
|
+
end
|
128
|
+
|
129
|
+
unless options['macaroon'].present?
|
130
|
+
errors.add(:base, "macaroon is a required field")
|
131
|
+
end
|
132
|
+
|
133
|
+
unless options['expected_receive_period_in_days'].present? && options['expected_receive_period_in_days'].to_i > 0
|
134
|
+
errors.add(:base, "Please provide 'expected_receive_period_in_days' to indicate how many days can pass before this Agent is considered to be not working")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def working?
|
139
|
+
event_created_within?(options['expected_receive_period_in_days']) && !recent_error_logs?
|
140
|
+
end
|
141
|
+
|
142
|
+
def check
|
143
|
+
fetch
|
144
|
+
end
|
145
|
+
|
146
|
+
private
|
147
|
+
|
148
|
+
def log_curl_output(code,body)
|
149
|
+
|
150
|
+
log "request status : #{code}"
|
151
|
+
|
152
|
+
if interpolated['debug'] == 'true'
|
153
|
+
log "request status : #{code}"
|
154
|
+
log "body"
|
155
|
+
log body
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
def fetch
|
161
|
+
uri = URI.parse("#{interpolated['url']}/v1/getinfo")
|
162
|
+
request = Net::HTTP::Get.new(uri)
|
163
|
+
request["Grpc-Metadata-Macaroon"] = "#{interpolated['macaroon']}"
|
164
|
+
|
165
|
+
req_options = {
|
166
|
+
use_ssl: uri.scheme == "https",
|
167
|
+
verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
168
|
+
}
|
169
|
+
|
170
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
171
|
+
http.request(request)
|
172
|
+
end
|
173
|
+
|
174
|
+
log_curl_output(response.code,response.body)
|
175
|
+
|
176
|
+
payload_ori = JSON.parse(response.body)
|
177
|
+
payload = payload_ori.dup
|
178
|
+
|
179
|
+
if interpolated['changes_only'] == 'true'
|
180
|
+
if payload != memory['last_status']
|
181
|
+
if "#{memory['last_status']}" == ''
|
182
|
+
create_event payload: payload
|
183
|
+
else
|
184
|
+
last_status = memory['last_status']
|
185
|
+
found = false
|
186
|
+
if payload['num_active_channels'] != last_status['num_active_channels']
|
187
|
+
payload[:num_active_channels_changed] = true
|
188
|
+
found = true
|
189
|
+
if interpolated['debug'] == 'true'
|
190
|
+
log "number of active channels changed"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
if payload['num_inactive_channels'] != last_status['num_inactive_channels']
|
194
|
+
payload[:num_inactive_channels_changed] = true
|
195
|
+
found = true
|
196
|
+
if interpolated['debug'] == 'true'
|
197
|
+
log "number of inactive channels changed"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
if payload['version'] != last_status['version']
|
201
|
+
payload[:version_changed] = true
|
202
|
+
found = true
|
203
|
+
if interpolated['debug'] == 'true'
|
204
|
+
log "version changed"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
if payload['identity_pubkey'] != last_status['identity_pubkey']
|
208
|
+
payload[:identity_pubkey_changed] = true
|
209
|
+
if interpolated['debug'] == 'true'
|
210
|
+
log "identity pubkey changed"
|
211
|
+
end
|
212
|
+
found = true
|
213
|
+
end
|
214
|
+
if found == true
|
215
|
+
create_event payload: payload
|
216
|
+
end
|
217
|
+
end
|
218
|
+
memory['last_status'] = payload_ori
|
219
|
+
else
|
220
|
+
log "no diff"
|
221
|
+
end
|
222
|
+
else
|
223
|
+
create_event payload: payload
|
224
|
+
if payload != memory['last_status']
|
225
|
+
memory['last_status'] = payload_ori
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
require 'huginn_agent/spec_helper'
|
3
|
+
|
4
|
+
describe Agents::LndNodeInfoAgent do
|
5
|
+
before(:each) do
|
6
|
+
@valid_options = Agents::LndNodeInfoAgent.new.default_options
|
7
|
+
@checker = Agents::LndNodeInfoAgent.new(:name => "LndNodeInfoAgent", :options => @valid_options)
|
8
|
+
@checker.user = users(:bob)
|
9
|
+
@checker.save!
|
10
|
+
end
|
11
|
+
|
12
|
+
pending "add specs here"
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: huginn_lnd_node_info_agent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicolas Germain
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 12.3.3
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 12.3.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: huginn_agent
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Write a longer description or delete this line.
|
56
|
+
email:
|
57
|
+
- ngermain@hihouhou.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- LICENSE.txt
|
63
|
+
- lib/huginn_lnd_node_info_agent.rb
|
64
|
+
- lib/huginn_lnd_node_info_agent/lnd_node_info_agent.rb
|
65
|
+
- spec/lnd_node_info_agent_spec.rb
|
66
|
+
homepage: https://github.com/hihouhou/huginn_lnd_node_info_agent
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.3.3
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Write a short summary, because Rubygems requires one.
|
89
|
+
test_files:
|
90
|
+
- spec/lnd_node_info_agent_spec.rb
|