2019-04-16 10:21:02 +02:00
|
|
|
package contractcourt
|
|
|
|
|
|
|
|
import (
|
2019-08-26 14:06:57 +02:00
|
|
|
"io"
|
|
|
|
|
2019-10-31 12:42:49 +01:00
|
|
|
"github.com/btcsuite/btcd/wire"
|
2019-04-16 10:21:02 +02:00
|
|
|
"github.com/lightningnetwork/lnd/channeldb"
|
2022-11-18 12:15:22 +01:00
|
|
|
"github.com/lightningnetwork/lnd/channeldb/models"
|
2019-08-26 14:06:57 +02:00
|
|
|
"github.com/lightningnetwork/lnd/htlcswitch/hop"
|
2019-10-31 12:42:49 +01:00
|
|
|
"github.com/lightningnetwork/lnd/input"
|
2019-04-16 10:21:02 +02:00
|
|
|
"github.com/lightningnetwork/lnd/invoices"
|
|
|
|
"github.com/lightningnetwork/lnd/lntypes"
|
2020-03-11 08:52:20 +01:00
|
|
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
2019-04-16 10:21:02 +02:00
|
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
2019-10-31 12:42:49 +01:00
|
|
|
"github.com/lightningnetwork/lnd/sweep"
|
2019-04-16 10:21:02 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Registry is an interface which represents the invoice registry.
|
|
|
|
type Registry interface {
|
|
|
|
// LookupInvoice attempts to look up an invoice according to its 32
|
2019-08-20 14:54:39 +02:00
|
|
|
// byte payment hash.
|
2022-11-30 12:00:37 +01:00
|
|
|
LookupInvoice(lntypes.Hash) (invoices.Invoice, error)
|
2019-04-16 10:21:02 +02:00
|
|
|
|
|
|
|
// NotifyExitHopHtlc attempts to mark an invoice as settled. If the
|
|
|
|
// invoice is a debug invoice, then this method is a noop as debug
|
|
|
|
// invoices are never fully settled. The return value describes how the
|
|
|
|
// htlc should be resolved. If the htlc cannot be resolved immediately,
|
|
|
|
// the resolution is sent on the passed in hodlChan later.
|
|
|
|
NotifyExitHopHtlc(payHash lntypes.Hash, paidAmount lnwire.MilliSatoshi,
|
2019-04-16 12:11:20 +02:00
|
|
|
expiry uint32, currentHeight int32,
|
2022-11-18 12:15:22 +01:00
|
|
|
circuitKey models.CircuitKey, hodlChan chan<- interface{},
|
2020-02-06 18:35:10 +01:00
|
|
|
payload invoices.Payload) (invoices.HtlcResolution, error)
|
2019-04-16 10:21:02 +02:00
|
|
|
|
2019-12-20 11:25:07 +01:00
|
|
|
// HodlUnsubscribeAll unsubscribes from all htlc resolutions.
|
2019-04-16 10:21:02 +02:00
|
|
|
HodlUnsubscribeAll(subscriber chan<- interface{})
|
|
|
|
}
|
2019-08-26 14:06:57 +02:00
|
|
|
|
|
|
|
// OnionProcessor is an interface used to decode onion blobs.
|
|
|
|
type OnionProcessor interface {
|
|
|
|
// ReconstructHopIterator attempts to decode a valid sphinx packet from
|
|
|
|
// the passed io.Reader instance.
|
|
|
|
ReconstructHopIterator(r io.Reader, rHash []byte) (hop.Iterator, error)
|
|
|
|
}
|
2019-10-31 12:42:49 +01:00
|
|
|
|
|
|
|
// UtxoSweeper defines the sweep functions that contract court requires.
|
|
|
|
type UtxoSweeper interface {
|
|
|
|
// SweepInput sweeps inputs back into the wallet.
|
2019-12-09 11:42:58 +01:00
|
|
|
SweepInput(input input.Input, params sweep.Params) (chan sweep.Result,
|
|
|
|
error)
|
2019-10-31 12:42:49 +01:00
|
|
|
|
|
|
|
// CreateSweepTx accepts a list of inputs and signs and generates a txn
|
|
|
|
// that spends from them. This method also makes an accurate fee
|
|
|
|
// estimate before generating the required witnesses.
|
|
|
|
CreateSweepTx(inputs []input.Input, feePref sweep.FeePreference,
|
|
|
|
currentBlockHeight uint32) (*wire.MsgTx, error)
|
2020-03-11 08:52:20 +01:00
|
|
|
|
|
|
|
// RelayFeePerKW returns the minimum fee rate required for transactions
|
|
|
|
// to be relayed.
|
|
|
|
RelayFeePerKW() chainfee.SatPerKWeight
|
2019-11-25 13:17:44 +01:00
|
|
|
|
|
|
|
// UpdateParams allows updating the sweep parameters of a pending input
|
|
|
|
// in the UtxoSweeper. This function can be used to provide an updated
|
|
|
|
// fee preference that will be used for a new sweep transaction of the
|
|
|
|
// input that will act as a replacement transaction (RBF) of the
|
|
|
|
// original sweeping transaction, if any.
|
|
|
|
UpdateParams(input wire.OutPoint, params sweep.ParamsUpdate) (
|
|
|
|
chan sweep.Result, error)
|
2019-10-31 12:42:49 +01:00
|
|
|
}
|
2022-08-29 13:28:17 +02:00
|
|
|
|
|
|
|
// HtlcNotifier defines the notification functions that contract court requires.
|
|
|
|
type HtlcNotifier interface {
|
|
|
|
// NotifyFinalHtlcEvent notifies the HtlcNotifier that the final outcome
|
|
|
|
// for an htlc has been determined.
|
2022-11-18 12:15:22 +01:00
|
|
|
NotifyFinalHtlcEvent(key models.CircuitKey,
|
2022-08-29 13:28:17 +02:00
|
|
|
info channeldb.FinalHtlcInfo)
|
|
|
|
}
|