|
35 | 35 | //! # #[cfg(feature = "no-std")] |
36 | 36 | //! # extern crate core2; |
37 | 37 | //! # |
38 | | -//! # use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; |
| 38 | +//! # use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret, RecipientInfo}; |
39 | 39 | //! # use lightning::ln::channelmanager::{ChannelDetails, PaymentId, PaymentSendFailure}; |
40 | 40 | //! # use lightning::ln::msgs::LightningError; |
41 | 41 | //! # use lightning::routing::scoring::Score; |
|
64 | 64 | //! # impl Payer for FakePayer { |
65 | 65 | //! # fn node_id(&self) -> PublicKey { unimplemented!() } |
66 | 66 | //! # fn first_hops(&self) -> Vec<ChannelDetails> { unimplemented!() } |
67 | | -//! # fn send_payment(&self, route: &Route, payment_hash: PaymentHash, |
68 | | -//! # payment_secret: &Option<PaymentSecret>, payment_metadata: Option<Vec<u8>> |
| 67 | +//! # fn send_payment(&self, route: &Route, payment_hash: PaymentHash, recipient_info: &RecipientInfo |
69 | 68 | //! # ) -> Result<PaymentId, PaymentSendFailure> { unimplemented!() } |
70 | 69 | //! # fn send_spontaneous_payment( |
71 | 70 | //! # &self, route: &Route, payment_preimage: PaymentPreimage |
@@ -139,7 +138,7 @@ use bitcoin_hashes::Hash; |
139 | 138 | use bitcoin_hashes::sha256::Hash as Sha256; |
140 | 139 |
|
141 | 140 | use crate::prelude::*; |
142 | | -use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; |
| 141 | +use lightning::ln::{PaymentHash, PaymentPreimage, RecipientInfo}; |
143 | 142 | use lightning::ln::channelmanager::{ChannelDetails, PaymentId, PaymentSendFailure}; |
144 | 143 | use lightning::ln::msgs::LightningError; |
145 | 144 | use lightning::routing::scoring::{LockableScore, Score}; |
@@ -186,8 +185,8 @@ pub trait Payer { |
186 | 185 | fn first_hops(&self) -> Vec<ChannelDetails>; |
187 | 186 |
|
188 | 187 | /// Sends a payment over the Lightning Network using the given [`Route`]. |
189 | | - fn send_payment(&self, route: &Route, payment_hash: PaymentHash, |
190 | | - payment_secret: &Option<PaymentSecret>, payment_metadata: Option<Vec<u8>> |
| 188 | + fn send_payment( |
| 189 | + &self, route: &Route, payment_hash: PaymentHash, recipient_info: &RecipientInfo |
191 | 190 | ) -> Result<PaymentId, PaymentSendFailure>; |
192 | 191 |
|
193 | 192 | /// Sends a spontaneous payment over the Lightning Network using the given [`Route`]. |
@@ -309,7 +308,8 @@ where |
309 | 308 | }; |
310 | 309 |
|
311 | 310 | let send_payment = |route: &Route| { |
312 | | - self.payer.send_payment(route, payment_hash, &payment_secret, invoice.payment_metadata().cloned()) |
| 311 | + let recipient_info = RecipientInfo { payment_secret, payment_metadata: invoice.payment_metadata().cloned() }; |
| 312 | + self.payer.send_payment(route, payment_hash, &recipient_info) |
313 | 313 | }; |
314 | 314 | self.pay_internal(&route_params, payment_hash, send_payment) |
315 | 315 | .map_err(|e| { self.payment_cache.lock().unwrap().remove(&payment_hash); e }) |
@@ -528,7 +528,7 @@ mod tests { |
528 | 528 | use crate::{InvoiceBuilder, Currency}; |
529 | 529 | use utils::create_invoice_from_channelmanager_and_duration_since_epoch; |
530 | 530 | use bitcoin_hashes::sha256::Hash as Sha256; |
531 | | - use lightning::ln::PaymentPreimage; |
| 531 | + use lightning::ln::{PaymentPreimage, PaymentSecret}; |
532 | 532 | use lightning::ln::features::{ChannelFeatures, NodeFeatures, InitFeatures}; |
533 | 533 | use lightning::ln::functional_test_utils::*; |
534 | 534 | use lightning::ln::msgs::{ChannelMessageHandler, ErrorAction, LightningError}; |
@@ -1463,8 +1463,8 @@ mod tests { |
1463 | 1463 | Vec::new() |
1464 | 1464 | } |
1465 | 1465 |
|
1466 | | - fn send_payment(&self, route: &Route, _payment_hash: PaymentHash, |
1467 | | - _payment_secret: &Option<PaymentSecret>, _payment_metadata: Option<Vec<u8>> |
| 1466 | + fn send_payment( |
| 1467 | + &self, route: &Route, _payment_hash: PaymentHash, _recipient_info: &RecipientInfo |
1468 | 1468 | ) -> Result<PaymentId, PaymentSendFailure> { |
1469 | 1469 | self.check_value_msats(Amount::ForInvoice(route.get_total_amount())); |
1470 | 1470 | self.check_attempts() |
|
0 commit comments