Skip to content

Commit d50d1b1

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 88e9a52 commit d50d1b1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lightning/src/offers/invoice_request.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ macro_rules! invoice_request_builder_methods { (
264264
///
265265
/// [`ContactSecrets`]: crate::offers::contacts::ContactSecrets
266266
pub fn contact_secrets($($self_mut)* $self: $self_type, contact_secrets: crate::offers::contacts::ContactSecrets) -> $return_type {
267-
$self.invoice_request.invreq_contact_secret = Some(contact_secrets.primary_secret().to_vec());
267+
$self.invoice_request.invreq_contact_secret = Some(*contact_secrets.primary_secret());
268268
$return_value
269269
}
270270

@@ -714,7 +714,7 @@ pub(super) struct InvoiceRequestContentsWithoutPayerSigningPubkey {
714714
quantity: Option<u64>,
715715
payer_note: Option<String>,
716716
offer_from_hrn: Option<HumanReadableName>,
717-
invreq_contact_secret: Option<Vec<u8>>,
717+
invreq_contact_secret: Option<[u8; 32]>,
718718
invreq_payer_offer: Option<Vec<u8>>,
719719
#[cfg(test)]
720720
experimental_bar: Option<u64>,
@@ -779,7 +779,7 @@ macro_rules! invoice_request_accessors { ($self: ident, $contents: expr) => {
779779
}
780780

781781
/// Returns the contact secret if present in the invoice request.
782-
pub fn contact_secret(&$self) -> Option<&[u8]> {
782+
pub fn contact_secret(&$self) -> Option<[u8; 32]> {
783783
$contents.contact_secret()
784784
}
785785

@@ -1095,7 +1095,7 @@ macro_rules! fields_accessor {
10951095
} = &$inner;
10961096

10971097
// Extract BLIP-42 contact information if present
1098-
let contact_secret = $self.contact_secret().and_then(|bytes| bytes.try_into().ok());
1098+
let contact_secret = $self.contact_secret();
10991099
let payer_offer = $self
11001100
.payer_offer()
11011101
.and_then(|bytes| crate::offers::offer::Offer::try_from(bytes.to_vec()).ok());
@@ -1227,8 +1227,8 @@ impl InvoiceRequestContents {
12271227
&self.inner.offer_from_hrn
12281228
}
12291229

1230-
pub(super) fn contact_secret(&self) -> Option<&[u8]> {
1231-
self.inner.invreq_contact_secret.as_ref().map(|secret| secret.as_slice())
1230+
pub(super) fn contact_secret(&self) -> Option<[u8; 32]> {
1231+
self.inner.invreq_contact_secret
12321232
}
12331233

12341234
pub(super) fn payer_offer(&self) -> Option<&[u8]> {

0 commit comments

Comments
 (0)