Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cli #84

Merged
merged 36 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fdb72c7
add options in clap Derive mode
max-zengo Aug 10, 2023
4313a5e
temp cargo changes
max-zengo Aug 13, 2023
5ea7db0
temp wallet mod changes
max-zengo Aug 13, 2023
12223d5
only secp256k1 0.21.3 and 0.20.3 duplication remains
max-zengo Aug 13, 2023
6cb7323
code compiles
max-zengo Aug 13, 2023
436e9bd
begin integration debugging
max-zengo Aug 14, 2023
ae32e76
* move to Electrumx trait
max-zengo Aug 16, 2023
ae7590b
private_share.master_key.chain_code changes from ChainCode2 struct to…
max-zengo Aug 21, 2023
e7ad580
intermediate testing
max-zengo Aug 21, 2023
62fc88a
* replace SighashComponents with SigHashCache
max-zengo Aug 21, 2023
843fddd
cargo fmt --all
max-zengo Aug 21, 2023
5a5fa40
minor changes
max-zengo Aug 21, 2023
62bf0d3
minor cli commands change
max-zengo Aug 22, 2023
2cd871a
export elliptic::curves::traits::ECPoint in client lib
max-zengo Aug 30, 2023
5a7338f
export elliptic::curves::traits::* in client lib
max-zengo Aug 30, 2023
20edea6
import ethereum cli external code into demo-wallet package.
max-zengo Sep 14, 2023
408a4f4
reorder code into several files
max-zengo Sep 14, 2023
3df542d
clean clap from Cargo.toml files
max-zengo Sep 14, 2023
586e52e
delete cli.yml
max-zengo Sep 14, 2023
e9904dc
clean Cargo.toml
max-zengo Sep 14, 2023
aecb72a
pass settings to bitcoin_commands function
max-zengo Sep 14, 2023
f577daf
return Cargo.lock for integration tests
max-zengo Sep 14, 2023
bd60c0c
return Cargo.lock for integration tests
max-zengo Sep 14, 2023
ca9bc5f
Merge branch 'master' into update-cli
max-zengo Sep 18, 2023
17b7c01
return Cargo.lock for integration tests
max-zengo Sep 18, 2023
a561d9b
cargo fmt --all
max-zengo Sep 18, 2023
f4998a9
refactor some bitcoin CLI parameters into settings.toml
max-zengo Sep 18, 2023
dfbe91b
Add readme for Ethereum wallet
max-zengo Sep 19, 2023
68b10f3
Add readme for Bitcoin wallet
max-zengo Sep 19, 2023
3d5f497
cargo fmt --all
max-zengo Sep 19, 2023
180b414
change amount and gas-price to floating point nums
max-zengo Sep 20, 2023
15d3795
change ETH amount to floating point nums
max-zengo Sep 20, 2023
8947dc6
small fix in README.md
max-zengo Sep 21, 2023
0227520
add wallet commands to README.md
max-zengo Sep 21, 2023
094c487
apply cargo fix
max-zengo Sep 21, 2023
c1d7409
apply cargo fmt
max-zengo Sep 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "[email protected]"}
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
```
Loading