Skip to content

Commit 989304e

Browse files
authored
Merge pull request #2652 from tnull/2023-10-deref-achannelmanager
2 parents 1f1a8dd + 808e72a commit 989304e

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

lightning-invoice/src/payment.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ use core::time::Duration;
3333
/// with the same [`PaymentHash`] is never sent.
3434
///
3535
/// If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`].
36-
pub fn pay_invoice<C: AChannelManager>(
37-
invoice: &Bolt11Invoice, retry_strategy: Retry, channelmanager: &C
36+
pub fn pay_invoice<C: Deref>(
37+
invoice: &Bolt11Invoice, retry_strategy: Retry, channelmanager: C
3838
) -> Result<PaymentId, PaymentError>
39+
where C::Target: AChannelManager,
3940
{
4041
let payment_id = PaymentId(invoice.payment_hash().into_inner());
4142
pay_invoice_with_id(invoice, payment_id, retry_strategy, channelmanager.get_cm())
@@ -52,9 +53,10 @@ pub fn pay_invoice<C: AChannelManager>(
5253
/// [`PaymentHash`] has never been paid before.
5354
///
5455
/// See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token.
55-
pub fn pay_invoice_with_id<C: AChannelManager>(
56-
invoice: &Bolt11Invoice, payment_id: PaymentId, retry_strategy: Retry, channelmanager: &C
56+
pub fn pay_invoice_with_id<C: Deref>(
57+
invoice: &Bolt11Invoice, payment_id: PaymentId, retry_strategy: Retry, channelmanager: C
5758
) -> Result<(), PaymentError>
59+
where C::Target: AChannelManager,
5860
{
5961
let amt_msat = invoice.amount_milli_satoshis().ok_or(PaymentError::Invoice("amount missing"))?;
6062
pay_invoice_using_amount(invoice, amt_msat, payment_id, retry_strategy, channelmanager.get_cm())
@@ -69,9 +71,10 @@ pub fn pay_invoice_with_id<C: AChannelManager>(
6971
///
7072
/// If you wish to use a different payment idempotency token, see
7173
/// [`pay_zero_value_invoice_with_id`].
72-
pub fn pay_zero_value_invoice<C: AChannelManager>(
73-
invoice: &Bolt11Invoice, amount_msats: u64, retry_strategy: Retry, channelmanager: &C
74+
pub fn pay_zero_value_invoice<C: Deref>(
75+
invoice: &Bolt11Invoice, amount_msats: u64, retry_strategy: Retry, channelmanager: C
7476
) -> Result<PaymentId, PaymentError>
77+
where C::Target: AChannelManager,
7578
{
7679
let payment_id = PaymentId(invoice.payment_hash().into_inner());
7780
pay_zero_value_invoice_with_id(invoice, amount_msats, payment_id, retry_strategy,
@@ -90,10 +93,11 @@ pub fn pay_zero_value_invoice<C: AChannelManager>(
9093
///
9194
/// See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the
9295
/// idempotency token.
93-
pub fn pay_zero_value_invoice_with_id<C: AChannelManager>(
96+
pub fn pay_zero_value_invoice_with_id<C: Deref>(
9497
invoice: &Bolt11Invoice, amount_msats: u64, payment_id: PaymentId, retry_strategy: Retry,
95-
channelmanager: &C
98+
channelmanager: C
9699
) -> Result<(), PaymentError>
100+
where C::Target: AChannelManager,
97101
{
98102
if invoice.amount_milli_satoshis().is_some() {
99103
Err(PaymentError::Invoice("amount unexpected"))
@@ -125,9 +129,10 @@ fn pay_invoice_using_amount<P: Deref>(
125129
/// Sends payment probes over all paths of a route that would be used to pay the given invoice.
126130
///
127131
/// See [`ChannelManager::send_preflight_probes`] for more information.
128-
pub fn preflight_probe_invoice<C: AChannelManager>(
129-
invoice: &Bolt11Invoice, channelmanager: &C, liquidity_limit_multiplier: Option<u64>,
132+
pub fn preflight_probe_invoice<C: Deref>(
133+
invoice: &Bolt11Invoice, channelmanager: C, liquidity_limit_multiplier: Option<u64>,
130134
) -> Result<Vec<(PaymentHash, PaymentId)>, ProbingError>
135+
where C::Target: AChannelManager,
131136
{
132137
let amount_msat = if let Some(invoice_amount_msat) = invoice.amount_milli_satoshis() {
133138
invoice_amount_msat
@@ -156,10 +161,11 @@ pub fn preflight_probe_invoice<C: AChannelManager>(
156161
/// invoice using the given amount.
157162
///
158163
/// See [`ChannelManager::send_preflight_probes`] for more information.
159-
pub fn preflight_probe_zero_value_invoice<C: AChannelManager>(
160-
invoice: &Bolt11Invoice, amount_msat: u64, channelmanager: &C,
164+
pub fn preflight_probe_zero_value_invoice<C: Deref>(
165+
invoice: &Bolt11Invoice, amount_msat: u64, channelmanager: C,
161166
liquidity_limit_multiplier: Option<u64>,
162167
) -> Result<Vec<(PaymentHash, PaymentId)>, ProbingError>
168+
where C::Target: AChannelManager,
163169
{
164170
if invoice.amount_milli_satoshis().is_some() {
165171
return Err(ProbingError::Invoice("amount unexpected"));

0 commit comments

Comments
 (0)