cnct: add resolver report output type

This commit prepares for the commit sweep resolver to report on its
state.
This commit is contained in:
Joost Jager 2019-10-30 10:31:01 +01:00
parent 7e472c9e8c
commit 1597a92160
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
4 changed files with 22 additions and 5 deletions

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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,