diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index e63a20461..460e6a61b 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -129,13 +129,27 @@ type ChannelArbitratorConfig struct { ChainArbitratorConfig } +// ReportOutputType describes the type of output that is being reported +// on. +type ReportOutputType uint8 + +const ( + // ReportOutputIncomingHtlc is an incoming hash time locked contract on + // the commitment tx. + ReportOutputIncomingHtlc ReportOutputType = iota + + // ReportOutputOutgoingHtlc is an outgoing hash time locked contract on + // the commitment tx. + ReportOutputOutgoingHtlc +) + // ContractReport provides a summary of a commitment tx output. type ContractReport struct { // Outpoint is the final output that will be swept back to the wallet. Outpoint wire.OutPoint - // Incoming indicates whether the htlc was incoming to this channel. - Incoming bool + // Type indicates the type of the reported output. + Type ReportOutputType // Amount is the final value that will be swept in back to the wallet. Amount btcutil.Amount diff --git a/contractcourt/htlc_incoming_contest_resolver.go b/contractcourt/htlc_incoming_contest_resolver.go index 2e089724f..abedcc14e 100644 --- a/contractcourt/htlc_incoming_contest_resolver.go +++ b/contractcourt/htlc_incoming_contest_resolver.go @@ -293,7 +293,7 @@ func (h *htlcIncomingContestResolver) report() *ContractReport { return &ContractReport{ Outpoint: h.htlcResolution.ClaimOutpoint, - Incoming: true, + Type: ReportOutputIncomingHtlc, Amount: finalAmt, MaturityHeight: h.htlcExpiry, LimboBalance: finalAmt, diff --git a/contractcourt/htlc_outgoing_contest_resolver.go b/contractcourt/htlc_outgoing_contest_resolver.go index 93a4adfa9..28d95247a 100644 --- a/contractcourt/htlc_outgoing_contest_resolver.go +++ b/contractcourt/htlc_outgoing_contest_resolver.go @@ -166,7 +166,7 @@ func (h *htlcOutgoingContestResolver) report() *ContractReport { return &ContractReport{ Outpoint: h.htlcResolution.ClaimOutpoint, - Incoming: false, + Type: ReportOutputOutgoingHtlc, Amount: finalAmt, MaturityHeight: h.htlcResolution.Expiry, LimboBalance: finalAmt, diff --git a/rpcserver.go b/rpcserver.go index 4833eb714..d9a083a92 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -34,6 +34,7 @@ import ( "github.com/lightningnetwork/lnd/chanbackup" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channelnotifier" + "github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/input" @@ -2451,8 +2452,10 @@ func (r *rpcServer) arbitratorPopulateForceCloseResp(chanPoint *wire.OutPoint, reports := arbitrator.Report() for _, report := range reports { + incoming := report.Type == contractcourt.ReportOutputIncomingHtlc + htlc := &lnrpc.PendingHTLC{ - Incoming: report.Incoming, + Incoming: incoming, Amount: int64(report.Amount), Outpoint: report.Outpoint.String(), MaturityHeight: report.MaturityHeight,