Class: Node::Channels

Inherits:
Object
  • Object
show all
Includes:
Lnd
Defined in:
lib/node.rb

Instance Method Summary collapse

Instance Method Details

#channel_balanceObject



77
78
79
# File 'lib/node.rb', line 77

def channel_balance
  stub.channel_balance(Lnrpc::ChannelBalanceRequest.new())
end

#close_channel(channel_point) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/node.rb', line 59

def close_channel(channel_point)

  cp = Lnrpc::ChannelPoint.new(funding_txid_str: channel_point)

  stub.close_channel(Lnrpc::CloseChannelRequest.new(channel_point: cp,
                                                    force: true,
                                                    target_conf: 6,
                                                    sat_per_byte: 150000))
end

#close_channelsObject



70
71
72
73
74
75
# File 'lib/node.rb', line 70

def close_channels
  Node::Payments.new.list_channels["channels"].map do |r|
    puts "Closing #{r["channel_point"]}"
    Node::Payments.new.close_channel( r["channel_point"] )
  end
end

#fee_reportObject



98
99
100
# File 'lib/node.rb', line 98

def fee_report
  stub.fee_report(Lnrpc::FeeReportRequest.new())
end

#get_chain_info(chain_id) ⇒ Object



89
90
91
92
# File 'lib/node.rb', line 89

def get_chain_info(chain_id)
  # TODO: ERROR OUT
  stub.get_chain_info(Lnrpc::ChainInfoRequest.new(chain_id: chain_id))
end

#get_network_infoObject



94
95
96
# File 'lib/node.rb', line 94

def get_network_info
  stub.get_network_info(Lnrpc::FeeReportRequest.new())
end

#list_channelsObject



85
86
87
# File 'lib/node.rb', line 85

def list_channels
  stub.list_channels(Lnrpc::ListChannelsRequest.new())
end

#open_channel(addr, amt) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/node.rb', line 43

def open_channel(addr, amt)

  r = addr.split("@")
  pubkey = r[0]
  host = r[1]


  hex = bin_to_hex(pubkey)

  request = Lnrpc::OpenChannelRequest.new(node_pubkey_string: pubkey,
                                          local_funding_amount: amt, 
                                          push_sat: (amt / 100))

  r = stub.open_channel_sync(request)
end

#pending_channelsObject



81
82
83
# File 'lib/node.rb', line 81

def pending_channels
  stub.pending_channels(Lnrpc::PendingChannelsRequest.new())
end

#update_chan_policyObject



102
103
104
105
# File 'lib/node.rb', line 102

def update_chan_policy
  # TODO: Raise won't do
  raise "won't do :) "
end