Skip to content

Commit b995c16

Browse files
committed
Add coin-store and signer and basic-cli
1 parent 93090bd commit b995c16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1555
-4453
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.data
2+
config.toml
3+
14
# Generated by Cargo
25
# will have compiled files and executables
36
debug/

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ anyhow = { version = "1.0.100" }
1616

1717
tracing = { version = "0.1.41" }
1818

19-
contracts = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "35449ea", package = "contracts" }
20-
simplicityhl-core = { version = "0.2.1", features = ["encoding"] }
19+
contracts = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "6a53bf7", package = "contracts" }
20+
cli-helper = { git = "https://github.com/BlockstreamResearch/simplicity-contracts.git", rev = "6a53bf7", package = "cli" }
21+
simplicityhl-core = { version = "0.3.0", features = ["encoding"] }
2122

2223
simplicityhl = { version = "0.4.0" }

crates/cli-client/Cargo.toml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
[package]
22
name = "cli-client"
3-
version = "0.1.0"
4-
edition = "2024"
5-
description = ""
3+
description = "CLI client for Simplicity Options trading on Liquid"
64
license = "MIT OR Apache-2.0"
7-
readme = "README.md"
8-
publish = false
95

6+
version.workspace = true
7+
edition.workspace = true
8+
rust-version.workspace = true
9+
authors.workspace = true
1010

1111
[[bin]]
1212
name = "simplicity-dex"
1313
path = "src/bin/main.rs"
1414

1515
[dependencies]
16+
signer = { path = "../signer" }
17+
coin-store = { path = "../coin-store" }
18+
options-relay = { path = "../options-relay" }
19+
20+
contracts = { workspace = true }
21+
cli-helper = { workspace = true }
22+
simplicityhl = { workspace = true }
23+
simplicityhl-core = { workspace = true }
24+
25+
clap = { version = "4", features = ["derive", "env"] }
26+
27+
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
28+
29+
thiserror = "2"
30+
anyhow = { workspace = true }
31+
32+
tracing = { workspace = true }
33+
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
34+
35+
serde = { version = "1", features = ["derive"] }
36+
toml = "0.8"
37+
hex = "0.4"
38+
dotenvy = "0.15"
1639

crates/cli-client/README.md

Whitespace-only changes.

crates/cli-client/src/bin/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
#![warn(clippy::all, clippy::pedantic)]
22

33
use clap::Parser;
4-
5-
use dex_cli::logger::init_logger;
6-
7-
use dex_cli::cli::Cli;
4+
use cli_client::cli::Cli;
85

96
#[tokio::main]
10-
#[tracing::instrument]
117
async fn main() -> anyhow::Result<()> {
128
let _ = dotenvy::dotenv();
13-
let _logger_guard = init_logger();
9+
let cli = Cli::parse();
1410

15-
Cli::parse().process().await?;
11+
cli.run().await?;
1612

1713
Ok(())
1814
}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
use clap::Subcommand;
2+
use simplicityhl::elements::OutPoint;
3+
4+
#[derive(Debug, Subcommand)]
5+
pub enum Command {
6+
/// Maker commands for creating and managing options
7+
Maker {
8+
#[command(subcommand)]
9+
command: MakerCommand,
10+
},
11+
12+
/// Taker commands for participating in options
13+
Taker {
14+
#[command(subcommand)]
15+
command: TakerCommand,
16+
},
17+
18+
/// Helper utilities
19+
Helper {
20+
#[command(subcommand)]
21+
command: HelperCommand,
22+
},
23+
24+
/// Show current configuration
25+
Config,
26+
27+
/// Basic transaction commands (transfer, split, issue)
28+
Basic {
29+
#[command(subcommand)]
30+
command: BasicCommand,
31+
},
32+
}
33+
34+
#[derive(Debug, Subcommand)]
35+
pub enum MakerCommand {
36+
/// Create a new options contract
37+
Create,
38+
39+
/// Fund an options contract with collateral
40+
Fund,
41+
42+
/// Exercise an option before expiration
43+
Exercise,
44+
45+
/// Cancel an unfilled option and retrieve collateral
46+
Cancel,
47+
48+
/// List your created options
49+
List,
50+
}
51+
52+
#[derive(Debug, Subcommand)]
53+
pub enum TakerCommand {
54+
/// Browse available options
55+
Browse,
56+
57+
/// Take an option by purchasing grantor token
58+
Take,
59+
60+
/// Claim settlement after expiration
61+
Claim,
62+
63+
/// List your positions
64+
List,
65+
}
66+
67+
#[derive(Debug, Subcommand)]
68+
pub enum HelperCommand {
69+
/// Show wallet details
70+
Address,
71+
72+
/// Initialize the wallet database
73+
Init,
74+
75+
/// Show wallet balance
76+
Balance,
77+
78+
/// List UTXOs
79+
Utxos,
80+
81+
/// Import a UTXO into the wallet
82+
Import {
83+
/// Outpoint (txid:vout)
84+
#[arg(long, short = 'o')]
85+
outpoint: OutPoint,
86+
87+
/// Blinding key (hex, optional for confidential outputs)
88+
#[arg(long, short = 'b')]
89+
blinding_key: Option<String>,
90+
},
91+
}
92+
93+
#[derive(Debug, Subcommand)]
94+
pub enum BasicCommand {
95+
/// Transfer LBTC to a recipient
96+
TransferNative {
97+
/// Recipient address
98+
#[arg(long)]
99+
to: String,
100+
/// Amount to send in satoshis
101+
#[arg(long)]
102+
amount: u64,
103+
/// Fee amount in satoshis
104+
#[arg(long)]
105+
fee: u64,
106+
/// Broadcast transaction
107+
#[arg(long)]
108+
broadcast: bool,
109+
},
110+
111+
/// Split LBTC into multiple UTXOs
112+
SplitNative {
113+
/// Number of parts to split into
114+
#[arg(long)]
115+
parts: u64,
116+
/// Fee amount in satoshis
117+
#[arg(long)]
118+
fee: u64,
119+
/// Broadcast transaction
120+
#[arg(long)]
121+
broadcast: bool,
122+
},
123+
124+
/// Transfer an asset to a recipient
125+
TransferAsset {
126+
/// Asset ID (hex)
127+
#[arg(long)]
128+
asset: String,
129+
/// Recipient address
130+
#[arg(long)]
131+
to: String,
132+
/// Amount to send
133+
#[arg(long)]
134+
amount: u64,
135+
/// Fee amount in satoshis
136+
#[arg(long)]
137+
fee: u64,
138+
/// Broadcast transaction
139+
#[arg(long)]
140+
broadcast: bool,
141+
},
142+
143+
/// Issue a new asset
144+
IssueAsset {
145+
/// Asset name (local reference)
146+
#[arg(long)]
147+
name: String,
148+
/// Amount to issue
149+
#[arg(long)]
150+
amount: u64,
151+
/// Fee amount in satoshis
152+
#[arg(long)]
153+
fee: u64,
154+
/// Broadcast transaction
155+
#[arg(long)]
156+
broadcast: bool,
157+
},
158+
159+
/// Reissue an existing asset
160+
ReissueAsset {
161+
/// Asset name (local reference)
162+
#[arg(long)]
163+
name: String,
164+
/// Amount to reissue
165+
#[arg(long)]
166+
amount: u64,
167+
/// Fee amount in satoshis
168+
#[arg(long)]
169+
fee: u64,
170+
/// Broadcast transaction
171+
#[arg(long)]
172+
broadcast: bool,
173+
},
174+
}

crates/cli-client/src/cli/dex.rs

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)