@@ -15,7 +15,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
1515
1616use lightning:: blinded_path:: message:: BlindedMessagePath ;
1717use lightning:: ln:: channelmanager:: { OptionalOfferPaymentParams , PaymentId , Retry } ;
18- use lightning:: offers:: offer:: { Amount , Offer as LdkOffer , Quantity } ;
18+ use lightning:: offers:: offer:: { Amount , Offer as LdkOffer , OfferFromHrn , Quantity } ;
1919use lightning:: offers:: parse:: Bolt12SemanticError ;
2020use lightning:: routing:: router:: RouteParametersConfig ;
2121#[ cfg( feature = "uniffi" ) ]
@@ -45,6 +45,11 @@ type Refund = lightning::offers::refund::Refund;
4545#[ cfg( feature = "uniffi" ) ]
4646type Refund = Arc < crate :: ffi:: Refund > ;
4747
48+ #[ cfg( not( feature = "uniffi" ) ) ]
49+ type HumanReadableName = lightning:: onion_message:: dns_resolution:: HumanReadableName ;
50+ #[ cfg( feature = "uniffi" ) ]
51+ type HumanReadableName = Arc < crate :: ffi:: HumanReadableName > ;
52+
4853/// A payment handler allowing to create and pay [BOLT 12] offers and refunds.
4954///
5055/// Should be retrieved by calling [`Node::bolt12_payment`].
@@ -192,7 +197,7 @@ impl Bolt12Payment {
192197 /// node-wide parameters configured via [`Config::route_parameters`] on a per-field basis.
193198 pub fn send_using_amount (
194199 & self , offer : & Offer , amount_msat : u64 , quantity : Option < u64 > , payer_note : Option < String > ,
195- route_parameters : Option < RouteParametersConfig > ,
200+ route_parameters : Option < RouteParametersConfig > , hrn : Option < HumanReadableName > ,
196201 ) -> Result < PaymentId , Error > {
197202 if !* self . is_running . read ( ) . unwrap ( ) {
198203 return Err ( Error :: NotRunning ) ;
@@ -228,7 +233,11 @@ impl Bolt12Payment {
228233 retry_strategy,
229234 route_params_config : route_parameters,
230235 } ;
231- let res = if let Some ( quantity) = quantity {
236+ let res = if let Some ( hrn) = hrn {
237+ let hrn = maybe_deref ( & hrn) ;
238+ let offer = OfferFromHrn { offer : offer. clone ( ) , hrn : * hrn } ;
239+ self . channel_manager . pay_for_offer_from_hrn ( & offer, amount_msat, payment_id, params)
240+ } else if let Some ( quantity) = quantity {
232241 self . channel_manager . pay_for_offer_with_quantity (
233242 & offer,
234243 Some ( amount_msat) ,
0 commit comments