Skip to content

Commit

Permalink
backport: fix(cli) don't expect a txid from the faucet api (#482) (#483)
Browse files Browse the repository at this point in the history
fix(cli) don't expect a txid from the faucet api (#482)

* fix(cli) don't expect a txid from the faucet api

* chore: clippy

* chore(cli) update messaging

Co-authored-by: azz <[email protected]>
  • Loading branch information
storopoli and Zk2u authored Nov 20, 2024
1 parent 9c45b61 commit 70d8beb
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions bin/strata-cli/src/cmd/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use std::str::FromStr;
#[cfg(feature = "strata_faucet")]
use alloy::{primitives::Address as StrataAddress, providers::WalletProvider};
use argh::FromArgs;
use bdk_wallet::{
bitcoin::{Address, Txid},
KeychainKind,
};
use bdk_wallet::{bitcoin::Address, KeychainKind};
use console::Term;
use indicatif::ProgressBar;
use rand::{distributions::uniform::SampleRange, rngs::OsRng};
Expand All @@ -20,11 +17,7 @@ use crate::{
net_type::{net_type_or_exit, NetworkType},
strata::StrataWallet,
};
use crate::{
seed::Seed,
settings::Settings,
signet::{print_bitcoin_explorer_url, SignetWallet},
};
use crate::{seed::Seed, settings::Settings, signet::SignetWallet};

/// Request some bitcoin from the faucet
#[derive(FromArgs, PartialEq, Debug)]
Expand Down Expand Up @@ -168,21 +161,9 @@ pub async fn faucet(args: FaucetArgs, seed: Seed, settings: Settings) {
let status = res.status();
let body = res.text().await.expect("invalid response");
if status == StatusCode::OK {
#[cfg(feature = "strata_faucet")]
if network_type == NetworkType::Signet {
let _ = print_bitcoin_explorer_url(
&Txid::from_str(&body).expect("valid txid"),
&term,
&settings,
);
}
#[cfg(not(feature = "strata_faucet"))]
let _ = print_bitcoin_explorer_url(
&Txid::from_str(&body).expect("valid txid"),
&term,
&settings,
let _ = term.write_line(
"Successful queued request for signet bitcoin. It should arrive in your wallet soon.",
);
let _ = term.write_line(&format!("Successful. Claimed in transaction {body}"));
} else {
let _ = term.write_line(&format!("Failed: faucet responded with {status}: {body}"));
}
Expand Down

0 comments on commit 70d8beb

Please sign in to comment.