Skip to content

Commit 5c7e16e

Browse files
committed
fixup! Add BOLT11 underpaying send RPC
AI-assisted-by: OpenAI Codex
1 parent ccef6ac commit 5c7e16e

7 files changed

Lines changed: 33 additions & 16 deletions

File tree

docs/api-guide.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,17 @@ All RPCs are unary (single request, single response) unless noted otherwise.
9393

9494
### BOLT11 Payments
9595

96-
| RPC | Description |
97-
|---------------------------|------------------------------------------------------------------------------------|
98-
| `Bolt11Receive` | Create an invoice (fixed or variable amount) with automatic claim |
99-
| `Bolt11Send` | Pay a BOLT11 invoice (with optional routing config) |
100-
| `Bolt11SendUnderpaying` | Pay less than the invoice amount when the receiver accepts underpaying HTLCs |
96+
| RPC | Description |
97+
|-------------------------|-------------------------------------------------------------------|
98+
| `Bolt11Receive` | Create an invoice (fixed or variable amount) with automatic claim |
99+
| `Bolt11Send` | Pay a BOLT11 invoice (with optional routing config) |
100+
| `Bolt11SendUnderpaying` | Send part of the amount for a BOLT11 invoice |
101+
102+
> [!NOTE]
103+
> `Bolt11SendUnderpaying` sends one part of a multi-part payment (MPP) for a BOLT11
104+
> invoice. Other nodes must send compatible partial payments for the same invoice until
105+
> the combined amount equals the invoice amount. Without those payments, the receiver
106+
> holds the incomplete MPP payment and eventually fails it.
101107
102108
### BOLT11 Hodl Invoices
103109

ldk-server-cli/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,14 @@ enum Commands {
247247
)]
248248
max_channel_saturation_power_of_half: Option<u32>,
249249
},
250-
#[command(about = "Underpay a BOLT11 invoice")]
250+
#[command(
251+
about = "Send part of a BOLT11 invoice. Other nodes must send partial payments for the same invoice until the combined amount equals the invoice amount"
252+
)]
251253
Bolt11SendUnderpaying {
252254
#[arg(help = "A BOLT11 invoice for a payment within the Lightning Network")]
253255
invoice: String,
254256
#[arg(
255-
help = "Amount to send, e.g. 50sat or 50000msat. Must be less than the invoice amount"
257+
help = "Amount from this payer, for example 50sat or 50000msat. Must be less than the invoice amount"
256258
)]
257259
amount: Amount,
258260
#[arg(

ldk-server-client/src/client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ impl LdkServerClient {
244244
self.grpc_unary(&request, BOLT11_SEND_PATH).await
245245
}
246246

247-
/// Send an underpaying payment for a BOLT11 invoice.
247+
/// Send part of the amount for a BOLT11 invoice.
248+
///
249+
/// Other nodes must send partial payments for the same invoice until the combined amount equals
250+
/// the invoice amount. Without those payments, the receiver holds the incomplete MPP payment
251+
/// and eventually fails it.
248252
pub async fn bolt11_send_underpaying(
249253
&self, request: Bolt11SendUnderpayingRequest,
250254
) -> Result<Bolt11SendUnderpayingResponse, LdkServerError> {

ldk-server-grpc/src/api.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ pub struct Bolt11SendResponse {
376376
#[prost(string, tag = "1")]
377377
pub payment_id: ::prost::alloc::string::String,
378378
}
379-
/// Send an underpaying payment for a BOLT11 invoice.
379+
/// Send part of the amount for a BOLT11 invoice.
380+
/// Other nodes must send partial payments for the same invoice until the combined amount equals the invoice amount.
381+
/// Without those payments, the receiver holds the incomplete MPP payment and eventually fails it.
380382
/// See more: <https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt11Payment.html#method.send_using_amount_underpaying>
381383
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
382384
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
@@ -387,7 +389,7 @@ pub struct Bolt11SendUnderpayingRequest {
387389
/// An invoice for a payment within the Lightning Network.
388390
#[prost(string, tag = "1")]
389391
pub invoice: ::prost::alloc::string::String,
390-
/// Amount in millisatoshis to send. Must be less than the amount required by the invoice.
392+
/// Amount in millisatoshis from this payer. Must be less than the amount required by the invoice.
391393
#[prost(uint64, tag = "2")]
392394
pub amount_msat: u64,
393395
/// Configuration options for payment routing and pathfinding.

ldk-server-grpc/src/proto/api.proto

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,16 @@ message Bolt11SendResponse {
296296
string payment_id = 1;
297297
}
298298

299-
// Send an underpaying payment for a BOLT11 invoice.
299+
// Send part of the amount for a BOLT11 invoice.
300+
// Other nodes must send partial payments for the same invoice until the combined amount equals the invoice amount.
301+
// Without those payments, the receiver holds the incomplete MPP payment and eventually fails it.
300302
// See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt11Payment.html#method.send_using_amount_underpaying
301303
message Bolt11SendUnderpayingRequest {
302304

303305
// An invoice for a payment within the Lightning Network.
304306
string invoice = 1;
305307

306-
// Amount in millisatoshis to send. Must be less than the amount required by the invoice.
308+
// Amount in millisatoshis from this payer. Must be less than the amount required by the invoice.
307309
uint64 amount_msat = 2;
308310

309311
// Configuration options for payment routing and pathfinding.
@@ -950,7 +952,8 @@ service LightningNode {
950952
rpc Bolt11ReceiveVariableAmountViaJitChannel(Bolt11ReceiveVariableAmountViaJitChannelRequest) returns (Bolt11ReceiveVariableAmountViaJitChannelResponse);
951953
// Send a payment for a BOLT11 invoice.
952954
rpc Bolt11Send(Bolt11SendRequest) returns (Bolt11SendResponse);
953-
// Send an underpaying payment for a BOLT11 invoice.
955+
// Send part of the amount for a BOLT11 invoice.
956+
// Other nodes must send partial payments for the same invoice until the combined amount equals the invoice amount.
954957
rpc Bolt11SendUnderpaying(Bolt11SendUnderpayingRequest) returns (Bolt11SendUnderpayingResponse);
955958
// Return a BOLT12 offer.
956959
rpc Bolt12Receive(Bolt12ReceiveRequest) returns (Bolt12ReceiveResponse);

ldk-server-mcp/src/tools/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub fn build_tool_registry() -> ToolRegistry {
141141
),
142142
tool_spec(
143143
"bolt11_send_underpaying",
144-
"Underpay a BOLT11 Lightning invoice",
144+
"Send part of a BOLT11 invoice. Other nodes must send partial payments for the same invoice until the combined amount equals the invoice amount",
145145
schema::bolt11_send_underpaying_schema,
146146
|client, args| Box::pin(handlers::handle_bolt11_send_underpaying(client, args)),
147147
),

ldk-server-mcp/src/tools/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,11 @@ pub fn bolt11_send_underpaying_schema() -> Value {
317317
"properties": {
318318
"invoice": {
319319
"type": "string",
320-
"description": "A BOLT11 invoice string to underpay"
320+
"description": "The BOLT11 invoice that all payers use"
321321
},
322322
"amount_msat": {
323323
"type": "integer",
324-
"description": "Amount in millisatoshis to send. Must be less than the invoice amount"
324+
"description": "Amount in millisatoshis from this payer. Must be less than the invoice amount"
325325
},
326326
"route_parameters": route_parameters_config_schema()
327327
},

0 commit comments

Comments
 (0)