rpc: add channel reserve fields in RPC responses.

In this commit two fields were added to the Channl RPC result in both
open and pending states.
The fields: local_chan_reserve, remote_chan_reserve represents the
reservation the nodes are rquired to keep in both sides of the channel.
This is usefull when calculating the "real" inbound and outbound
liquidity in an accurate way.
This commit is contained in:
Roei Erez 2019-06-23 13:06:09 +03:00
parent 7a5247b766
commit 404abcbd04
4 changed files with 585 additions and 502 deletions

File diff suppressed because it is too large Load diff

View file

@ -1161,6 +1161,14 @@ message Channel {
/// A set of flags showing the current state of the channel.
string chan_status_flags = 19 [json_name = "chan_status_flags"];
/// The minimum satoshis this node is required to reserve in its balance.
int64 local_chan_reserve_sat = 20 [json_name = "local_chan_reserve_sat"];
/**
The minimum satoshis the other node is required to reserve in its balance.
*/
int64 remote_chan_reserve_sat = 21 [json_name = "remote_chan_reserve_sat"];
}
@ -1468,6 +1476,15 @@ message PendingChannelsResponse {
int64 local_balance = 4 [ json_name = "local_balance" ];
int64 remote_balance = 5 [ json_name = "remote_balance" ];
/// The minimum satoshis this node is required to reserve in its balance.
int64 local_chan_reserve_sat = 6 [json_name = "local_chan_reserve_sat"];
/**
The minimum satoshis the other node is required to reserve in its
balance.
*/
int64 remote_chan_reserve_sat = 7 [json_name = "remote_chan_reserve_sat"];
}
message PendingOpenChannel {

View file

@ -1407,6 +1407,16 @@
"remote_balance": {
"type": "string",
"format": "int64"
},
"local_chan_reserve_sat": {
"type": "string",
"format": "int64",
"description": "/ The minimum satoshis this node is required to reserve in its balance."
},
"remote_chan_reserve_sat": {
"type": "string",
"format": "int64",
"description": "*\nThe minimum satoshis the other node is required to reserve in its\nbalance."
}
}
},
@ -1626,6 +1636,16 @@
"chan_status_flags": {
"type": "string",
"description": "/ A set of flags showing the current state of the channel."
},
"local_chan_reserve_sat": {
"type": "string",
"format": "int64",
"description": "/ The minimum satoshis this node is required to reserve in its balance."
},
"remote_chan_reserve_sat": {
"type": "string",
"format": "int64",
"description": "*\nThe minimum satoshis the other node is required to reserve in its balance."
}
}
},

View file

@ -2232,11 +2232,13 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
resp.PendingOpenChannels[i] = &lnrpc.PendingChannelsResponse_PendingOpenChannel{
Channel: &lnrpc.PendingChannelsResponse_PendingChannel{
RemoteNodePub: hex.EncodeToString(pub),
ChannelPoint: pendingChan.FundingOutpoint.String(),
Capacity: int64(pendingChan.Capacity),
LocalBalance: int64(localCommitment.LocalBalance.ToSatoshis()),
RemoteBalance: int64(localCommitment.RemoteBalance.ToSatoshis()),
RemoteNodePub: hex.EncodeToString(pub),
ChannelPoint: pendingChan.FundingOutpoint.String(),
Capacity: int64(pendingChan.Capacity),
LocalBalance: int64(localCommitment.LocalBalance.ToSatoshis()),
RemoteBalance: int64(localCommitment.RemoteBalance.ToSatoshis()),
LocalChanReserveSat: int64(pendingChan.LocalChanCfg.ChanReserve),
RemoteChanReserveSat: int64(pendingChan.RemoteChanCfg.ChanReserve),
},
CommitWeight: commitWeight,
CommitFee: int64(localCommitment.CommitFee),
@ -2647,6 +2649,8 @@ func createRPCOpenChannel(r *rpcServer, graph *channeldb.ChannelGraph,
CsvDelay: uint32(dbChannel.LocalChanCfg.CsvDelay),
Initiator: dbChannel.IsInitiator,
ChanStatusFlags: dbChannel.ChanStatus().String(),
LocalChanReserveSat: int64(dbChannel.LocalChanCfg.ChanReserve),
RemoteChanReserveSat: int64(dbChannel.RemoteChanCfg.ChanReserve),
}
for i, htlc := range localCommit.Htlcs {