Merge pull request #561 from ok300/ok300-remove-rand

Remove dependency on `rand`
This commit is contained in:
thesimplekid
2025-01-24 17:47:08 +00:00
committed by GitHub
8 changed files with 7 additions and 11 deletions

View File

@@ -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"] }

View File

@@ -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};

View File

@@ -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",

View File

@@ -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;
@@ -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;
@@ -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)?;

View File

@@ -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"

View File

@@ -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::{
@@ -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;
@@ -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);

View File

@@ -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"]

View File

@@ -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;
@@ -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(