contractcourt+server: settle invoice for on-chain HTLC sweep

In this commit, we extend the htlcSuccessResolver to settle the invoice,
if any, of the corresponding on-chain HTLC sweep. This ensures that the
invoice state is consistent as when claiming the HTLC "off-chain".
This commit is contained in:
Wilmer Paulino
2019-01-22 20:45:35 -08:00
parent 974e0f2df5
commit 41f638c7cf
4 changed files with 30 additions and 4 deletions

View File

@@ -6,8 +6,6 @@ import (
"sync"
"sync/atomic"
"github.com/lightningnetwork/lnd/sweep"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
@@ -15,6 +13,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/sweep"
)
// ErrChainArbExiting signals that the chain arbitrator is shutting down.
@@ -135,6 +134,11 @@ type ChainArbitratorConfig struct {
// Sweeper allows resolvers to sweep their final outputs.
Sweeper *sweep.UtxoSweeper
// SettleInvoice attempts to settle an existing invoice on-chain with
// the given payment hash. ErrInvoiceNotFound is returned if an invoice
// is not found.
SettleInvoice func(chainhash.Hash, lnwire.MilliSatoshi) error
}
// ChainArbitrator is a sub-system that oversees the on-chain resolution of all