Skip to content

Commit 5eb7c38

Browse files
feat(lsps4): handle SpliceChannel events and wire lifecycle hooks
- Plumb fee_estimator into LiquiditySource for splice UTXO selection - Add splice_channel_for_lsps4() helper mirroring Node::splice_in() - Add open_channel_for_lsps4() helper extracted from OpenChannel handler - Handle SpliceChannel event: try splice, fallback to create_channel - Wire SpliceFailed to reset LSPS4 liquidity cooldown - Wire ChannelClosed to clear LSPS4 liquidity cooldown - Switch to local path deps for cross-repo development
1 parent 1421000 commit 5eb7c38

4 files changed

Lines changed: 332 additions & 26 deletions

File tree

Cargo.toml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ default = []
4242
# lightning-macros = { version = "0.2.0" }
4343

4444
# Branch: https://github.com/moneydevkit/rust-lightning/commits/lsp-0.2.0/
45-
lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["std"] }
46-
lightning-types = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
47-
lightning-invoice = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["std"] }
48-
lightning-net-tokio = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
49-
lightning-persister = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["tokio"] }
50-
lightning-background-processor = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
51-
lightning-rapid-gossip-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
52-
lightning-block-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["rest-client", "rpc-client", "tokio"] }
53-
lightning-transaction-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
54-
lightning-liquidity = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["std"] }
55-
lightning-macros = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
56-
57-
#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
58-
#lightning-types = { path = "../rust-lightning/lightning-types" }
59-
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
60-
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
61-
#lightning-persister = { path = "../rust-lightning/lightning-persister", features = ["tokio"] }
62-
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor" }
63-
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
64-
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rest-client", "rpc-client", "tokio"] }
65-
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "electrum-rustls-ring", "time"] }
66-
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }
67-
#lightning-macros = { path = "../rust-lightning/lightning-macros" }
45+
#lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["std"] }
46+
#lightning-types = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
47+
#lightning-invoice = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["std"] }
48+
#lightning-net-tokio = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
49+
#lightning-persister = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["tokio"] }
50+
#lightning-background-processor = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
51+
#lightning-rapid-gossip-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
52+
#lightning-block-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["rest-client", "rpc-client", "tokio"] }
53+
#lightning-transaction-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
54+
#lightning-liquidity = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["std"] }
55+
#lightning-macros = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0" }
56+
57+
lightning = { path = "../rust-lightning/lightning", features = ["std"] }
58+
lightning-types = { path = "../rust-lightning/lightning-types" }
59+
lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
60+
lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
61+
lightning-persister = { path = "../rust-lightning/lightning-persister", features = ["tokio"] }
62+
lightning-background-processor = { path = "../rust-lightning/lightning-background-processor" }
63+
lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
64+
lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rest-client", "rpc-client", "tokio"] }
65+
lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "electrum-rustls-ring", "time"] }
66+
lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }
67+
lightning-macros = { path = "../rust-lightning/lightning-macros" }
6868

6969
bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
7070
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
@@ -101,8 +101,8 @@ winapi = { version = "0.3", features = ["winbase"] }
101101
[dev-dependencies]
102102
# lightning = { version = "0.2.0", features = ["std", "_test_utils"] }
103103
# Branch: https://github.com/moneydevkit/rust-lightning/commits/lsp-0.2.0/
104-
lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["std", "_test_utils"] }
105-
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
104+
#lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "55f7619f235a05297e81607c2f652d87ed896ce0", features = ["std", "_test_utils"] }
105+
lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
106106
proptest = "1.0.0"
107107
regex = "1.5.6"
108108
criterion = { version = "0.7.0", features = ["async_tokio"] }

src/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,7 @@ fn build_with_store_internal(
17501750
Arc::clone(&keys_manager),
17511751
Arc::clone(&chain_source),
17521752
Arc::clone(&tx_broadcaster),
1753+
Arc::clone(&fee_estimator),
17531754
Arc::clone(&kv_store),
17541755
Arc::clone(&config),
17551756
Arc::clone(&logger),

src/event.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,13 @@ where
15061506
} => {
15071507
log_info!(self.logger, "Channel {} closed due to: {}", channel_id, reason);
15081508

1509+
// Clear LSPS4 liquidity cooldown so the timer can retry.
1510+
if let Some(ref counterparty) = counterparty_node_id {
1511+
if let Some(liquidity_source) = self.liquidity_source.as_ref() {
1512+
liquidity_source.handle_channel_closed(counterparty).await;
1513+
}
1514+
}
1515+
15091516
let event = Event::ChannelClosed {
15101517
channel_id,
15111518
user_channel_id: UserChannelId(user_channel_id),
@@ -1782,6 +1789,11 @@ where
17821789
return Err(ReplayEvent());
17831790
}
17841791

1792+
// Reset LSPS4 cooldown so the timer can retry after cooldown period.
1793+
if let Some(liquidity_source) = self.liquidity_source.as_ref() {
1794+
liquidity_source.handle_splice_failed(&counterparty_node_id).await;
1795+
}
1796+
17851797
let event = Event::SpliceFailed {
17861798
channel_id,
17871799
user_channel_id: UserChannelId(user_channel_id),

0 commit comments

Comments
 (0)