@@ -2,6 +2,7 @@ package main
2
2
3
3
import (
4
4
"context"
5
+ "encoding/hex"
5
6
"fmt"
6
7
"math"
7
8
"strconv"
@@ -101,6 +102,20 @@ var loopOutCommand = cli.Command{
101
102
"payment might be retried, the actual total " +
102
103
"time may be longer" ,
103
104
},
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
+ },
104
119
forceFlag ,
105
120
labelFlag ,
106
121
verboseFlag ,
@@ -134,6 +149,10 @@ func loopOut(ctx *cli.Context) error {
134
149
// element.
135
150
var outgoingChanSet []uint64
136
151
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
+ }
137
156
chanStrings := strings .Split (ctx .String ("channel" ), "," )
138
157
for _ , chanString := range chanStrings {
139
158
chanID , err := strconv .ParseUint (chanString , 10 , 64 )
@@ -186,6 +205,33 @@ func loopOut(ctx *cli.Context) error {
186
205
}
187
206
}
188
207
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
+
189
235
client , cleanup , err := getClient (ctx )
190
236
if err != nil {
191
237
return err
@@ -210,6 +256,7 @@ func loopOut(ctx *cli.Context) error {
210
256
Amt : int64 (amt ),
211
257
ConfTarget : sweepConfTarget ,
212
258
SwapPublicationDeadline : uint64 (swapDeadline .Unix ()),
259
+ AssetInfo : assetLoopOutInfo ,
213
260
}
214
261
quote , err := client .LoopOutQuote (context .Background (), quoteReq )
215
262
if err != nil {
@@ -281,6 +328,8 @@ func loopOut(ctx *cli.Context) error {
281
328
Label : label ,
282
329
Initiator : defaultInitiator ,
283
330
PaymentTimeout : uint32 (paymentTimeout ),
331
+ AssetInfo : assetLoopOutInfo ,
332
+ AssetRfqInfo : quote .AssetRfqInfo ,
284
333
})
285
334
if err != nil {
286
335
return err
0 commit comments