Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: show payment duration #1113

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tools/sdk-cli/src/command_handlers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fs;
use std::sync::Arc;
use std::time::SystemTime;

use anyhow::{anyhow, Context, Error, Result};
use breez_sdk_core::InputType::{LnUrlAuth, LnUrlPay, LnUrlWithdraw};
Expand Down Expand Up @@ -247,6 +248,7 @@ pub(crate) async fn handle_command(
label,
use_trampoline,
} => {
let start = SystemTime::now();
let payment = sdk()?
.send_payment(SendPaymentRequest {
bolt11,
Expand All @@ -255,13 +257,17 @@ pub(crate) async fn handle_command(
use_trampoline,
})
.await?;
let end = SystemTime::now();
let diff = end.duration_since(start)?;
println!("payment took {}s", diff.as_secs_f32());
serde_json::to_string_pretty(&payment).map_err(|e| e.into())
}
Commands::SendSpontaneousPayment {
node_id,
amount_msat,
label,
} => {
let start = SystemTime::now();
let response = sdk()?
.send_spontaneous_payment(SendSpontaneousPaymentRequest {
node_id,
Expand All @@ -270,6 +276,9 @@ pub(crate) async fn handle_command(
label,
})
.await?;
let end = SystemTime::now();
let diff = end.duration_since(start)?;
println!("payment took {}s", diff.as_secs_f32());
serde_json::to_string_pretty(&response.payment).map_err(|e| e.into())
}
Commands::ListPayments {
Expand Down Expand Up @@ -481,6 +490,7 @@ pub(crate) async fn handle_command(
);

let amount_msat = rl.readline(&prompt)?;
let start = SystemTime::now();
let pay_res = sdk()?
.lnurl_pay(LnUrlPayRequest {
data: pd,
Expand All @@ -491,6 +501,9 @@ pub(crate) async fn handle_command(
validate_success_action_url: validate_success_url,
})
.await?;
let end = SystemTime::now();
let diff = end.duration_since(start)?;
println!("payment took {}s", diff.as_secs_f32());
//show_results(pay_res);
serde_json::to_string_pretty(&pay_res).map_err(|e| e.into())
}
Expand Down
Loading