@@ -1492,13 +1492,29 @@ where
14921492 } => ( destination, None ) ,
14931493 } ;
14941494
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+ } ) ?;
15011516
1517+ let result = self . enqueue_outbound_onion_message ( onion_message, first_node_id, addresses) ;
15021518 match result. as_ref ( ) {
15031519 Err ( SendError :: GetNodeIdFailed ) => {
15041520 log_warn ! ( logger, "Unable to retrieve node id {}" , log_suffix) ;
@@ -1578,22 +1594,10 @@ where
15781594 . map_err ( |_| SendError :: PathNotFound )
15791595 }
15801596
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 > > ,
15841600 ) -> 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-
15971601 let mut message_recipients = self . message_recipients . lock ( ) . unwrap ( ) ;
15981602 if outbound_buffer_full ( & first_node_id, & message_recipients) {
15991603 return Err ( SendError :: BufferFull ) ;
@@ -1713,7 +1717,16 @@ where
17131717 pub fn send_onion_message_using_path < T : OnionMessageContents > (
17141718 & self , path : OnionMessagePath , contents : T , reply_path : Option < BlindedMessagePath > ,
17151719 ) -> 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)
17171730 }
17181731
17191732 pub ( crate ) fn peel_onion_message (
0 commit comments