Skip to content

Commit 79a6533

Browse files
committed
Persist LSPS2 cleanup on intercept errors
When htlc_intercepted rejects an LSPS2-owned HTLC, it fails the intercept and prunes the per-peer and global SCID mappings before returning an API error. Persist the peer state after releasing locks so the cleanup survives restarts.
1 parent 95c0713 commit 79a6533

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lightning-liquidity/src/lsps2/service.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,13 +1057,22 @@ where
10571057
.get_cm()
10581058
.fail_intercepted_htlc(intercept_id)?;
10591059
peer_state.remove_outbound_channel(intercept_scid);
1060+
let err = e.err;
10601061
drop(peer_state);
10611062
drop(outer_state_lock);
10621063
self.peer_by_intercept_scid
10631064
.write()
10641065
.unwrap()
10651066
.remove(&intercept_scid);
1066-
return Err(APIError::APIMisuseError { err: e.err });
1067+
self.persist_peer_state(counterparty_node_id).await.map_err(
1068+
|e| APIError::APIMisuseError {
1069+
err: format!(
1070+
"Failed to persist peer state for {}: {}",
1071+
counterparty_node_id, e
1072+
),
1073+
},
1074+
)?;
1075+
return Err(APIError::APIMisuseError { err });
10671076
},
10681077
}
10691078
} else {

0 commit comments

Comments
 (0)