Skip to content

Commit f424a65

Browse files
LSPS4 Splice In (#16)
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 fix(lsps4): handle channel-not-usable splice error without fallback When splice fails because the channel is reestablishing (not usable yet), don't fall back to create_channel. The timer retries in ~1s once reestablishment completes. fix(lsps4): use unconfirmed UTXOs for splice funding Splices are zero-conf anyway, so using unconfirmed inputs adds no additional risk. Prevents splice failures when the LSP wallet has unconfirmed change from a previous splice. --------- Co-authored-by: Martin Saposnic <martinsaposnic@gmail.com>
1 parent 1421000 commit f424a65

5 files changed

Lines changed: 378 additions & 15 deletions

File tree

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ 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" }
45+
lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121", features = ["std"] }
46+
lightning-types = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121" }
47+
lightning-invoice = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121", features = ["std"] }
48+
lightning-net-tokio = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121" }
49+
lightning-persister = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121", features = ["tokio"] }
50+
lightning-background-processor = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121" }
51+
lightning-rapid-gossip-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121" }
52+
lightning-block-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121", features = ["rest-client", "rpc-client", "tokio"] }
53+
lightning-transaction-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
54+
lightning-liquidity = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121", features = ["std"] }
55+
lightning-macros = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121" }
5656

5757
#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
5858
#lightning-types = { path = "../rust-lightning/lightning-types" }
@@ -101,7 +101,7 @@ 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"] }
104+
lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "b89fc7121", features = ["std", "_test_utils"] }
105105
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
106106
proptest = "1.0.0"
107107
regex = "1.5.6"

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)