Skip to content

Commit 3c43376

Browse files
committed
cmd: EstimateFee for explicit inputs
1 parent 2936dbf commit 3c43376

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

cmd/commands/commands.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,20 @@ var estimateFeeCommand = cli.Command{
402402
"transaction *should* confirm in",
403403
},
404404
coinSelectionStrategyFlag,
405+
cli.BoolFlag{
406+
Name: "show_outpoints",
407+
Usage: "(optional) if set, the outpoints that will " +
408+
"be used for the transaction will be printed " +
409+
"to the console",
410+
},
411+
cli.StringSliceFlag{
412+
Name: "utxo",
413+
Usage: "a utxo specified as outpoint(tx:idx) which " +
414+
"will be used as input for the transaction " +
415+
"to be estimated. This flag can be " +
416+
"repeatedly used to specify multiple utxos " +
417+
"as inputs.",
418+
},
405419
},
406420
Action: actionDecorator(estimateFees),
407421
}
@@ -423,10 +437,22 @@ func estimateFees(ctx *cli.Context) error {
423437
client, cleanUp := getClient(ctx)
424438
defer cleanUp()
425439

440+
var outpoints []*lnrpc.OutPoint
441+
if ctx.IsSet("utxo") {
442+
utxos := ctx.StringSlice("utxo")
443+
444+
outpoints, err = lnd.UtxosToOutpoints(utxos)
445+
if err != nil {
446+
return fmt.Errorf("unable to decode utxos: %w", err)
447+
}
448+
}
449+
426450
resp, err := client.EstimateFee(ctxc, &lnrpc.EstimateFeeRequest{
427451
AddrToAmount: amountToAddr,
428452
TargetConf: int32(ctx.Int64("conf_target")),
429453
CoinSelectionStrategy: coinSelectionStrategy,
454+
Outpoints: outpoints,
455+
ShowOutpoints: ctx.Bool("show_outpoints"),
430456
})
431457
if err != nil {
432458
return err

0 commit comments

Comments
 (0)