Skip to content

Reject invalid parameters instead of silently dropping them#182

Open
benthecarman wants to merge 2 commits intolightningdevkit:mainfrom
benthecarman:cli-silent
Open

Reject invalid parameters instead of silently dropping them#182
benthecarman wants to merge 2 commits intolightningdevkit:mainfrom
benthecarman:cli-silent

Conversation

@benthecarman
Copy link
Copy Markdown
Collaborator

Previously, onchain_send silently fell back to the node's default fee estimation when given an invalid fee_rate_sat_per_vb (e.g., overflows), and bolt12_receive silently dropped the quantity parameter when amount_msat was not set. Both cases now return an error instead.

Matching CLI-side validation added for both cases.

benthecarman and others added 2 commits April 7, 2026 15:41
Previously, an invalid fee_rate_sat_per_vb (overflows) was silently
collapsed into None via .and_then(), causing the node to substitute
its default fee estimation without informing the user. Now the server
returns an InvalidRequestError and the CLI rejects invalid fee rates
before sending the request.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously, setting quantity without amount_msat silently produced a
variable-amount offer with no quantity constraint. Now both the server
and CLI reject this misconfiguration with a clear error message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Apr 7, 2026

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@benthecarman benthecarman requested a review from tnull April 7, 2026 20:43
},
Commands::OnchainSend { address, amount, send_all, fee_rate_sat_per_vb } => {
if let Some(rate) = fee_rate_sat_per_vb {
// Mirrors FeeRate::from_sat_per_vb: sat/vb * 1000/4 = sat/kwu
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get into that territory, let's just take a dependency on bitcoin and use bitcoin::FeeRate?

Commands::Bolt12Receive { description, amount, expiry_secs, quantity } => {
if quantity.is_some() && amount.is_none() {
handle_error_msg(
"quantity can only be set for fixed-amount offers (amount must be provided)",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debatable, @TheBlueMatt previously wanted to drop quantity from the LDK Node API (lightningdevkit/ldk-node#642, but was closed as abandoned). Matt, do you still think we should?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants