-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
use clap::{Parser, Subcommand}; | ||
|
||
/// A fictional versioning CLI | ||
#[derive(Parser)] | ||
#[clap( | ||
name = "keytool", | ||
about = "A Cli Crypto Wallet Tool", | ||
version = "0.1.0", | ||
long_about = None, | ||
)] | ||
pub struct KeyToolCli { | ||
#[clap(subcommand)] | ||
pub command: KeyToolCommand, | ||
} | ||
|
||
#[derive(Subcommand)] | ||
pub enum KeyToolCommand { | ||
/* | ||
todo x: | ||
1. 生成 HD 钱包, 助记词/私钥/地址 | ||
2. 多链支持: BTC/ETH/DOT | ||
3. 命令行查询 | ||
- 钱包余额 | ||
- 钱包交易记录 | ||
- 单笔交易状态 | ||
4. 命令行转账: | ||
- 发起交易 | ||
- 交易状态查询 | ||
*/ | ||
/// Generate a new crypto wallet account: mnemonic/private key/address | ||
#[clap(arg_required_else_help = true)] | ||
Generate { | ||
/// allow emtpy | ||
empty: String, | ||
}, | ||
|
||
/// Query blockchain info | ||
#[clap(arg_required_else_help = true)] | ||
#[clap(subcommand)] | ||
Query(QueryCommand), | ||
|
||
/// Send a transaction | ||
#[clap(arg_required_else_help = true)] | ||
Send { | ||
/// chain name | ||
chain_type: String, | ||
|
||
/// from address | ||
from: String, | ||
|
||
/// to address | ||
to: String, | ||
|
||
/// amount | ||
amount: String, | ||
|
||
/// miner fee | ||
fee: String, | ||
}, | ||
} | ||
|
||
#[derive(Subcommand)] | ||
pub enum QueryCommand { | ||
/// Query balance | ||
#[clap(arg_required_else_help = true)] | ||
Balance { | ||
/// blockchain type | ||
chain_type: String, | ||
|
||
/// blockchain id: | ||
chain_id: String, | ||
|
||
/// address | ||
address: String, | ||
}, | ||
|
||
/// Query transaction | ||
Transaction { | ||
/// blockchain type | ||
chain_type: String, | ||
|
||
/// blockchain id: | ||
chain_id: String, | ||
|
||
/// transaction id | ||
tx_id: String, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod binance; | ||
pub mod eth; | ||
pub mod keytool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use clap::Parser; | ||
use log::info; | ||
use pretty_env_logger; | ||
|
||
use crate::commands::keytool::{KeyToolCli, KeyToolCommand, QueryCommand}; | ||
|
||
mod commands; | ||
mod modules; | ||
|
||
fn main() { | ||
pretty_env_logger::init(); | ||
|
||
let args = KeyToolCli::parse(); | ||
|
||
match &args.command { | ||
KeyToolCommand::Generate { empty: _ } => { | ||
info!("GenerateAccount command"); | ||
}, | ||
|
||
// subcommands: | ||
KeyToolCommand::Query(x) => { | ||
info!("GenerateAccount command"); | ||
match x { | ||
QueryCommand::Balance { chain_type, chain_id, address } => { | ||
info!("Balance command: {}, {}, {}", chain_type, chain_id, address); | ||
}, | ||
QueryCommand::Transaction { chain_type, chain_id, tx_id } => { | ||
info!("Balance command: {}, {}, {}", chain_type, chain_id, tx_id); | ||
}, | ||
} | ||
}, | ||
KeyToolCommand::Send { chain_type, from, to, amount, fee } => { | ||
info!("GenerateAccount command: {}, {}, {}, {}, {}", chain_type, from, to, amount, fee); | ||
}, | ||
} | ||
|
||
info!("cli finished"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use log::info; | ||
|
||
fn generate_wallet() { | ||
info!("Generating wallet"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod binance; | ||
pub mod eth; | ||
pub mod keytool; |