LDK
← All projectsLightning Dev Kit

rust-lightning

Composable Rust libraries for building Lightning wallets, nodes, and services.

BitcoinCryptographic librariesLightning NetworkNormal
Repository coverage

1947 commits in the local evidence base

Every captured commit receives deterministic security triage and a separate communication-quality score. Security candidates and broader second-pass signals receive full-patch Ollama analysis.

305security candidates264second-pass queue1614AI analyses
174commits · 30 days
273commits · 60 days
653commits · 180 days
1332commits · 365 days
Backfill bands
Aug 5 → Feb 6819 seen18 candidatesComplete
Feb 6 → Jun 6468 seen16 candidatesComplete
Jun 6 → Jul 6128 seen8 candidatesComplete
Jul 6 → Aug 561 seen3 candidatesComplete
Commit communication

Does the history explain itself?

Message quality measures whether a commit identifies its scope, purpose, rationale, testing, and supporting references. It does not change the security-severity score.

71/100 average clarity
726Strong · 80–100
857Adequate · 60–79
302Thin · 40–59
62Opaque · 0–39
3security candidates with opaque commit messaging
Read the scoring rubric →
Developer activity

Who is changing the project?

Public Git author strings; identities are not independently verified.

DeveloperCommitsCandidatesAnalyzedHigh riskMessage avg.
Matt Corallo60181423876
Elias Rohrer15415153667
auto-pr-bot622025487
Jeffrey Czyz19645182169
Wilmer Paulino15945155169
Valentine Wallace15715145169
Leo Nash11613116162
Vincenzo Palazzo11311183
Joost Jager16324162069
elnosh401434059
shaavan22622069
wpaulino2059082
Analysis record

Published AI watches

Last scanned 25 minutes ago

Low 48 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Fix 32-bit spin in Vec<u8> deserialization on huge lengths' (#5102)

This commit fixes a bug in how rust-lightning reads variable-length byte blobs on 32-bit systems. A malicious message could claim a huge byte count; on 32-bit builds the old code would try to allocate an oversized buffer in tiny increments…

Integer truncation / cast-down bug in deserializationPotential memory exhaustion / denial-of-service on 32-bit targetsFix caps read chunk size before usize conversion
227b5256by Matt Corallo+1−11 file
No security note in commit
Moderate 62 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Refuse to sign messages that alias channel_announcement serializations' (#5727)

This change tightens a security guardrail in LDK's message-signing helper. Previously, the code refused to sign arbitrary text if the prefixed text happened to look like a 'node_announcement' gossip message, because an attacker could repla…

signature-replay hardeninggossip-message aliasing preventiondefensive signing policy expansion
6bc00947by Matt Corallo+69−143 files
Vendor flagged security relevance
High 76 AI analysisMessage 100 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Refuse to sign messages that alias channel_announcement serializations

This commit fixes a security gap in how the Lightning Dev Kit signs arbitrary messages. Previously, the code refused to sign messages that could be mistaken for a 'node_announcement' gossip message, because such a signature could be replay…

Signature replay / cross-protocol forgery preventionExpansion of existing anti-aliasing guard to additional gossip message typesCommit message explicitly describes forged gossip signature risk
66c2acecby auto-pr-bot+69−143 files
Vendor flagged security relevance
Low 29 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Make Path and Route fields private' (#5068)

This commit makes the internal fields of two data structures, Path and Route, private and adds controlled constructors and read-only accessors. It also adds validation so that empty paths or routes are rejected. The change is primarily a d…

Encapsulation of previously public struct fieldsAddition of input validation in constructors (non-empty hops/paths)Deserialization now rejects invalid empty paths/routes
8f8f95a2by Matt Corallo+83−205 files
No security note in commit
Low 35 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Populate non-witness UTXOs in bump PSBTs' (#5471)

This change fixes how transaction fee-bumping PSBTs (Partially Signed Bitcoin Transactions) are built in LDK. Previously, when a non-witness UTXO (a non-SegWit coin) was used as an input, the PSBT only had a witness UTXO field populated fo…

PSBT input metadata correctness fixNon-witness UTXO now populated for legacy inputs in fee-bump transactionsAffects CPFP anchor and HTLC transaction signing paths
f1688ce6by Matt Corallo+4−21 file
No security note in commit
Moderate 66 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Track refused monitor updates as pending until persisted' (#5663)

This commit fixes a bug in the Lightning Dev Kit's handling of channel monitor updates that are refused because the channel's funding transaction was already spent on-chain. Previously, such refused updates were persisted as a full monitor…

Durability ordering bug: later MonitorEvent::Completed could imply earlier refused update was persistedRefused monitor update may carry forwarded HTLC preimage, creating risk of inconsistent state across restartAsynchronous persistence tracking gap for refused updates
ea277539by Matt Corallo+56−354 files
Vendor flagged security relevance
Informational 15 AI analysisMessage 91 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Expand coverage of splices confirmed before tx_signatures complete' (#5691)

This commit only adds and modifies test code in rust-lightning. It expands test coverage for a specific edge case in Lightning channel splicing: when a splice transaction gets confirmed before both peers have finished exchanging signatures…

11a8e901by Val Wallace+102−411 file
No security note in commit
Informational 15 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Correct FeeEstimator docs on the 253 sat/kW lower bound

This is a documentation-only edit. It corrects a misleading comment in the code that wrongly claimed all fee estimates returned to LDK are forced to be at least 253 satoshis per 1000 weight units. The new comment clarifies that this minimu…

ea2051feby auto-pr-bot+9−31 file
No security note in commit
Moderate 54 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Track splice confirmation while awaiting tx_signatures' (#5570)

This change fixes a bug in Lightning Dev Kit's splicing logic. During a splice, one side can broadcast the new funding transaction as soon as it has the other side's signatures. Previously, if that transaction confirmed on-chain before the…

State-machine inconsistency in channel funding lifecycleMissing chain-source watch for in-flight splice funding transactionPotential failure to send splice_locked after splice confirms during signature exchange
ca778e61by Matt Corallo+245−32 files
No security note in commit
Moderate 63 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Account for current HTLC fees in dust exposure' (#5690)

This change fixes how Lightning nodes calculate the financial risk from tiny ('dust') HTLCs when the current on-chain fee rate is higher than the node's own local fee estimate. Previously, the code only considered a buffered fee rate when …

Incorrect fee exposure accounting for dust HTLCsPotential to accept HTLCs whose commitment/HTLC-success fees exceed their value under current feerateEconomic griefing / forced-channel-closure cost manipulation
cc798f60by Matt Corallo+108−382 files
No security note in commit
Informational 15 AI analysisMessage 91 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Replace cloned array literal with slice::from_ref in reload test' (#5689)

This is a one-line code cleanup in a test file. It replaces a cloned array literal with a slice reference to silence a Rust compiler lint. There is no change to production code, no security fix, and no functional behavior change.

03ca832fby Matt Corallo+1−11 file
No security note in commit
Informational 15 AI analysisMessage 91 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Replace cloned array literal with slice::from_ref in reload test

This is a one-line change in a test file to satisfy a Rust linter warning. It replaces a needless clone of a funding transaction with a reference-based slice construction. There is no functional change, no user-facing behavior change, and …

93e0129cby auto-pr-bot+1−11 file
No security note in commit
Informational 12 AI analysisMessage 91 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Fix CI: rebuild test coin-selection impl and rework reused-ID balance test' (#5684)

This commit is a test-only fix for a broken continuous integration (CI) build. It updates a test mock to match a new function signature and rewrites an existing test to use three nodes instead of two so the test scenario remains valid unde…

17bac68aby Matt Corallo+26−202 files
No security note in commit
Moderate 68 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Guard pending closing signatures before channel_ready' (#5681)

This change fixes a Lightning channel bug where a malicious peer could renegotiate the closing transaction fee while the local node was still waiting for its own signer to produce the final signature. If allowed, the local node might combi…

State-machine guard expansion to prevent fee renegotiation while a closing signature is pendingRisk of combining mismatched signatures across different closing feesRegression test demonstrates malicious peer renegotiation attempt and expected warning rejection
a01273a2by Matt Corallo+169−21 file
No security note in commit
Low 48 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Release wallet UTXOs when FundingBuilder rejects a coin selection' (#5634)

This change fixes a wallet bug in rust-lightning where a UTXO could be selected for a Lightning funding transaction, then rejected because its previous transaction was too large to fit in a Lightning peer message. Previously, that rejectio…

API change to CoinSelectionSource::select_confirmed_utxos adding max_input_prevtx_serialized_lenWalletSync filters UTXOs by prevtx serialized length before selectionFundingBuilder enforces Lightning tx_add_input message-size limit at selection time
56054190by Matt Corallo+148−155 files
No security note in commit
Low 48 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Refuse to pay BOLT 12 invoices with records above experimental range

This commit hardens LDK's BOLT 12 payment logic so it refuses to pay invoices containing very large unknown record types (4 billion and up). These records are legal under the Lightning spec, but LDK doesn't understand them, so the change t…

Defensive refusal to pay invoices with unknown high-numbered TLV recordsReuses existing UnknownRequiredFeatures failure path instead of adding a new oneAdds explicit checks before payment state insertion and route construction
2970372fby auto-pr-bot+106−177 files
No security note in commit
Moderate 64 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Read invoice TLV records above the experimental range

This commit fixes a backward-compatibility bug in LDK's BOLT 12 invoice parser. A previous change had capped the range of 'experimental' TLV record types at 4 billion, but the Lightning spec imposes no upper bound. As a result, invoices cr…

Backward-compatibility regression in deserialization of persisted channel monitorsDenial-of-service via unreadable monitor blocking all channel monitoringSpec compliance fix: TLV record types have no upper bound
9e28db58by auto-pr-bot+133−84 files
No security note in commit
High 74 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Refuse to sign messages that collide with gossip serializations' (#5677)

This change fixes a security issue where a signed text message could be crafted so that its prefixed form looks exactly like a Lightning 'node_announcement' gossip message. Because both use the same double-SHA256 hash and the same signing …

Signature replay / message confusion between signed messages and gossip announcementsForged `node_announcement` signatures via chosen-prefix message constructionNew validation rejects prefixed messages that deserialize as `UnsignedNodeAnnouncement`
ec40e097by Matt Corallo+74−148 files
Vendor flagged security relevance
Low 37 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Retry a single HTLC before abandoning an unfundable batch' (#5406)

This change fixes a corner case in how the Lightning node tries to claim multiple pending HTLCs (small Bitcoin payments locked in a channel) when the wallet cannot fund a single large batch transaction. Previously, if the multi-HTLC batch …

Funds-recovery robustness improvement: prevents premature abandonment of a single unbatched HTLCChange in error-handling arithmetic from checked_sub/saturating_sub with max(1)New unit tests covering both failed and successful singleton HTLC funding paths
643e8684by wpaulino+119−21 file
No security note in commit
Moderate 54 AI analysisMessage 81 · Strong
LDK Lightning Dev Kitrust-lightning BitcoinCryptographic librariesLightning Network

Merge PR 'Refuse to persist fresh monitors that alias archived monitors' (#5645)

This change prevents a Lightning node from accidentally overwriting an archived copy of a channel's security monitor with a brand-new one that happens to use the same identifier. In the old code, if a new channel reused the same identifier…

Data-loss prevention: stops archived ChannelMonitor from being overwritten by a later channel with the same keySafety guard added to both sync and async persistence pathsPersistence refusal surfaces as InProgress/UnrecoverableError rather than silent overwrite
3c606c11by Matt Corallo+298−332 files
No security note in commit
Repository ledger

Explore captured commits

Expand any commit for its author, full message, clarity score, changed files, triage signals, analysis, and source link.

Lower-priorityAdd clarifying comment to signer_maybe_unblockedby Jeffrey Czyz · de65412a · Aug 26, 2025 · 1 fileMessage 45 · ThinInformational 15Details
Commit message · Jeffrey Czyz

Add clarifying comment to signer_maybe_unblocked

45/100 · ThinMessage clarity
✓ Descriptive subject✓ Names a concrete action or component! No meaningful explanatory body
AI analysis · Informational 15/100

This commit only adds a clarifying code comment explaining why a specific transaction number is used when building a commitment transaction. No code behavior was changed, so there is no security impact.

Lower-priorityInclude fees in SpliceContribution docsby Jeffrey Czyz · 8213f65d · Aug 25, 2025 · 1 fileMessage 68 · AdequateInformational 15Details
Commit message · Jeffrey Czyz

Include fees in SpliceContribution docs

How fees are paid for in a SpliceContribution depends on whether it is a
SpliceIn or SpliceOut. Include this in its docs for clarification.

68/100 · AdequateMessage clarity
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Informational 15/100

This commit only updates documentation comments for the SpliceContribution type. It clarifies that users must account for transaction fees when providing inputs for a splice-in or outputs for a splice-out. No code behavior changed.

Lower-priorityFix debug_assert on our_funding_contributionby Jeffrey Czyz · 9fa6e3c6 · Aug 25, 2025 · 1 fileMessage 58 · ThinInformational 16Details
Commit message · Jeffrey Czyz

Fix debug_assert on our_funding_contribution

When processing a splice_ack, the debug_assert on the range of
our_funding_contribution should account for values that are for both
positive (splice-in) and negative (splice-out).

58/100 · ThinMessage clarity
✓ Descriptive subject✓ Provides detailed explanatory context
AI analysis · Informational 16/100

This commit fixes a sanity check (debug_assert) used during a new experimental feature called splicing in the Lightning Dev Kit. The check previously only accepted positive funding contributions, but splicing can also involve negative contributions (splice-out). The fix makes the check use the absolute value. This is a debug-only assertion, so it only affects test/debug builds and cannot be exploited in production release builds.

Lower-prioritySupport accepting splice-outby Jeffrey Czyz · ce203f27 · Aug 25, 2025 · 1 fileMessage 58 · ThinLow 42Details
Commit message · Jeffrey Czyz

Support accepting splice-out

When a counterparty sends splice_init with a negative contribution, they
are requesting to remove funds from a channel. Remove conditions
guarding against this and check that they have enough channel balance to
cover the removed funds.

58/100 · ThinMessage clarity
✓ Descriptive subject✓ Provides detailed explanatory context
AI analysis · Low 42/100

This commit adds support for 'splice-out', a way for a Lightning channel partner to remove funds from an existing channel rather than only adding funds. Previously, the code rejected negative contribution values outright. The change removes that blanket rejection and adds checks to ensure the counterparty actually has enough balance in the channel to cover the requested withdrawal. It also centralizes validation of the counterparty's splice contribution in a new helper function used in both incoming and outgoing splice paths.

Lower-priorityAdd splice-out supportby Jeffrey Czyz · 3245ebff · Aug 25, 2025 · 4 filesMessage 51 · ThinLow 32Details
Commit message · Jeffrey Czyz

Add splice-out support

Update SpliceContribution with a variant used to support splice-out
(i.e., removing funds from a channel). The TxOut values must not exceed
the users channel balance after accounting for fees and the reserve
requirement.

51/100 · ThinMessage clarity
✓ Subject identifies a change✓ Provides detailed explanatory context
AI analysis · Low 32/100

This commit adds 'splice-out' support to the Lightning Dev Kit, allowing users to remove funds from an existing channel while keeping the channel open. The change introduces new code paths that handle negative contributions (removing funds) and adds checks to ensure the user cannot remove more than their channel balance after accounting for fees and reserve requirements. It is a feature addition, not a documented security fix, but it touches sensitive financial-validation logic.

Lower-priorityUse a SpliceContribution enum for passing splice-in paramsby Jeffrey Czyz · ae58a4f6 · Aug 25, 2025 · 4 filesMessage 73 · AdequateInformational 15Details
Commit message · Jeffrey Czyz

Use a SpliceContribution enum for passing splice-in params

ChannelManager::splice_channel takes individual parameters to support
splice-in. Change these to an enum such that it can be used for
splice-out as well.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Informational 15/100

This commit is a straightforward code refactor. It bundles several parameters related to adding funds to a Lightning channel (a 'splice-in') into a single new enum called SpliceContribution. The goal is to make the API cleaner and prepare it for a future 'splice-out' feature. There is no security fix or vulnerability here.

Lower-priorityReplace funding input tuple with structby Jeffrey Czyz · bdb8d5d8 · Aug 25, 2025 · 7 filesMessage 68 · AdequateInformational 15Details
Commit message · Jeffrey Czyz

Replace funding input tuple with struct

The funding inputs used for splicing and v2 channel establishment are
passed as a tuple of txin, prevtx, and witness weight. Add a struct so
that the items included can be better documented.

68/100 · AdequateMessage clarity
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Informational 15/100

This commit is a straightforward internal code cleanup in the Lightning Dev Kit's rust-lightning project. It replaces a plain tuple (a simple grouping of three related pieces of data) with a named struct called FundingTxInput for funding inputs used in splicing and v2 channel establishment. The change improves code readability and documentation but does not fix a security bug or change user-facing behavior in a security-relevant way.

Lower-priorityRename ChannelContext::counterparty_prev_commitment_pointby Jeffrey Czyz · 6bde10ca · Aug 22, 2025 · 1 fileMessage 63 · AdequateInformational 15Details
Commit message · Jeffrey Czyz

Rename ChannelContext::counterparty_prev_commitment_point

To align with the "current" and "next" nomenclature used by
HolderCommitmentPoint, update the naming of the counterparty commitment
point field to use "current" instead of "previous".

63/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Provides detailed explanatory context
AI analysis · Informational 15/100

This commit is a pure internal rename of a variable from 'previous' to 'current' to make the code easier to understand. No behavior changed, and there is no security issue.

Lower-priorityRename ChannelContext::counterparty_cur_commitment_pointby Jeffrey Czyz · a6cef30b · Aug 22, 2025 · 1 fileMessage 63 · AdequateInformational 15Details
Commit message · Jeffrey Czyz

Rename ChannelContext::counterparty_cur_commitment_point

To align with the "current" and "next" nomenclature used by
HolderCommitmentPoint, update the naming of the counterparty commitment
point field to use "next" instead of "current".

63/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Provides detailed explanatory context
AI analysis · Informational 15/100

This commit is a simple rename of an internal variable from 'current' to 'next' to make the code's naming more consistent. It does not change any program logic, security behavior, or data format. There is no security issue here.

Lower-priorityRename ChannelContext::cur_counterparty_commitment_transaction_numberby Jeffrey Czyz · 9d7ec5f2 · Aug 22, 2025 · 1 fileMessage 63 · AdequateInformational 15Details
Commit message · Jeffrey Czyz

Rename ChannelContext::cur_counterparty_commitment_transaction_number

To align with the "current" and "next" nomenclature used by
HolderCommitmentPoint, update the naming of the counterparty commitment
transaction number field to use "next" instead of "current".

63/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Provides detailed explanatory context
AI analysis · Informational 15/100

This commit is a simple rename of an internal variable from 'cur_counterparty_commitment_transaction_number' to 'counterparty_next_commitment_transaction_number' to make the naming more consistent with other parts of the code. There are no functional changes, no bug fixes, and no security implications.

Lower-priorityReturn ChannelError instead of calling expectby Jeffrey Czyz · 1f8a7d78 · Aug 21, 2025 · 1 fileMessage 45 · ThinLow 42Details
Commit message · Jeffrey Czyz

Return ChannelError instead of calling expect

45/100 · ThinMessage clarity
✓ Descriptive subject✓ Names a concrete action or component! No meaningful explanatory body
AI analysis · Low 42/100

This change replaces a hard program crash (an 'expect' call that would terminate the node) with a graceful error return when a specific piece of channel state is missing during a splicing operation. Instead of the entire Lightning node panicking and shutting down, the node now reports a controlled channel-closing error. This is a defensive improvement that reduces denial-of-service risk from malformed or unexpected peer messages, but the commit itself does not claim a security vulnerability was fixed.

Lower-priorityDelete dead `next_{local, remote}_commitment_tx_fee_info_cached`by Leo Nash · f75812ff · Aug 21, 2025 · 1 fileMessage 75 · AdequateInformational 14Details
Commit message · Leo Nash

Delete dead `next_{local, remote}_commitment_tx_fee_info_cached`

The cached fee is never checked in the current test suite.

75/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides an explanatory body✓ Mentions testing or verification
AI analysis · Informational 14/100

This commit removes unused test-only code that cached predicted commitment transaction fees. The removed fields were only compiled under test/fuzzing configurations and were never checked by the current test suite. The commit does not change production behavior or fix any security issue.

Lower-priorityAdd validation of the fees predicted by `next_commitment_stats`by Leo Nash · 8a1c9d94 · Aug 21, 2025 · 1 fileMessage 73 · AdequateLow 27Details
Commit message · Leo Nash

Add validation of the fees predicted by `next_commitment_stats`

Anytime we build a (feerate, nondust-htlc-count, fee) pair, cache it,
and check that the fee matches if the feerate and nondust-htlc-count
match when building a commitment transaction.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Low 27/100

This commit adds internal bookkeeping and consistency checks to make sure the fee predicted when planning a Lightning channel commitment transaction matches the fee actually used when the transaction is later built. It only runs during tests and fuzzing, so it does not directly change production behavior. It is a defensive hardening/debugging patch rather than a fix for an active exploit.

Lower-priorityAdd `ChannelContext::get_next_{local, remote}_commitment_stats`by Leo Nash · 06ed9cb5 · Aug 21, 2025 · 1 fileMessage 73 · AdequateInformational 11Details
Commit message · Leo Nash

Add `ChannelContext::get_next_{local, remote}_commitment_stats`

In upcoming commits, these methods will serve as proxies to
`SpecTxBuilder::get_next_commitment_stats` in all validation of channel
updates in `ChannelContext`.

Eventually, these methods will completely replace
`get_pending_htlc_stats`, and
`get_next_{local, remote}_commit_tx_fee_msat`.

When predicting the HTLCs on next commitment, we take the conservative
approach and only assume that a HTLC will not be in the next commitment
when it is guaranteed that it won't be.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Informational 11/100

This commit adds four new private helper methods to the Lightning channel code. The methods are marked `#[allow(dead_code)]`, meaning they are not yet called anywhere. They are intended to replace older balance/fee estimation helpers in future commits. There is no functional change to how channels are validated today, and no security fix or vulnerability is introduced in this patch.

AI review queuedAdd `TxBuilder::get_next_commitment_stats`by Leo Nash · 0a75f927 · Aug 21, 2025 · 2 filesMessage 58 · ThinInformational 11Details
Commit message · Leo Nash

Add `TxBuilder::get_next_commitment_stats`

Given a snapshot of the lightning state machine,
`TxBuilder::get_next_commitment_stats` calculates the transaction fees,
the dust exposure, and the holder and counterparty balances
(the balances themselves do *not* account for the transaction fee).

58/100 · ThinMessage clarity
✓ Descriptive subject✓ Provides detailed explanatory context
Why it was queued
signing or wallet pathsecond-pass: security-sensitive path
AI analysis · Informational 11/100

This commit adds a new internal helper method that estimates the fees, dust exposure, and balances for a future Lightning channel commitment transaction. It does not change any existing behavior or fix a known bug; it appears to be preparatory/refactoring work to support future channel-fee logic. There is no indication in the commit that it addresses a security vulnerability.

Lower-priorityImprove prediction of commitment stats in `validate_update_fee`by Leo Nash · d36fdabe · Aug 21, 2025 · 1 fileMessage 73 · AdequateModerate 61Details
Commit message · Leo Nash

Improve prediction of commitment stats in `validate_update_fee`

`ChannelContext::get_pending_htlc_stats` predicts that the set of HTLCs
on the next commitment will be all the HTLCs in
`ChannelContext.pending_inbound_htlcs`, and
`ChannelContext.pending_outbound_htlcs`, as well as all the outbound
HTLC adds in the holding cell.

This is an overestimate:

* Outbound HTLC removals which have been ACK'ed by the counterparty will
certainly not be present in any *next* commitment, even though they
remain in `pending_outbound_htlcs`.

* Outbound HTLCs in the `RemoteRemoved` state, will not be present in
the next *local* commitment.

* Outbound HTLCs in the `LocalAnnounced` state have no guarantee that
they were received by the counterparty before she sent the
`update_fee`.

* Outbound `update_add_htlc`'s in the holding cell are certainly not
known by the counterparty, and we will reevaluate their addition to
the channel when freeing the holding cell.

* Inbound HTLCs in the `LocalRemoved` state will not be present in the
next *remote* commitment.

This commit stops using `get_pending_htlc_stats` in favor of the newly
added `ChannelContext::get_next_{local, remote}_commitment_stats`
methods, and fixes the issues described above.

We now always calculate dust exposure using a buffer from
`msg.feerate_per_kw`, and not from
`max(self.feerate_per_kw, msg.feerate_per_kw)`.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
Why it was queued
defensive validation
AI analysis · Moderate 61/100

This patch tightens how a Lightning node estimates which pending payments (HTLCs) will actually appear on the next commitment transaction when checking a peer's proposed fee rate. Previously the node counted HTLCs that might already be removed or not yet known to the peer, which could cause it to reject valid fee updates or, conversely, accept fee updates that expose it to more 'dust' HTLC risk than intended. The change makes the dust-exposure check more accurate by predicting the next local and next remote commitment separately and using only the new fee rate for the dust buffer.

Lower-priorityImprove prediction of commitment stats in `can_send_update_fee`by Leo Nash · 124bd421 · Aug 21, 2025 · 1 fileMessage 73 · AdequateModerate 63Details
Commit message · Leo Nash

Improve prediction of commitment stats in `can_send_update_fee`

`ChannelContext::get_pending_htlc_stats` predicts that the set of HTLCs
on the next commitment will be all the HTLCs in
`ChannelContext.pending_inbound_htlcs`, and
`ChannelContext.pending_outbound_htlcs`, as well as all the outbound
HTLC adds in the holding cell.

This is an overestimate:

* Outbound HTLC removals which have been ACK'ed by the counterparty will
certainly not be present in any *next* commitment, even though they
remain in `pending_outbound_htlcs` (I refer to states
`AwaitingRemoteRevokeToRemove` and `AwaitingRemovedRemoteRevoke`).

* Outbound HTLCs in the `RemoteRemoved` state, will not be present in
the next *local* commitment.

* Inbound HTLCs in the `LocalRemoved` state will not be present in the
next *remote* commitment.

`ChannelContext::build_commitment_stats(funding, true, true, ..)` makes
these errors when predicting the HTLC count on the remote commitment:

* Inbound HTLCs in the state `RemoteAnnounced` are not included, but
they will be in the next remote commitment transaction if the local
ACK's the addition before producing the next remote commitment.

* Inbound HTLCs in the state `AwaitingRemoteRevokeToAnnounce` are not
included, even though the local has ACK'ed the addition.

* Outbound HTLCs in the state `AwaitingRemoteRevokeToRemove` are
counted, even though the local party has ACK'ed the removal.

This commit replaces these functions in favor of the newly added
`ChannelContext::get_next_{local, remote}_commitment_stats` methods,
and fixes the issues described above.

We now always calculate dust exposure using a buffer from
`msg.feerate_per_kw`, and not from
`max(feerate_per_kw, self.feerate_per_kw, self.pending_update_fee)`.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Moderate 63/100

This commit fixes how a Lightning node predicts the contents of its next commitment transactions when deciding whether it can safely propose a fee update. Previously the code over- or under-counted pending HTLCs depending on their state, which could let the node accept a feerate that leaves it unable to pay the resulting commitment transaction fee or reserve, or that exceeds dust-exposure safety limits. The fix replaces the old prediction helpers with new state-aware methods that model the next local and remote commitments more accurately.

Lower-priorityImprove prediction of commitment stats in `can_accept_incoming_htlc`by Leo Nash · 3218db15 · Aug 21, 2025 · 2 filesMessage 73 · AdequateModerate 63Details
Commit message · Leo Nash

Improve prediction of commitment stats in `can_accept_incoming_htlc`

`ChannelContext::get_pending_htlc_stats` predicts that the set of HTLCs
on the next commitment will be all the HTLCs in
`ChannelContext.pending_inbound_htlcs`, and
`ChannelContext.pending_outbound_htlcs`, as well as all the outbound
HTLC adds in the holding cell.

This is an overestimate:

* Outbound HTLC removals which have been ACK'ed by the counterparty will
certainly not be present in any *next* commitment, even though they
remain in `pending_outbound_htlcs`.

* Outbound HTLCs in the `RemoteRemoved` state, will not be present in
the next *local* commitment.

* Outbound HTLCs in the `LocalAnnounced` state have no guarantee that
they were yet received by the counterparty.

* Outbound `update_add_htlc`'s in the holding cell are certainly not
known by the counterparty, and we will reevaluate their addition to
the channel when freeing the holding cell.

* Inbound HTLCs in the `LocalRemoved` state will not be present in the
next *remote* commitment.

This commit stops using `get_pending_htlc_stats` in favor of the newly
added `ChannelContext::get_next_{local, remote}_commitment_stats`
methods, and fixes the issues described above.

`ChannelContext::next_remote_commit_tx_fee_msat` counts inbound HTLCs in
the `LocalRemoved` state, as well as outbound HTLCs in the
`LocalAnnounced` state. We now do not count them for the same reasons
described above.

Inbound `LocalRemoved` HTLCs that were **not** successful are now
credited to `remote_balance_before_fee_msat` as they will certainly not
be on the next remote commitment. We previously debited these from the
remote balance to arrive at `remote_balance_before_fee_msat`.

We now always check holder dust exposure, whereas we previously would
only do it if the incoming HTLC was dust on our own commitment
transaction.

Furthermore, dust exposure calculations now take a buffer from the
currently committed feerate, and ignore any fee updates in
`ChannelContext.pending_update_fee`.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Moderate 63/100

This commit fixes how a Lightning node predicts the contents of its next commitment transactions when deciding whether to accept an incoming payment (HTLC). Previously, the node overestimated which HTLCs would appear on the next commitment, which could cause it to wrongly reject valid incoming payments (a denial-of-service/availability issue) or apply incorrect fee and dust checks. The patch replaces the overestimate with more precise per-commitment statistics and tightens dust-exposure checks for the node's own commitment transaction.

Lower-priorityImprove prediction of commitment stats in `validate_update_add_htlc`by Leo Nash · 48b412a4 · Aug 21, 2025 · 1 fileMessage 73 · AdequateModerate 63Details
Commit message · Leo Nash

Improve prediction of commitment stats in `validate_update_add_htlc`

`ChannelContext::get_pending_htlc_stats` predicts that the set of HTLCs
on the next commitment will be all the HTLCs in
`ChannelContext.pending_inbound_htlcs`, and
`ChannelContext.pending_outbound_htlcs`, as well as all the outbound
HTLC adds in the holding cell.

This is an overestimate:

* Outbound HTLC removals which have been ACK'ed by the counterparty will
certainly not be present in any *next* commitment, even though they
remain in `pending_outbound_htlcs`.

* Outbound HTLCs in the `RemoteRemoved` state, will not be present in
the next *local* commitment.

* Outbound HTLCs in the `LocalAnnounced` state have no guarantee that
they were received by the counterparty before she sent the
`update_fee`.

* Outbound `update_add_htlc`'s in the holding cell are certainly not
known by the counterparty, and we will reevaluate their addition to
the channel when freeing the holding cell.

* Inbound HTLCs in the `LocalRemoved` state will not be present in the
next *remote* commitment.

`ChannelContext::next_local_commit_tx_fee_msat` over-counts outbound
HTLCs in the `LocalAnnounced` and `RemoteRemoved` states, as well as
outbound `update_add_htlc`'s in the holding cell.

`ChannelContext::next_remote_commit_tx_fee_msat` over-counts inbound
HTLCs in the `LocalRemoved` state, as well as outbound HTLCs in the
`LocalAnnounced` state.

This commit stops using these functions in favor of the newly added
`ChannelContext::get_next_{local, remote}_commitment_stats` methods,
and fixes the issues described above.

If we are the funder, we also check that adding this inbound HTLC
doesn't increase the commitment transaction fee to the point of
exhausting our balance on the local commitment. Previously, we would
only subtract the anchors from `funding.value_to_self_msat`; we now
also subtract the outbound HTLCs on the next local commitment from
`funding.value_to_self_msat` before checking if we can afford the
additional transaction fees.

Inbound `LocalRemoved` HTLCs that were **not** successful are now
credited to `remote_balance_before_fee_msat` as they will certainly not
be on the next remote commitment. We previously debited these from the
remote balance to arrive at `remote_balance_before_fee_msat`.

When calculating dust exposure, we now take a buffer from the currently
committed feerate, and ignore any fee updates in
`ChannelContext.pending_update_fee`.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
Why it was queued
defensive validation
AI analysis · Moderate 63/100

This commit fixes how a Lightning node predicts which pending payments (HTLCs) will actually appear on the next commitment transaction when validating a new incoming HTLC. The old code over-counted HTLCs, which could cause the node to reject valid HTLCs or, more importantly, accept HTLCs while miscalculating whether the remote party can afford the on-chain fees and channel reserve. The patch also improves the funder's check so it subtracts outbound HTLCs from its own balance before checking fee affordability, and fixes a balance-credit bug for inbound HTLCs being removed. In short, it tightens the economic safety checks that prevent a channel from being created with terms one side cannot actually honor on-chain.

AI review queuedAdjust dust exposure due to excess fees for clarityby Leo Nash · 3a3e7eb8 · Aug 21, 2025 · 1 fileMessage 62 · AdequateInformational 12Details
Commit message · Leo Nash

Adjust dust exposure due to excess fees for clarity

62/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Explains rationale or failure mode! No meaningful explanatory body
Why it was queued
signing or wallet pathsecond-pass: security-sensitive path
AI analysis · Informational 12/100

This commit is a code clarity and variable-naming refactor in a function that calculates how much money a Lightning channel could lose due to tiny ('dust') transactions plus extra fees. It renames variables, removes an unnecessary mutable parameter, and reorders calculations so the math is easier to follow. The actual arithmetic result appears unchanged, so this is not a security fix.

Lower-priorityRemove now-unused ServeStaticInvoice::invoice_idby Valentine Wallace · e159ae42 · Aug 21, 2025 · 5 filesMessage 68 · AdequateInformational 15Details
Commit message · Valentine Wallace

Remove now-unused ServeStaticInvoice::invoice_id

In the initially-merged version of the static invoice server protocol, the
static invoice server would sometimes have to find a specific static invoice
based on (recipient_id, invoice_slot) and sometimetimes based on (recipient_id,
invoice_id). This made the API harder to use in terms of how the server would
index into the KVStore.

Over the course of the previous commits we transitioned to the server always
finding a specific invoice based on (recipient_id, invoice_slot). We still have
a few dangling references to invoice_id in some messages and events though, so
remove those here.

68/100 · AdequateMessage clarity
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Informational 15/100

This commit is a routine cleanup of an internal messaging protocol. It removes a now-unused field called invoice_id and standardizes on a different identifier (invoice_slot) for looking up stored invoices. There is no security fix here; it is purely a simplification of the code and data structures.

Lower-priorityReplace StaticInvoiceReq::invoice_id with ::inv_slotby Valentine Wallace · f53325bf · Aug 21, 2025 · 5 filesMessage 73 · AdequateInformational 15Details
Commit message · Valentine Wallace

Replace StaticInvoiceReq::invoice_id with ::inv_slot

In the initially-merged version of the static invoice server protocol, the
static invoice server would sometimes have to find a specific static invoice
based on (recipient_id, invoice_slot) and sometime based on (recipient_id,
invoice_id). This made the API harder to use in terms of how the server would
index into the KVStore.

We'd like to transition to the server always finding a specific invoice based on
(recipient_id, invoice_slot) and get rid of the invoice_id concept.

Previously, when an invoice request would come in for the server on behalf of
the often-offline recipient, they would need to find the static invoice based
on the recipient_id and invoice_id. However, previous commits have now led to
the server being able to use the invoice_slot in the initial offer paths that
they create, which we do here, obviating the need for them to create their own
randomly-generated invoice_id. The final dangling references to the invoice_id
will be removed in the next commit.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Informational 15/100

This commit is a straightforward internal API cleanup in the experimental static-invoice-server protocol. It replaces a randomly-generated 128-bit invoice_id with a simpler 16-bit invoice_slot when looking up stored invoices. There is no security fix here—just making the database lookup key consistent and easier to use.

Lower-priorityRemove now-unused ServeStaticInv::inv_slot from OMby Valentine Wallace · 06f20197 · Aug 21, 2025 · 3 filesMessage 73 · AdequateInformational 18Details
Commit message · Valentine Wallace

Remove now-unused ServeStaticInv::inv_slot from OM

In the initially-merged version of the static invoice server protocol, the
static invoice server would sometimes have to find a specific static invoice
based on (recipient_id, invoice_slot) and sometime based on (recipient_id,
invoice_id). This made the API harder to use in terms of how the server would
index into the KVStore.

We'd like to transition to the server always finding a specific invoice based on
(recipient_id, invoice_slot) and get rid of the invoice_id concept.

In the previous commit the server began including the invoice_slot in the
ServeStaticInvoice blinded path context that gets provided back to themselves.
Therefore there is no need for the recipient to redundantly include it in the
ServeStaticInvoice onion message itself.

73/100 · AdequateMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Informational 18/100

This commit removes an unused data field called invoice_slot from a message type used in a new Lightning protocol feature for storing static invoices on a server. The change is described by the developers as a cleanup to simplify how the server looks up stored invoices. There is no indication in the commit that this fixes a security bug; it appears to be a normal API and protocol simplification.

Lower-priorityTrack invoice_slot in ServeStaticInvoice contextby Valentine Wallace · 748c04a0 · Aug 21, 2025 · 3 filesMessage 80 · StrongInformational 18Details
Commit message · Valentine Wallace

Track invoice_slot in ServeStaticInvoice context

In the initially-merged version of the static invoice server protocol, the
static invoice server would sometimes have to find a specific static invoice
based on (recipient_id, invoice_slot) and sometime based on (recipient_id,
invoice_id). This made the API harder to use in terms of how the server would
index into the KVStore.

We'd like to transition to the server always finding a specific invoice based on
(recipient_id, invoice_slot) and get rid of the invoice_id concept.

As part of this series of commits, include the invoice_slot in the
ServeStaticInvoice blinded path context that the server creates when sending an
offer_paths message. This is possible due to a previous commit including the
invoice_slot in the initial offer_paths_request from the recipient, and lays
the groundwork for removing the invoice_id field from this blinded path
context.

80/100 · StrongMessage clarity
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
AI analysis · Informational 18/100

This commit is a small internal cleanup in the code that handles static Lightning invoices. It makes the software remember an 'invoice_slot' number earlier in the process so that later, when serving a stored invoice, the server can look it up by slot number instead of relying only on an 'invoice_id'. The change adds a new field to a protocol data structure and threads it through the request/response flow. There is no indication this fixes a security bug; it appears to be a design/API simplification.

Lower-priorityCache pending offer in specific invoice slotby Valentine Wallace · ed0bf367 · Aug 21, 2025 · 3 filesMessage 68 · AdequateLow 26Details
Commit message · Valentine Wallace

Cache pending offer in specific invoice slot

When we as an async recipient receive offer paths from the static invoice server,
we create an offer and cache it, retrying persisting a corresponding invoice with
the server until it succeeds.

In the initially-merged version of this protocol, we would put this cached
offer in any slot in the cache that needed an offer at the time the offer paths
were received. However, in the last commit we started requesting offer paths
for a specific slot in the cache, as part of eliminating the use of the
invoice_id field in the overall protocol.

As a result, here we put the cached offer in the specific cache slot that the
original OfferPathsRequest indicated, rather than any slot that could use a new
offer.

68/100 · AdequateMessage clarity
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
AI analysis · Low 26/100

This commit tightens up how a Lightning node caches payment offers when receiving them from a static invoice server. Previously, the node would place a newly received offer into any open slot in its cache. After this change, it stores the offer only in the specific slot it originally requested. The change is part of a protocol cleanup to remove reliance on an invoice_id field. It is primarily a correctness and protocol-consistency fix rather than a clear security patch, though the old behavior could theoretically have allowed a server to confuse or overwrite unrelated cached offers.