Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ use lightning::ln::funding::{
use lightning::ln::msgs::{BaseMessageHandler, SocketAddress};
use lightning::ln::peer_handler::CustomMessageHandler;
use lightning::routing::gossip::NodeAlias;

use lightning::sign::EntropySource;
use lightning::util::persist::KVStore;
use lightning::util::wallet_utils::{ConfirmedUtxo, Wallet as LdkWallet};
Expand Down
15 changes: 7 additions & 8 deletions src/liquidity/client/lsps2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ use lightning_types::payment::PaymentHash;
use tokio::sync::oneshot;
use tokio::task::JoinSet;

use self::router::LSPS2LeaseParameters;
use self::state::{
is_lease_usable, is_lease_valid_for, now_secs, LSPS2LeaseState, LeaseCacheTarget,
LeaseCacheTargetId, LeaseCacheTargetStore, PaymentLease, PaymentLeaseId, PaymentLeaseStore,
PendingLeaseRequestState, MIN_CACHED_LEASE_REMAINING_SECS,
};
use crate::connection::ConnectionManager;
use crate::liquidity::{
select_all_lsps_for_protocol, select_lsps_for_protocol, LspConfig, LspNode, PendingRequest,
Expand All @@ -44,13 +50,6 @@ use crate::runtime::Runtime;
use crate::types::{ChannelManager, KeysManager, LiquidityManager};
use crate::{Config, Error};

use self::router::LSPS2LeaseParameters;
use self::state::{
is_lease_usable, is_lease_valid_for, now_secs, LSPS2LeaseState, LeaseCacheTarget,
LeaseCacheTargetId, LeaseCacheTargetStore, PaymentLease, PaymentLeaseId, PaymentLeaseStore,
PendingLeaseRequestState, MIN_CACHED_LEASE_REMAINING_SECS,
};

// LSPS2 requires two blocks more than the usual final CLTV delta.
const LSPS2_MIN_FINAL_CLTV_EXPIRY_DELTA: u16 = MIN_FINAL_CLTV_EXPIRY_DELTA + 2;

Expand Down Expand Up @@ -1337,10 +1336,10 @@ pub(crate) struct LSPS2BuyResponse {

#[cfg(test)]
mod tests {
use super::*;
use std::future::poll_fn;
use std::task::Poll;

use super::*;
use crate::builder::NodeBuilder;
use crate::entropy::NodeEntropy;
use crate::io::test_utils::InMemoryStore;
Expand Down
13 changes: 6 additions & 7 deletions src/liquidity/client/lsps2/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

//! Router helpers for injecting LSPS2 blinded payment paths.

use bitcoin::secp256k1::{self, PublicKey, Secp256k1};
use std::sync::Arc;

use bitcoin::secp256k1::{self, PublicKey, Secp256k1};
use lightning::blinded_path::payment::{
BlindedPaymentPath, ForwardTlvs, PaymentConstraints, PaymentContext, PaymentForwardNode,
PaymentRelay, ReceiveTlvs,
Expand All @@ -22,13 +23,11 @@ use lightning::routing::router::{InFlightHtlcs, Route, RouteParameters, Router};
use lightning::sign::{EntropySource, ReceiveAuthKey};
use lightning::types::features::BlindedHopFeatures;
use lightning::types::payment::PaymentHash;
use std::sync::Arc;

use super::LSPS2_MIN_FINAL_CLTV_EXPIRY_DELTA;
use crate::payment::PaymentMetadata;
use crate::types::Graph;

use super::LSPS2_MIN_FINAL_CLTV_EXPIRY_DELTA;

/// Parameters needed to construct an LSPS2 blinded payment path.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct LSPS2LeaseParameters {
Expand Down Expand Up @@ -218,11 +217,11 @@ impl<R: Router, ES: EntropySource> Router for LSPS2Router<R, ES> {

#[cfg(test)]
mod tests {
use super::*;
use core::sync::atomic::{AtomicUsize, Ordering};
use std::collections::BTreeMap;

use bitcoin::secp256k1::SecretKey;
use bitcoin::Network;
use core::sync::atomic::{AtomicUsize, Ordering};
use lightning::blinded_path::payment::{Bolt12OfferContext, PaymentConstraints};
use lightning::ln::channel_state::{
ChannelCounterparty, ChannelShutdownState, CounterpartyForwardingInfo,
Expand All @@ -233,8 +232,8 @@ mod tests {
use lightning::offers::offer::OfferId;
use lightning::types::features::{ChannelFeatures, InitFeatures};
use lightning::types::payment::PaymentSecret;
use std::collections::BTreeMap;

use super::*;
use crate::logger::Logger;

#[derive(Clone)]
Expand Down
8 changes: 3 additions & 5 deletions src/liquidity/client/lsps2/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ use lightning_liquidity::lsps2::msgs::LSPS2OpeningFeeParams;
use lightning_liquidity::lsps2::utils::compute_opening_fee;
use tokio::sync::Mutex as AsyncMutex;

use super::LSPS2_MIN_FINAL_CLTV_EXPIRY_DELTA;
use crate::data_store::{DataStore, StorableObject, StorableObjectId};
use crate::hex_utils;
use crate::io::{
LSPS2_CACHE_TARGET_PERSISTENCE_KEY, LSPS2_CACHE_TARGET_PERSISTENCE_PRIMARY_NAMESPACE,
LSPS2_CACHE_TARGET_PERSISTENCE_SECONDARY_NAMESPACE,
};
use crate::logger::{log_error, LdkLogger};
use crate::types::DynStore;
use crate::Error;

use super::LSPS2_MIN_FINAL_CLTV_EXPIRY_DELTA;
use crate::{hex_utils, Error};

pub(crate) const MIN_CACHED_LEASE_REMAINING_SECS: u64 = 24 * 60 * 60;

Expand Down Expand Up @@ -555,14 +553,14 @@ pub(crate) fn now_secs() -> u64 {
mod tests {
use std::sync::Arc;

use super::*;
use bitcoin::secp256k1::{Secp256k1, SecretKey};
use lightning::io;
use lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA;
use lightning::util::persist::{KVStore, PageToken, PaginatedKVStore, PaginatedListResponse};
use lightning::util::ser::{Readable, Writeable};
use lightning::util::test_utils::TestLogger;

use super::*;
use crate::io::test_utils::InMemoryStore;
use crate::io::{
LSPS2_CACHE_TARGET_PERSISTENCE_KEY, LSPS2_CACHE_TARGET_PERSISTENCE_PRIMARY_NAMESPACE,
Expand Down
3 changes: 1 addition & 2 deletions src/payment/bolt12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

mod offers;

pub(crate) use offers::NodeOffersMessageHandler;

use std::num::NonZeroU64;
use std::sync::{Arc, RwLock};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
Expand All @@ -30,6 +28,7 @@ use lightning::sign::{EntropySource, NodeSigner};
use lightning::util::ser::{Readable, Writeable};
use lightning_types::payment::PaymentPreimage;
use lightning_types::string::UntrustedString;
pub(crate) use offers::NodeOffersMessageHandler;

use crate::config::{AsyncPaymentsRole, Config};
use crate::connection::ConnectionManager;
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ use crate::ffi::maybe_wrap;
use crate::liquidity::client::lsps2::router::LSPS2Router;
use crate::logger::Logger;
use crate::message_handler::NodeCustomMessageHandler;
use crate::payment::NodeOffersMessageHandler;
use crate::payment::{
ChannelPairForwardingStats, ForwardedPaymentDetails, PaymentDetails, PendingPaymentDetails,
ChannelPairForwardingStats, ForwardedPaymentDetails, NodeOffersMessageHandler, PaymentDetails,
PendingPaymentDetails,
};
use crate::runtime::RuntimeSpawner;
use crate::wallet::provenance::ChannelTxFacts;
Expand Down