lnrpc: expose commit hashes for waiting close channels

To make it easier to determine which pending sweep to bump in order to
get your anchor commitment tx confirmed.
This commit is contained in:
Joost Jager
2020-03-11 16:48:45 +01:00
parent ab451f634e
commit d60303b092
4 changed files with 870 additions and 718 deletions

View File

@@ -2756,6 +2756,43 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
for _, waitingClose := range waitingCloseChans {
pub := waitingClose.IdentityPub.SerializeCompressed()
chanPoint := waitingClose.FundingOutpoint
var commitments lnrpc.PendingChannelsResponse_Commitments
// Report local commit. May not be present when DLP is active.
if waitingClose.LocalCommitment.CommitTx != nil {
commitments.LocalTxid =
waitingClose.LocalCommitment.CommitTx.TxHash().
String()
}
// Report remote commit. May not be present when DLP is active.
if waitingClose.RemoteCommitment.CommitTx != nil {
commitments.RemoteTxid =
waitingClose.RemoteCommitment.CommitTx.TxHash().
String()
}
// Report the remote pending commit if any.
remoteCommitDiff, err := waitingClose.RemoteCommitChainTip()
switch {
// Don't set hash if there is no pending remote commit.
case err == channeldb.ErrNoPendingCommit:
// An unexpected error occurred.
case err != nil:
return nil, err
// There is a pending remote commit. Set its hash in the
// response.
default:
hash := remoteCommitDiff.Commitment.CommitTx.TxHash()
commitments.RemotePendingTxid = hash.String()
}
channel := &lnrpc.PendingChannelsResponse_PendingChannel{
RemoteNodePub: hex.EncodeToString(pub),
ChannelPoint: chanPoint.String(),
@@ -2766,14 +2803,16 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
RemoteChanReserveSat: int64(waitingClose.RemoteChanCfg.ChanReserve),
}
waitingCloseResp := &lnrpc.PendingChannelsResponse_WaitingCloseChannel{
Channel: channel,
LimboBalance: channel.LocalBalance,
Commitments: &commitments,
}
// A close tx has been broadcasted, all our balance will be in
// limbo until it confirms.
resp.WaitingCloseChannels = append(
resp.WaitingCloseChannels,
&lnrpc.PendingChannelsResponse_WaitingCloseChannel{
Channel: channel,
LimboBalance: channel.LocalBalance,
},
resp.WaitingCloseChannels, waitingCloseResp,
)
resp.TotalLimboBalance += channel.LocalBalance