Skip to content

Commit e147725

Browse files
fixup! blip42: add the possibility to inject conctact secret inside the pay for offer
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
1 parent d001559 commit e147725

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lightning/src/ln/offers_tests.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use crate::blinded_path::payment::{Bolt12OfferContext, Bolt12RefundContext, Paym
5151
use crate::blinded_path::message::OffersContext;
5252
use crate::events::{ClosureReason, Event, HTLCHandlingFailureType, PaidBolt12Invoice, PaymentFailureReason, PaymentPurpose};
5353
use crate::ln::channelmanager::{self, Bolt12PaymentError, OptionalOfferPaymentParams, PaymentId, RecentPaymentDetails, RecipientOnionFields, Retry};
54-
use crate::offers::contacts::ContactSecrets;
54+
use crate::offers::contacts::{compute_contact_secret, ContactSecrets};
5555
use crate::offers::offer::Offer;
5656
use crate::types::features::Bolt12InvoiceFeatures;
5757
use crate::ln::functional_test_utils::*;
@@ -2564,8 +2564,22 @@ fn pay_offer_and_add_contacts_info_blip42() {
25642564
assert_ne!(offer.issuer_signing_pubkey(), Some(alice_id));
25652565
assert!(!offer.paths().is_empty());
25662566

2567+
// Compute Bob's contact secret for BLIP-42 contact management
2568+
// Bob is node 1, so his seed is [1u8; 32]
2569+
let bob_seed = [1u8; 32];
2570+
let secp_ctx = Secp256k1::new();
2571+
let bob_master_key = bitcoin::bip32::Xpriv::new_master(Network::Testnet, &bob_seed).unwrap();
2572+
let bob_private_key = bob_master_key
2573+
.derive_priv(&secp_ctx, &bitcoin::bip32::ChildNumber::Hardened { index: 0 })
2574+
.expect("derivation failed")
2575+
.private_key;
2576+
let bob_contact_secrets = compute_contact_secret(&bob_private_key, &offer);
2577+
25672578
let payment_id = PaymentId([1; 32]);
2568-
bob.node.pay_for_offer(&offer, None, payment_id, Default::default()).unwrap();
2579+
bob.node.pay_for_offer(&offer, None, payment_id, OptionalOfferPaymentParams {
2580+
contact_secrects: Some(bob_contact_secrets),
2581+
..Default::default()
2582+
}).unwrap();
25692583

25702584
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
25712585
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();

0 commit comments

Comments
 (0)