@@ -200,6 +200,16 @@ func newAddress(ctx *cli.Context) error {
200
200
return nil
201
201
}
202
202
203
+ var coinSelectionStrategyFlag = cli.StringFlag {
204
+ Name : "coin_selection_strategy" ,
205
+ Usage : "(optional) the strategy to use for selecting " +
206
+ "coins. Possible values are 'largest', 'random', or " +
207
+ "'global-config'. If either 'largest' or 'random' is " +
208
+ "specified, it will override the globally configured " +
209
+ "strategy in lnd.conf" ,
210
+ Value : "global-config" ,
211
+ }
212
+
203
213
var estimateFeeCommand = cli.Command {
204
214
Name : "estimatefee" ,
205
215
Category : "On-chain" ,
@@ -215,9 +225,10 @@ var estimateFeeCommand = cli.Command{
215
225
Flags : []cli.Flag {
216
226
cli.Int64Flag {
217
227
Name : "conf_target" ,
218
- Usage : "(optional) the number of blocks that the transaction *should* " +
219
- "confirm in" ,
228
+ Usage : "(optional) the number of blocks that the " +
229
+ "transaction *should* confirm in" ,
220
230
},
231
+ coinSelectionStrategyFlag ,
221
232
},
222
233
Action : actionDecorator (estimateFees ),
223
234
}
@@ -231,12 +242,18 @@ func estimateFees(ctx *cli.Context) error {
231
242
return err
232
243
}
233
244
245
+ coinSelectionStrategy , err := parseCoinSelectionStrategy (ctx )
246
+ if err != nil {
247
+ return err
248
+ }
249
+
234
250
client , cleanUp := getClient (ctx )
235
251
defer cleanUp ()
236
252
237
253
resp , err := client .EstimateFee (ctxc , & lnrpc.EstimateFeeRequest {
238
- AddrToAmount : amountToAddr ,
239
- TargetConf : int32 (ctx .Int64 ("conf_target" )),
254
+ AddrToAmount : amountToAddr ,
255
+ TargetConf : int32 (ctx .Int64 ("conf_target" )),
256
+ CoinSelectionStrategy : coinSelectionStrategy ,
240
257
})
241
258
if err != nil {
242
259
return err
@@ -313,6 +330,7 @@ var sendCoinsCommand = cli.Command{
313
330
"terminal avoid breaking existing shell " +
314
331
"scripts" ,
315
332
},
333
+ coinSelectionStrategyFlag ,
316
334
txLabelFlag ,
317
335
},
318
336
Action : actionDecorator (sendCoins ),
@@ -375,6 +393,11 @@ func sendCoins(ctx *cli.Context) error {
375
393
"sweep all coins out of the wallet" )
376
394
}
377
395
396
+ coinSelectionStrategy , err := parseCoinSelectionStrategy (ctx )
397
+ if err != nil {
398
+ return err
399
+ }
400
+
378
401
client , cleanUp := getClient (ctx )
379
402
defer cleanUp ()
380
403
minConfs := int32 (ctx .Uint64 ("min_confs" ))
@@ -409,14 +432,15 @@ func sendCoins(ctx *cli.Context) error {
409
432
}
410
433
411
434
req := & lnrpc.SendCoinsRequest {
412
- Addr : addr ,
413
- Amount : amt ,
414
- TargetConf : int32 (ctx .Int64 ("conf_target" )),
415
- SatPerVbyte : ctx .Uint64 (feeRateFlag ),
416
- SendAll : ctx .Bool ("sweepall" ),
417
- Label : ctx .String (txLabelFlag .Name ),
418
- MinConfs : minConfs ,
419
- SpendUnconfirmed : minConfs == 0 ,
435
+ Addr : addr ,
436
+ Amount : amt ,
437
+ TargetConf : int32 (ctx .Int64 ("conf_target" )),
438
+ SatPerVbyte : ctx .Uint64 (feeRateFlag ),
439
+ SendAll : ctx .Bool ("sweepall" ),
440
+ Label : ctx .String (txLabelFlag .Name ),
441
+ MinConfs : minConfs ,
442
+ SpendUnconfirmed : minConfs == 0 ,
443
+ CoinSelectionStrategy : coinSelectionStrategy ,
420
444
}
421
445
txid , err := client .SendCoins (ctxc , req )
422
446
if err != nil {
@@ -585,6 +609,7 @@ var sendManyCommand = cli.Command{
585
609
"must satisfy" ,
586
610
Value : defaultUtxoMinConf ,
587
611
},
612
+ coinSelectionStrategyFlag ,
588
613
txLabelFlag ,
589
614
},
590
615
Action : actionDecorator (sendMany ),
@@ -615,17 +640,23 @@ func sendMany(ctx *cli.Context) error {
615
640
return err
616
641
}
617
642
643
+ coinSelectionStrategy , err := parseCoinSelectionStrategy (ctx )
644
+ if err != nil {
645
+ return err
646
+ }
647
+
618
648
client , cleanUp := getClient (ctx )
619
649
defer cleanUp ()
620
650
621
651
minConfs := int32 (ctx .Uint64 ("min_confs" ))
622
652
txid , err := client .SendMany (ctxc , & lnrpc.SendManyRequest {
623
- AddrToAmount : amountToAddr ,
624
- TargetConf : int32 (ctx .Int64 ("conf_target" )),
625
- SatPerVbyte : ctx .Uint64 (feeRateFlag ),
626
- Label : ctx .String (txLabelFlag .Name ),
627
- MinConfs : minConfs ,
628
- SpendUnconfirmed : minConfs == 0 ,
653
+ AddrToAmount : amountToAddr ,
654
+ TargetConf : int32 (ctx .Int64 ("conf_target" )),
655
+ SatPerVbyte : ctx .Uint64 (feeRateFlag ),
656
+ Label : ctx .String (txLabelFlag .Name ),
657
+ MinConfs : minConfs ,
658
+ SpendUnconfirmed : minConfs == 0 ,
659
+ CoinSelectionStrategy : coinSelectionStrategy ,
629
660
})
630
661
if err != nil {
631
662
return err
0 commit comments