@@ -2,6 +2,7 @@ package liquidity
22
33import (
44 "context"
5+ "encoding/hex"
56
67 "github.com/btcsuite/btcd/btcutil"
78 "github.com/lightninglabs/loop"
@@ -84,6 +85,11 @@ func (b *loopOutBuilder) inUse(traffic *swapTraffic, peer route.Vertex,
8485 return nil
8586}
8687
88+ type assetSwapInfo struct {
89+ assetId string
90+ peerPubkey []byte
91+ }
92+
8793// buildSwap creates a swap for the target peer/channels provided. The autoloop
8894// boolean indicates whether this swap will actually be executed, because there
8995// are some calls we can leave out if this swap is just for a dry run (ie, when
@@ -94,14 +100,35 @@ func (b *loopOutBuilder) inUse(traffic *swapTraffic, peer route.Vertex,
94100// dry-run, and we do not add the autoloop label to the recommended swap.
95101func (b * loopOutBuilder ) buildSwap (ctx context.Context , pubkey route.Vertex ,
96102 channels []lnwire.ShortChannelID , amount btcutil.Amount ,
97- params Parameters ) (swapSuggestion , error ) {
103+ params Parameters , assetSwap * assetSwapInfo ) (swapSuggestion , error ) {
104+
105+ var (
106+ assetRfqRequest * loop.AssetRFQRequest
107+ assetIdBytes []byte
108+ err error
109+ )
110+
111+ initatior := getInitiator (params )
112+
113+ if assetSwap != nil {
114+ assetIdBytes , err = hex .DecodeString (assetSwap .assetId )
115+ if err != nil {
116+ return nil , err
117+ }
118+ assetRfqRequest = & loop.AssetRFQRequest {
119+ AssetId : assetIdBytes ,
120+ AssetEdgeNode : assetSwap .peerPubkey ,
121+ }
122+ initatior += "-" + assetSwap .assetId
123+ }
98124
99125 quote , err := b .cfg .LoopOutQuote (
100126 ctx , & loop.LoopOutQuoteRequest {
101127 Amount : amount ,
102128 SweepConfTarget : params .SweepConfTarget ,
103129 SwapPublicationDeadline : b .cfg .Clock .Now (),
104- Initiator : getInitiator (params ),
130+ Initiator : initatior ,
131+ AssetRFQRequest : assetRfqRequest ,
105132 },
106133 )
107134 if err != nil {
@@ -146,7 +173,13 @@ func (b *loopOutBuilder) buildSwap(ctx context.Context, pubkey route.Vertex,
146173 MaxSwapFee : quote .SwapFee ,
147174 MaxPrepayAmount : quote .PrepayAmount ,
148175 SweepConfTarget : params .SweepConfTarget ,
149- Initiator : getInitiator (params ),
176+ Initiator : initatior ,
177+ }
178+
179+ if assetSwap != nil {
180+ request .AssetId = assetIdBytes
181+ request .AssetPrepayRfqId = quote .LoopOutRfq .PrepayRfqId
182+ request .AssetSwapRfqId = quote .LoopOutRfq .SwapRfqId
150183 }
151184
152185 if params .Autoloop {
0 commit comments