Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions contractcourt/chain_arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/sweep"
)

// ErrChainArbExiting signals that the chain arbitrator is shutting down.
Expand Down Expand Up @@ -113,8 +112,7 @@ type ChainArbitratorConfig struct {
// the process of incubation. This is used when a resolver wishes to
// pass off the output to the nursery as we're only waiting on an
// absolute/relative item block.
IncubateOutputs func(wire.OutPoint, *lnwallet.CommitOutputResolution,
*lnwallet.OutgoingHtlcResolution,
IncubateOutputs func(wire.OutPoint, *lnwallet.OutgoingHtlcResolution,
Comment thread
joostjager marked this conversation as resolved.
Outdated
*lnwallet.IncomingHtlcResolution, uint32) error

// PreimageDB is a global store of all known pre-images. We'll use this
Expand Down Expand Up @@ -142,7 +140,7 @@ type ChainArbitratorConfig struct {
DisableChannel func(wire.OutPoint) error

// Sweeper allows resolvers to sweep their final outputs.
Sweeper *sweep.UtxoSweeper
Sweeper UtxoSweeper

// Registry is the invoice database that is used by resolvers to lookup
// preimages and settle invoices.
Expand Down
1 change: 1 addition & 0 deletions contractcourt/chain_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (m *mockNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, _ []byte,
heightHint uint32) (*chainntnfs.ConfirmationEvent, error) {
return &chainntnfs.ConfirmationEvent{
Confirmed: m.confChan,
Cancel: func() {},
}, nil
}

Expand Down
43 changes: 20 additions & 23 deletions contractcourt/channel_arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,31 @@ type ChannelArbitratorConfig struct {
ChainArbitratorConfig
}

// ReportOutputType describes the type of output that is being reported
// on.
type ReportOutputType uint8
Comment thread
joostjager marked this conversation as resolved.
Outdated

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

// ReportOutputUnencumbered is an uncontested output on the commitment
// transaction paying to us directly.
ReportOutputUnencumbered
Comment thread
joostjager marked this conversation as resolved.
Outdated
)

// 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
Expand Down Expand Up @@ -859,27 +877,6 @@ func (c *ChannelArbitrator) stateStep(
break
}

// If we've have broadcast the commitment transaction, we send
// our commitment output for incubation, but only if it wasn't
// trimmed. We'll need to wait for a CSV timeout before we can
// reclaim the funds.
commitRes := contractResolutions.CommitResolution
if commitRes != nil && commitRes.MaturityDelay > 0 {
log.Infof("ChannelArbitrator(%v): sending commit "+
"output for incubation", c.cfg.ChanPoint)

err = c.cfg.IncubateOutputs(
c.cfg.ChanPoint, commitRes,
nil, nil, triggerHeight,
)
if err != nil {
// TODO(roasbeef): check for AlreadyExists errors
log.Errorf("unable to incubate commitment "+
"output: %v", err)
return StateError, closeTx, err
}
}

// Now that we know we'll need to act, we'll process the htlc
// actions, wen create the structures we need to resolve all
// outstanding contracts.
Expand Down
2 changes: 1 addition & 1 deletion contractcourt/channel_arbitrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func createTestChannelArbitrator(t *testing.T, log ArbitratorLog) (*chanArbTestC
spendChan: make(chan *chainntnfs.SpendDetail),
confChan: make(chan *chainntnfs.TxConfirmation),
},
IncubateOutputs: func(wire.OutPoint, *lnwallet.CommitOutputResolution,
IncubateOutputs: func(wire.OutPoint,
*lnwallet.OutgoingHtlcResolution,
*lnwallet.IncomingHtlcResolution, uint32) error {

Expand Down
Loading