@@ -1694,15 +1694,20 @@ where
1694
1694
/// #
1695
1695
/// # fn example<T: AChannelManager>(channel_manager: T, refund: &Refund) {
1696
1696
/// # let channel_manager = channel_manager.get_cm();
1697
- /// match channel_manager.request_refund_payment(refund) {
1698
- /// Ok(()) => println!("Requesting payment for refund"),
1699
- /// Err(e) => println!("Unable to request payment for refund: {:?}", e),
1700
- /// }
1697
+ /// let known_payment_hash = match channel_manager.request_refund_payment(refund) {
1698
+ /// Ok(invoice) => {
1699
+ /// let payment_hash = invoice.payment_hash();
1700
+ /// println!("Requesting refund payment {}", payment_hash);
1701
+ /// payment_hash
1702
+ /// },
1703
+ /// Err(e) => panic!("Unable to request payment for refund: {:?}", e),
1704
+ /// };
1701
1705
///
1702
1706
/// // On the event processing thread
1703
1707
/// channel_manager.process_pending_events(&|event| match event {
1704
1708
/// Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
1705
1709
/// PaymentPurpose::InvoicePayment { payment_preimage: Some(payment_preimage), .. } => {
1710
+ /// assert_eq!(payment_hash, known_payment_hash);
1706
1711
/// println!("Claiming payment {}", payment_hash);
1707
1712
/// channel_manager.claim_funds(payment_preimage);
1708
1713
/// },
@@ -1713,6 +1718,7 @@ where
1713
1718
/// # _ => {},
1714
1719
/// },
1715
1720
/// Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
1721
+ /// assert_eq!(payment_hash, known_payment_hash);
1716
1722
/// println!("Claimed {} msats", amount_msat);
1717
1723
/// },
1718
1724
/// // ...
@@ -8774,7 +8780,7 @@ where
8774
8780
///
8775
8781
/// The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a
8776
8782
/// [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding
8777
- /// [`PaymentPreimage`].
8783
+ /// [`PaymentPreimage`]. It is returned purely for informational purposes.
8778
8784
///
8779
8785
/// # Limitations
8780
8786
///
@@ -8791,7 +8797,9 @@ where
8791
8797
/// the invoice.
8792
8798
///
8793
8799
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
8794
- pub fn request_refund_payment(&self, refund: &Refund) -> Result<(), Bolt12SemanticError> {
8800
+ pub fn request_refund_payment(
8801
+ &self, refund: &Refund
8802
+ ) -> Result<Bolt12Invoice, Bolt12SemanticError> {
8795
8803
let expanded_key = &self.inbound_payment_key;
8796
8804
let entropy = &*self.entropy_source;
8797
8805
let secp_ctx = &self.secp_ctx;
@@ -8830,7 +8838,7 @@ where
8830
8838
let mut pending_offers_messages = self.pending_offers_messages.lock().unwrap();
8831
8839
if refund.paths().is_empty() {
8832
8840
let message = new_pending_onion_message(
8833
- OffersMessage::Invoice(invoice),
8841
+ OffersMessage::Invoice(invoice.clone() ),
8834
8842
Destination::Node(refund.payer_id()),
8835
8843
Some(reply_path),
8836
8844
);
@@ -8846,7 +8854,7 @@ where
8846
8854
}
8847
8855
}
8848
8856
8849
- Ok(() )
8857
+ Ok(invoice )
8850
8858
},
8851
8859
Err(()) => Err(Bolt12SemanticError::InvalidAmount),
8852
8860
}
0 commit comments