Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]: lncli command for walletrpc.EstimateFee #8726

Closed
feelancer21 opened this issue May 5, 2024 · 4 comments · Fixed by #8730
Closed

[feature]: lncli command for walletrpc.EstimateFee #8726

feelancer21 opened this issue May 5, 2024 · 4 comments · Fixed by #8730
Assignees
Labels
enhancement Improvements to existing features / behaviour fees Related to the fees paid for transactions (both LN and funding/commitment transactions) P3 might get fixed, nice to have rpc Related to the RPC interface wallet The wallet (lnwallet) which LND uses

Comments

@feelancer21
Copy link
Contributor

I am looking for a lncli command returning the sat_per_kw for a given conf_target. There is walletrpc.EstimateFee, but I cannot find a corresponding lncli command for this. I found lncli estimatefee but this calls lnrpc.EstimateFee.

Have I missed something?

@feelancer21 feelancer21 added the enhancement Improvements to existing features / behaviour label May 5, 2024
@Chinwendu20
Copy link
Contributor

Chinwendu20 commented May 6, 2024

how about this?

lnd/cmd/lncli/commands.go

Lines 212 to 268 in 399ea86

var estimateFeeCommand = cli.Command{
Name: "estimatefee",
Category: "On-chain",
Usage: "Get fee estimates for sending bitcoin on-chain to multiple addresses.",
ArgsUsage: "send-json-string [--conf_target=N]",
Description: `
Get fee estimates for sending a transaction paying the specified amount(s) to the passed address(es).
The send-json-string' param decodes addresses and the amount to send respectively in the following format:
'{"ExampleAddr": NumCoinsInSatoshis, "SecondAddr": NumCoins}'
`,
Flags: []cli.Flag{
cli.Int64Flag{
Name: "conf_target",
Usage: "(optional) the number of blocks that the " +
"transaction *should* confirm in",
},
coinSelectionStrategyFlag,
},
Action: actionDecorator(estimateFees),
}
func estimateFees(ctx *cli.Context) error {
ctxc := getContext()
var amountToAddr map[string]int64
jsonMap := ctx.Args().First()
if err := json.Unmarshal([]byte(jsonMap), &amountToAddr); err != nil {
return err
}
coinSelectionStrategy, err := parseCoinSelectionStrategy(ctx)
if err != nil {
return err
}
client, cleanUp := getClient(ctx)
defer cleanUp()
resp, err := client.EstimateFee(ctxc, &lnrpc.EstimateFeeRequest{
AddrToAmount: amountToAddr,
TargetConf: int32(ctx.Int64("conf_target")),
CoinSelectionStrategy: coinSelectionStrategy,
})
if err != nil {
return err
}
printRespJSON(resp)
return nil
}
var txLabelFlag = cli.StringFlag{
Name: "label",
Usage: "(optional) a label for the transaction",
}

@feelancer21
Copy link
Contributor Author

how about this?

It is not exactly the same. For lnrpc.EstimateFee you have to provice adresses in a json string to get the feerate. It's fine for the usecase of estimating the exact fee in satoshis for a transaction. If you only like to know the current onchain feerate you don't need the overhead of providing the json string.

@guggero
Copy link
Collaborator

guggero commented May 6, 2024

Maybe the new command should therefore be called estimatefeerate to distinguish better between the two use cases?

@feelancer21
Copy link
Contributor Author

Maybe the new command should therefore be called estimatefeerate to distinguish better between the two use cases?

Made a PR yesterday. Named it estimatefee too but placed it as subcommand for wallet, because it calls walletrpc. But now there are two cli.commands with the same name. Not really sure if there are unseen side effects.

But maybe better to discuss it here.
#8730

@saubyk saubyk added wallet The wallet (lnwallet) which LND uses P3 might get fixed, nice to have rpc Related to the RPC interface fees Related to the fees paid for transactions (both LN and funding/commitment transactions) labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features / behaviour fees Related to the fees paid for transactions (both LN and funding/commitment transactions) P3 might get fixed, nice to have rpc Related to the RPC interface wallet The wallet (lnwallet) which LND uses
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants