Skip to content

Commit 5a0211b

Browse files
[bcr-ebill-core]: reduce the dependencies set
move from nostr-sdk to nostr reduces substantially the cardinality of the dependencies With this rough test ``` $ cargo tree -p bcr-ebill-core | wc -l ``` The set goes from 407 to 297
1 parent 42d30d5 commit 5a0211b

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ uuid = { version = "1", default-features = false, features = ["v4", "js"] }
3434
bitcoin = { version = "0.32", default-features = false }
3535
bip39 = { version = "2.1", features = ["rand"] }
3636
ecies = { version = "0.2", default-features = false, features = ["pure"] }
37+
nostr = { version = "0.40"}
3738
nostr-sdk = { version = "0.40", features = ["nip04", "nip59"] }
3839
getrandom = { version = "0.3.1", features = ["wasm_js"] }
3940
reqwest = { version = "0.12", default-features = false, features = ["json"] }

crates/bcr-ebill-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ thiserror.workspace = true
1919
bitcoin.workspace = true
2020
bip39.workspace = true
2121
ecies.workspace = true
22-
nostr-sdk.workspace = true
22+
nostr.workspace = true
2323
secp256k1 = { workspace = true, features = ["global-context"] }
2424
rust_decimal = { version = "1.36.0", default-features = false }
2525

crates/bcr-ebill-core/src/util/crypto.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use bitcoin::{
1010
self, Keypair, Message, PublicKey, SECP256K1, Scalar, SecretKey, rand, schnorr::Signature,
1111
},
1212
};
13-
use nostr_sdk::ToBech32;
13+
use nostr::ToBech32;
1414
use thiserror::Error;
1515

1616
pub type Result<T> = std::result::Result<T, Error>;
@@ -20,12 +20,6 @@ pub enum Error {
2020
#[error("Private key error: {0}")]
2121
PrivateKey(#[from] secp256k1::Error),
2222

23-
#[error("Nostr key error: {0}")]
24-
NostrKey(#[from] nostr_sdk::key::Error),
25-
26-
#[error("Nostr bech32 key error: {0}")]
27-
NostrNip19(#[from] nostr_sdk::nips::nip19::Error),
28-
2923
#[error("Ecies encryption error: {0}")]
3024
Ecies(String),
3125

@@ -111,8 +105,8 @@ impl BcrKeys {
111105
}
112106

113107
/// Returns the key pair as a nostr key pair
114-
pub fn get_nostr_keys(&self) -> nostr_sdk::Keys {
115-
nostr_sdk::Keys::new(self.inner.secret_key().into())
108+
pub fn get_nostr_keys(&self) -> nostr::Keys {
109+
nostr::Keys::new(self.inner.secret_key().into())
116110
}
117111

118112
/// Returns the nostr public key as an XOnlyPublicKey hex string
@@ -172,7 +166,7 @@ pub fn is_node_id_nostr_hex_npub(node_id: &str, npub: &str) -> bool {
172166
Ok(pub_key) => pub_key,
173167
Err(_) => return false,
174168
};
175-
match nostr_sdk::PublicKey::from_hex(&x_only_pub_key) {
169+
match nostr::PublicKey::from_hex(&x_only_pub_key) {
176170
Ok(npub_from_node_id) => npub == npub_from_node_id.to_hex(),
177171
Err(_) => false,
178172
}
@@ -738,14 +732,14 @@ mod tests {
738732
npub_as_hex.to_string()
739733
);
740734
let npub =
741-
nostr_sdk::PublicKey::from_hex(&get_nostr_npub_as_hex_from_node_id(node_id).unwrap())
735+
nostr::PublicKey::from_hex(&get_nostr_npub_as_hex_from_node_id(node_id).unwrap())
742736
.unwrap();
743737
assert_eq!(npub.to_hex(), npub_as_hex);
744738
assert_eq!(
745739
get_nostr_npub_as_hex_from_node_id(TEST_NODE_ID_SECP).unwrap(),
746740
TEST_NODE_ID_SECP_AS_NPUB_HEX.to_string()
747741
);
748-
let npub = nostr_sdk::PublicKey::from_hex(
742+
let npub = nostr::PublicKey::from_hex(
749743
&get_nostr_npub_as_hex_from_node_id(TEST_NODE_ID_SECP).unwrap(),
750744
)
751745
.unwrap();

0 commit comments

Comments
 (0)