Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut, ...) (loopdb.SwapCost, error)
- func IsTaprootSwap(swapContract *loopdb.SwapContract) bool
- func MigrateLoopOutCosts(ctx context.Context, lnd lndclient.LndServices, paymentBatchSize int, ...) error
- func ReleaseRoutingPlugin(ctx context.Context)
- func SelectHopHints(ctx context.Context, lndClient lndclient.LightningClient, amt btcutil.Amount, ...) ([][]zpay32.HopHint, error)
- func UseLogger(logger btclog.Logger)
- func UserAgent(initiator string) string
- func ValidateLoopInContract(height int32, htlcExpiry int32) error
- func Version() string
- type AbandonSwapRequest
- type Client
- func (s *Client) AbandonSwap(ctx context.Context, req *AbandonSwapRequest) error
- func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error)
- func (s *Client) GetConn() *grpc.ClientConn
- func (s *Client) LoopIn(globalCtx context.Context, request *LoopInRequest) (*LoopInSwapInfo, error)
- func (s *Client) LoopInQuote(ctx context.Context, request *LoopInQuoteRequest) (*LoopInQuote, error)
- func (s *Client) LoopInTerms(ctx context.Context, initiator string) (*LoopInTerms, error)
- func (s *Client) LoopOut(globalCtx context.Context, request *OutRequest) (*LoopOutSwapInfo, error)
- func (s *Client) LoopOutQuote(ctx context.Context, request *LoopOutQuoteRequest) (*LoopOutQuote, error)
- func (s *Client) LoopOutTerms(ctx context.Context, initiator string) (*LoopOutTerms, error)
- func (s *Client) Probe(ctx context.Context, req *ProbeRequest) error
- func (s *Client) Run(ctx context.Context, statusChan chan<- SwapInfo) error
- type ClientConfig
- type HopHintInfo
- type In
- type LoopInQuote
- type LoopInQuoteRequest
- type LoopInRequest
- type LoopInSwapInfo
- type LoopInTerms
- type LoopOutQuote
- type LoopOutQuoteRequest
- type LoopOutSwapInfo
- type LoopOutTerms
- type Out
- type OutRequest
- type ProbeRequest
- type RoutingPlugin
- type RoutingPluginType
- type SelectHopHintsCfg
- type ServerUpdate
- type StaticAddressLoopInRequest
- type SwapInfo
- type SwapInfoKit
Constants ¶
const ( // MinLoopOutPreimageRevealDelta configures the minimum number of // remaining blocks before htlc expiry required to reveal preimage. MinLoopOutPreimageRevealDelta = 20 // DefaultSweepConfTarget is the default confirmation target we'll use // when sweeping on-chain HTLCs. DefaultSweepConfTarget = 9 // DefaultHtlcConfTarget is the default confirmation target we'll use // for on-chain htlcs published by the swap client for Loop In. DefaultHtlcConfTarget = 6 // DefaultSweepConfTargetDelta is the delta of blocks from a Loop Out // swap's expiration height at which we begin to cap the sweep // confirmation target with urgentSweepConfTarget and multiply feerate // by factor urgentSweepConfTargetFactor. DefaultSweepConfTargetDelta = 10 )
Variables ¶
var ( // ErrSwapFeeTooHigh is returned when the swap invoice amount is too // high. ErrSwapFeeTooHigh = errors.New("swap fee too high") // ErrPrepayAmountTooHigh is returned when the prepay invoice amount is // too high. ErrPrepayAmountTooHigh = errors.New("prepay amount too high") // ErrSwapAmountTooLow is returned when the requested swap amount is // less than the server minimum. ErrSwapAmountTooLow = errors.New("swap amount too low") // ErrSwapAmountTooHigh is returned when the requested swap amount is // more than the server maximum. ErrSwapAmountTooHigh = errors.New("swap amount too high") // ErrExpiryTooFar is returned when the server proposes an expiry that // is too far in the future. ErrExpiryTooFar = errors.New("swap expiry too far") // ErrExpiryTooSoon is returned when the server proposes an expiry that // is too soon. ErrExpiryTooSoon = errors.New("swap expiry too soon") // ErrInsufficientBalance indicates insufficient confirmed balance to // publish a swap. ErrInsufficientBalance = errors.New("insufficient confirmed balance") // MinerFeeEstimationFailed is a magic number that is returned in a // quote call as the miner fee if the fee estimation in lnd's wallet // failed because of insufficient funds. MinerFeeEstimationFailed btcutil.Amount = -1 )
var ( // MaxLoopInAcceptDelta configures the maximum acceptable number of // remaining blocks until the on-chain htlc expires. This value is used // to decide whether we want to continue with the swap parameters as // proposed by the server. It is a protection to prevent the server from // getting us to lock up our funds to an arbitrary point in the future. MaxLoopInAcceptDelta = int32(1500) // MinLoopInExpiryDelta defines the minimum number of remaining blocks // that we accept until htlc expiry path that opens up for us to sweep. MinLoopInExpiryDelta = int32(100) // MinLoopInPublishDelta defines the minimum number of remaining blocks // until on-chain htlc expiry required to proceed to publishing the htlc // tx. This value isn't critical, as we could even safely publish the // htlc after expiry. The reason we do implement this check is to // prevent us from publishing an htlc that the server surely wouldn't // follow up to. MinLoopInPublishDelta = int32(10) // TimeoutTxConfTarget defines the confirmation target for the loop in // timeout tx. TimeoutTxConfTarget = int32(2) // ErrSwapFinalized is returned when a to be executed swap is already in // a final state. ErrSwapFinalized = errors.New("swap is in a final state") )
var ( // ErrRoutingPluginNotApplicable means that the selected routing plugin // is not able to enhance routing given the current conditions and // therefore shouldn't be used. ErrRoutingPluginNotApplicable = fmt.Errorf("routing plugin not " + "applicable") // ErrRoutingPluginNoMoreRetries means that the routing plugin can't // effectively help the payment with more retries. ErrRoutingPluginNoMoreRetries = fmt.Errorf("routing plugin can't " + "retry more") )
var AgentName = defaultAgentName
AgentName stores the name of the software that is added as the first part of the user agent string. This defaults to the value "loopd" when being run as a standalone component but can be overwritten by LiT for example when loopd is integrated into the UI.
var Commit string
Commit stores the current commit hash of this build, this should be set using the -ldflags during compilation.
var (
// DefaultMaxHopHints is set to 20 as that is the default set in LND.
DefaultMaxHopHints = 20
)
Functions ¶
func CalculateLoopOutCost ¶
func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut, paymentFees map[lntypes.Hash]lnwire.MilliSatoshi) (loopdb.SwapCost, error)
CalculateLoopOutCost calculates the total cost of a loop out swap. It will correctly account for the on-chain and off-chain fees that were paid and make sure that all costs are positive.
func IsTaprootSwap ¶
func IsTaprootSwap(swapContract *loopdb.SwapContract) bool
IsTaproot returns true if the swap referenced by the passed swap contract uses the v3 (taproot) htlc.
func MigrateLoopOutCosts ¶
func MigrateLoopOutCosts(ctx context.Context, lnd lndclient.LndServices, paymentBatchSize int, db loopdb.SwapStore) error
MigrateLoopOutCosts will calculate the correct cost for all loop out swaps and override the cost values of the last update in the database.
func ReleaseRoutingPlugin ¶
ReleaseRoutingPlugin will release the RoutingPlugin, allowing other requestors to acquire the instance.
func SelectHopHints ¶
func SelectHopHints(ctx context.Context, lndClient lndclient.LightningClient, amt btcutil.Amount, numMaxHophints int, includeNodes map[route.Vertex]struct{}) ([][]zpay32.HopHint, error)
SelectHopHints calls into LND's exposed SelectHopHints prefiltered to the includeNodes map (unless it's empty).
func UseLogger ¶
UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.
func UserAgent ¶
UserAgent returns the full user agent string that identifies the software that is submitting swaps to the loop server.
func ValidateLoopInContract ¶
ValidateLoopInContract validates the contract parameters against our configured maximum values.
func Version ¶
func Version() string
Version returns the application version as a properly formed string per the semantic versioning 2.0.0 spec (http://semver.org/) and the commit it was built on.
Types ¶
type AbandonSwapRequest ¶
AbandonSwapRequest specifies the swap to abandon. It is identified by its swap hash.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client performs the client side part of swaps. This interface exists to be able to implement a stub.
func NewClient ¶
func NewClient(dbDir string, loopDB loopdb.SwapStore, sweeperDb sweepbatcher.BatcherStore, cfg *ClientConfig) ( *Client, func(), error)
NewClient returns a new instance to initiate swaps with.
func (*Client) AbandonSwap ¶
func (s *Client) AbandonSwap(ctx context.Context, req *AbandonSwapRequest) error
AbandonSwap sends a signal on the abandon channel of the swap identified by the passed swap hash. This will cause the swap to abandon itself.
func (*Client) FetchSwaps ¶
FetchSwaps returns all loop in and out swaps currently in the database.
func (*Client) GetConn ¶
func (s *Client) GetConn() *grpc.ClientConn
GetConn returns the gRPC connection to the server.
func (*Client) LoopIn ¶
func (s *Client) LoopIn(globalCtx context.Context, request *LoopInRequest) (*LoopInSwapInfo, error)
LoopIn initiates a loop in swap.
func (*Client) LoopInQuote ¶
func (s *Client) LoopInQuote(ctx context.Context, request *LoopInQuoteRequest) (*LoopInQuote, error)
LoopInQuote takes an amount and returns a breakdown of estimated costs for the client. Both the swap server and the on-chain fee estimator are queried to get to build the quote response.
func (*Client) LoopInTerms ¶
LoopInTerms returns the terms on which the server executes swaps.
func (*Client) LoopOut ¶
func (s *Client) LoopOut(globalCtx context.Context, request *OutRequest) (*LoopOutSwapInfo, error)
LoopOut initiates a loop out swap. It blocks until the swap is initiation with the swap server is completed (typically this takes only a short amount of time). From there on further status information can be acquired through the status channel returned from the Run call.
When the call returns, the swap has been persisted and will be resumed automatically after restarts.
The return value is a hash that uniquely identifies the new swap.
func (*Client) LoopOutQuote ¶
func (s *Client) LoopOutQuote(ctx context.Context, request *LoopOutQuoteRequest) (*LoopOutQuote, error)
LoopOutQuote takes a LoopOut amount and returns a break down of estimated costs for the client. Both the swap server and the on-chain fee estimator are queried to get to build the quote response.
func (*Client) LoopOutTerms ¶
LoopOutTerms returns the terms on which the server executes swaps.
func (*Client) Probe ¶
func (s *Client) Probe(ctx context.Context, req *ProbeRequest) error
Probe asks the server to probe a route to us given a requested amount and last hop. The server is free to discard frequent request to avoid abuse or if there's been a recent probe to us for the same amount.
type ClientConfig ¶
type ClientConfig struct { // ServerAddress is the loop server to connect to. ServerAddress string // ProxyAddress is the SOCKS proxy that should be used to establish the // connection. ProxyAddress string // SwapServerNoTLS skips TLS for the swap server connection when set. SwapServerNoTLS bool // TLSPathServer is the path to the TLS certificate that is required to // connect to the server. TLSPathServer string // Lnd is an instance of the lnd proxy. Lnd *lndclient.LndServices // MaxL402Cost is the maximum price we are willing to pay to the server // for the token. MaxL402Cost btcutil.Amount // MaxL402Fee is the maximum that we are willing to pay in routing fees // to obtain the token. MaxL402Fee btcutil.Amount // LoopOutMaxParts defines the maximum number of parts that may be used // for a loop out swap. When greater than one, a multi-part payment may // be attempted. LoopOutMaxParts uint32 // TotalPaymentTimeout is the total amount of time until we time out // off-chain payments (used in loop out). TotalPaymentTimeout time.Duration // MaxPaymentRetries is the maximum times we retry an off-chain payment // (used in loop out). MaxPaymentRetries int // MaxStaticAddrHtlcFeePercentage is the percentage of the swap amount // that we allow the server to charge for the htlc transaction. // Although highly unlikely, this is a defense against the server // publishing the htlc without paying the swap invoice, forcing us to // sweep the timeout path. MaxStaticAddrHtlcFeePercentage float64 // MaxStaticAddrHtlcBackupFeePercentage is the percentage of the swap // amount that we allow the server to charge for the htlc backup // transactions. This is a defense against the server publishing the // htlc backup without paying the swap invoice, forcing us to sweep the // timeout path. This value is elevated compared to // MaxStaticAddrHtlcFeePercentage since it serves the server as backup // transaction in case of fee spikes. MaxStaticAddrHtlcBackupFeePercentage float64 }
ClientConfig is the exported configuration structure that is required to instantiate the loop client.
type HopHintInfo ¶
type HopHintInfo struct { // IsPublic indicates whether a channel is advertised to the network. IsPublic bool // IsActive indicates whether the channel is online and available for // use. IsActive bool // FundingOutpoint is the funding txid:index for the channel. FundingOutpoint wire.OutPoint // RemotePubkey is the public key of the remote party that this channel // is in. RemotePubkey *btcec.PublicKey // RemoteBalance is the remote party's balance (our current incoming // capacity). RemoteBalance lnwire.MilliSatoshi // ShortChannelID is the short channel ID of the channel. ShortChannelID uint64 // ConfirmedScidZC is the confirmed SCID of a zero-conf channel. This // may be used for looking up a channel in the graph. ConfirmedScidZC uint64 // ScidAliasFeature denotes whether the channel has negotiated the // option-scid-alias feature bit. ScidAliasFeature bool }
HopHintInfo contains the channel information required to create a hop hint.
type In ¶
type In struct { loopdb.LoopInContract SwapInfoKit // State where the swap is in. State loopdb.SwapState }
In contains status information for a loop in swap.
func (*In) LastUpdate ¶
LastUpdate returns the last update time of the swap.
type LoopInQuote ¶
type LoopInQuote struct { // SwapFee is the fee that the swap server is charging for the swap. SwapFee btcutil.Amount // MinerFee is an estimate of the on-chain fee that needs to be paid to // sweep the htlc. MinerFee btcutil.Amount // Time lock delta relative to current block height that swap server // will accept on the swap initiation call. CltvDelta int32 }
LoopInQuote contains estimates for the fees making up the total swap cost for the client.
type LoopInQuoteRequest ¶
type LoopInQuoteRequest struct { // Amount specifies the requested swap amount in sat. This does not // include the swap and miner fee. Amount btcutil.Amount // HtlcConfTarget specifies the targeted confirmation target for the // client sweep tx. HtlcConfTarget int32 // ExternalHtlc specifies whether the htlc is published by an external // source. ExternalHtlc bool // LastHop is an optional last hop to use. This last hop is used when // the client has already requested a server probe for more accurate // routing fee estimation. LastHop *route.Vertex // RouteHints are optional route hints to reach the destination through // private channels. RouteHints [][]zpay32.HopHint // Private indicates whether the destination node should be considered // private. In which case, loop will generate hophints to assist with // probing and payment. Private bool // Initiator is an optional string that identifies what software // initiated the swap (loop CLI, autolooper, LiT UI and so on) and is // appended to the user agent string. Initiator string // The number of static address deposits the client wants to quote for. // If the number of deposits exceeds one the server will apply a // per-input service fee. This is to cover for the increased on-chain // fee the server has to pay when the sweeping transaction is broadcast. NumDeposits uint32 }
LoopInQuoteRequest specifies the swap parameters for which a quote is requested.
type LoopInRequest ¶
type LoopInRequest struct { // Amount specifies the requested swap amount in sat. This does not // include the swap and miner fee. Amount btcutil.Amount // MaxSwapFee is the maximum we are willing to pay the server for the // swap. This value is not disclosed in the swap initiation call, but if // the server asks for a higher fee, we abort the swap. Typically this // value is taken from the response of the LoopInQuote call. It // includes the prepay amount. MaxSwapFee btcutil.Amount // MaxMinerFee is the maximum in on-chain fees that we are willing to // spent. If we publish the on-chain htlc and the fee estimate turns out // higher than this value, we cancel the swap. // // MaxMinerFee is typically taken from the response of the LoopInQuote // call. MaxMinerFee btcutil.Amount // HtlcConfTarget specifies the targeted confirmation target for the // client htlc tx. HtlcConfTarget int32 // LastHop optionally specifies the last hop to use for the loop in // payment. LastHop *route.Vertex // ExternalHtlc specifies whether the htlc is published by an external // source. ExternalHtlc bool // Label contains an optional label for the swap. Label string // Initiator is an optional string that identifies what software // initiated the swap (loop CLI, autolooper, LiT UI and so on) and is // appended to the user agent string. Initiator string // Private indicates whether the destination node should be considered // private. In which case, loop will generate hophints to assist with // probing and payment. Private bool // RouteHints are optional route hints to reach the destination through // private channels. RouteHints [][]zpay32.HopHint }
LoopInRequest contains the required parameters for the swap.
type LoopInSwapInfo ¶
type LoopInSwapInfo struct { // SwapHash contains the sha256 hash of the swap preimage. SwapHash lntypes.Hash // HtlcAddressP2WSH contains the native segwit swap htlc address, // where the loop-in funds may be paid. HtlcAddressP2WSH btcutil.Address // HtlcAddressP2TR contains the v3 (pay to taproot) htlc address. HtlcAddressP2TR btcutil.Address // ServerMessage is the human-readable message received from the loop // server. ServerMessage string }
LoopInSwapInfo contains essential information of a loop-in swap after the swap is initiated.
type LoopInTerms ¶
type LoopInTerms struct { // MinSwapAmount is the minimum amount that the server requires for a // swap. MinSwapAmount btcutil.Amount // MaxSwapAmount is the maximum amount that the server accepts for a // swap. MaxSwapAmount btcutil.Amount }
LoopInTerms are the server terms on which it executes loop in swaps.
type LoopOutQuote ¶
type LoopOutQuote struct { // SwapFee is the fee that the swap server is charging for the swap. SwapFee btcutil.Amount // PrepayAmount is the part of the swap fee that is requested as a // prepayment. PrepayAmount btcutil.Amount // MinerFee is an estimate of the on-chain fee that needs to be paid to // sweep the htlc. MinerFee btcutil.Amount // SwapPaymentDest is the node pubkey where to swap payment needs to be // sent to. SwapPaymentDest [33]byte }
LoopOutQuote contains estimates for the fees making up the total swap cost for the client.
type LoopOutQuoteRequest ¶
type LoopOutQuoteRequest struct { // Amount specifies the requested swap amount in sat. This does not // include the swap and miner fee. Amount btcutil.Amount // SweepConfTarget specifies the targeted confirmation target for the // client sweep tx. SweepConfTarget int32 // SwapPublicationDeadline can be set by the client to allow the server // delaying publication of the swap HTLC to save on chain fees. SwapPublicationDeadline time.Time // Initiator is an optional string that identifies what software // initiated the swap (loop CLI, autolooper, LiT UI and so on) and is // appended to the user agent string. Initiator string }
LoopOutQuoteRequest specifies the swap parameters for which a quote is requested.
type LoopOutSwapInfo ¶
type LoopOutSwapInfo struct { // SwapHash contains the sha256 hash of the swap preimage. SwapHash lntypes.Hash // HtlcAddress contains the swap htlc address that the server will // publish to. HtlcAddress btcutil.Address // ServerMessage is the human-readable message received from the loop // server. ServerMessage string }
LoopOutSwapInfo contains essential information of a loop-out swap after the swap is initiated.
type LoopOutTerms ¶
type LoopOutTerms struct { // MinSwapAmount is the minimum amount that the server requires for a // swap. MinSwapAmount btcutil.Amount // MaxSwapAmount is the maximum amount that the server accepts for a // swap. MaxSwapAmount btcutil.Amount // MinCltvDelta is the minimum expiry delta for loop out swaps. MinCltvDelta int32 // MaxCltvDelta is the maximum expiry delta for loop out swaps. MaxCltvDelta int32 }
LoopOutTerms are the server terms on which it executes swaps.
type Out ¶
type Out struct { // LoopOutContract describes the details of this loop.Out. Using these // details,the full swap can be executed. loopdb.LoopOutContract // State is the current state of the target swap. State loopdb.SwapState // SwapInfoKit contains shared data amongst all swap types. SwapInfoKit }
Out contains the full details of a loop out request. This includes things like the payment hash, the total value, and the final CTLV delay of the swap. We'll use this to track an active swap throughout that various swap stages.
type OutRequest ¶
type OutRequest struct { // Amount specifies the requested swap amount in sat. This does not // include the swap and miner fee. Amount btcutil.Amount // Destination address for the swap. DestAddr btcutil.Address // IsExternalAddr indicates whether the provided destination address // does not belong to the underlying wallet. This helps indicate // whether the sweep of this swap can be batched or not. IsExternalAddr bool // MaxSwapRoutingFee is the maximum off-chain fee in msat that may be // paid for payment to the server. This limit is applied during path // finding. Typically this value is taken from the response of the // LoopOutQuote call. MaxSwapRoutingFee btcutil.Amount // MaxPrepayRoutingFee is the maximum off-chain fee in msat that may be // paid for payment to the server. This limit is applied during path // finding. Typically this value is taken from the response of the // LoopOutQuote call. MaxPrepayRoutingFee btcutil.Amount // MaxSwapFee is the maximum we are willing to pay the server for the // swap. This value is not disclosed in the swap initiation call, but // if the server asks for a higher fee, we abort the swap. Typically // this value is taken from the response of the LoopOutQuote call. It // includes the prepay amount. MaxSwapFee btcutil.Amount // MaxPrepayAmount is the maximum amount of the swap fee that may be // charged as a prepayment. MaxPrepayAmount btcutil.Amount // MaxMinerFee is the maximum in on-chain fees that we are willing to // spent. If we want to sweep the on-chain htlc and the fee estimate // turns out higher than this value, we cancel the swap. If the fee // estimate is lower, we publish the sweep tx. // // If the sweep tx isn't confirmed, we are forced to ratchet up fees // until it is swept. Possibly even exceeding MaxMinerFee if we get // close to the htlc timeout. Because the initial publication revealed // the preimage, we have no other choice. The server may already have // pulled the off-chain htlc. Only when the fee becomes higher than the // swap amount, we can only wait for fees to come down and hope - if we // are past the timeout - that the server isn't publishing the // revocation. // // MaxMinerFee is typically taken from the response of the // LoopOutQuote call. MaxMinerFee btcutil.Amount // SweepConfTarget specifies the targeted confirmation target for the // client sweep tx. SweepConfTarget int32 // HtlcConfirmations specifies the number of confirmations we require // for on chain loop out htlcs. HtlcConfirmations int32 // OutgoingChanSet optionally specifies the short channel ids of the // channels that may be used to loop out. OutgoingChanSet loopdb.ChannelSet // SwapPublicationDeadline can be set by the client to allow the server // delaying publication of the swap HTLC to save on chain fees. SwapPublicationDeadline time.Time // Expiry is the absolute expiry height of the on-chain htlc. Expiry int32 // Label contains an optional label for the swap. Label string // Initiator is an optional string that identifies what software // initiated the swap (loop CLI, autolooper, LiT UI and so on) and is // appended to the user agent string. Initiator string // PaymentTimeout specifies the payment timeout for the individual // off-chain payments. As the swap payment may be retried (depending on // the configured maximum payment timeout) the total time spent may be // a multiple of this value. PaymentTimeout time.Duration }
OutRequest contains the required parameters for a loop out swap.
type ProbeRequest ¶
type ProbeRequest struct { // Amount is the amount that will be probed. Amount btcutil.Amount // LastHop is the last hop along the route. LastHop *route.Vertex // Optional hop hints. RouteHints [][]zpay32.HopHint }
ProbeRequest specifies probe parameters for the server probe.
type RoutingPlugin ¶
type RoutingPlugin interface { // Init initializes the routing plugin. Init(ctx context.Context, target route.Vertex, routeHints [][]zpay32.HopHint, amt btcutil.Amount) error // Done deinitializes the routing plugin (restoring any state the // plugin might have changed). Done(ctx context.Context) error // BeforePayment is called before each payment. Attempt counter is // passed, counting attempts from 1. BeforePayment(ctx context.Context, attempt int, maxAttempts int) error }
RoutingPlugin is a generic interface for off-chain payment helpers.
func AcquireRoutingPlugin ¶
func AcquireRoutingPlugin(ctx context.Context, pluginType RoutingPluginType, lnd lndclient.LndServices, target route.Vertex, routeHints [][]zpay32.HopHint, amt btcutil.Amount) ( RoutingPlugin, error)
AcquireRoutingPlugin will return a RoutingPlugin instance (or nil). As the LND instance used is a shared resource, currently only one requestor will be able to acquire a RoutingPlugin instance. If someone is already holding the instance a nil is returned.
type RoutingPluginType ¶
type RoutingPluginType uint8
RoutingPluginType represents the routing plugin type directly.
const ( // RoutingPluginNone is recommended when the client shouldn't use any // routing plugin. RoutingPluginNone RoutingPluginType = 0 // RoutingPluginLowHigh is recommended when the client should use // low-high routing method. RoutingPluginLowHigh RoutingPluginType = 1 )
func (RoutingPluginType) String ¶
func (r RoutingPluginType) String() string
String pretty prints a RoutingPluginType.
type SelectHopHintsCfg ¶
type SelectHopHintsCfg struct { // IsPublicNode is returns a bool indicating whether the node with the // given public key is seen as a public node in the graph from the // graph's source node's point of view. IsPublicNode func(pubKey [33]byte) (bool, error) // FetchChannelEdgesByID attempts to lookup the two directed edges for // the channel identified by the channel ID. FetchChannelEdgesByID func(chanID uint64) (*models.ChannelEdgeInfo, *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) // GetAlias allows the peer's alias SCID to be retrieved for private // option_scid_alias channels. GetAlias func(lnwire.ChannelID) (lnwire.ShortChannelID, error) }
SelectHopHintsCfg contains the dependencies required to obtain hop hints for an invoice.
type ServerUpdate ¶
type ServerUpdate struct { // State is the state that the server has sent us. State swapserverrpc.ServerSwapState // Timestamp is the time of the server state update. Timestamp time.Time }
ServerUpdate summarizes an update from the swap server.
type StaticAddressLoopInRequest ¶
type StaticAddressLoopInRequest struct { // DepositOutpoints contain the outpoints in format txid:idx of the // static address deposits that are being looped in. The sum of output // values constitute the swap amount. DepositOutpoints []string // MaxSwapFee is the maximum we are willing to pay the server for the // swap. This value is not disclosed in the swap initiation call, but if // the server asks for a higher fee, we abort the swap. Typically, this // value is taken from the response of the LoopInQuote call. It // includes the pre-pay amount. MaxSwapFee btcutil.Amount // LastHop optionally specifies the last hop to use for the loop in // payment. LastHop *route.Vertex // Label contains an optional text label for the swap. Label string // Initiator is an optional string that identifies what software // initiated the swap (loop CLI, autolooper, LiT UI and so on) and is // appended to the user agent string. Initiator string // Private indicates whether the destination node should be considered // private. In which case, loop will generate hophints to assist with // probing and payment. Private bool // RouteHints are optional route hints to reach the destination through // private channels. RouteHints [][]zpay32.HopHint // PaymentTimeoutSeconds allows the user to specify an upper limit for // the amount of time the server is allowed to fulfill the off-chain // swap payment. If the timeout is reached the swap will be aborted and // the client can retry the swap if desired with different parameters. PaymentTimeoutSeconds uint32 }
StaticAddressLoopInRequest contains the required parameters for the swap.
type SwapInfo ¶
type SwapInfo struct { loopdb.SwapStateData loopdb.SwapContract // LastUpdate is the time of the last state change. LastUpdate time.Time // SwapHash stores the swap preimage hash. SwapHash lntypes.Hash // SwapType describes whether this is a loop in or loop out swap. SwapType swap.Type // HtlcAddressP2WSH stores the address of the P2WSH (native segwit) // swap htlc. This is used for both loop-in and loop-out. HtlcAddressP2WSH btcutil.Address // HtlcAddressP2TR stores the address of the P2TR (taproot) swap htlc. // This is used for both internal and external loop-in and loop out. HtlcAddressP2TR btcutil.Address // ExternalHtlc is set to true for external loop-in swaps. ExternalHtlc bool // LastHop optionally specifies the last hop to use for the loop in // payment. On a loop out this field is nil. LastHop *route.Vertex // OutgoingChanSet optionally specifies the short channel ids of the // channels that may be used to loop out. On a loop in this field // is nil. OutgoingChanSet loopdb.ChannelSet }
SwapInfo exposes common info fields for loop in and loop out swaps.
type SwapInfoKit ¶
type SwapInfoKit struct { // Hash is the sha256 hash of the preimage that unlocks the htlcs. It // is used to uniquely identify this swap. Hash lntypes.Hash // LastUpdateTime is the time of the last update of this swap. LastUpdateTime time.Time }
SwapInfoKit contains common swap info fields.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package liquidity is responsible for monitoring our node's liquidity.
|
Package liquidity is responsible for monitoring our node's liquidity. |
looprpc
module
|
|
swapserverrpc
module
|
|