55// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66// accordance with one or both of these licenses.
77
8- //! Holds a payment handler allowing to create [BIP 21] URIs with an on-chain, [BOLT 11], and [BOLT 12] payment
8+ //! Holds a payment handler allowing to create [BIP 21] URIs with on-chain, [BOLT 11], and [BOLT 12] payment
99//! options.
1010//!
11+ //! Also allows to send payments using these URIs as well as [BIP 353] HRNs.
12+ //!
1113//! [BIP 21]: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
14+ //! [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
1215//! [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
1316//! [BOLT 12]: https://github.com/lightning/bolts/blob/master/12-offer-encoding.md
17+ use crate :: error:: Error ;
18+ use crate :: ffi:: maybe_wrap;
19+ use crate :: logger:: { log_error, LdkLogger , Logger } ;
20+ use crate :: payment:: { Bolt11Payment , Bolt12Payment , OnchainPayment } ;
21+ use crate :: types:: HRNResolver ;
22+ use crate :: Config ;
1423use std:: sync:: Arc ;
1524use std:: vec:: IntoIter ;
1625
17- use bip21:: de:: ParamKind ;
18- use bip21:: { DeserializationError , DeserializeParams , Param , SerializeParams } ;
19- use bitcoin:: address:: { NetworkChecked , NetworkUnchecked } ;
20- use bitcoin:: { Amount , Txid } ;
2126use lightning:: ln:: channelmanager:: PaymentId ;
2227use lightning:: offers:: offer:: Offer ;
2328use lightning_invoice:: { Bolt11Invoice , Bolt11InvoiceDescription , Description } ;
2429
25- use crate :: error:: Error ;
26- use crate :: ffi:: maybe_wrap;
27- use crate :: logger:: { log_error, LdkLogger , Logger } ;
28- use crate :: payment:: { Bolt11Payment , Bolt12Payment , OnchainPayment } ;
29- use crate :: Config ;
30+ use bip21:: de:: ParamKind ;
31+ use bip21:: { DeserializationError , DeserializeParams , Param , SerializeParams } ;
32+ use bitcoin:: address:: { NetworkChecked , NetworkUnchecked } ;
33+ use bitcoin:: { Amount , Txid } ;
3034
3135type Uri < ' a > = bip21:: Uri < ' a , NetworkChecked , Extras > ;
3236
@@ -39,26 +43,31 @@ struct Extras {
3943/// A payment handler allowing to create [BIP 21] URIs with an on-chain, [BOLT 11], and [BOLT 12] payment
4044/// option.
4145///
42- /// Should be retrieved by calling [`Node::unified_qr_payment`]
46+ /// Should be retrieved by calling [`Node::unified_payment`]
47+ ///
48+ /// This handler allows you to send payments to these URIs as well as [BIP 353] HRNs.
4349///
4450/// [BIP 21]: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
51+ /// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
4552/// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
4653/// [BOLT 12]: https://github.com/lightning/bolts/blob/master/12-offer-encoding.md
47- /// [`Node::unified_qr_payment `]: crate::Node::unified_qr_payment
54+ /// [`Node::unified_payment `]: crate::Node::unified_payment
4855pub struct UnifiedPayment {
4956 onchain_payment : Arc < OnchainPayment > ,
5057 bolt11_invoice : Arc < Bolt11Payment > ,
5158 bolt12_payment : Arc < Bolt12Payment > ,
5259 config : Arc < Config > ,
5360 logger : Arc < Logger > ,
61+ hrn_resolver : Arc < HRNResolver > ,
5462}
5563
5664impl UnifiedPayment {
5765 pub ( crate ) fn new (
5866 onchain_payment : Arc < OnchainPayment > , bolt11_invoice : Arc < Bolt11Payment > ,
5967 bolt12_payment : Arc < Bolt12Payment > , config : Arc < Config > , logger : Arc < Logger > ,
68+ hrn_resolver : Arc < HRNResolver > ,
6069 ) -> Self {
61- Self { onchain_payment, bolt11_invoice, bolt12_payment, config, logger }
70+ Self { onchain_payment, bolt11_invoice, bolt12_payment, config, logger, hrn_resolver }
6271 }
6372
6473 /// Generates a URI with an on-chain address, [BOLT 11] invoice and [BOLT 12] offer.
@@ -142,6 +151,8 @@ impl UnifiedPayment {
142151 let uri: bip21:: Uri < NetworkUnchecked , Extras > =
143152 uri_str. parse ( ) . map_err ( |_| Error :: InvalidUri ) ?;
144153
154+ let _resolver = & self . hrn_resolver ;
155+
145156 let uri_network_checked =
146157 uri. clone ( ) . require_network ( self . config . network ) . map_err ( |_| Error :: InvalidNetwork ) ?;
147158
0 commit comments