Skip to content

Commit 5f400bb

Browse files
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.
1 parent 2653b02 commit 5f400bb

2 files changed

Lines changed: 26 additions & 12 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/feature/lsps4-splice-in/
45-
lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0", features = ["std"] }
46-
lightning-types = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0" }
47-
lightning-invoice = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0", features = ["std"] }
48-
lightning-net-tokio = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0" }
49-
lightning-persister = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0", features = ["tokio"] }
50-
lightning-background-processor = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0" }
51-
lightning-rapid-gossip-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0" }
52-
lightning-block-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0", features = ["rest-client", "rpc-client", "tokio"] }
53-
lightning-transaction-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
54-
lightning-liquidity = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0", features = ["std"] }
55-
lightning-macros = { git = "https://github.com/moneydevkit/rust-lightning", rev = "afe7b5bb0" }
45+
lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3", features = ["std"] }
46+
lightning-types = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3" }
47+
lightning-invoice = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3", features = ["std"] }
48+
lightning-net-tokio = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3" }
49+
lightning-persister = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3", features = ["tokio"] }
50+
lightning-background-processor = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3" }
51+
lightning-rapid-gossip-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3" }
52+
lightning-block-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3", features = ["rest-client", "rpc-client", "tokio"] }
53+
lightning-transaction-sync = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3", features = ["esplora-async-https", "time", "electrum-rustls-ring"] }
54+
lightning-liquidity = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3", features = ["std"] }
55+
lightning-macros = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3" }
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 = "afe7b5bb0", features = ["std", "_test_utils"] }
104+
lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "457a504b3", 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/liquidity.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,16 @@ where
11461146
their_network_key
11471147
);
11481148
},
1149+
Err(ref e) if is_channel_not_yet_usable(e) => {
1150+
// Channel exists but is reestablishing. Don't fall back to
1151+
// create_channel - the 1Hz timer will retry once usable (~1s).
1152+
log_info!(
1153+
self.logger,
1154+
"LSPS4 splice deferred on channel {} with peer {} (channel reestablishing)",
1155+
channel_id,
1156+
their_network_key
1157+
);
1158+
},
11491159
Err(e) => {
11501160
log_error!(
11511161
self.logger,
@@ -2176,6 +2186,10 @@ fn is_splice_already_pending(err: &APIError) -> bool {
21762186
matches!(err, APIError::APIMisuseError { ref err } if err.contains("splice pending"))
21772187
}
21782188

2189+
fn is_channel_not_yet_usable(err: &APIError) -> bool {
2190+
matches!(err, APIError::APIMisuseError { ref err } if err.contains("pending open/close"))
2191+
}
2192+
21792193
#[derive(Debug, Clone)]
21802194
pub(crate) struct LSPS1OpeningParamsResponse {
21812195
supported_options: LSPS1Options,

0 commit comments

Comments
 (0)