Skip to content

Commit 69b3d9d

Browse files
committed
Thread destination through max_sendable signature
Reshape MdkClient::max_sendable to accept Option<&PaymentInstructions> so the follow-up can wire destination-aware per-hop fee inversion (MDK-865) without churning the signature again. The None branch keeps the v0 buffer behaviour; Some(_) trips a debug_assert until the real implementation lands with the ldk-node bump that exposes Node::find_route. The daemon /getbalance handler now passes None. The JSON field max_withdrawable_sat is unchanged.
1 parent e5c3d66 commit 69b3d9d

4 files changed

Lines changed: 55 additions & 31 deletions

File tree

Cargo.lock

Lines changed: 40 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ demo = []
1616

1717
[dependencies]
1818
# Branch: https://github.com/moneydevkit/ldk-node/tree/lsp-0.7.0_accept-underpaying-htlcs_with_timing_logs
19-
ldk-node = { git = "https://github.com/moneydevkit/ldk-node", rev = "5dce44b6e795560bbf62f49d3648308ce88a0586" }
19+
ldk-node = { git = "https://github.com/moneydevkit/ldk-node", rev = "f13fcead7e02ef4b77489a83854f204de11e902b" }
2020

2121
# Pinned to the same git rev as ldk-node's transitive pull to avoid duplicate
2222
# crate compilation. Verify with `cargo tree -d | grep bitcoin-payment-instructions`.

src/daemon/api/balance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub async fn handle_get_balance(
3535
.map(|ch| ch.outbound_capacity_msat / 1000)
3636
.sum();
3737

38-
let max_withdrawable_sat = client.max_sendable().ok().map(|e| e.amount_msat / 1000);
38+
let max_withdrawable_sat = client.max_sendable(None).ok().map(|e| e.amount_msat / 1000);
3939

4040
Ok(Json(GetBalanceResponse {
4141
balance_sat: lightning_sat,

src/mdk/client.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::str::FromStr;
22
use std::sync::Arc;
33

4+
use bitcoin_payment_instructions::PaymentInstructions;
45
use chrono::{DateTime, SecondsFormat};
56
use ldk_node::bitcoin::hashes::sha256;
67
use ldk_node::bitcoin::hashes::Hash as _;
@@ -147,7 +148,18 @@ impl MdkClient {
147148
/// over Lightning right now, with routing-fee headroom subtracted.
148149
/// Computed inline from `node.list_channels()` on every call so
149150
/// the result reflects in-flight HTLCs and reserve as of *now*.
150-
pub fn max_sendable(&self) -> Result<MaxSendableEstimate, MaxSendableError> {
151+
///
152+
/// `dest` is currently ignored — only the `None` (destination-agnostic
153+
/// buffer) path is implemented.
154+
pub fn max_sendable(
155+
&self,
156+
dest: Option<&PaymentInstructions>,
157+
) -> Result<MaxSendableEstimate, MaxSendableError> {
158+
debug_assert!(
159+
dest.is_none(),
160+
"destination-aware max_sendable is not yet implemented"
161+
);
162+
let _ = dest;
151163
let snaps: Vec<ChannelSnapshot> = self
152164
.node
153165
.list_channels()

0 commit comments

Comments
 (0)