Skip to content
Draft
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
49 changes: 25 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ default = []
#lightning-liquidity = { version = "0.2.0", features = ["std"] }
#lightning-macros = { version = "0.2.0" }

lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["std"] }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
lightning = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3", features = ["std"] }
lightning-types = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-invoice = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-persister = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3", features = ["tokio"] }
lightning-background-processor = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-rapid-gossip-sync = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-block-sync = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
lightning-liquidity = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3", features = ["std"] }
lightning-macros = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }

bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
Expand Down Expand Up @@ -85,7 +85,7 @@ bitcoin-payment-instructions = { git = "https://github.com/tnull/bitcoin-payment
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["std", "_test_utils"] }
lightning = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3", features = ["std", "_test_utils"] }
rand = { version = "0.9.2", default-features = false, features = ["std", "thread_rng", "os_rng"] }
proptest = "1.0.0"
regex = "1.5.6"
Expand Down Expand Up @@ -125,6 +125,7 @@ check-cfg = [
"cfg(cln_test)",
"cfg(lnd_test)",
"cfg(cycle_tests)",
"cfg(lsps1_service)",
]

[[bench]]
Expand Down Expand Up @@ -171,15 +172,15 @@ harness = false
#vss-client-ng = { path = "../vss-client" }
#vss-client-ng = { git = "https://github.com/lightningdevkit/vss-client", branch = "main" }
#
#[patch."https://github.com/lightningdevkit/rust-lightning"]
#lightning = { path = "../rust-lightning/lightning" }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor" }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync" }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity" }
#lightning-macros = { path = "../rust-lightning/lightning-macros" }
[patch."https://github.com/lightningdevkit/rust-lightning"]
lightning = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-types = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-invoice = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-net-tokio = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-persister = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-background-processor = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-rapid-gossip-sync = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-block-sync = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-transaction-sync = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-liquidity = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
lightning-macros = { git = "https://github.com/vincenzopalazzo/rust-lightning", rev = "96f1d193b75cf9534def6cc2b3e65f1aaea5d4e3" }
4 changes: 3 additions & 1 deletion bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ enum NodeError {
"FeerateEstimationUpdateTimeout",
"WalletOperationFailed",
"WalletOperationTimeout",
"PayerProofCreationFailed",
"PayerProofUnavailable",
"OnchainTxSigningFailed",
"TxSyncFailed",
"TxSyncTimeout",
Expand Down Expand Up @@ -225,6 +227,7 @@ enum NodeError {
"LnurlAuthFailed",
"LnurlAuthTimeout",
"InvalidLnurl",
"InvalidPayerProof",
};

typedef dictionary NodeStatus;
Expand Down Expand Up @@ -300,7 +303,6 @@ dictionary LSPS1ChannelInfo {
[Remote]
enum LSPS1PaymentState {
"ExpectPayment",
"Hold",
"Paid",
"Refunded",
};
Expand Down
53 changes: 40 additions & 13 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ use crate::gossip::GossipSource;
use crate::io::sqlite_store::SqliteStore;
use crate::io::utils::{
read_event_queue, read_external_pathfinding_scores_from_cache, read_network_graph,
read_node_metrics, read_output_sweeper, read_payments, read_peer_info, read_pending_payments,
read_scorer, write_node_metrics,
read_node_metrics, read_output_sweeper, read_payer_proof_contexts, read_payments,
read_peer_info, read_pending_payments, read_scorer, write_node_metrics,
};
use crate::io::vss_store::VssStoreBuilder;
use crate::io::{
self, PAYMENT_INFO_PERSISTENCE_PRIMARY_NAMESPACE, PAYMENT_INFO_PERSISTENCE_SECONDARY_NAMESPACE,
self, PAYER_PROOF_CONTEXT_PERSISTENCE_PRIMARY_NAMESPACE,
PAYER_PROOF_CONTEXT_PERSISTENCE_SECONDARY_NAMESPACE,
PAYMENT_INFO_PERSISTENCE_PRIMARY_NAMESPACE, PAYMENT_INFO_PERSISTENCE_SECONDARY_NAMESPACE,
PENDING_PAYMENT_INFO_PERSISTENCE_PRIMARY_NAMESPACE,
PENDING_PAYMENT_INFO_PERSISTENCE_SECONDARY_NAMESPACE,
};
Expand All @@ -77,8 +79,8 @@ use crate::runtime::{Runtime, RuntimeSpawner};
use crate::tx_broadcaster::TransactionBroadcaster;
use crate::types::{
AsyncPersister, ChainMonitor, ChannelManager, DynStore, DynStoreWrapper, GossipSync, Graph,
KeysManager, MessageRouter, OnionMessenger, PaymentStore, PeerManager, PendingPaymentStore,
Persister, SyncAndAsyncKVStore,
KeysManager, MessageRouter, OnionMessenger, PayerProofContextStore, PaymentStore, PeerManager,
PendingPaymentStore, Persister, SyncAndAsyncKVStore,
};
use crate::wallet::persist::KVStoreWalletPersister;
use crate::wallet::Wallet;
Expand Down Expand Up @@ -1260,14 +1262,19 @@ fn build_with_store_internal(

let kv_store_ref = Arc::clone(&kv_store);
let logger_ref = Arc::clone(&logger);
let (payment_store_res, node_metris_res, pending_payment_store_res) =
runtime.block_on(async move {
tokio::join!(
read_payments(&*kv_store_ref, Arc::clone(&logger_ref)),
read_node_metrics(&*kv_store_ref, Arc::clone(&logger_ref)),
read_pending_payments(&*kv_store_ref, Arc::clone(&logger_ref))
)
});
let (
payment_store_res,
node_metris_res,
pending_payment_store_res,
payer_proof_context_store_res,
) = runtime.block_on(async move {
tokio::join!(
read_payments(&*kv_store_ref, Arc::clone(&logger_ref)),
read_node_metrics(&*kv_store_ref, Arc::clone(&logger_ref)),
read_pending_payments(&*kv_store_ref, Arc::clone(&logger_ref)),
read_payer_proof_contexts(&*kv_store_ref, Arc::clone(&logger_ref))
)
});

// Initialize the status fields.
let node_metrics = match node_metris_res {
Expand Down Expand Up @@ -1296,6 +1303,20 @@ fn build_with_store_internal(
},
};

let payer_proof_context_store = match payer_proof_context_store_res {
Ok(contexts) => Arc::new(PayerProofContextStore::new(
contexts,
PAYER_PROOF_CONTEXT_PERSISTENCE_PRIMARY_NAMESPACE.to_string(),
PAYER_PROOF_CONTEXT_PERSISTENCE_SECONDARY_NAMESPACE.to_string(),
Arc::clone(&kv_store),
Arc::clone(&logger),
)),
Err(e) => {
log_error!(logger, "Failed to read payer proof contexts from store: {}", e);
return Err(BuildError::ReadFailed);
},
};

let (chain_source, chain_tip_opt) = match chain_data_source_config {
Some(ChainDataSourceConfig::Esplora { server_url, headers, sync_config }) => {
let sync_config = sync_config.unwrap_or(EsploraSyncConfig::default());
Expand Down Expand Up @@ -1796,6 +1817,11 @@ fn build_with_store_internal(
Arc::clone(&wallet),
Arc::clone(&channel_manager),
Arc::clone(&keys_manager),
Arc::clone(&chain_source),
ChainParameters {
network: config.network.into(),
best_block: channel_manager.current_best_block(),
},
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Expand Down Expand Up @@ -1992,6 +2018,7 @@ fn build_with_store_internal(
scorer,
peer_store,
payment_store,
payer_proof_context_store,
lnurl_auth,
is_running,
node_metrics,
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ pub(crate) fn default_user_config(config: &Config) -> UserConfig {
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx =
config.anchor_channels_config.is_some();
user_config.reject_inbound_splices = false;
user_config.manually_handle_bolt12_invoices = true;

if may_announce_channel(config).is_err() {
user_config.accept_forwards_to_priv_channels = false;
Expand Down
11 changes: 11 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ pub enum Error {
WalletOperationFailed,
/// A wallet operation timed out.
WalletOperationTimeout,
/// Creating a payer proof failed.
PayerProofCreationFailed,
/// A payer proof is unavailable for the requested payment.
PayerProofUnavailable,
/// A signing operation for transaction failed.
OnchainTxSigningFailed,
/// A transaction sync operation failed.
Expand Down Expand Up @@ -137,6 +141,8 @@ pub enum Error {
LnurlAuthTimeout,
/// The provided lnurl is invalid.
InvalidLnurl,
/// The provided payer proof is invalid.
InvalidPayerProof,
}

impl fmt::Display for Error {
Expand Down Expand Up @@ -168,6 +174,10 @@ impl fmt::Display for Error {
},
Self::WalletOperationFailed => write!(f, "Failed to conduct wallet operation."),
Self::WalletOperationTimeout => write!(f, "A wallet operation timed out."),
Self::PayerProofCreationFailed => write!(f, "Failed to create payer proof."),
Self::PayerProofUnavailable => {
write!(f, "A payer proof is unavailable for the requested payment.")
},
Self::OnchainTxSigningFailed => write!(f, "Failed to sign given transaction."),
Self::TxSyncFailed => write!(f, "Failed to sync transactions."),
Self::TxSyncTimeout => write!(f, "Syncing transactions timed out."),
Expand Down Expand Up @@ -222,6 +232,7 @@ impl fmt::Display for Error {
Self::LnurlAuthFailed => write!(f, "LNURL-auth authentication failed."),
Self::LnurlAuthTimeout => write!(f, "LNURL-auth authentication timed out."),
Self::InvalidLnurl => write!(f, "The provided lnurl is invalid."),
Self::InvalidPayerProof => write!(f, "The provided payer proof is invalid."),
}
}
}
Expand Down
Loading
Loading