mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: loop in swap
This commit is contained in:
parent
6a0a9556a0
commit
3e960b8b54
28 changed files with 2376 additions and 273 deletions
94
interface.go
94
interface.go
|
|
@ -158,6 +158,90 @@ type LoopOutTerms struct {
|
|||
SwapPaymentDest [33]byte
|
||||
}
|
||||
|
||||
// LoopInRequest contains the required parameters for the swap.
|
||||
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 UnchargeQuote 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 UnchargeQuote
|
||||
// call.
|
||||
MaxMinerFee btcutil.Amount
|
||||
|
||||
// HtlcConfTarget specifies the targeted confirmation target for the
|
||||
// client htlc tx.
|
||||
HtlcConfTarget int32
|
||||
|
||||
// LoopInChannel optionally specifies the short channel id of the
|
||||
// channel to charge.
|
||||
LoopInChannel *uint64
|
||||
}
|
||||
|
||||
// LoopInTerms are the server terms on which it executes charge swaps.
|
||||
type LoopInTerms struct {
|
||||
// SwapFeeBase is the fixed per-swap base fee.
|
||||
SwapFeeBase btcutil.Amount
|
||||
|
||||
// SwapFeeRate is the variable fee in parts per million.
|
||||
SwapFeeRate int64
|
||||
|
||||
// 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
|
||||
|
||||
// Time lock delta relative to current block height that swap server
|
||||
// will accept on the swap initiation call.
|
||||
CltvDelta int32
|
||||
}
|
||||
|
||||
// In contains status information for a loop in swap.
|
||||
type In struct {
|
||||
loopdb.LoopInContract
|
||||
|
||||
SwapInfoKit
|
||||
|
||||
// State where the swap is in.
|
||||
State loopdb.SwapState
|
||||
}
|
||||
|
||||
// LoopInQuoteRequest specifies the swap parameters for which a quote is
|
||||
// requested.
|
||||
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
|
||||
}
|
||||
|
||||
// LoopInQuote contains estimates for the fees making up the total swap cost
|
||||
// for the client.
|
||||
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
|
||||
}
|
||||
|
||||
// SwapInfoKit contains common swap info fields.
|
||||
type SwapInfoKit struct {
|
||||
// Hash is the sha256 hash of the preimage that unlocks the htlcs. It
|
||||
|
|
@ -191,3 +275,13 @@ type SwapInfo struct {
|
|||
|
||||
loopdb.SwapContract
|
||||
}
|
||||
|
||||
// LastUpdate returns the last update time of the swap
|
||||
func (s *In) LastUpdate() time.Time {
|
||||
return s.LastUpdateTime
|
||||
}
|
||||
|
||||
// SwapHash returns the swap hash.
|
||||
func (s *In) SwapHash() lntypes.Hash {
|
||||
return s.Hash
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue