|
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};
|
@@ -185,9 +184,13 @@ pub trait Payer {
|
185 | 184 | /// Returns the payer's channels.
|
186 | 185 | fn first_hops(&self) -> Vec<ChannelDetails>;
|
187 | 186 |
|
| 187 | +// /// Sends a payment over the Lightning Network using the given [`Route`]. |
| 188 | +// fn send_payment(&self, route: &Route, payment_hash: PaymentHash, |
| 189 | +// payment_secret: &Option<PaymentSecret>, payment_metadata: Option<Vec<u8>> |
| 190 | +// ) -> Result<PaymentId, PaymentSendFailure>; |
| 191 | + |
188 | 192 | /// 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>> |
| 193 | + fn send_payment(&self, route: &Route, payment_hash: PaymentHash, recipient_info: &RecipientInfo |
191 | 194 | ) -> Result<PaymentId, PaymentSendFailure>;
|
192 | 195 |
|
193 | 196 | /// Sends a spontaneous payment over the Lightning Network using the given [`Route`].
|
@@ -309,7 +312,8 @@ where
|
309 | 312 | };
|
310 | 313 |
|
311 | 314 | let send_payment = |route: &Route| {
|
312 |
| - self.payer.send_payment(route, payment_hash, &payment_secret, invoice.payment_metadata().cloned()) |
| 315 | + let recipient_info = RecipientInfo { payment_secret, payment_metadata: invoice.payment_metadata().cloned() }; |
| 316 | + self.payer.send_payment(route, payment_hash, &recipient_info) |
313 | 317 | };
|
314 | 318 | self.pay_internal(&route_params, payment_hash, send_payment)
|
315 | 319 | .map_err(|e| { self.payment_cache.lock().unwrap().remove(&payment_hash); e })
|
@@ -528,7 +532,7 @@ mod tests {
|
528 | 532 | use crate::{InvoiceBuilder, Currency};
|
529 | 533 | use utils::create_invoice_from_channelmanager_and_duration_since_epoch;
|
530 | 534 | use bitcoin_hashes::sha256::Hash as Sha256;
|
531 |
| - use lightning::ln::PaymentPreimage; |
| 535 | + use lightning::ln::{PaymentPreimage, PaymentSecret}; |
532 | 536 | use lightning::ln::features::{ChannelFeatures, NodeFeatures, InitFeatures};
|
533 | 537 | use lightning::ln::functional_test_utils::*;
|
534 | 538 | use lightning::ln::msgs::{ChannelMessageHandler, ErrorAction, LightningError};
|
@@ -1464,7 +1468,7 @@ mod tests {
|
1464 | 1468 | }
|
1465 | 1469 |
|
1466 | 1470 | fn send_payment(&self, route: &Route, _payment_hash: PaymentHash,
|
1467 |
| - _payment_secret: &Option<PaymentSecret>, _payment_metadata: Option<Vec<u8>> |
| 1471 | + _recipient_info: &RecipientInfo |
1468 | 1472 | ) -> Result<PaymentId, PaymentSendFailure> {
|
1469 | 1473 | self.check_value_msats(Amount::ForInvoice(route.get_total_amount()));
|
1470 | 1474 | self.check_attempts()
|
|
0 commit comments