@@ -418,17 +418,19 @@ impl Responder {
418
418
pub fn respond ( self ) -> ResponseInstruction {
419
419
ResponseInstruction {
420
420
destination : Destination :: BlindedPath ( self . reply_path ) ,
421
- context : None ,
421
+ reply_data : ( None , None ) ,
422
422
}
423
423
}
424
424
425
425
/// Creates a [`ResponseInstruction`] for responding including a reply path.
426
426
///
427
427
/// Use when the recipient needs to send back a reply to us.
428
- pub fn respond_with_reply_path ( self , context : MessageContext ) -> ResponseInstruction {
428
+ pub fn respond_with_reply_path (
429
+ self , context : MessageContext , custom_data : Option < Vec < u8 > > ,
430
+ ) -> ResponseInstruction {
429
431
ResponseInstruction {
430
432
destination : Destination :: BlindedPath ( self . reply_path ) ,
431
- context : Some ( context) ,
433
+ reply_data : ( Some ( context) , custom_data ) ,
432
434
}
433
435
}
434
436
}
@@ -440,7 +442,7 @@ pub struct ResponseInstruction {
440
442
/// [`Destination`] rather than an explicit [`BlindedMessagePath`] simplifies the logic in
441
443
/// [`OnionMessenger::send_onion_message_internal`] somewhat.
442
444
destination : Destination ,
443
- context : Option < MessageContext > ,
445
+ reply_data : ( Option < MessageContext > , Option < Vec < u8 > > ) ,
444
446
}
445
447
446
448
impl ResponseInstruction {
@@ -469,7 +471,7 @@ pub enum MessageSendInstructions {
469
471
destination : Destination ,
470
472
/// The context to include in the reply path we'll give the recipient so they can respond
471
473
/// to us.
472
- context : MessageContext ,
474
+ reply_data : ( MessageContext , Option < Vec < u8 > > ) ,
473
475
} ,
474
476
/// Indicates that a message should be sent without including a reply path, preventing the
475
477
/// recipient from responding.
@@ -886,7 +888,8 @@ pub trait CustomOnionMessageHandler {
886
888
///
887
889
/// The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`].
888
890
fn handle_custom_message (
889
- & self , message : Self :: CustomMessage , context : Option < Vec < u8 > > , responder : Option < Responder > ,
891
+ & self , message : Self :: CustomMessage , context : Option < Vec < u8 > > ,
892
+ custom_data : Option < Vec < u8 > > , responder : Option < Responder > ,
890
893
) -> Option < ( Self :: CustomMessage , ResponseInstruction ) > ;
891
894
892
895
/// Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the
@@ -1332,10 +1335,14 @@ where
1332
1335
MessageSendInstructions :: WithSpecifiedReplyPath { destination, reply_path } => {
1333
1336
( destination, Some ( reply_path) )
1334
1337
} ,
1335
- MessageSendInstructions :: WithReplyPath { destination, context }
1338
+ MessageSendInstructions :: WithReplyPath {
1339
+ destination,
1340
+ reply_data : ( context, custom_data) ,
1341
+ }
1336
1342
| MessageSendInstructions :: ForReply {
1337
- instructions : ResponseInstruction { destination, context : Some ( context) } ,
1338
- } => match self . create_blinded_path ( context) {
1343
+ instructions :
1344
+ ResponseInstruction { destination, reply_data : ( Some ( context) , custom_data) } ,
1345
+ } => match self . create_blinded_path ( context, custom_data) {
1339
1346
Ok ( reply_path) => ( destination, Some ( reply_path) ) ,
1340
1347
Err ( err) => {
1341
1348
log_trace ! (
@@ -1349,7 +1356,7 @@ where
1349
1356
} ,
1350
1357
MessageSendInstructions :: WithoutReplyPath { destination }
1351
1358
| MessageSendInstructions :: ForReply {
1352
- instructions : ResponseInstruction { destination, context : None } ,
1359
+ instructions : ResponseInstruction { destination, reply_data : ( None , _ ) } ,
1353
1360
} => ( destination, None ) ,
1354
1361
} ;
1355
1362
@@ -1407,7 +1414,7 @@ where
1407
1414
}
1408
1415
1409
1416
fn create_blinded_path (
1410
- & self , context : MessageContext ,
1417
+ & self , context : MessageContext , custom_data : Option < Vec < u8 > > ,
1411
1418
) -> Result < BlindedMessagePath , SendError > {
1412
1419
let recipient = self
1413
1420
. node_signer
@@ -1424,7 +1431,7 @@ where
1424
1431
. collect :: < Vec < _ > > ( )
1425
1432
} ;
1426
1433
1427
- let recipient_tlvs = ReceiveTlvs { context : Some ( context) , custom_data : None } ;
1434
+ let recipient_tlvs = ReceiveTlvs { context : Some ( context) , custom_data } ;
1428
1435
1429
1436
self . message_router
1430
1437
. create_blinded_paths ( recipient, recipient_tlvs, peers, secp_ctx)
@@ -1932,8 +1939,12 @@ where
1932
1939
return ;
1933
1940
} ,
1934
1941
} ;
1935
- let response_instructions =
1936
- self . custom_handler . handle_custom_message ( msg, context, responder) ;
1942
+ let response_instructions = self . custom_handler . handle_custom_message (
1943
+ msg,
1944
+ context,
1945
+ custom_data,
1946
+ responder,
1947
+ ) ;
1937
1948
if let Some ( ( msg, instructions) ) = response_instructions {
1938
1949
let _ = self . handle_onion_message_response ( msg, instructions) ;
1939
1950
}
0 commit comments