@@ -62,6 +62,7 @@ use crate::sign::{EntropySource, NodeSigner, ReceiveAuthKey};
62
62
use crate :: offers:: static_invoice:: { StaticInvoice , StaticInvoiceBuilder } ;
63
63
use crate :: sync:: { Mutex , RwLock } ;
64
64
use crate :: types:: payment:: { PaymentHash , PaymentSecret } ;
65
+ use crate :: util:: logger:: Logger ;
65
66
use crate :: util:: ser:: Writeable ;
66
67
67
68
#[ cfg( feature = "dnssec" ) ]
75
76
///
76
77
/// [`OffersMessageFlow`] is parameterized by a [`MessageRouter`], which is responsible
77
78
/// for finding message paths when initiating and retrying onion messages.
78
- pub struct OffersMessageFlow < MR : Deref >
79
+ pub struct OffersMessageFlow < MR : Deref , L : Deref >
79
80
where
80
81
MR :: Target : MessageRouter ,
82
+ L :: Target : Logger ,
81
83
{
82
84
chain_hash : ChainHash ,
83
85
best_block : RwLock < BestBlock > ,
@@ -103,17 +105,21 @@ where
103
105
pub ( crate ) hrn_resolver : OMNameResolver ,
104
106
#[ cfg( feature = "dnssec" ) ]
105
107
pending_dns_onion_messages : Mutex < Vec < ( DNSResolverMessage , MessageSendInstructions ) > > ,
108
+
109
+ logger : L ,
106
110
}
107
111
108
- impl < MR : Deref > OffersMessageFlow < MR >
112
+ impl < MR : Deref , L : Deref > OffersMessageFlow < MR , L >
109
113
where
110
114
MR :: Target : MessageRouter ,
115
+ L :: Target : Logger ,
111
116
{
112
117
/// Creates a new [`OffersMessageFlow`]
113
118
pub fn new (
114
119
chain_hash : ChainHash , best_block : BestBlock , our_network_pubkey : PublicKey ,
115
120
current_timestamp : u32 , inbound_payment_key : inbound_payment:: ExpandedKey ,
116
121
receive_auth_key : ReceiveAuthKey , secp_ctx : Secp256k1 < secp256k1:: All > , message_router : MR ,
122
+ logger : L ,
117
123
) -> Self {
118
124
Self {
119
125
chain_hash,
@@ -137,6 +143,8 @@ where
137
143
pending_dns_onion_messages : Mutex :: new ( Vec :: new ( ) ) ,
138
144
139
145
async_receive_offer_cache : Mutex :: new ( AsyncReceiveOfferCache :: new ( ) ) ,
146
+
147
+ logger,
140
148
}
141
149
}
142
150
@@ -260,9 +268,10 @@ const DEFAULT_ASYNC_RECEIVE_OFFER_EXPIRY: Duration = Duration::from_secs(365 * 2
260
268
pub ( crate ) const TEST_DEFAULT_ASYNC_RECEIVE_OFFER_EXPIRY : Duration =
261
269
DEFAULT_ASYNC_RECEIVE_OFFER_EXPIRY ;
262
270
263
- impl < MR : Deref > OffersMessageFlow < MR >
271
+ impl < MR : Deref , L : Deref > OffersMessageFlow < MR , L >
264
272
where
265
273
MR :: Target : MessageRouter ,
274
+ L :: Target : Logger ,
266
275
{
267
276
/// [`BlindedMessagePath`]s for an async recipient to communicate with this node and interactively
268
277
/// build [`Offer`]s and [`StaticInvoice`]s for receiving async payments.
@@ -278,6 +287,7 @@ where
278
287
peers : Vec < MessageForwardNode > ,
279
288
) -> Result < Vec < BlindedMessagePath > , ( ) > {
280
289
if recipient_id. len ( ) > 1024 {
290
+ log_trace ! ( self . logger, "Async recipient ID exceeds 1024 bytes" ) ;
281
291
return Err ( ( ) ) ;
282
292
}
283
293
@@ -409,9 +419,10 @@ pub enum InvreqResponseInstructions {
409
419
} ,
410
420
}
411
421
412
- impl < MR : Deref > OffersMessageFlow < MR >
422
+ impl < MR : Deref , L : Deref > OffersMessageFlow < MR , L >
413
423
where
414
424
MR :: Target : MessageRouter ,
425
+ L :: Target : Logger ,
415
426
{
416
427
/// Verifies an [`InvoiceRequest`] using the provided [`OffersContext`] or the [`InvoiceRequest::metadata`].
417
428
///
@@ -439,6 +450,7 @@ where
439
450
path_absolute_expiry,
440
451
} ) => {
441
452
if path_absolute_expiry < self . duration_since_epoch ( ) {
453
+ log_trace ! ( self . logger, "Static invoice request has expired" ) ;
442
454
return Err ( ( ) ) ;
443
455
}
444
456
@@ -1281,6 +1293,10 @@ where
1281
1293
let reply_paths = match self . create_blinded_paths ( peers, context) {
1282
1294
Ok ( paths) => paths,
1283
1295
Err ( ( ) ) => {
1296
+ log_error ! (
1297
+ self . logger,
1298
+ "Failed to create blinded paths for OfferPathsRequest message"
1299
+ ) ;
1284
1300
return Err ( ( ) ) ;
1285
1301
} ,
1286
1302
} ;
@@ -1399,7 +1415,13 @@ where
1399
1415
1400
1416
match self . create_blinded_paths ( peers, context) {
1401
1417
Ok ( paths) => ( paths, path_absolute_expiry) ,
1402
- Err ( ( ) ) => return None ,
1418
+ Err ( ( ) ) => {
1419
+ log_error ! (
1420
+ self . logger,
1421
+ "Failed to create blinded paths for OfferPaths message"
1422
+ ) ;
1423
+ return None ;
1424
+ } ,
1403
1425
}
1404
1426
} ;
1405
1427
@@ -1473,6 +1495,7 @@ where
1473
1495
let ( offer_id, offer) = match offer_builder. build ( ) {
1474
1496
Ok ( offer) => ( offer. id ( ) , offer) ,
1475
1497
Err ( _) => {
1498
+ log_error ! ( self . logger, "Failed to build async receive offer" ) ;
1476
1499
debug_assert ! ( false ) ;
1477
1500
return None ;
1478
1501
} ,
@@ -1487,7 +1510,10 @@ where
1487
1510
router,
1488
1511
) {
1489
1512
Ok ( res) => res,
1490
- Err ( ( ) ) => return None ,
1513
+ Err ( ( ) ) => {
1514
+ log_error ! ( self . logger, "Failed to create static invoice for server" ) ;
1515
+ return None ;
1516
+ } ,
1491
1517
} ;
1492
1518
1493
1519
if let Err ( ( ) ) = self . async_receive_offer_cache . lock ( ) . unwrap ( ) . cache_pending_offer (
@@ -1498,6 +1524,7 @@ where
1498
1524
duration_since_epoch,
1499
1525
invoice_slot,
1500
1526
) {
1527
+ log_error ! ( self . logger, "Failed to cache pending offer" ) ;
1501
1528
return None ;
1502
1529
}
1503
1530
@@ -1581,6 +1608,7 @@ where
1581
1608
& self , message : & ServeStaticInvoice , context : AsyncPaymentsContext ,
1582
1609
) -> Result < ( Vec < u8 > , u16 ) , ( ) > {
1583
1610
if message. invoice . is_expired_no_std ( self . duration_since_epoch ( ) ) {
1611
+ log_trace ! ( self . logger, "Received expired StaticInvoice" ) ;
1584
1612
return Err ( ( ) ) ;
1585
1613
}
1586
1614
if message. invoice . serialized_length ( ) > MAX_STATIC_INVOICE_SIZE_BYTES {
@@ -1593,6 +1621,7 @@ where
1593
1621
path_absolute_expiry,
1594
1622
} => {
1595
1623
if self . duration_since_epoch ( ) > path_absolute_expiry {
1624
+ log_trace ! ( self . logger, "Received expired StaticInvoice path" ) ;
1596
1625
return Err ( ( ) ) ;
1597
1626
}
1598
1627
0 commit comments