mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-26 22:17:51 +01:00
cnct: expose non-incubating htlcs after channel force close
In this commit we fix a reporting gap that previously existed for htlcs that were still contested.
This commit is contained in:
48
rpcserver.go
48
rpcserver.go
@@ -2063,6 +2063,11 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
ClosingTxid: closeTXID,
|
||||
}
|
||||
|
||||
// Fetch reports from both nursery and resolvers. At the
|
||||
// moment this is not an atomic snapshot. This is
|
||||
// planned to be resolved when the nursery is removed
|
||||
// and channel arbitrator will be the single source for
|
||||
// these kind of reports.
|
||||
err := r.nurseryPopulateForceCloseResp(
|
||||
&chanPoint, currentHeight, forceClose,
|
||||
)
|
||||
@@ -2070,6 +2075,13 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = r.arbitratorPopulateForceCloseResp(
|
||||
&chanPoint, currentHeight, forceClose,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp.TotalLimboBalance += int64(forceClose.LimboBalance)
|
||||
|
||||
resp.PendingForceClosingChannels = append(
|
||||
@@ -2115,6 +2127,42 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// arbitratorPopulateForceCloseResp populates the pending channels response
|
||||
// message with channel resolution information from the contract resolvers.
|
||||
func (r *rpcServer) arbitratorPopulateForceCloseResp(chanPoint *wire.OutPoint,
|
||||
currentHeight int32,
|
||||
forceClose *lnrpc.PendingChannelsResponse_ForceClosedChannel) error {
|
||||
|
||||
// Query for contract resolvers state.
|
||||
arbitrator, err := r.server.chainArb.GetChannelArbitrator(*chanPoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
reports := arbitrator.Report()
|
||||
|
||||
for _, report := range reports {
|
||||
htlc := &lnrpc.PendingHTLC{
|
||||
Incoming: report.Incoming,
|
||||
Amount: int64(report.Amount),
|
||||
Outpoint: report.Outpoint.String(),
|
||||
MaturityHeight: report.MaturityHeight,
|
||||
Stage: report.Stage,
|
||||
}
|
||||
|
||||
if htlc.MaturityHeight != 0 {
|
||||
htlc.BlocksTilMaturity =
|
||||
int32(htlc.MaturityHeight) - currentHeight
|
||||
}
|
||||
|
||||
forceClose.LimboBalance += int64(report.LimboBalance)
|
||||
forceClose.RecoveredBalance += int64(report.RecoveredBalance)
|
||||
|
||||
forceClose.PendingHtlcs = append(forceClose.PendingHtlcs, htlc)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// nurseryPopulateForceCloseResp populates the pending channels response
|
||||
// message with contract resolution information from utxonursery.
|
||||
func (r *rpcServer) nurseryPopulateForceCloseResp(chanPoint *wire.OutPoint,
|
||||
|
||||
Reference in New Issue
Block a user