Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f239e2f
Add missing `Clone` (and `Copy`) derives to config structs
TheBlueMatt Dec 5, 2025
2b2f4c3
Don't bother `clone`'ing a `Secp256k1` context into the offers flow
TheBlueMatt Nov 3, 2025
78f4152
Make `as_directed_to` non-public
TheBlueMatt Mar 1, 2022
28ed4a5
Restrict ChannelInfo::as_directed_from visibility
jkczyz Mar 29, 2022
577dcfb
Use an explicit `Sign` type on the `ChannelMonitor` read tuple
TheBlueMatt Dec 24, 2022
e14e58d
Export `outbound_payment` structs in their respective modules
TheBlueMatt Dec 23, 2024
f959254
Avoid enums containing references with lifetimes
TheBlueMatt Dec 13, 2024
2a77d9a
Hard-code scorer parameters to `ProbabilisticScoringFeeParameters`
TheBlueMatt Oct 16, 2025
51d0ef6
Mark several types no-export which should be exported eventually
TheBlueMatt Jul 19, 2023
4ae7bdb
`crate`-only several BOLT12 methods that require unbounded generics
TheBlueMatt Sep 28, 2023
05f3a63
Make ChannelMonitor always clonable
TheBlueMatt Feb 1, 2021
93ee743
Make the custom message traits cloneable as they're deep in nested st…
TheBlueMatt Sep 24, 2021
82347ec
Avoid slices without inner references
TheBlueMatt Sep 28, 2023
c065a80
Avoid options holding references in the public API
TheBlueMatt Aug 17, 2024
92eefae
Hide `Direction::select_node_id` due to lifetimes
TheBlueMatt May 11, 2024
f65de4c
Drop `SerialId` type as bindings don't support primitive aliasing
TheBlueMatt May 11, 2024
6719ef1
Minimal updates to `lightning-transaction-sync` for bindings
TheBlueMatt Jun 5, 2024
688e310
Require an OM in BP as this should generally be true and its easier t…
TheBlueMatt Aug 20, 2024
b600c62
Avoid returning references in `NodeAnnouncementInfo` accessors
TheBlueMatt Aug 24, 2024
d7e4a44
Use `[u8; 32]` rather than `Hmac<Sha256>` for simplicity
TheBlueMatt Oct 16, 2025
53934a2
Use inline bounds for secp contexts, rather than `where` clauses
TheBlueMatt Aug 26, 2024
4560d71
Mark `RawBolt11Invoice`'s de/ser methods as no-export
TheBlueMatt Jan 29, 2025
6017742
Mark `Bolt11Bech32` as bindings-no-export as its unconstructable
TheBlueMatt Apr 2, 2025
f90f299
Require several additional traits to be `Clone`
TheBlueMatt Nov 2, 2025
b06ba92
Use explicit `Send`/`Sync` rather than `MaybeSend`/`MaybeSync`
TheBlueMatt Nov 3, 2025
030740d
Make `onion_utils` public rather than re-exporting
TheBlueMatt Nov 3, 2025
5ced763
Remove `lightning-liquidity` from bindings
TheBlueMatt Dec 5, 2025
464a8db
Ensure `Option<Address>` gets derived
TheBlueMatt Dec 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use lightning::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, CommitmentUpdate, Init, MessageSendEvent,
UpdateAddHTLC,
};
use lightning::ln::outbound_payment::{RecipientOnionFields, Retry};
use lightning::ln::script::ShutdownScript;
use lightning::ln::types::ChannelId;
use lightning::offers::invoice::UnsignedBolt12Invoice;
Expand Down
5 changes: 2 additions & 3 deletions fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ use lightning::chain::transaction::OutPoint;
use lightning::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen};
use lightning::events::Event;
use lightning::ln::channel_state::ChannelDetails;
use lightning::ln::channelmanager::{
ChainParameters, ChannelManager, InterceptId, PaymentId, RecipientOnionFields, Retry,
};
use lightning::ln::channelmanager::{ChainParameters, ChannelManager, InterceptId, PaymentId};
use lightning::ln::functional_test_utils::*;
use lightning::ln::inbound_payment::ExpandedKey;
use lightning::ln::outbound_payment::{RecipientOnionFields, Retry};
use lightning::ln::peer_handler::{
IgnoringMessageHandler, MessageHandler, PeerManager, SocketDescriptor,
};
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/onion_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl AsyncPaymentsMessageHandler for TestAsyncPaymentsMessageHandler {
fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {}
}

#[derive(Debug)]
#[derive(Clone, Debug)]
struct TestCustomMessage {}

const CUSTOM_MESSAGE_TYPE: u64 = 4242;
Expand Down
68 changes: 21 additions & 47 deletions lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,6 @@ type DynRouter = lightning::routing::router::DefaultRouter<
&'static (dyn Logger + Send + Sync),
>,
>,
lightning::routing::scoring::ProbabilisticScoringFeeParameters,
lightning::routing::scoring::ProbabilisticScorer<
&'static NetworkGraph<&'static (dyn Logger + Send + Sync)>,
&'static (dyn Logger + Send + Sync),
>,
>;

#[cfg(not(c_bindings))]
Expand Down Expand Up @@ -1483,7 +1478,6 @@ impl BackgroundProcessor {
PGS: 'static + Deref<Target = P2PGossipSync<G, UL, L>> + Send,
RGS: 'static + Deref<Target = RapidGossipSync<G, L>> + Send,
PM: 'static + Deref + Send,
LM: 'static + Deref + Send,
S: 'static + Deref<Target = SC> + Send + Sync,
SC: for<'b> WriteableScore<'b>,
D: 'static + Deref,
Expand All @@ -1492,8 +1486,8 @@ impl BackgroundProcessor {
OS: 'static + Deref<Target = OutputSweeperSync<T, D, F, CF, K, L, O>> + Send,
>(
kv_store: K, event_handler: EH, chain_monitor: M, channel_manager: CM,
onion_messenger: Option<OM>, gossip_sync: GossipSync<PGS, RGS, G, UL, L>, peer_manager: PM,
liquidity_manager: Option<LM>, sweeper: Option<OS>, logger: L, scorer: Option<S>,
onion_messenger: OM, gossip_sync: GossipSync<PGS, RGS, G, UL, L>, peer_manager: PM,
sweeper: Option<OS>, logger: L, scorer: Option<S>,
) -> Self
where
UL::Target: 'static + UtxoLookup,
Expand All @@ -1506,7 +1500,6 @@ impl BackgroundProcessor {
CM::Target: AChannelManager,
OM::Target: AOnionMessenger,
PM::Target: APeerManager,
LM::Target: ALiquidityManagerSync,
D::Target: ChangeDestinationSourceSync,
O::Target: 'static + OutputSpender,
K::Target: 'static + KVStoreSync,
Expand Down Expand Up @@ -1561,7 +1554,7 @@ impl BackgroundProcessor {
loop {
channel_manager.get_cm().process_pending_events(&event_handler);
chain_monitor.process_pending_events(&event_handler);
if let Some(om) = &onion_messenger {
if let Some(om) = Some(&onion_messenger) {
om.get_om().process_pending_events(&event_handler)
};

Expand All @@ -1586,24 +1579,13 @@ impl BackgroundProcessor {
log_trace!(logger, "Terminating background processor.");
break;
}
let sleeper = match (onion_messenger.as_ref(), liquidity_manager.as_ref()) {
(Some(om), Some(lm)) => Sleeper::from_four_futures(
&channel_manager.get_cm().get_event_or_persistence_needed_future(),
&chain_monitor.get_update_future(),
&om.get_om().get_update_future(),
&lm.get_lm().get_pending_msgs_or_needs_persist_future(),
),
(Some(om), None) => Sleeper::from_three_futures(
let sleeper = match Some(&onion_messenger) {
Some(om) => Sleeper::from_three_futures(
&channel_manager.get_cm().get_event_or_persistence_needed_future(),
&chain_monitor.get_update_future(),
&om.get_om().get_update_future(),
),
(None, Some(lm)) => Sleeper::from_three_futures(
&channel_manager.get_cm().get_event_or_persistence_needed_future(),
&chain_monitor.get_update_future(),
&lm.get_lm().get_pending_msgs_or_needs_persist_future(),
),
(None, None) => Sleeper::from_two_futures(
None => Sleeper::from_two_futures(
&channel_manager.get_cm().get_event_or_persistence_needed_future(),
&chain_monitor.get_update_future(),
),
Expand Down Expand Up @@ -1635,13 +1617,6 @@ impl BackgroundProcessor {
log_trace!(logger, "Done persisting ChannelManager.");
}

if let Some(liquidity_manager) = liquidity_manager.as_ref() {
log_trace!(logger, "Persisting LiquidityManager...");
let _ = liquidity_manager.get_lm().persist().map_err(|e| {
log_error!(logger, "Persisting LiquidityManager failed: {}", e);
});
}

// Note that we want to run a graph prune once not long after startup before
// falling back to our usual hourly prunes. This avoids short-lived clients never
// pruning their network graph. We run once 60 seconds after startup before
Expand Down Expand Up @@ -1713,7 +1688,7 @@ impl BackgroundProcessor {
last_sweeper_call = Instant::now();
}
if last_onion_message_handler_call.elapsed() > ONION_MESSAGE_HANDLER_TIMER {
if let Some(om) = &onion_messenger {
if let Some(om) = Some(&onion_messenger) {
log_trace!(logger, "Calling OnionMessageHandler's timer_tick_occurred");
om.get_om().timer_tick_occurred();
}
Expand Down Expand Up @@ -1899,8 +1874,6 @@ mod tests {
Arc<test_utils::TestLogger>,
Arc<KeysManager>,
Arc<LockingWrapper<TestScorer>>,
(),
TestScorer,
>,
>,
Arc<
Expand Down Expand Up @@ -2187,10 +2160,11 @@ mod tests {
}

impl ScoreLookUp for TestScorer {
#[cfg(not(c_bindings))]
type ScoreParams = ();
fn channel_penalty_msat(
&self, _candidate: &CandidateRouteHop, _usage: ChannelUsage,
_score_params: &Self::ScoreParams,
_score_params: &lightning::routing::scoring::ProbabilisticScoringFeeParameters,
) -> u64 {
unimplemented!();
}
Expand Down Expand Up @@ -2625,7 +2599,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].p2p_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -2720,7 +2694,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -2764,7 +2738,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -2847,7 +2821,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].p2p_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -2878,7 +2852,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -2926,7 +2900,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -2990,7 +2964,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -3154,7 +3128,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -3185,7 +3159,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -3283,7 +3257,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].rapid_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -3495,7 +3469,7 @@ mod tests {
event_handler,
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
Some(Arc::clone(&nodes[0].messenger)),
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
Some(Arc::clone(&nodes[0].liquidity_manager)),
Expand Down Expand Up @@ -3602,7 +3576,7 @@ mod tests {
move |_: Event| Ok(()),
Arc::clone(&nodes[0].chain_monitor),
Arc::clone(&nodes[0].node),
crate::NO_ONION_MESSENGER,
Arc::clone(&nodes[0].messenger),
nodes[0].no_gossip_sync(),
Arc::clone(&nodes[0].peer_manager),
crate::NO_LIQUIDITY_MANAGER_SYNC,
Expand Down
30 changes: 30 additions & 0 deletions lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ pub const MAX_LENGTH: usize = 7089;

/// The [`bech32::Bech32`] checksum algorithm, with extended max length suitable
/// for BOLT11 invoices.
///
/// This is not exported to bindings users as it generally shouldn't be used directly publicly
/// anyway.
pub enum Bolt11Bech32 {}

impl Checksum for Bolt11Bech32 {
Expand Down Expand Up @@ -1220,12 +1223,16 @@ impl RawBolt11Invoice {

/// Convert to HRP prefix and Fe32 encoded data part.
/// Can be used to transmit unsigned invoices for remote signing.
///
/// This is not exported to bindings users as we don't currently support Fe32s
pub fn to_raw(&self) -> (String, Vec<Fe32>) {
(self.hrp.to_string(), self.data.fe_iter().collect())
}

/// Convert from HRP prefix and Fe32 encoded data part.
/// Can be used to receive unsigned invoices for remote signing.
///
/// This is not exported to bindings users as we don't currently support Fe32s
pub fn from_raw(hrp: &str, data: &[Fe32]) -> Result<Self, Bolt11ParseError> {
let raw_hrp: RawHrp = RawHrp::from_str(hrp)?;
let data_part = RawDataPart::from_base32(data)?;
Expand Down Expand Up @@ -1602,6 +1609,29 @@ impl Bolt11Invoice {
self.fallbacks().iter().filter_map(filter_fn).collect()
}

/// Returns the first fallback address as an [`Address`].
///
/// See [`Self::fallback_addresses`] to fetch all addresses of known type.
pub fn first_fallback_address(&self) -> Option<Address> {
let filter_fn = |fallback: &&Fallback| {
let address = match fallback {
Fallback::SegWitProgram { version, program } => {
match WitnessProgram::new(*version, &program) {
Ok(witness_program) => {
Address::from_witness_program(witness_program, self.network())
},
Err(_) => return None,
}
},
Fallback::PubKeyHash(pkh) => Address::p2pkh(*pkh, self.network()),
Fallback::ScriptHash(sh) => Address::p2sh_from_hash(*sh, self.network()),
};

Some(address)
};
self.fallbacks().iter().filter_map(filter_fn).next()
}

/// Returns a list of all routes included in the invoice
pub fn private_routes(&self) -> Vec<&PrivateRoute> {
self.signed_invoice.private_routes()
Expand Down
2 changes: 1 addition & 1 deletion lightning-liquidity/tests/lsps2_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use lightning::check_added_monitors;
use lightning::events::{ClosureReason, Event};
use lightning::get_event_msg;
use lightning::ln::channelmanager::PaymentId;
use lightning::ln::channelmanager::Retry;
use lightning::ln::outbound_payment::Retry;
use lightning::ln::functional_test_utils::create_funding_transaction;
use lightning::ln::functional_test_utils::do_commitment_signed_dance;
use lightning::ln::functional_test_utils::expect_channel_pending_event;
Expand Down
5 changes: 3 additions & 2 deletions lightning-persister/src/fs_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ struct FilesystemStoreInner {
/// A [`KVStore`] and [`KVStoreSync`] implementation that writes to and reads from the file system.
///
/// [`KVStore`]: lightning::util::persist::KVStore
#[derive(Clone)]
pub struct FilesystemStore {
inner: Arc<FilesystemStoreInner>,

// Version counter to ensure that writes are applied in the correct order. It is assumed that read and list
// operations aren't sensitive to the order of execution.
next_version: AtomicU64,
next_version: Arc<AtomicU64>,
}

impl FilesystemStore {
Expand All @@ -68,7 +69,7 @@ impl FilesystemStore {
let tmp_file_counter = AtomicUsize::new(0);
Self {
inner: Arc::new(FilesystemStoreInner { data_dir, tmp_file_counter, locks }),
next_version: AtomicU64::new(1),
next_version: Arc::new(AtomicU64::new(1)),
}
}

Expand Down
2 changes: 2 additions & 0 deletions lightning-transaction-sync/src/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
// accordance with one or both of these licenses.

//! Chain sync using the electrum protocol

use crate::common::{ConfirmedTx, FilterQueue, SyncState};
use crate::error::{InternalError, TxSyncError};

Expand Down
2 changes: 2 additions & 0 deletions lightning-transaction-sync/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
// accordance with one or both of these licenses.

//! Common error types

use std::fmt;

#[derive(Debug)]
Expand Down
2 changes: 2 additions & 0 deletions lightning-transaction-sync/src/esplora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
// accordance with one or both of these licenses.

//! Chain sync using the Esplora API

use crate::common::{ConfirmedTx, FilterQueue, SyncState};
use crate::error::{InternalError, TxSyncError};

Expand Down
6 changes: 3 additions & 3 deletions lightning-transaction-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
mod esplora;
pub mod esplora;

#[cfg(any(feature = "_electrum"))]
mod electrum;
pub mod electrum;

#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "_electrum"))]
mod common;
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "_electrum"))]
mod error;
pub mod error;
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "_electrum"))]
pub use error::TxSyncError;

Expand Down
Loading
Loading