]> git.bitcoin.ninja Git - ldk-sample/commitdiff
Avoid using `hex_str` for payment hashes which now impl Display
authorMatt Corallo <git@bluematt.me>
Mon, 18 Sep 2023 05:33:26 +0000 (05:33 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 15 Oct 2023 17:14:03 +0000 (17:14 +0000)
src/cli.rs
src/main.rs

index 121aa98554b1126944509f8c7f5945af9b4dc3e7..9cb0f174fa70b3be67d13c4438e2bc011554dcb4 100644 (file)
@@ -559,7 +559,7 @@ fn list_payments(inbound_payments: &PaymentInfoStorage, outbound_payments: &Paym
                println!("");
                println!("\t{{");
                println!("\t\tamount_millisatoshis: {},", payment_info.amt_msat);
-               println!("\t\tpayment_hash: {},", hex_utils::hex_str(&payment_hash.0));
+               println!("\t\tpayment_hash: {},", payment_hash);
                println!("\t\thtlc_direction: inbound,");
                println!(
                        "\t\thtlc_status: {},",
@@ -577,7 +577,7 @@ fn list_payments(inbound_payments: &PaymentInfoStorage, outbound_payments: &Paym
                println!("");
                println!("\t{{");
                println!("\t\tamount_millisatoshis: {},", payment_info.amt_msat);
-               println!("\t\tpayment_hash: {},", hex_utils::hex_str(&payment_hash.0));
+               println!("\t\tpayment_hash: {},", payment_hash);
                println!("\t\thtlc_direction: outbound,");
                println!(
                        "\t\thtlc_status: {},",
index 69f0981ca4091403f827f5861258166a2087c5ce..ffe0e69c4595c3d4067ef6336df2d8669da5e3a4 100644 (file)
@@ -218,8 +218,7 @@ async fn handle_ldk_events(
                } => {
                        println!(
                                "\nEVENT: received payment from payment hash {} of {} millisatoshis",
-                               hex_utils::hex_str(&payment_hash.0),
-                               amount_msat,
+                               payment_hash, amount_msat,
                        );
                        print!("> ");
                        io::stdout().flush().unwrap();
@@ -239,8 +238,7 @@ async fn handle_ldk_events(
                } => {
                        println!(
                                "\nEVENT: claimed payment from payment hash {} of {} millisatoshis",
-                               hex_utils::hex_str(&payment_hash.0),
-                               amount_msat,
+                               payment_hash, amount_msat,
                        );
                        print!("> ");
                        io::stdout().flush().unwrap();
@@ -277,15 +275,15 @@ async fn handle_ldk_events(
                                        payment.status = HTLCStatus::Succeeded;
                                        println!(
                                                "\nEVENT: successfully sent payment of {} millisatoshis{} from \
-                                                                payment hash {:?} with preimage {:?}",
+                                                                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)
+                                               payment_hash,
+                                               payment_preimage
                                        );
                                        print!("> ");
                                        io::stdout().flush().unwrap();
@@ -328,8 +326,8 @@ async fn handle_ldk_events(
                Event::ProbeFailed { .. } => {}
                Event::PaymentFailed { payment_hash, reason, .. } => {
                        print!(
-                               "\nEVENT: Failed to send payment to payment hash {:?}: {:?}",
-                               hex_utils::hex_str(&payment_hash.0),
+                               "\nEVENT: Failed to send payment to payment hash {}: {:?}",
+                               payment_hash,
                                if let Some(r) = reason { r } else { PaymentFailureReason::RetriesExhausted }
                        );
                        print!("> ");