Skip to content

Commit 1519251

Browse files
authored
Merge pull request #5 from Rigidity/redesign-wallet
Redesign wallet
2 parents 5eace07 + 1aa344a commit 1519251

22 files changed

+1746
-964
lines changed

Cargo.lock

Lines changed: 801 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,26 @@ repository = "https://github.com/Rigidity/chia-wallet-sdk"
1010

1111
[dependencies]
1212
tokio = { version = "1.33.0", features = ["macros"] }
13-
log = "0.4.20"
1413
indexmap = "2.1.0"
15-
anyhow = "1.0.75"
1614
sha2 = "0.9.9"
1715
thiserror = "1.0.50"
18-
serde = { version = "1.0.193", features = ["derive"] }
1916
clvmr = "0.4.0"
2017
chia-protocol = "0.4.0"
2118
chia-wallet = "0.4.0"
2219
chia-bls = "0.4.0"
2320
chia-client = "0.4.0"
2421
clvm-traits = "0.3.3"
2522
clvm-utils = "0.4.0"
23+
chia-ssl = "0.2.14"
24+
native-tls = "0.2.11"
25+
tokio-tungstenite = { version = "0.21.0", features = ["native-tls"] }
26+
parking_lot = "0.12.1"
27+
hex = "0.4.3"
28+
bech32 = "0.9.1"
29+
rand = "0.8.5"
30+
rand_chacha = "0.3.1"
2631

2732
[dev-dependencies]
2833
bip39 = "2.0.0"
29-
hex = "0.4.3"
3034
hex-literal = "0.4.1"
3135
once_cell = "1.19.0"

src/address.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// Parses an address into a puzzle hash.
2+
pub fn parse_address(address: &str) -> [u8; 32] {
3+
if let Ok(puzzle_hash) = hex::decode(strip_prefix(address)) {
4+
puzzle_hash.try_into().expect("invalid puzzle hash")
5+
} else {
6+
let (_hrp, data, _variant) = bech32::decode(address).expect("invalid address");
7+
let puzzle_hash = bech32::convert_bits(&data, 5, 8, false).expect("invalid address data");
8+
puzzle_hash
9+
.try_into()
10+
.expect("invalid address puzzle hash encoding")
11+
}
12+
}
13+
14+
/// Removes the `0x` prefix from a puzzle hash in hex format.
15+
fn strip_prefix(puzzle_hash: &str) -> &str {
16+
if let Some(puzzle_hash) = puzzle_hash.strip_prefix("0x") {
17+
puzzle_hash
18+
} else if let Some(puzzle_hash) = puzzle_hash.strip_prefix("0X") {
19+
puzzle_hash
20+
} else {
21+
puzzle_hash
22+
}
23+
}

src/coin_selection.rs

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

src/condition.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ use clvm_traits::{
55
MatchByte, ToClvm, ToClvmError,
66
};
77

8+
/// A condition that must be met in order to spend a coin.
89
#[derive(Debug, Clone, PartialEq, Eq, ToClvm, FromClvm)]
910
#[clvm(list)]
11+
#[allow(missing_docs)]
1012
#[repr(u64)]
1113
pub enum Condition<T> {
1214
Remark = 1,
@@ -147,8 +149,10 @@ pub enum Condition<T> {
147149
} = 90,
148150
}
149151

152+
/// A create coin condition.
150153
#[derive(Debug, Clone, PartialEq, Eq, ToClvm, FromClvm)]
151154
#[clvm(untagged, list)]
155+
#[allow(missing_docs)]
152156
pub enum CreateCoin {
153157
Normal {
154158
puzzle_hash: Bytes32,
@@ -161,16 +165,21 @@ pub enum CreateCoin {
161165
},
162166
}
163167

168+
/// A condition that must be met in order to spend a CAT coin.
164169
#[derive(Debug, Clone, PartialEq, Eq, ToClvm, FromClvm)]
165170
#[clvm(untagged, tuple)]
171+
#[allow(missing_docs)]
166172
pub enum CatCondition<T> {
167173
Normal(Condition<T>),
168174
RunTail(RunTail<T>),
169175
}
170176

177+
/// A run TAIL condition.
171178
#[derive(Debug, Clone, PartialEq, Eq)]
172179
pub struct RunTail<T> {
180+
/// The TAIL program reveal.
173181
pub program: T,
182+
/// The solution to the TAIL program.
174183
pub solution: T,
175184
}
176185

src/key_store.rs

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

src/lib.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
mod coin_selection;
1+
#![deny(missing_docs)]
2+
3+
//! This crate is a work in progress.
4+
5+
mod address;
26
mod condition;
3-
mod key_store;
7+
mod signer;
48
mod spends;
9+
mod ssl;
510
mod utils;
611
mod wallet;
712

8-
pub use coin_selection::*;
13+
pub use address::*;
914
pub use condition::*;
10-
pub use key_store::*;
15+
pub use signer::*;
1116
pub use spends::*;
12-
pub use utils::*;
17+
pub use ssl::*;
1318
pub use wallet::*;
1419

1520
#[cfg(test)]

0 commit comments

Comments
 (0)