@@ -2,6 +2,7 @@ package main
22
33import (
44 "context"
5+ "encoding/hex"
56 "fmt"
67 "math"
78 "strconv"
@@ -101,6 +102,20 @@ var loopOutCommand = cli.Command{
101102 "payment might be retried, the actual total " +
102103 "time may be longer" ,
103104 },
105+ cli.StringFlag {
106+ Name : "asset_id" ,
107+ Usage : "the asset ID of the asset to loop out, " +
108+ "if this is set, the loop daemon will " +
109+ "require a connection to a taproot assets " +
110+ "daemon" ,
111+ },
112+ cli.StringFlag {
113+ Name : "asset_edge_node" ,
114+ Usage : "the pubkey of the edge node of the asset to " +
115+ "loop out, this is required if the taproot " +
116+ "assets daemon has multiple channels of the " +
117+ "given asset id with different edge nodes" ,
118+ },
104119 forceFlag ,
105120 labelFlag ,
106121 verboseFlag ,
@@ -134,6 +149,10 @@ func loopOut(ctx *cli.Context) error {
134149 // element.
135150 var outgoingChanSet []uint64
136151 if ctx .IsSet ("channel" ) {
152+ if ctx .IsSet ("asset_id" ) {
153+ return fmt .Errorf ("channel flag is not supported when " +
154+ "looping out assets" )
155+ }
137156 chanStrings := strings .Split (ctx .String ("channel" ), "," )
138157 for _ , chanString := range chanStrings {
139158 chanID , err := strconv .ParseUint (chanString , 10 , 64 )
@@ -186,6 +205,33 @@ func loopOut(ctx *cli.Context) error {
186205 }
187206 }
188207
208+ var assetLoopOutInfo * looprpc.AssetLoopOutRequest
209+
210+ var assetId []byte
211+ if ctx .IsSet ("asset_id" ) {
212+ if ! ctx .IsSet ("asset_edge_node" ) {
213+ return fmt .Errorf ("asset edge node is required when " +
214+ "assetid is set" )
215+ }
216+
217+ assetId , err = hex .DecodeString (ctx .String ("asset_id" ))
218+ if err != nil {
219+ return err
220+ }
221+
222+ assetEdgeNode , err := hex .DecodeString (
223+ ctx .String ("asset_edge_node" ),
224+ )
225+ if err != nil {
226+ return err
227+ }
228+
229+ assetLoopOutInfo = & looprpc.AssetLoopOutRequest {
230+ AssetId : assetId ,
231+ AssetEdgeNode : assetEdgeNode ,
232+ }
233+ }
234+
189235 client , cleanup , err := getClient (ctx )
190236 if err != nil {
191237 return err
@@ -210,6 +256,7 @@ func loopOut(ctx *cli.Context) error {
210256 Amt : int64 (amt ),
211257 ConfTarget : sweepConfTarget ,
212258 SwapPublicationDeadline : uint64 (swapDeadline .Unix ()),
259+ AssetInfo : assetLoopOutInfo ,
213260 }
214261 quote , err := client .LoopOutQuote (context .Background (), quoteReq )
215262 if err != nil {
@@ -281,6 +328,8 @@ func loopOut(ctx *cli.Context) error {
281328 Label : label ,
282329 Initiator : defaultInitiator ,
283330 PaymentTimeout : uint32 (paymentTimeout ),
331+ AssetInfo : assetLoopOutInfo ,
332+ AssetRfqInfo : quote .AssetRfqInfo ,
284333 })
285334 if err != nil {
286335 return err
0 commit comments