@@ -1492,13 +1492,29 @@ where
1492
1492
} => ( destination, None ) ,
1493
1493
} ;
1494
1494
1495
- let mut logger = WithContext :: from ( & self . logger , None , None , None ) ;
1496
- let result = self . find_path ( destination) . and_then ( |path| {
1497
- let first_hop = path. intermediate_nodes . get ( 0 ) . map ( |p| * p) ;
1498
- logger = WithContext :: from ( & self . logger , first_hop, None , None ) ;
1499
- self . enqueue_onion_message ( path, contents, reply_path, log_suffix)
1500
- } ) ;
1495
+ let path = self . find_path ( destination) . map_err ( |e| {
1496
+ log_trace ! ( self . logger, "Failed to find path {}" , log_suffix) ;
1497
+ e
1498
+ } ) ?;
1499
+ let first_hop = path. intermediate_nodes . get ( 0 ) . map ( |p| * p) ;
1500
+ let logger = WithContext :: from ( & self . logger , first_hop, None , None ) ;
1501
+
1502
+ log_trace ! ( logger, "Constructing onion message {}: {:?}" , log_suffix, contents) ;
1503
+ let ( first_node_id, onion_message, addresses) = create_onion_message (
1504
+ & self . entropy_source ,
1505
+ & self . node_signer ,
1506
+ & self . node_id_lookup ,
1507
+ & self . secp_ctx ,
1508
+ path,
1509
+ contents,
1510
+ reply_path,
1511
+ )
1512
+ . map_err ( |e| {
1513
+ log_warn ! ( logger, "Failed to create onion message with {:?} {}" , e, log_suffix) ;
1514
+ e
1515
+ } ) ?;
1501
1516
1517
+ let result = self . enqueue_outbound_onion_message ( onion_message, first_node_id, addresses) ;
1502
1518
match result. as_ref ( ) {
1503
1519
Err ( SendError :: GetNodeIdFailed ) => {
1504
1520
log_warn ! ( logger, "Unable to retrieve node id {}" , log_suffix) ;
@@ -1578,22 +1594,10 @@ where
1578
1594
. map_err ( |_| SendError :: PathNotFound )
1579
1595
}
1580
1596
1581
- fn enqueue_onion_message < T : OnionMessageContents > (
1582
- & self , path : OnionMessagePath , contents : T , reply_path : Option < BlindedMessagePath > ,
1583
- log_suffix : fmt :: Arguments ,
1597
+ fn enqueue_outbound_onion_message (
1598
+ & self , onion_message : OnionMessage , first_node_id : PublicKey ,
1599
+ addresses : Option < Vec < SocketAddress > > ,
1584
1600
) -> Result < SendSuccess , SendError > {
1585
- log_trace ! ( self . logger, "Constructing onion message {}: {:?}" , log_suffix, contents) ;
1586
-
1587
- let ( first_node_id, onion_message, addresses) = create_onion_message (
1588
- & self . entropy_source ,
1589
- & self . node_signer ,
1590
- & self . node_id_lookup ,
1591
- & self . secp_ctx ,
1592
- path,
1593
- contents,
1594
- reply_path,
1595
- ) ?;
1596
-
1597
1601
let mut message_recipients = self . message_recipients . lock ( ) . unwrap ( ) ;
1598
1602
if outbound_buffer_full ( & first_node_id, & message_recipients) {
1599
1603
return Err ( SendError :: BufferFull ) ;
@@ -1713,7 +1717,16 @@ where
1713
1717
pub fn send_onion_message_using_path < T : OnionMessageContents > (
1714
1718
& self , path : OnionMessagePath , contents : T , reply_path : Option < BlindedMessagePath > ,
1715
1719
) -> Result < SendSuccess , SendError > {
1716
- self . enqueue_onion_message ( path, contents, reply_path, format_args ! ( "" ) )
1720
+ let ( first_node_id, onion_message, addresses) = create_onion_message (
1721
+ & self . entropy_source ,
1722
+ & self . node_signer ,
1723
+ & self . node_id_lookup ,
1724
+ & self . secp_ctx ,
1725
+ path,
1726
+ contents,
1727
+ reply_path,
1728
+ ) ?;
1729
+ self . enqueue_outbound_onion_message ( onion_message, first_node_id, addresses)
1717
1730
}
1718
1731
1719
1732
pub ( crate ) fn peel_onion_message (
0 commit comments