@@ -10,8 +10,8 @@ use crate::exchange_rate_provider::{ExchangeRateProvider, ExchangeRateProviderIm
10
10
use crate :: logger:: init_logger_once;
11
11
use crate :: util:: LogIgnoreError ;
12
12
use crate :: {
13
- enable_backtrace, register_webhook_url, sanitize_input, start_sdk, Config , RuntimeErrorCode ,
14
- UserPreferences , DB_FILENAME , LOGS_DIR ,
13
+ enable_backtrace, register_webhook_url, sanitize_input, start_sdk, Config , EnableStatus ,
14
+ RuntimeErrorCode , UserPreferences , DB_FILENAME , LOGS_DIR ,
15
15
} ;
16
16
use breez_sdk_core:: {
17
17
BreezEvent , BreezServices , EventListener , InvoicePaidDetails , OpenChannelFeeRequest , Payment ,
@@ -306,6 +306,29 @@ fn handle_lnurl_pay_request_notification(
306
306
"Failed to query open channel fees" ,
307
307
) ?;
308
308
309
+ // Prevent payments sent to disabled address from being received
310
+ let db_path = format ! ( "{}/{DB_FILENAME}" , config. local_persistence_path) ;
311
+ let mut data_store = DataStore :: new ( & db_path)
312
+ . map_runtime_error_using ( NotificationHandlingErrorCode :: from_runtime_error) ?;
313
+ match data_store
314
+ . retrieve_lightning_addresses ( )
315
+ . map_runtime_error_using ( NotificationHandlingErrorCode :: from_runtime_error) ?
316
+ . iter ( )
317
+ . find ( |( a, _) | data. recipient == * a)
318
+ {
319
+ None => {
320
+ permanent_failure ! (
321
+ "Received LNURL Pay request notification for unrecognized address/phone number"
322
+ )
323
+ }
324
+ Some ( ( _, EnableStatus :: FeatureDisabled ) ) => {
325
+ permanent_failure ! (
326
+ "Received LNURL Pay request notification for disabled address/phone number feature"
327
+ )
328
+ }
329
+ Some ( ( _, EnableStatus :: Enabled ) ) => { }
330
+ }
331
+
309
332
let strong_typed_seed = get_strong_typed_seed ( & config) ?;
310
333
let environment = get_environment ( & config) ?;
311
334
@@ -370,9 +393,6 @@ fn handle_lnurl_pay_request_notification(
370
393
"Failed to get exchange rates" ,
371
394
) ?;
372
395
373
- let db_path = format ! ( "{}/{DB_FILENAME}" , config. local_persistence_path) ;
374
- let mut data_store = DataStore :: new ( & db_path)
375
- . map_runtime_error_using ( NotificationHandlingErrorCode :: from_runtime_error) ?;
376
396
data_store
377
397
. store_payment_info (
378
398
& receive_payment_result. ln_invoice . payment_hash ,
0 commit comments