cli/commands/wallet/
mod.rs

1pub mod address;
2pub mod balance;
3pub mod generate;
4pub mod send;
5pub mod status;
6
7use super::Network;
8use crate::exit_with_error;
9
10#[derive(Debug, clap::Args)]
11pub struct Wallet {
12    #[command(subcommand)]
13    pub command: WalletCommand,
14}
15
16#[derive(Debug, clap::Subcommand)]
17pub enum WalletCommand {
18    /// Get the address from an encrypted key file
19    Address(address::Address),
20    /// Get account balance via GraphQL
21    Balance(balance::Balance),
22    /// Generate a new encrypted key pair
23    Generate(generate::Generate),
24    /// Send a payment transaction
25    Send(send::Send),
26    /// Check transaction status
27    Status(status::Status),
28}
29
30impl Wallet {
31    pub fn run(self, network: Network) -> anyhow::Result<()> {
32        let result = match self.command {
33            WalletCommand::Address(cmd) => cmd.run(),
34            WalletCommand::Balance(cmd) => cmd.run(),
35            WalletCommand::Generate(cmd) => cmd.run(),
36            WalletCommand::Send(cmd) => cmd.run(network),
37            WalletCommand::Status(cmd) => cmd.run(),
38        };
39
40        // Handle errors without backtraces for wallet commands
41        if let Err(err) = result {
42            exit_with_error(err);
43        }
44
45        Ok(())
46    }
47}