Skip to content

Commit

Permalink
feat: new cli
Browse files Browse the repository at this point in the history
feat: new cli
  • Loading branch information
max-zengo committed Sep 26, 2023
1 parent 1be70c0 commit 1b785a9
Show file tree
Hide file tree
Showing 12 changed files with 1,407 additions and 271 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = [
"demo-wallet",
"gotham-server",
"gotham-client",
"integration-tests",
Expand All @@ -8,7 +9,7 @@ members = [
[workspace.dependencies]
gotham-server = { path = "gotham-server" }
gotham-client = { path = "gotham-client" }
serde = { version = "1", features = ["serde_derive"] }
serde = { version = "1", features = ["derive", "serde_derive"] }
serde_json = "1"
log = "0.4"
reqwest = "0.9.5"
Expand All @@ -19,6 +20,8 @@ config = "0.9.2"
uuid = { version = "0.7", features = ["v4"] }
jsonwebtoken = "8"
hex = "0.4"
secp256k1 = {version = "0.21.0", features = ["global-context"]}
rand = "0.8"

two-party-ecdsa = { git = "https://github.com/ZenGo-X/two-party-ecdsa.git" }
kms = { git = "https://github.com/ZenGo-X/kms-secp256k1.git", branch = "2.0" }
36 changes: 36 additions & 0 deletions demo-wallet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "demo-wallet"
version = "0.1.0"
edition = "2021"
description = "Bitcoin and Ethereum minimalist wallet CLI app on top of Gotham City Client"

[dependencies]
# Common
serde = "1.0"
serde_json = "1.0"
clap = { version = "4.3", features = ["derive"] }
config = "0.13"

# Etherum
ethers = { version = "2.0", features = ["rustls"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
eyre = "0.6"
async-trait = "0.1"
thiserror = "1.0"

# Bitcoin
uuid = { version = "0.7", features = ["v4"] }
bitcoin = "0.27.1"
itertools = "0.11.0"
electrumx_client = { git = "https://github.com/ZenGo-X/rust-electrumx-client.git", tag = "bitcoin@0.26.0"}
kms.workspace = true
two-party-ecdsa.workspace = true
log.workspace = true
hex.workspace = true

# Client
gotham-client.workspace = true


[dev-dependencies]
mockall = "0.11.4"
207 changes: 207 additions & 0 deletions demo-wallet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# Demo Wallet
Bitcoin and Ethereum minimalist wallet CLI app on top of Gotham City Client.

## Requirement
Gotham server is required to interact with the client, for instruction on how to run it see [here](../gotham-server/README.md).

## Installation
```bash
git clone https://github.com/ZenGo-X/gotham-city.git
cargo run --bin demo-wallet
```

## Usage
```
Commands:
evm EVM-compatible blockchain
bitcoin Bitcoin blockchain
help Print this message or the help of the given subcommand(s)
Options:
-s, --settings <SETTINGS> Settings file [default: settings.toml]
-h, --help Print help
```

## Ethereum Wallet
Configuration variables in settings file:
* __rpc_url__ - endpoint to communicate with the Ethereum network.
* __wallet_file__ - file-path to wallet JSON file `[default: wallet.json]`.
* __gotham_server_url__ - URL to Gotham Server`[default: http://127.0.0.1:8000]`.

### Commands
```
Usage: demo-wallet evm [OPTIONS] <COMMAND>
Commands:
new Create new MPC EVM wallet
send Broadcast a transaction to the network
transfer Broadcast an ERC20 transfer command to the network
balance Retrieve wallet balance
help Print this message or the help of the given subcommand(s)
Options:
--no-mpc
Disable MPC Gotham wallet, use a wallet instantiated with a locally stored private key
-h, --help
Print help (see a summary with '-h')
```

### New wallet
Create new MPC EVM wallet

```
Usage: demo-wallet evm new [OPTIONS] --chain-id <CHAIN_ID>
Options:
--chain-id <CHAIN_ID> Network Chain ID
-o, --output <OUTPUT> Output filepath [default: wallet.json]
--hd-path <HD_PATH> Hierarchical Deterministic path
-h, --help Print help
```

### Send transaction
Broadcast a transaction to the network

```
Usage: demo-wallet evm send [OPTIONS] --to <TO> --amount <AMOUNT>
Options:
--to <TO> Recipient address
--amount <AMOUNT> Amount of Wei to transfer (10^18 Wei = 1 ETH)
--gas-limit <GAS_LIMIT> Maximum amount of gas units this transaction can consume
--gas-price <GAS_PRICE> Amount of Giga-Wei to pay for gas (10^9 Giga-Wei = 1 ETH)
--nonce <NONCE> Sequentially incrementing counter to indicates transaction number
-h, --help Print help
```

### Transfer ERC20
Broadcast an ERC20 transfer command to the network

```
Usage: demo-wallet evm transfer [OPTIONS] --token <TOKEN> --to <TO> --amount <AMOUNT>
Options:
--token <TOKEN> ERC20 token address
--to <TO> Recipient address
--amount <AMOUNT> Amount of tokens to transfer
--gas-limit <GAS_LIMIT> Maximum amount of gas units this transaction can consume
--gas-price <GAS_PRICE> Amount of Giga-Wei to pay for gas (10^9 Giga-Wei = 1 ETH)
--nonce <NONCE> Sequentially incrementing counter to indicates transaction number
-h, --help Print help
```

### See balance
Retrieve wallet balance

```
Usage: demo-wallet evm balance [OPTIONS]
Options:
--tokens <TOKENS> ERC20 token addresses seperated by commas
-h, --help Print help
```

## Bitcoin Wallet
Configuration variables in settings file:
* __electrum_server_url__ - endpoint of [Electrum server](https://thebitcoinmanual.com/articles/btc-electrum-server/).
* __wallet_file__ - file-path to wallet JSON file `[default: wallet.json]`.
* __gotham_server_url__ - URL to Gotham Server`[default: http://127.0.0.1:8000]`.

### Commands
```
Usage: demo-wallet bitcoin <COMMAND>
Commands:
create-wallet Create an MPC Bitcoin wallet
new-address Generate a new address
get-balance Total balance
list-unspent List unspent transactions (tx hash)
send Send a transaction
backup Private share backup
verify Backup verification
help Print this message or the help of the given subcommand(s)
Options:
-h, --help
Print help (see a summary with '-h')
```

### New wallet
Create an MPC Bitcoin wallet

```
Usage: demo-wallet bitcoin create-wallet [OPTIONS]
Options:
-n, --network <NETWORK> Bitcoin network [bitcoin|testnet|signet|regtest] [default: testnet]
-o, --output <OUTPUT> Output filepath [default: wallet.json]
-e, --escrow-path <ESCROW_PATH> Escrow filepath [default: escrow-bitcoin.json]
-h, --help Print help
```

### New Address
Generate a new address

```
Usage: demo-wallet bitcoin new-address
Options:
-h, --help Print help
```
### Get Balance
Retrieve total wallet balance

```
Usage: demo-wallet bitcoin get-balance
Options:
-h, --help Print help
```

### Unspent transactions
List unspent transactions (tx hash)

```
Usage: demo-wallet bitcoin list-unspent
Options:
-h, --help Print help
```

### Send
Send a transaction

```
Usage: demo-wallet bitcoin send --to <TO> --amount <AMOUNT>
Options:
-t, --to <TO> Recipient
-a, --amount <AMOUNT> Amount in BTC
-h, --help Print help
```


### Backup
Private share backup

```
Usage: demo-wallet bitcoin backup [OPTIONS]
Options:
-b, --backup-path <BACKUP_PATH> Backup filepath [default: backup-bitcoin.json]
-e, --escrow-path <ESCROW_PATH> Escrow filepath [default: escrow-bitcoin.json]
-h, --help Print help
```

### Verify
Backup verification

```
Usage: demo-wallet bitcoin verify [OPTIONS]
Options:
-b, --backup-path <BACKUP_PATH> Backup filepath [default: backup-bitcoin.json]
-e, --escrow-path <ESCROW_PATH> Escrow filepath [default: escrow-bitcoin.json]
-h, --help Print help
```

0 comments on commit 1b785a9

Please sign in to comment.