Skip to content

Commit

Permalink
Remove dependency on rand
Browse files Browse the repository at this point in the history
  • Loading branch information
ok300 committed Jan 24, 2025
1 parent 780fa9a commit fe223c4
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion crates/cashu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ serde_with = "3"
instant = { version = "0.1", features = ["wasm-bindgen", "inaccurate"] }

[dev-dependencies]
rand = "0.8.5"
bip39 = "2.0"
uuid = { version = "1", features = ["v4", "serde"] }
2 changes: 1 addition & 1 deletion crates/cashu/src/nuts/nut02.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl From<&MintKeys> for Id {
mod test {
use std::str::FromStr;

use rand::RngCore;
use bitcoin::secp256k1::rand::{self, RngCore};

use super::{KeySetInfo, Keys, KeysetResponse};
use crate::nuts::nut02::{Error, Id};
Expand Down
1 change: 0 additions & 1 deletion crates/cdk-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ serde_json = "1"
tokio = { version = "1", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
rand = "0.8.5"
home = "0.5.5"
nostr-sdk = { version = "0.35.0", default-features = false, features = [
"nip04",
Expand Down
4 changes: 2 additions & 2 deletions crates/cdk-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::str::FromStr;
use std::sync::Arc;

use anyhow::{bail, Result};
use bip39::rand::{thread_rng, Rng};
use bip39::Mnemonic;
use cdk::cdk_database;
use cdk::cdk_database::WalletDatabase;
Expand All @@ -12,7 +13,6 @@ use cdk::wallet::{MultiMintWallet, Wallet};
use cdk_redb::WalletRedbDatabase;
use cdk_sqlite::WalletSqliteDatabase;
use clap::{Parser, Subcommand};
use rand::Rng;
use tracing::Level;
use tracing_subscriber::EnvFilter;
use url::Url;
Expand Down Expand Up @@ -128,7 +128,7 @@ async fn main() -> Result<()> {
Mnemonic::from_str(&contents)?
}
Err(_e) => {
let mut rng = rand::thread_rng();
let mut rng = thread_rng();
let random_bytes: [u8; 32] = rng.gen();

let mnemonic = Mnemonic::from_entropy(&random_bytes)?;
Expand Down
1 change: 0 additions & 1 deletion crates/cdk-fake-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ serde = "1"
serde_json = "1"
lightning-invoice = { version = "0.32.0", features = ["serde", "std"] }
tokio-stream = "0.1.15"
rand = "0.8.5"
4 changes: 2 additions & 2 deletions crates/cdk-fake-wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::sync::Arc;

use async_trait::async_trait;
use bitcoin::hashes::{sha256, Hash};
use bitcoin::secp256k1::rand::{thread_rng, Rng};
use bitcoin::secp256k1::{Secp256k1, SecretKey};
use cdk::amount::{to_unit, Amount, MSAT_IN_SAT};
use cdk::cdk_lightning::{
Expand All @@ -26,7 +27,6 @@ use error::Error;
use futures::stream::StreamExt;
use futures::Stream;
use lightning_invoice::{Bolt11Invoice, Currency, InvoiceBuilder, PaymentSecret};
use rand::Rng;
use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use tokio::time;
Expand Down Expand Up @@ -281,7 +281,7 @@ pub fn create_fake_invoice(amount_msat: u64, description: String) -> Bolt11Invoi
)
.unwrap();

let mut rng = rand::thread_rng();
let mut rng = thread_rng();
let mut random_bytes = [0u8; 32];
rng.fill(&mut random_bytes);

Expand Down
1 change: 0 additions & 1 deletion crates/cdk-mintd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ home = "0.5.5"
url = "2.3"
utoipa = { version = "4", optional = true }
utoipa-swagger-ui = { version = "4", features = ["axum"], optional = true }
rand = "0.8.5"

[features]
swagger = ["cdk-axum/swagger", "dep:utoipa", "dep:utoipa-swagger-ui"]
Expand Down
4 changes: 2 additions & 2 deletions crates/cdk-mintd/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::sync::Arc;

use anyhow::{anyhow, bail};
use axum::{async_trait, Router};
use bip39::rand::{thread_rng, Rng};
use cdk::cdk_lightning::MintLightning;
use cdk::mint::FeeReserve;
use cdk::mint_url::MintUrl;
use cdk::nuts::CurrencyUnit;
use rand::Rng;
use tokio::sync::Mutex;
use url::Url;

Expand Down Expand Up @@ -217,7 +217,7 @@ impl LnBackendSetup for config::FakeWallet {
};

// calculate random delay time
let mut rng = rand::thread_rng();
let mut rng = thread_rng();
let delay_time = rng.gen_range(self.min_delay_time..=self.max_delay_time);

let fake_wallet = cdk_fake_wallet::FakeWallet::new(
Expand Down

0 comments on commit fe223c4

Please # to comment.