]> git.bitcoin.ninja Git - ldk-sample/commitdiff
Expose the fee paid on a payment in stdout
authorMatt Corallo <git@bluematt.me>
Sun, 19 Dec 2021 21:20:11 +0000 (21:20 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 19 Dec 2021 21:27:36 +0000 (21:27 +0000)
src/main.rs

index 343c2d5356f3457c8f9372b1f54718a5ae8ea38e..71b2cdc7c38e3cf63ca51aeb071de1e09c9e5fe7 100644 (file)
@@ -195,16 +195,21 @@ async fn handle_ldk_events(
                                }
                        }
                }
-               Event::PaymentSent { payment_preimage, payment_hash, .. } => {
+               Event::PaymentSent { payment_preimage, payment_hash, fee_paid_msat, .. } => {
                        let mut payments = outbound_payments.lock().unwrap();
                        for (hash, payment) in payments.iter_mut() {
                                if *hash == *payment_hash {
                                        payment.preimage = Some(*payment_preimage);
                                        payment.status = HTLCStatus::Succeeded;
                                        println!(
-                                               "\nEVENT: successfully sent payment of {} millisatoshis from \
+                                               "\nEVENT: successfully sent payment of {} millisatoshis{} from \
                                                                 payment hash {:?} with preimage {:?}",
                                                payment.amt_msat,
+                                               if let Some(fee) = fee_paid_msat {
+                                                       format!(" (fee {} msat)", fee)
+                                               } else {
+                                                       "".to_string()
+                                               },
                                                hex_utils::hex_str(&payment_hash.0),
                                                hex_utils::hex_str(&payment_preimage.0)
                                        );