github.com/decred/dcrlnd@v0.7.6/contractcourt/interfaces.go (about) 1 package contractcourt 2 3 import ( 4 "io" 5 6 "github.com/decred/dcrd/wire" 7 "github.com/decred/dcrlnd/channeldb" 8 "github.com/decred/dcrlnd/htlcswitch/hop" 9 "github.com/decred/dcrlnd/input" 10 "github.com/decred/dcrlnd/invoices" 11 "github.com/decred/dcrlnd/lntypes" 12 "github.com/decred/dcrlnd/lnwallet/chainfee" 13 "github.com/decred/dcrlnd/lnwire" 14 "github.com/decred/dcrlnd/sweep" 15 ) 16 17 // Registry is an interface which represents the invoice registry. 18 type Registry interface { 19 // LookupInvoice attempts to look up an invoice according to its 32 20 // byte payment hash. 21 LookupInvoice(lntypes.Hash) (channeldb.Invoice, error) 22 23 // NotifyExitHopHtlc attempts to mark an invoice as settled. If the 24 // invoice is a debug invoice, then this method is a noop as debug 25 // invoices are never fully settled. The return value describes how the 26 // htlc should be resolved. If the htlc cannot be resolved immediately, 27 // the resolution is sent on the passed in hodlChan later. 28 NotifyExitHopHtlc(payHash lntypes.Hash, paidAmount lnwire.MilliAtom, 29 expiry uint32, currentHeight int32, 30 circuitKey channeldb.CircuitKey, hodlChan chan<- interface{}, 31 payload invoices.Payload) (invoices.HtlcResolution, error) 32 33 // HodlUnsubscribeAll unsubscribes from all htlc resolutions. 34 HodlUnsubscribeAll(subscriber chan<- interface{}) 35 } 36 37 // OnionProcessor is an interface used to decode onion blobs. 38 type OnionProcessor interface { 39 // ReconstructHopIterator attempts to decode a valid sphinx packet from 40 // the passed io.Reader instance. 41 ReconstructHopIterator(r io.Reader, rHash []byte) (hop.Iterator, error) 42 } 43 44 // UtxoSweeper defines the sweep functions that contract court requires. 45 type UtxoSweeper interface { 46 // SweepInput sweeps inputs back into the wallet. 47 SweepInput(input input.Input, params sweep.Params) (chan sweep.Result, 48 error) 49 50 // CreateSweepTx accepts a list of inputs and signs and generates a txn 51 // that spends from them. This method also makes an accurate fee 52 // estimate before generating the required witnesses. 53 CreateSweepTx(inputs []input.Input, feePref sweep.FeePreference, 54 currentBlockHeight uint32) (*wire.MsgTx, error) 55 56 // RelayFeePerKB returns the minimum fee rate required for transactions 57 // to be relayed. 58 RelayFeePerKB() chainfee.AtomPerKByte 59 60 // UpdateParams allows updating the sweep parameters of a pending input 61 // in the UtxoSweeper. This function can be used to provide an updated 62 // fee preference that will be used for a new sweep transaction of the 63 // input that will act as a replacement transaction (RBF) of the 64 // original sweeping transaction, if any. 65 UpdateParams(input wire.OutPoint, params sweep.ParamsUpdate) ( 66 chan sweep.Result, error) 67 }