]> git.bitcoin.ninja Git - rust-lightning/blobdiff - lightning-invoice/src/utils.rs
Support spontaneous payments in InvoicePayer
[rust-lightning] / lightning-invoice / src / utils.rs
index 35a74b6a5ac6a3bf6a41984babc8619551a19622..641a09ad7463b22066565928b6e2880e71d798db 100644 (file)
@@ -8,7 +8,7 @@ use bitcoin_hashes::Hash;
 use lightning::chain;
 use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
 use lightning::chain::keysinterface::{Sign, KeysInterface};
-use lightning::ln::{PaymentHash, PaymentSecret};
+use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
 use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, PaymentSendFailure, MIN_FINAL_CLTV_EXPIRY};
 use lightning::ln::msgs::LightningError;
 use lightning::routing;
@@ -141,6 +141,13 @@ where
                self.send_payment(route, payment_hash, payment_secret)
        }
 
+       fn send_spontaneous_payment(
+               &self, route: &Route, payment_preimage: PaymentPreimage,
+       ) -> Result<PaymentId, PaymentSendFailure> {
+               self.send_spontaneous_payment(route, Some(payment_preimage))
+                       .map(|(_, payment_id)| payment_id)
+       }
+
        fn retry_payment(
                &self, route: &Route, payment_id: PaymentId
        ) -> Result<(), PaymentSendFailure> {