Skip to content

Commit 6814b3d

Browse files
committed
staticaddr: loop-in manager and fsm
1 parent 81846ce commit 6814b3d

File tree

8 files changed

+2372
-4
lines changed

8 files changed

+2372
-4
lines changed

interface.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,42 @@ type LoopInRequest struct {
234234
RouteHints [][]zpay32.HopHint
235235
}
236236

237+
// StaticAddressLoopInRequest contains the required parameters for the swap.
238+
type StaticAddressLoopInRequest struct {
239+
// DepositOutpoints contain the outpoints of the static address deposits
240+
// that are being looped in. The sum of output values constitute the
241+
// swap amount.
242+
DepositOutpoints []string
243+
244+
// MaxSwapFee is the maximum we are willing to pay the server for the
245+
// swap. This value is not disclosed in the swap initiation call, but if
246+
// the server asks for a higher fee, we abort the swap. Typically, this
247+
// value is taken from the response of the LoopInQuote call. It
248+
// includes the pre-pay amount.
249+
MaxSwapFee btcutil.Amount
250+
251+
// LastHop optionally specifies the last hop to use for the loop in
252+
// payment.
253+
LastHop *route.Vertex
254+
255+
// Label contains an optional label for the swap.
256+
Label string
257+
258+
// Initiator is an optional string that identifies what software
259+
// initiated the swap (loop CLI, autolooper, LiT UI and so on) and is
260+
// appended to the user agent string.
261+
Initiator string
262+
263+
// Private indicates whether the destination node should be considered
264+
// private. In which case, loop will generate hophints to assist with
265+
// probing and payment.
266+
Private bool
267+
268+
// RouteHints are optional route hints to reach the destination through
269+
// private channels.
270+
RouteHints [][]zpay32.HopHint
271+
}
272+
237273
// LoopInTerms are the server terms on which it executes loop in swaps.
238274
type LoopInTerms struct {
239275
// MinSwapAmount is the minimum amount that the server requires for a

loopin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig,
248248

249249
// Validate if the response parameters are outside our allowed range
250250
// preventing us from continuing with a swap.
251-
err = validateLoopInContract(currentHeight, swapResp)
251+
err = ValidateLoopInContract(currentHeight, swapResp.expiry)
252252
if err != nil {
253253
return nil, err
254254
}
@@ -429,11 +429,11 @@ func resumeLoopInSwap(_ context.Context, cfg *swapConfig,
429429
return swap, nil
430430
}
431431

432-
// validateLoopInContract validates the contract parameters against our request.
433-
func validateLoopInContract(height int32, response *newLoopInResponse) error {
432+
// ValidateLoopInContract validates the contract parameters against our request.
433+
func ValidateLoopInContract(height int32, htlcExpiry int32) error {
434434
// Verify that we are not forced to publish a htlc that locks up our
435435
// funds for too long in case the server doesn't follow through.
436-
if response.expiry-height > MaxLoopInAcceptDelta {
436+
if htlcExpiry-height > MaxLoopInAcceptDelta {
437437
return ErrExpiryTooFar
438438
}
439439

0 commit comments

Comments
 (0)