Skip to content

Commit 8916f80

Browse files
committed
loopout: add asset id and edge node
1 parent c5bb544 commit 8916f80

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

client.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,13 @@ func (s *Client) LoopOut(globalCtx context.Context,
530530

531531
// Create a new swap object for this swap.
532532
swapCfg := newSwapConfig(s.lndServices, s.Store, s.Server, s.assetClient)
533+
534+
// Verify that if we have an asset id set, we have a valid asset client
535+
// to use.
536+
if request.AssetId != nil && s.assetClient == nil {
537+
return nil, errors.New("asset id set but no asset client provided")
538+
}
539+
533540
initResult, err := newLoopOutSwap(
534541
globalCtx, swapCfg, initiationHeight, request,
535542
)

interface.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ type OutRequest struct {
9898
// the configured maximum payment timeout) the total time spent may be
9999
// a multiple of this value.
100100
PaymentTimeout time.Duration
101+
102+
// AssetId is an optional asset id that can be used to specify the asset
103+
// that will be used to pay for the swap. If this is set, a connection
104+
// to a tapd server is required to pay for the asset.
105+
AssetId []byte
106+
107+
// AssetEdgeNode is an optional Parameter that is required should the
108+
// tapd server have multiple channels with different peers for the given
109+
// asset id.
110+
AssetEdgeNode []byte
101111
}
102112

103113
// Out contains the full details of a loop out request. This includes things

loopd/swapclient_server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
206206
Label: in.Label,
207207
Initiator: in.Initiator,
208208
PaymentTimeout: paymentTimeout,
209+
AssetId: in.AssetId,
210+
AssetEdgeNode: in.AssetEdgeNode,
209211
}
210212

211213
switch {

loopdb/loopout.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ type LoopOutContract struct {
6565
// PaymentTimeout is the timeout for any individual off-chain payment
6666
// attempt.
6767
PaymentTimeout time.Duration
68+
69+
// AssetId is the optional asset id that is used to pay the swap invoice.
70+
AssetId []byte
71+
72+
// AssetEdgeNode is the optional asset edge node that is used to pay the
73+
// swap invoice.
74+
AssetEdgeNode []byte
6875
}
6976

7077
// ChannelSet stores a set of channels.

loopout.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig,
206206
},
207207
OutgoingChanSet: chanSet,
208208
PaymentTimeout: request.PaymentTimeout,
209+
AssetId: request.AssetId,
210+
AssetEdgeNode: request.AssetEdgeNode,
209211
}
210212

211213
swapKit := newSwapKit(

0 commit comments

Comments
 (0)