Skip to content

Commit

Permalink
Strict typing the internal structs
Browse files Browse the repository at this point in the history
This PR uses strict typing for all the internal SwapScript and
SwapTx structures.

This also removes two redundant dependency, rand and hex. These are already
available from the bitcoin library.
  • Loading branch information
rajarshimaitra committed Feb 23, 2024
1 parent 7f77786 commit 1c6ce65
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 192 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ codegen-units = 1
panic = "abort"

[dependencies]
hex = "0.4.3"
serde = { version = "1.0.0", features = ["derive"] }
serde_json = "1.0.0"
rand_core = {version = "0.6.4", features = ["getrandom"]}
ureq = {version = "2.8.0", features = ["json"]}
bip39 = "2.0.0"
electrum-client = "0.19.0"
Expand Down
13 changes: 13 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub enum Error {
BIP32(bitcoin::bip32::Error),
BIP39(bip39::Error),
Hash(bitcoin::hashes::FromSliceError),
Locktime(String),
}

impl From<electrum_client::Error> for Error {
Expand Down Expand Up @@ -139,3 +140,15 @@ impl From<bip39::Error> for Error {
Self::BIP39(value)
}
}

impl From<bitcoin::absolute::Error> for Error {
fn from(value: bitcoin::absolute::Error) -> Self {
Self::Locktime(value.to_string())
}
}

impl From<elements::locktime::Error> for Error {
fn from(value: elements::locktime::Error) -> Self {
Self::Locktime(value.to_string())
}
}
Loading

0 comments on commit 1c6ce65

Please sign in to comment.