mirror of https://github.com/bumi/lnrpc
Merge branch 'master' into v0.14.1-beta
This commit is contained in:
commit
df9165414f
|
@ -24,7 +24,7 @@ Or install it yourself as:
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
This gem makes the gRPC client classes created from the [LND service defintions](https://github.com/lightningnetwork/lnd/tree/master/lnrpc) available.
|
This gem makes the gRPC client classes created from the [LND service definitions](https://github.com/lightningnetwork/lnd/tree/master/lnrpc) available.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
require "lnrpc"
|
require "lnrpc"
|
||||||
|
@ -32,7 +32,7 @@ require "lnrpc"
|
||||||
# With the changes in LND v.10.0 this load the `Lnrpc` and `Routerrpc` namespace
|
# With the changes in LND v.10.0 this load the `Lnrpc` and `Routerrpc` namespace
|
||||||
|
|
||||||
Lnrpc::Lightning::Stub
|
Lnrpc::Lightning::Stub
|
||||||
Routerrpc:::Routerrpc::Stub
|
Routerrpc::Routerrpc::Stub
|
||||||
Lnrpc::GetInfoRequest
|
Lnrpc::GetInfoRequest
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
@ -75,7 +75,7 @@ lnd = Lnrpc::Client.new({credentials_path: '/path/to.cert.cls', macaroon_path: '
|
||||||
lnd.lightning # => Lnrpc::Lightning::Stub
|
lnd.lightning # => Lnrpc::Lightning::Stub
|
||||||
lnd.router # => Lnrpc::Router::Stub
|
lnd.router # => Lnrpc::Router::Stub
|
||||||
|
|
||||||
lnd.ligthning.get_info
|
lnd.lightning.get_info
|
||||||
```
|
```
|
||||||
|
|
||||||
Also have a look at [examples.rb](https://github.com/bumi/lnrpc/blob/master/examples.rb)
|
Also have a look at [examples.rb](https://github.com/bumi/lnrpc/blob/master/examples.rb)
|
||||||
|
@ -130,7 +130,7 @@ client.lightning.grpc.list_channels(request)
|
||||||
|
|
||||||
client.lightning.wallet_balance.total_balance
|
client.lightning.wallet_balance.total_balance
|
||||||
# is the same as:
|
# is the same as:
|
||||||
request = Lnrpc::WalletBalanceRequest.new()
|
request = Lnrpc::WalletBalanceRequest.new
|
||||||
client.lightning.grpc.wallet_balance(request).total_balance
|
client.lightning.grpc.wallet_balance(request).total_balance
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
39
examples.rb
39
examples.rb
|
@ -21,6 +21,41 @@ puts lnd.versioner.get_version
|
||||||
puts lnd.wallet_kit.estimate_fee(conf_target: 10)
|
puts lnd.wallet_kit.estimate_fee(conf_target: 10)
|
||||||
puts lnd.wallet_kit.next_addr
|
puts lnd.wallet_kit.next_addr
|
||||||
|
|
||||||
|
lnd.lightning.subscribe_invoices(settle_index: 1).each do |invoice|
|
||||||
|
puts invoice.payment_request
|
||||||
|
end
|
||||||
|
|
||||||
|
# sign a message with your node
|
||||||
|
signed_message = lnd.lightning.sign_message({ msg: "Money printer goes brrr" })
|
||||||
|
puts "Signature: " + signed_message.signature
|
||||||
|
|
||||||
|
# verify a signed message by another node
|
||||||
|
verification_response = lnd.lightning.verify_message({
|
||||||
|
msg: "Money printer goes brrr",
|
||||||
|
signature: signed_message.signature
|
||||||
|
})
|
||||||
|
puts "Pubkey: " + verification_response.pubkey # pubkey of the node that signed
|
||||||
|
puts "Valid: " + verification_response.valid.to_s
|
||||||
|
|
||||||
|
# get information on a node
|
||||||
|
node_info_response = lnd.lightning.get_node_info(pub_key: verification_response.pubkey, include_channels: true)
|
||||||
|
puts "Updated: " + Time.at(node_info_response.node.last_update).to_s
|
||||||
|
puts "Pubkey: " + node_info_response.node.pub_key.to_s
|
||||||
|
puts "Alias: " + node_info_response.node.alias.to_s
|
||||||
|
puts "Color: " + node_info_response.node.color.to_s
|
||||||
|
puts "Channels: " + node_info_response.num_channels.to_s
|
||||||
|
puts "Capacity SAT: " + node_info_response.total_capacity.to_s
|
||||||
|
puts "Address: " + node_info_response.node.addresses.first["addr"].to_s
|
||||||
|
|
||||||
|
# extract channel information
|
||||||
|
node_info_response.channels.each do |channel|
|
||||||
|
puts "Channel ID: " + channel["channel_id"].to_s
|
||||||
|
puts "Channel 1:" + channel["node1_pub"].to_s # pubkey of the first node
|
||||||
|
puts "Channel 2:" + channel["node2_pub"].to_s # pubkey of the second node
|
||||||
|
puts "Channel Capacity:" + channel["capacity"].to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
# update channel policy
|
||||||
channel = lnd.lightning.list_channels.channels[0]
|
channel = lnd.lightning.list_channels.channels[0]
|
||||||
puts lnd.lightning.get_chan_info(chan_id: channel.chan_id)
|
puts lnd.lightning.get_chan_info(chan_id: channel.chan_id)
|
||||||
channel_point = {
|
channel_point = {
|
||||||
|
@ -32,7 +67,3 @@ lnd.lightning.update_channel_policy({
|
||||||
base_fee_msat: 1100,
|
base_fee_msat: 1100,
|
||||||
chan_point: channel_point
|
chan_point: channel_point
|
||||||
})
|
})
|
||||||
|
|
||||||
#lnd.lightning.subscribe_invoices(settle_index: 1).each do |invoice|
|
|
||||||
# puts invoice.payment_request
|
|
||||||
#end
|
|
||||||
|
|
Loading…
Reference in New Issue