Class: LND::Tool::HTLCEventCapture

Inherits:
Object
  • Object
show all
Defined in:
lib/lnd/tool/htlc_event_capture.rb

Overview

Use SubscribeHtlcEvents to get HTLC events from LND and store them in the DB.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ HTLCEventCapture

Returns a new instance of HTLCEventCapture.



9
10
11
12
13
14
15
# File 'lib/lnd/tool/htlc_event_capture.rb', line 9

def initialize(config)
  @client = Lnrpc::Client.new({
                                credentials_path: config['credentials_path'],
                                macaroon_path: config['macaroon_path'],
                                address: "#{config['host']}:#{config['port']}"
                              })
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/lnd/tool/htlc_event_capture.rb', line 7

def client
  @client
end

Instance Method Details

#startObject

Start capture.



18
19
20
21
22
23
24
# File 'lib/lnd/tool/htlc_event_capture.rb', line 18

def start
  store = Store::HTLCEvent.new
  client.router.subscribe_htlc_events.each do |htlc_event|
    puts htlc_event
    store.save(htlc_event)
  end
end