cnct: add resolver report output type
This commit prepares for the commit sweep resolver to report on its state.
This commit is contained in:
parent
7e472c9e8c
commit
1597a92160
|
@ -129,13 +129,27 @@ type ChannelArbitratorConfig struct {
|
||||||
ChainArbitratorConfig
|
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.
|
// ContractReport provides a summary of a commitment tx output.
|
||||||
type ContractReport struct {
|
type ContractReport struct {
|
||||||
// Outpoint is the final output that will be swept back to the wallet.
|
// Outpoint is the final output that will be swept back to the wallet.
|
||||||
Outpoint wire.OutPoint
|
Outpoint wire.OutPoint
|
||||||
|
|
||||||
// Incoming indicates whether the htlc was incoming to this channel.
|
// Type indicates the type of the reported output.
|
||||||
Incoming bool
|
Type ReportOutputType
|
||||||
|
|
||||||
// Amount is the final value that will be swept in back to the wallet.
|
// Amount is the final value that will be swept in back to the wallet.
|
||||||
Amount btcutil.Amount
|
Amount btcutil.Amount
|
||||||
|
|
|
@ -293,7 +293,7 @@ func (h *htlcIncomingContestResolver) report() *ContractReport {
|
||||||
|
|
||||||
return &ContractReport{
|
return &ContractReport{
|
||||||
Outpoint: h.htlcResolution.ClaimOutpoint,
|
Outpoint: h.htlcResolution.ClaimOutpoint,
|
||||||
Incoming: true,
|
Type: ReportOutputIncomingHtlc,
|
||||||
Amount: finalAmt,
|
Amount: finalAmt,
|
||||||
MaturityHeight: h.htlcExpiry,
|
MaturityHeight: h.htlcExpiry,
|
||||||
LimboBalance: finalAmt,
|
LimboBalance: finalAmt,
|
||||||
|
|
|
@ -166,7 +166,7 @@ func (h *htlcOutgoingContestResolver) report() *ContractReport {
|
||||||
|
|
||||||
return &ContractReport{
|
return &ContractReport{
|
||||||
Outpoint: h.htlcResolution.ClaimOutpoint,
|
Outpoint: h.htlcResolution.ClaimOutpoint,
|
||||||
Incoming: false,
|
Type: ReportOutputOutgoingHtlc,
|
||||||
Amount: finalAmt,
|
Amount: finalAmt,
|
||||||
MaturityHeight: h.htlcResolution.Expiry,
|
MaturityHeight: h.htlcResolution.Expiry,
|
||||||
LimboBalance: finalAmt,
|
LimboBalance: finalAmt,
|
||||||
|
|
|
@ -34,6 +34,7 @@ import (
|
||||||
"github.com/lightningnetwork/lnd/chanbackup"
|
"github.com/lightningnetwork/lnd/chanbackup"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/channelnotifier"
|
"github.com/lightningnetwork/lnd/channelnotifier"
|
||||||
|
"github.com/lightningnetwork/lnd/contractcourt"
|
||||||
"github.com/lightningnetwork/lnd/discovery"
|
"github.com/lightningnetwork/lnd/discovery"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
|
@ -2451,8 +2452,10 @@ func (r *rpcServer) arbitratorPopulateForceCloseResp(chanPoint *wire.OutPoint,
|
||||||
reports := arbitrator.Report()
|
reports := arbitrator.Report()
|
||||||
|
|
||||||
for _, report := range reports {
|
for _, report := range reports {
|
||||||
|
incoming := report.Type == contractcourt.ReportOutputIncomingHtlc
|
||||||
|
|
||||||
htlc := &lnrpc.PendingHTLC{
|
htlc := &lnrpc.PendingHTLC{
|
||||||
Incoming: report.Incoming,
|
Incoming: incoming,
|
||||||
Amount: int64(report.Amount),
|
Amount: int64(report.Amount),
|
||||||
Outpoint: report.Outpoint.String(),
|
Outpoint: report.Outpoint.String(),
|
||||||
MaturityHeight: report.MaturityHeight,
|
MaturityHeight: report.MaturityHeight,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user