Skip to content

Commit 0d7fc1c

Browse files
committed
Pass hrn_resolver into UnifiedPayment and update unified.rs docs
1 parent 6ff4e41 commit 0d7fc1c

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ impl Node {
944944
self.bolt12_payment().into(),
945945
Arc::clone(&self.config),
946946
Arc::clone(&self.logger),
947+
Arc::clone(&self.hrn_resolver),
947948
)
948949
}
949950

@@ -961,6 +962,7 @@ impl Node {
961962
self.bolt12_payment(),
962963
Arc::clone(&self.config),
963964
Arc::clone(&self.logger),
965+
Arc::clone(&self.hrn_resolver),
964966
))
965967
}
966968

src/payment/unified.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
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
1417
use crate::error::Error;
@@ -29,6 +32,12 @@ use bitcoin::{Amount, Txid};
2932
use std::sync::Arc;
3033
use std::vec::IntoIter;
3134

35+
use bitcoin_payment_instructions::{
36+
amount::Amount as BPIAmount, PaymentInstructions, PaymentMethod,
37+
};
38+
39+
use crate::types::HRNResolver;
40+
3241
type Uri<'a> = bip21::Uri<'a, NetworkChecked, Extras>;
3342

3443
#[derive(Debug, Clone)]
@@ -40,26 +49,31 @@ struct Extras {
4049
/// A payment handler allowing to create [BIP 21] URIs with an on-chain, [BOLT 11], and [BOLT 12] payment
4150
/// option.
4251
///
43-
/// Should be retrieved by calling [`Node::unified_qr_payment`]
52+
/// Should be retrieved by calling [`Node::unified_payment`]
53+
///
54+
/// This handler allows you to send payments to these URIs as well as [BIP 353] HRNs.
4455
///
4556
/// [BIP 21]: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
57+
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
4658
/// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
4759
/// [BOLT 12]: https://github.com/lightning/bolts/blob/master/12-offer-encoding.md
48-
/// [`Node::unified_qr_payment`]: crate::Node::unified_qr_payment
60+
/// [`Node::unified_payment`]: crate::Node::unified_payment
4961
pub struct UnifiedPayment {
5062
onchain_payment: Arc<OnchainPayment>,
5163
bolt11_invoice: Arc<Bolt11Payment>,
5264
bolt12_payment: Arc<Bolt12Payment>,
5365
config: Arc<Config>,
5466
logger: Arc<Logger>,
67+
hrn_resolver: Arc<HRNResolver>,
5568
}
5669

5770
impl UnifiedPayment {
5871
pub(crate) fn new(
5972
onchain_payment: Arc<OnchainPayment>, bolt11_invoice: Arc<Bolt11Payment>,
6073
bolt12_payment: Arc<Bolt12Payment>, config: Arc<Config>, logger: Arc<Logger>,
74+
hrn_resolver: Arc<HRNResolver>,
6175
) -> Self {
62-
Self { onchain_payment, bolt11_invoice, bolt12_payment, config, logger }
76+
Self { onchain_payment, bolt11_invoice, bolt12_payment, config, logger, hrn_resolver }
6377
}
6478

6579
/// Generates a URI with an on-chain address, [BOLT 11] invoice and [BOLT 12] offer.

0 commit comments

Comments
 (0)