Skip to main content

soroban_cli/commands/tx/new/
create_account.rs

1use clap::Parser;
2
3use crate::{commands::tx, config::address, tx::builder, xdr};
4
5#[derive(Parser, Debug, Clone)]
6#[group(skip)]
7pub struct Cmd {
8    #[command(flatten)]
9    pub tx: tx::Args,
10    #[clap(flatten)]
11    pub op: Args,
12}
13
14#[derive(Debug, clap::Args, Clone)]
15pub struct Args {
16    /// Account Id to create, e.g. `GBX...`
17    #[arg(long)]
18    pub destination: address::UnresolvedMuxedAccount,
19    /// Initial balance in stroops of the account, default 1 XLM
20    #[arg(long, default_value = "10_000_000")]
21    pub starting_balance: builder::Amount,
22}
23
24impl TryFrom<&Cmd> for xdr::OperationBody {
25    type Error = tx::args::Error;
26    fn try_from(cmd: &Cmd) -> Result<Self, Self::Error> {
27        Ok(xdr::OperationBody::CreateAccount(xdr::CreateAccountOp {
28            destination: cmd.tx.resolve_account_id(&cmd.op.destination)?,
29            starting_balance: cmd.op.starting_balance.into(),
30        }))
31    }
32}