Skip to content

Commit ed7e617

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 5b29a11 commit ed7e617

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

lightning/src/events/mod.rs

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

@@ -1110,6 +1113,7 @@ fn creates_and_pays_for_offer_with_retry() {
11101113
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
11111114
quantity: None,
11121115
payer_note_truncated: None,
1116+
human_readable_name: None,
11131117
},
11141118
});
11151119
assert_eq!(invoice_request.amount_msats(), None);
@@ -1174,6 +1178,7 @@ fn pays_bolt12_invoice_asynchronously() {
11741178
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
11751179
quantity: None,
11761180
payer_note_truncated: None,
1181+
human_readable_name: None,
11771182
},
11781183
});
11791184

@@ -1263,6 +1268,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
12631268
payer_signing_pubkey: invoice_request.payer_signing_pubkey(),
12641269
quantity: None,
12651270
payer_note_truncated: None,
1271+
human_readable_name: None,
12661272
},
12671273
});
12681274
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
@@ -966,6 +966,7 @@ impl VerifiedInvoiceRequest {
966966
quantity: *quantity,
967967
payer_note_truncated: payer_note.clone()
968968
.map(|mut s| { s.truncate(PAYER_NOTE_LIMIT); UntrustedString(s) }),
969+
human_readable_name: self.source_human_readable_name().clone(),
969970
}
970971
}
971972
}
@@ -1233,6 +1234,9 @@ pub struct InvoiceRequestFields {
12331234
/// A payer-provided note which will be seen by the recipient and reflected back in the invoice
12341235
/// response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
12351236
pub payer_note_truncated: Option<UntrustedString>,
1237+
1238+
/// The Human Readable Name which the sender indicated they were paying to.
1239+
pub human_readable_name: Option<HumanReadableName>,
12361240
}
12371241

12381242
/// The maximum number of characters included in [`InvoiceRequestFields::payer_note_truncated`].
@@ -1242,6 +1246,7 @@ impl Writeable for InvoiceRequestFields {
12421246
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
12431247
write_tlv_fields!(writer, {
12441248
(0, self.payer_signing_pubkey, required),
1249+
(1, self.human_readable_name, option),
12451250
(2, self.quantity.map(|v| HighZeroBytesDroppedBigSize(v)), option),
12461251
(4, self.payer_note_truncated.as_ref().map(|s| WithoutLength(&s.0)), option),
12471252
});
@@ -1253,6 +1258,7 @@ impl Readable for InvoiceRequestFields {
12531258
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
12541259
_init_and_read_len_prefixed_tlv_fields!(reader, {
12551260
(0, payer_signing_pubkey, required),
1261+
(1, human_readable_name, option),
12561262
(2, quantity, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
12571263
(4, payer_note_truncated, (option, encoding: (String, WithoutLength))),
12581264
});
@@ -1261,6 +1267,7 @@ impl Readable for InvoiceRequestFields {
12611267
payer_signing_pubkey: payer_signing_pubkey.0.unwrap(),
12621268
quantity,
12631269
payer_note_truncated: payer_note_truncated.map(|s| UntrustedString(s)),
1270+
human_readable_name,
12641271
})
12651272
}
12661273
}
@@ -2378,6 +2385,7 @@ mod tests {
23782385
payer_signing_pubkey: payer_pubkey(),
23792386
quantity: Some(1),
23802387
payer_note_truncated: Some(UntrustedString("0".repeat(PAYER_NOTE_LIMIT))),
2388+
human_readable_name: None,
23812389
}
23822390
);
23832391

0 commit comments

Comments
 (0)