Skip to content

Commit 07a1347

Browse files
committed
Merge remote-tracking branch 'upstream/main' into add-cbf-chain-source
2 parents fdf6710 + bf7713d commit 07a1347

File tree

9 files changed

+1023
-157
lines changed

9 files changed

+1023
-157
lines changed

Cargo.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ default = []
3939
#lightning-liquidity = { version = "0.2.0", features = ["std"] }
4040
#lightning-macros = { version = "0.2.0" }
4141

42-
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["std"] }
43-
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
44-
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["std"] }
45-
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
46-
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["tokio"] }
47-
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
48-
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
49-
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["rest-client", "rpc-client", "tokio"] }
50-
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
51-
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["std"] }
52-
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953" }
42+
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["std"] }
43+
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
44+
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["std"] }
45+
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
46+
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["tokio"] }
47+
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
48+
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
49+
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["rest-client", "rpc-client", "tokio"] }
50+
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
51+
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["std"] }
52+
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
5353

5454
bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
5555
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
@@ -80,18 +80,19 @@ async-trait = { version = "0.1", default-features = false }
8080
vss-client = { package = "vss-client-ng", version = "0.5" }
8181
prost = { version = "0.11.6", default-features = false}
8282
#bitcoin-payment-instructions = { version = "0.6" }
83-
bitcoin-payment-instructions = { git = "https://github.com/tnull/bitcoin-payment-instructions", rev = "e9d7c07d7affc7714b023c853a65771e45277467" }
83+
bitcoin-payment-instructions = { git = "https://github.com/joostjager/bitcoin-payment-instructions", branch = "ldk-dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
8484

8585
[target.'cfg(windows)'.dependencies]
8686
winapi = { version = "0.3", features = ["winbase"] }
8787

8888
[dev-dependencies]
89-
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "49912057895ddfbd69d503de67c80d5576c09953", features = ["std", "_test_utils"] }
89+
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "dcf0c203e166da2348bef12b2e5eff4a250cdec7", features = ["std", "_test_utils"] }
9090
rand = { version = "0.9.2", default-features = false, features = ["std", "thread_rng", "os_rng"] }
9191
proptest = "1.0.0"
9292
regex = "1.5.6"
9393
criterion = { version = "0.7.0", features = ["async_tokio"] }
9494
ldk-node-062 = { package = "ldk-node", version = "=0.6.2" }
95+
ldk-node-070 = { package = "ldk-node", version = "=0.7.0" }
9596

9697
[target.'cfg(not(no_download))'.dev-dependencies]
9798
electrsd = { version = "0.36.1", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }

src/builder.rs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ use crate::peer_store::PeerStore;
7676
use crate::runtime::{Runtime, RuntimeSpawner};
7777
use crate::tx_broadcaster::TransactionBroadcaster;
7878
use crate::types::{
79-
AsyncPersister, ChainMonitor, ChannelManager, DynStore, DynStoreWrapper, GossipSync, Graph,
80-
KeysManager, MessageRouter, OnionMessenger, PaymentStore, PeerManager, PendingPaymentStore,
81-
Persister, SyncAndAsyncKVStore,
79+
AsyncPersister, ChainMonitor, ChannelManager, DynStore, DynStoreRef, DynStoreWrapper,
80+
GossipSync, Graph, KeysManager, MessageRouter, OnionMessenger, PaymentStore, PeerManager,
81+
PendingPaymentStore, SyncAndAsyncKVStore,
8282
};
8383
use crate::wallet::persist::KVStoreWalletPersister;
8484
use crate::wallet::Wallet;
@@ -1550,7 +1550,7 @@ fn build_with_store_internal(
15501550

15511551
let peer_storage_key = keys_manager.get_peer_storage_key();
15521552
let monitor_reader = Arc::new(AsyncPersister::new(
1553-
Arc::clone(&kv_store),
1553+
DynStoreRef(Arc::clone(&kv_store)),
15541554
RuntimeSpawner::new(Arc::clone(&runtime)),
15551555
Arc::clone(&logger),
15561556
PERSISTER_MAX_PENDING_UPDATES,
@@ -1563,7 +1563,7 @@ fn build_with_store_internal(
15631563
// Read ChannelMonitors and the NetworkGraph
15641564
let kv_store_ref = Arc::clone(&kv_store);
15651565
let logger_ref = Arc::clone(&logger);
1566-
let (monitor_read_res, network_graph_res) = runtime.block_on(async move {
1566+
let (monitor_read_res, network_graph_res) = runtime.block_on(async {
15671567
tokio::join!(
15681568
monitor_reader.read_all_channel_monitors_with_updates_parallel(),
15691569
read_network_graph(&*kv_store_ref, logger_ref),
@@ -1583,26 +1583,21 @@ fn build_with_store_internal(
15831583
},
15841584
};
15851585

1586-
let persister = Arc::new(Persister::new(
1587-
Arc::clone(&kv_store),
1588-
Arc::clone(&logger),
1589-
PERSISTER_MAX_PENDING_UPDATES,
1590-
Arc::clone(&keys_manager),
1591-
Arc::clone(&keys_manager),
1592-
Arc::clone(&tx_broadcaster),
1593-
Arc::clone(&fee_estimator),
1594-
));
1595-
15961586
// Initialize the ChainMonitor
1597-
let chain_monitor: Arc<ChainMonitor> = Arc::new(chainmonitor::ChainMonitor::new(
1598-
Some(Arc::clone(&chain_source)),
1599-
Arc::clone(&tx_broadcaster),
1600-
Arc::clone(&logger),
1601-
Arc::clone(&fee_estimator),
1602-
Arc::clone(&persister),
1603-
Arc::clone(&keys_manager),
1604-
peer_storage_key,
1605-
));
1587+
let chain_monitor: Arc<ChainMonitor> = {
1588+
let persister = Arc::try_unwrap(monitor_reader)
1589+
.unwrap_or_else(|_| panic!("Arc<AsyncPersister> should have no other references"));
1590+
Arc::new(chainmonitor::ChainMonitor::new_async_beta(
1591+
Some(Arc::clone(&chain_source)),
1592+
Arc::clone(&tx_broadcaster),
1593+
Arc::clone(&logger),
1594+
Arc::clone(&fee_estimator),
1595+
persister,
1596+
Arc::clone(&keys_manager),
1597+
peer_storage_key,
1598+
true,
1599+
))
1600+
};
16061601

16071602
// Initialize the network graph, scorer, and router
16081603
let network_graph = match network_graph_res {

src/event.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,26 @@ where
691691
if info.status == PaymentStatus::Succeeded
692692
|| matches!(info.kind, PaymentKind::Spontaneous { .. })
693693
{
694+
let stored_preimage = match info.kind {
695+
PaymentKind::Bolt11 { preimage, .. }
696+
| PaymentKind::Bolt11Jit { preimage, .. }
697+
| PaymentKind::Bolt12Offer { preimage, .. }
698+
| PaymentKind::Bolt12Refund { preimage, .. }
699+
| PaymentKind::Spontaneous { preimage, .. } => preimage,
700+
_ => None,
701+
};
702+
703+
if let Some(preimage) = stored_preimage {
704+
log_info!(
705+
self.logger,
706+
"Re-claiming previously succeeded payment with hash {} of {}msat",
707+
hex_utils::to_string(&payment_hash.0),
708+
amount_msat,
709+
);
710+
self.channel_manager.claim_funds(preimage);
711+
return Ok(());
712+
}
713+
694714
log_info!(
695715
self.logger,
696716
"Refused duplicate inbound payment from payment hash {} of {}msat",

0 commit comments

Comments
 (0)