Skip to content

Commit 8d2a054

Browse files
committed
fix: don't subtract anchor reserve in fund_max estimate
For fund_max the user wants maximum channel capacity. Don't hold back any anchor reserve — existing wallet UTXOs or future deposits can cover anchor fee-bumping if needed.
1 parent a71e899 commit 8d2a054

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/lib.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,20 +1376,10 @@ impl Node {
13761376
return Err(Error::NotRunning);
13771377
}
13781378

1379-
// Calculate the anchor reserve needed for this new channel.
1380-
let new_channel_anchor_reserve =
1381-
self.config.anchor_channels_config.as_ref().map_or(0, |c| {
1382-
// We can't check peer features before connecting, so assume anchors.
1383-
if !c.trusted_peers_no_reserve.contains(peer_node_id) {
1384-
c.per_channel_reserve_sats
1385-
} else {
1386-
0
1387-
}
1388-
});
1389-
1390-
let cur_anchor_reserve_sats =
1391-
total_anchor_channels_reserve_sats(&self.channel_manager, &self.config);
1392-
let total_reserve = cur_anchor_reserve_sats + new_channel_anchor_reserve;
1379+
// For fund_max, don't subtract any anchor reserve — the user wants
1380+
// maximum channel capacity. Existing wallet UTXOs or future deposits
1381+
// can cover anchor fee-bumping if needed.
1382+
let reserve: u64 = 0;
13931383

13941384
// Use a dummy P2WSH output script (like a real funding output) for size estimation.
13951385
let dummy_hash = bitcoin::hashes::Hash::from_byte_array([0u8; 32]);
@@ -1401,7 +1391,7 @@ impl Node {
14011391
let max_amount = self.wallet.estimate_max_funding_amount(
14021392
dummy_script,
14031393
confirmation_target,
1404-
total_reserve,
1394+
reserve,
14051395
utxos_owned,
14061396
)?;
14071397

@@ -1411,9 +1401,8 @@ impl Node {
14111401

14121402
log_info!(
14131403
self.logger,
1414-
"Estimated max channel funding amount: {}sats (anchor reserve: {}sats)",
1404+
"Estimated max channel funding amount: {}sats",
14151405
max_amount,
1416-
new_channel_anchor_reserve,
14171406
);
14181407

14191408
Ok(max_amount)

0 commit comments

Comments
 (0)