@@ -59,7 +59,7 @@ use crate::offers::invoice_error::InvoiceError;
59
59
use crate :: offers:: invoice_request:: { InvoiceRequest , InvoiceRequestFields } ;
60
60
use crate :: offers:: nonce:: Nonce ;
61
61
use crate :: offers:: parse:: Bolt12SemanticError ;
62
- use crate :: onion_message:: messenger:: { Destination , PeeledOnion , new_pending_onion_message } ;
62
+ use crate :: onion_message:: messenger:: { Destination , PeeledOnion , MessageSendInstructions } ;
63
63
use crate :: onion_message:: offers:: OffersMessage ;
64
64
use crate :: onion_message:: packet:: ParsedOnionMessageContents ;
65
65
use crate :: routing:: gossip:: { NodeAlias , NodeId } ;
@@ -1313,13 +1313,10 @@ fn fails_authentication_when_handling_invoice_request() {
1313
1313
expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1314
1314
1315
1315
connect_peers ( david, alice) ;
1316
- #[ cfg( not( c_bindings) ) ] {
1317
- david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . destination =
1318
- Destination :: Node ( alice_id) ;
1319
- }
1320
- #[ cfg( c_bindings) ] {
1321
- david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 =
1322
- Destination :: Node ( alice_id) ;
1316
+ match & mut david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 {
1317
+ MessageSendInstructions :: WithSpecifiedReplyPath { destination, .. } =>
1318
+ * destination = Destination :: Node ( alice_id) ,
1319
+ _ => panic ! ( ) ,
1323
1320
}
1324
1321
1325
1322
let onion_message = david. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
@@ -1341,13 +1338,10 @@ fn fails_authentication_when_handling_invoice_request() {
1341
1338
. unwrap ( ) ;
1342
1339
expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1343
1340
1344
- #[ cfg( not( c_bindings) ) ] {
1345
- david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . destination =
1346
- Destination :: BlindedPath ( invalid_path) ;
1347
- }
1348
- #[ cfg( c_bindings) ] {
1349
- david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 =
1350
- Destination :: BlindedPath ( invalid_path) ;
1341
+ match & mut david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 {
1342
+ MessageSendInstructions :: WithSpecifiedReplyPath { destination, .. } =>
1343
+ * destination = Destination :: BlindedPath ( invalid_path) ,
1344
+ _ => panic ! ( ) ,
1351
1345
}
1352
1346
1353
1347
connect_peers ( david, bob) ;
@@ -1427,11 +1421,9 @@ fn fails_authentication_when_handling_invoice_for_offer() {
1427
1421
let mut pending_offers_messages = david. node . pending_offers_messages . lock ( ) . unwrap ( ) ;
1428
1422
let pending_invoice_request = pending_offers_messages. pop ( ) . unwrap ( ) ;
1429
1423
pending_offers_messages. clear ( ) ;
1430
- #[ cfg( not( c_bindings) ) ] {
1431
- pending_invoice_request. reply_path
1432
- }
1433
- #[ cfg( c_bindings) ] {
1434
- pending_invoice_request. 2
1424
+ match pending_invoice_request. 1 {
1425
+ MessageSendInstructions :: WithSpecifiedReplyPath { reply_path, .. } => reply_path,
1426
+ _ => panic ! ( ) ,
1435
1427
}
1436
1428
} ;
1437
1429
@@ -1445,11 +1437,10 @@ fn fails_authentication_when_handling_invoice_for_offer() {
1445
1437
{
1446
1438
let mut pending_offers_messages = david. node . pending_offers_messages . lock ( ) . unwrap ( ) ;
1447
1439
let mut pending_invoice_request = pending_offers_messages. first_mut ( ) . unwrap ( ) ;
1448
- #[ cfg( not( c_bindings) ) ] {
1449
- pending_invoice_request. reply_path = invalid_reply_path;
1450
- }
1451
- #[ cfg( c_bindings) ] {
1452
- pending_invoice_request. 2 = invalid_reply_path;
1440
+ match & mut pending_invoice_request. 1 {
1441
+ MessageSendInstructions :: WithSpecifiedReplyPath { reply_path, .. } =>
1442
+ * reply_path = invalid_reply_path,
1443
+ _ => panic ! ( ) ,
1453
1444
}
1454
1445
}
1455
1446
@@ -1531,13 +1522,10 @@ fn fails_authentication_when_handling_invoice_for_refund() {
1531
1522
let expected_invoice = alice. node . request_refund_payment ( & refund) . unwrap ( ) ;
1532
1523
1533
1524
connect_peers ( david, alice) ;
1534
- #[ cfg( not( c_bindings) ) ] {
1535
- alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . destination =
1536
- Destination :: Node ( david_id) ;
1537
- }
1538
- #[ cfg( c_bindings) ] {
1539
- alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 =
1540
- Destination :: Node ( david_id) ;
1525
+ match & mut alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 {
1526
+ MessageSendInstructions :: WithSpecifiedReplyPath { destination, .. } =>
1527
+ * destination = Destination :: Node ( david_id) ,
1528
+ _ => panic ! ( ) ,
1541
1529
}
1542
1530
1543
1531
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ;
@@ -1565,13 +1553,10 @@ fn fails_authentication_when_handling_invoice_for_refund() {
1565
1553
1566
1554
let expected_invoice = alice. node . request_refund_payment ( & refund) . unwrap ( ) ;
1567
1555
1568
- #[ cfg( not( c_bindings) ) ] {
1569
- alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . destination =
1570
- Destination :: BlindedPath ( invalid_path) ;
1571
- }
1572
- #[ cfg( c_bindings) ] {
1573
- alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 =
1574
- Destination :: BlindedPath ( invalid_path) ;
1556
+ match & mut alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 {
1557
+ MessageSendInstructions :: WithSpecifiedReplyPath { destination, .. } =>
1558
+ * destination = Destination :: BlindedPath ( invalid_path) ,
1559
+ _ => panic ! ( ) ,
1575
1560
}
1576
1561
1577
1562
connect_peers ( alice, charlie) ;
@@ -2155,10 +2140,11 @@ fn fails_paying_invoice_with_unknown_required_features() {
2155
2140
. build_and_sign ( & secp_ctx) . unwrap ( ) ;
2156
2141
2157
2142
// Enqueue an onion message containing the new invoice.
2158
- let pending_message = new_pending_onion_message (
2159
- OffersMessage :: Invoice ( invoice) , Destination :: BlindedPath ( reply_path) , None
2160
- ) ;
2161
- alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . push ( pending_message) ;
2143
+ let instructions = MessageSendInstructions :: WithoutReplyPath {
2144
+ destination : Destination :: BlindedPath ( reply_path) ,
2145
+ } ;
2146
+ let message = OffersMessage :: Invoice ( invoice) ;
2147
+ alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . push ( ( message, instructions) ) ;
2162
2148
2163
2149
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( charlie_id) . unwrap ( ) ;
2164
2150
charlie. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
0 commit comments