Skip to content

Commit

Permalink
Depend on bitcoin/rand for rand (#261)
Browse files Browse the repository at this point in the history
Rand is already available in secp256k1/rand transiently through rust
bitcoin. rand-std is also an option to for std environments but having
wide support seems more important in the near term than adding all of
those feature flags.

This fixes #258 which
may have been triggering in an environment where bitcoin/rand was not
available.
  • Loading branch information
DanGould authored May 22, 2024
2 parents 9bb69fd + b7073a9 commit 1248694
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions payjoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ exclude = ["tests"]

[features]
send = []
receive = ["rand"]
receive = ["bitcoin/rand"]
base64 = ["bitcoin/base64"]
v2 = ["bitcoin/rand-std", "bitcoin/serde", "chacha20poly1305", "ohttp", "bhttp", "serde"]
v2 = ["bitcoin/rand", "bitcoin/serde", "chacha20poly1305", "ohttp", "bhttp", "serde"]

[dependencies]
bitcoin = { version = "0.30.0", features = ["base64"] }
Expand All @@ -27,7 +27,6 @@ chacha20poly1305 = { version = "0.10.1", optional = true }
log = { version = "0.4.14"}
ohttp = { version = "0.5.1", optional = true }
bhttp = { version = "0.5.1", optional = true }
rand = { version = "0.8.4", optional = true }
serde = { version = "1.0.186", default-features = false, optional = true }
url = "2.2.2"
serde_json = "1.0.108"
Expand Down
4 changes: 2 additions & 2 deletions payjoin/src/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ mod optional_parameters;
#[cfg(feature = "v2")]
pub mod v2;

use bitcoin::secp256k1::rand::seq::SliceRandom;
use bitcoin::secp256k1::rand::{self, Rng};
pub use error::{Error, RequestError, SelectionError};
use error::{InternalRequestError, InternalSelectionError};
use optional_parameters::Params;
use rand::seq::SliceRandom;
use rand::Rng;

use crate::input_type::InputType;
use crate::psbt::PsbtExt;
Expand Down
1 change: 1 addition & 0 deletions payjoin/src/receive/v2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use bitcoin::psbt::Psbt;
use bitcoin::secp256k1::rand;
use bitcoin::{base64, Amount, FeeRate, OutPoint, Script, TxOut};
use serde::ser::SerializeStruct;
use serde::{Deserialize, Serialize, Serializer};
Expand Down
2 changes: 2 additions & 0 deletions payjoin/src/send/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use std::str::FromStr;
use bitcoin::address::NetworkChecked;
use bitcoin::psbt::Psbt;
#[cfg(feature = "v2")]
use bitcoin::secp256k1::rand;
#[cfg(feature = "v2")]
use bitcoin::secp256k1::PublicKey;
use bitcoin::{FeeRate, Script, ScriptBuf, Sequence, TxOut, Weight};
pub use error::{CreateRequestError, ResponseError, ValidationError};
Expand Down

0 comments on commit 1248694

Please sign in to comment.