Skip to content

Commit 8d8416b

Browse files
committed
Store the source HumanReadableName in InvoiceRequestFields
When we receive a payment to an offer we issued resolved with a human readable name, it may have been resolved using a wildcard DNS entry which we want to map to a specific recipient account locally. To do this, we need the human readable name from the `InvoiceRequest` in the `PaymentClaim{able,ed}`, which we pipe through here using `InvoiceRequestFields`.
1 parent e447b49 commit 8d8416b

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

fuzz/src/invoice_request_deser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
8989
payer_note_truncated: invoice_request
9090
.payer_note()
9191
.map(|s| UntrustedString(s.to_string())),
92+
human_readable_name: None,
9293
},
9394
});
9495
let payee_tlvs = ReceiveTlvs {

lightning/src/events/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ pub enum PaymentPurpose {
125125
/// The context of the payment such as information about the corresponding [`Offer`] and
126126
/// [`InvoiceRequest`].
127127
///
128+
/// This includes the Human Readable Name which the sender indicated they were paying to,
129+
/// for possible recipient disambiguation if you're using a single wildcard DNS entry to
130+
/// resolve to many recipients.
131+
///
128132
/// [`Offer`]: crate::offers::offer::Offer
129133
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
130134
payment_context: Bolt12OfferContext,

lightning/src/ln/offers_tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
564564
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
565565
quantity: None,
566566
payer_note_truncated: None,
567+
human_readable_name: None,
567568
},
568569
});
569570
assert_eq!(invoice_request.amount_msats(), None);
@@ -724,6 +725,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
724725
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
725726
quantity: None,
726727
payer_note_truncated: None,
728+
human_readable_name: None,
727729
},
728730
});
729731
assert_eq!(invoice_request.amount_msats(), None);
@@ -844,6 +846,7 @@ fn pays_for_offer_without_blinded_paths() {
844846
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
845847
quantity: None,
846848
payer_note_truncated: None,
849+
human_readable_name: None,
847850
},
848851
});
849852

@@ -1111,6 +1114,7 @@ fn creates_and_pays_for_offer_with_retry() {
11111114
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
11121115
quantity: None,
11131116
payer_note_truncated: None,
1117+
human_readable_name: None,
11141118
},
11151119
});
11161120
assert_eq!(invoice_request.amount_msats(), None);
@@ -1175,6 +1179,7 @@ fn pays_bolt12_invoice_asynchronously() {
11751179
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
11761180
quantity: None,
11771181
payer_note_truncated: None,
1182+
human_readable_name: None,
11781183
},
11791184
});
11801185

@@ -1264,6 +1269,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
12641269
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
12651270
quantity: None,
12661271
payer_note_truncated: None,
1272+
human_readable_name: None,
12671273
},
12681274
});
12691275
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);

lightning/src/offers/invoice_request.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ impl VerifiedInvoiceRequest {
10301030
quantity: *quantity,
10311031
payer_note_truncated: payer_note.clone()
10321032
.map(|mut s| { s.truncate(PAYER_NOTE_LIMIT); UntrustedString(s) }),
1033+
human_readable_name: self.offer_from_hrn().clone(),
10331034
}
10341035
}
10351036
}
@@ -1350,6 +1351,9 @@ pub struct InvoiceRequestFields {
13501351
/// A payer-provided note which will be seen by the recipient and reflected back in the invoice
13511352
/// response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
13521353
pub payer_note_truncated: Option<UntrustedString>,
1354+
1355+
/// The Human Readable Name which the sender indicated they were paying to.
1356+
pub human_readable_name: Option<HumanReadableName>,
13531357
}
13541358

13551359
/// The maximum number of characters included in [`InvoiceRequestFields::payer_note_truncated`].
@@ -1359,6 +1363,7 @@ impl Writeable for InvoiceRequestFields {
13591363
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
13601364
write_tlv_fields!(writer, {
13611365
(0, self.payer_signing_pubkey, required),
1366+
(1, self.human_readable_name, option),
13621367
(2, self.quantity.map(|v| HighZeroBytesDroppedBigSize(v)), option),
13631368
(4, self.payer_note_truncated.as_ref().map(|s| WithoutLength(&s.0)), option),
13641369
});
@@ -1370,6 +1375,7 @@ impl Readable for InvoiceRequestFields {
13701375
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
13711376
_init_and_read_len_prefixed_tlv_fields!(reader, {
13721377
(0, payer_signing_pubkey, required),
1378+
(1, human_readable_name, option),
13731379
(2, quantity, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
13741380
(4, payer_note_truncated, (option, encoding: (String, WithoutLength))),
13751381
});
@@ -1378,6 +1384,7 @@ impl Readable for InvoiceRequestFields {
13781384
payer_signing_pubkey: payer_signing_pubkey.0.unwrap(),
13791385
quantity,
13801386
payer_note_truncated: payer_note_truncated.map(|s| UntrustedString(s)),
1387+
human_readable_name,
13811388
})
13821389
}
13831390
}
@@ -2733,6 +2740,7 @@ mod tests {
27332740
payer_signing_pubkey: payer_pubkey(),
27342741
quantity: Some(1),
27352742
payer_note_truncated: Some(UntrustedString("0".repeat(PAYER_NOTE_LIMIT))),
2743+
human_readable_name: None,
27362744
}
27372745
);
27382746

0 commit comments

Comments
 (0)