@@ -7,15 +7,16 @@ use cln_lsps::{
77 } ,
88 core:: {
99 lsps2:: {
10- htlc:: { Htlc , HtlcAcceptedHookHandler , HtlcDecision , Onion , RejectReason } ,
10+ htlc:: { Htlc , HtlcAcceptedHookHandler , HtlcDecision , HtlcError , Onion , RejectReason } ,
1111 service:: Lsps2ServiceHandler ,
1212 } ,
1313 server:: LspsService ,
1414 } ,
1515 proto:: lsps0:: { LSPS0_MESSAGE_TYPE , Msat } ,
16+ proto:: lsps2:: failure_codes:: TEMPORARY_CHANNEL_FAILURE ,
1617} ;
1718use cln_plugin:: { HookBuilder , HookFilter , Plugin , options} ;
18- use log:: { debug, error, trace} ;
19+ use log:: { debug, error, trace, warn } ;
1920use std:: path:: { Path , PathBuf } ;
2021use std:: sync:: Arc ;
2122
@@ -190,16 +191,31 @@ async fn handle_htlc_inner(
190191 log_decision ( & dec) ;
191192 decision_to_response ( dec) ?
192193 }
193- Err ( e) => {
194- // Fixme: Should we log **BROKEN** here?
195- debug ! ( "Htlc handler failed (continuing): {:#}" , e) ;
196- return Ok ( json_continue ( ) ) ;
197- }
194+ Err ( e) => return Ok ( handle_htlc_error ( e) ) ,
198195 } ;
199196
200197 Ok ( serde_json:: to_value ( & response) ?)
201198}
202199
200+ fn handle_htlc_error ( e : HtlcError ) -> serde_json:: Value {
201+ match e {
202+ HtlcError :: FundChannel ( ref cause) => {
203+ warn ! (
204+ "LSPS2: Failed to open JIT channel (likely insufficient on-chain balance): {:#}. \
205+ Operator action required.",
206+ cause
207+ ) ;
208+ }
209+ HtlcError :: ChannelReadyCheck ( ref cause) => {
210+ warn ! ( "LSPS2: Channel ready check failed: {:#}" , cause) ;
211+ }
212+ HtlcError :: CapacityQuery ( ref cause) => {
213+ error ! ( "LSPS2: Capacity query failed: {:#}" , cause) ;
214+ }
215+ }
216+ json_fail ( TEMPORARY_CHANNEL_FAILURE )
217+ }
218+
203219fn decision_to_response ( decision : HtlcDecision ) -> Result < serde_json:: Value , anyhow:: Error > {
204220 Ok ( match decision {
205221 HtlcDecision :: NotOurs => json_continue ( ) ,
0 commit comments