mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-23 07:11:11 +02:00
Merge pull request #4111 from carlaKC/4067-pendingchannelsrpcadditions
lnrpc: add fee and initiator to pending channels
This commit is contained in:
commit
f5e364071b
1490
lnrpc/rpc.pb.go
1490
lnrpc/rpc.pb.go
File diff suppressed because it is too large
Load Diff
@ -1973,6 +1973,9 @@ message PendingChannelsResponse {
|
||||
balance.
|
||||
*/
|
||||
int64 remote_chan_reserve_sat = 7;
|
||||
|
||||
// True if we initiated opening the channel.
|
||||
bool initiator = 8;
|
||||
}
|
||||
|
||||
message PendingOpenChannel {
|
||||
@ -2025,6 +2028,24 @@ message PendingChannelsResponse {
|
||||
|
||||
/// Hash of the remote pending version of the commitment tx.
|
||||
string remote_pending_txid = 3;
|
||||
|
||||
/*
|
||||
The amount in satoshis calculated to be paid in fees for the local
|
||||
commitment.
|
||||
*/
|
||||
uint64 local_commit_fee_sat = 4;
|
||||
|
||||
/*
|
||||
The amount in satoshis calculated to be paid in fees for the remote
|
||||
commitment.
|
||||
*/
|
||||
uint64 remote_commit_fee_sat = 5;
|
||||
|
||||
/*
|
||||
The amount in satoshis calculated to be paid in fees for the remote
|
||||
pending commitment.
|
||||
*/
|
||||
uint64 remote_pending_commit_fee_sat = 6;
|
||||
}
|
||||
|
||||
message ClosedChannel {
|
||||
@ -2075,8 +2096,12 @@ message PendingChannelsResponse {
|
||||
/// Channels pending opening
|
||||
repeated PendingOpenChannel pending_open_channels = 2;
|
||||
|
||||
/// Channels pending closing
|
||||
repeated ClosedChannel pending_closing_channels = 3;
|
||||
/*
|
||||
Deprecated: Channels pending closing previously contained cooperatively
|
||||
closed channels with a single confirmation. These channels are now
|
||||
considered closed from the time we see them on chain.
|
||||
*/
|
||||
repeated ClosedChannel pending_closing_channels = 3 [deprecated = true];
|
||||
|
||||
/// Channels pending force closing
|
||||
repeated ForceClosedChannel pending_force_closing_channels = 4;
|
||||
|
@ -1617,6 +1617,21 @@
|
||||
"remote_pending_txid": {
|
||||
"type": "string",
|
||||
"description": "/ Hash of the remote pending version of the commitment tx."
|
||||
},
|
||||
"local_commit_fee_sat": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The amount in satoshis calculated to be paid in fees for the local\ncommitment."
|
||||
},
|
||||
"remote_commit_fee_sat": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The amount in satoshis calculated to be paid in fees for the remote\ncommitment."
|
||||
},
|
||||
"remote_pending_commit_fee_sat": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The amount in satoshis calculated to be paid in fees for the remote\npending commitment."
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -1692,6 +1707,11 @@
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "*\nThe minimum satoshis the other node is required to reserve in its\nbalance."
|
||||
},
|
||||
"initiator": {
|
||||
"type": "boolean",
|
||||
"format": "boolean",
|
||||
"description": "True if we initiated opening the channel."
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -3919,7 +3939,7 @@
|
||||
"items": {
|
||||
"$ref": "#/definitions/PendingChannelsResponseClosedChannel"
|
||||
},
|
||||
"title": "/ Channels pending closing"
|
||||
"description": "Deprecated: Channels pending closing previously contained cooperatively\nclosed channels with a single confirmation. These channels are now\nconsidered closed from the time we see them on chain."
|
||||
},
|
||||
"pending_force_closing_channels": {
|
||||
"type": "array",
|
||||
|
60
rpcserver.go
60
rpcserver.go
@ -2665,6 +2665,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
RemoteBalance: int64(localCommitment.RemoteBalance.ToSatoshis()),
|
||||
LocalChanReserveSat: int64(pendingChan.LocalChanCfg.ChanReserve),
|
||||
RemoteChanReserveSat: int64(pendingChan.RemoteChanCfg.ChanReserve),
|
||||
Initiator: pendingChan.IsInitiator,
|
||||
},
|
||||
CommitWeight: commitWeight,
|
||||
CommitFee: int64(localCommitment.CommitFee),
|
||||
@ -2697,26 +2698,42 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
LocalBalance: int64(pendingClose.SettledBalance),
|
||||
}
|
||||
|
||||
// Lookup the channel in the historical channel bucket to obtain
|
||||
// initiator information. If the historical channel bucket was
|
||||
// not found, or the channel itself, this channel was closed
|
||||
// in a version before we started persisting historical
|
||||
// channels, so we silence the error.
|
||||
historical, err := r.server.chanDB.FetchHistoricalChannel(
|
||||
&pendingClose.ChanPoint,
|
||||
)
|
||||
switch err {
|
||||
// If the channel was closed in a version that did not record
|
||||
// historical channels, ignore the error.
|
||||
case channeldb.ErrNoHistoricalBucket:
|
||||
case channeldb.ErrChannelNotFound:
|
||||
|
||||
case nil:
|
||||
channel.Initiator = historical.IsInitiator
|
||||
|
||||
// If the error is non-nil, and not due to older versions of lnd
|
||||
// not persisting historical channels, return it.
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
|
||||
closeTXID := pendingClose.ClosingTXID.String()
|
||||
|
||||
switch pendingClose.CloseType {
|
||||
|
||||
// If the channel was closed cooperatively, then we'll only
|
||||
// need to tack on the closing txid.
|
||||
// TODO(halseth): remove. After recent changes, a coop closed
|
||||
// channel should never be in the "pending close" state.
|
||||
// Keeping for now to let someone that upgraded in the middle
|
||||
// of a close let their closing tx confirm.
|
||||
// A coop closed channel should never be in the "pending close"
|
||||
// state. If a node upgraded from an older lnd version in the
|
||||
// middle of a their channel confirming, it will be in this
|
||||
// state. We log a warning that the channel will not be included
|
||||
// in the now deprecated pending close channels field.
|
||||
case channeldb.CooperativeClose:
|
||||
resp.PendingClosingChannels = append(
|
||||
resp.PendingClosingChannels,
|
||||
&lnrpc.PendingChannelsResponse_ClosedChannel{
|
||||
Channel: channel,
|
||||
ClosingTxid: closeTXID,
|
||||
},
|
||||
)
|
||||
|
||||
resp.TotalLimboBalance += channel.LocalBalance
|
||||
rpcsLog.Warn("channel %v cooperatively closed and "+
|
||||
"in pending close state",
|
||||
pendingClose.ChanPoint)
|
||||
|
||||
// If the channel was force closed, then we'll need to query
|
||||
// the utxoNursery for additional information.
|
||||
@ -2776,6 +2793,10 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
commitments.LocalTxid =
|
||||
waitingClose.LocalCommitment.CommitTx.TxHash().
|
||||
String()
|
||||
|
||||
commitments.LocalCommitFeeSat = uint64(
|
||||
waitingClose.LocalCommitment.CommitFee,
|
||||
)
|
||||
}
|
||||
|
||||
// Report remote commit. May not be present when DLP is active.
|
||||
@ -2783,6 +2804,10 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
commitments.RemoteTxid =
|
||||
waitingClose.RemoteCommitment.CommitTx.TxHash().
|
||||
String()
|
||||
|
||||
commitments.RemoteCommitFeeSat = uint64(
|
||||
waitingClose.RemoteCommitment.CommitFee,
|
||||
)
|
||||
}
|
||||
|
||||
// Report the remote pending commit if any.
|
||||
@ -2802,7 +2827,9 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
default:
|
||||
hash := remoteCommitDiff.Commitment.CommitTx.TxHash()
|
||||
commitments.RemotePendingTxid = hash.String()
|
||||
|
||||
commitments.RemoteCommitFeeSat = uint64(
|
||||
remoteCommitDiff.Commitment.CommitFee,
|
||||
)
|
||||
}
|
||||
|
||||
channel := &lnrpc.PendingChannelsResponse_PendingChannel{
|
||||
@ -2813,6 +2840,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
RemoteBalance: int64(waitingClose.LocalCommitment.RemoteBalance.ToSatoshis()),
|
||||
LocalChanReserveSat: int64(waitingClose.LocalChanCfg.ChanReserve),
|
||||
RemoteChanReserveSat: int64(waitingClose.RemoteChanCfg.ChanReserve),
|
||||
Initiator: waitingClose.IsInitiator,
|
||||
}
|
||||
|
||||
waitingCloseResp := &lnrpc.PendingChannelsResponse_WaitingCloseChannel{
|
||||
|
Loading…
x
Reference in New Issue
Block a user