Skip to content

Commit 1248694

Browse files
authored
Depend on bitcoin/rand for rand (#261)
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.
2 parents 9bb69fd + b7073a9 commit 1248694

5 files changed

Lines changed: 7 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

payjoin/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ exclude = ["tests"]
1616

1717
[features]
1818
send = []
19-
receive = ["rand"]
19+
receive = ["bitcoin/rand"]
2020
base64 = ["bitcoin/base64"]
21-
v2 = ["bitcoin/rand-std", "bitcoin/serde", "chacha20poly1305", "ohttp", "bhttp", "serde"]
21+
v2 = ["bitcoin/rand", "bitcoin/serde", "chacha20poly1305", "ohttp", "bhttp", "serde"]
2222

2323
[dependencies]
2424
bitcoin = { version = "0.30.0", features = ["base64"] }
@@ -27,7 +27,6 @@ chacha20poly1305 = { version = "0.10.1", optional = true }
2727
log = { version = "0.4.14"}
2828
ohttp = { version = "0.5.1", optional = true }
2929
bhttp = { version = "0.5.1", optional = true }
30-
rand = { version = "0.8.4", optional = true }
3130
serde = { version = "1.0.186", default-features = false, optional = true }
3231
url = "2.2.2"
3332
serde_json = "1.0.108"

payjoin/src/receive/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ mod optional_parameters;
3535
#[cfg(feature = "v2")]
3636
pub mod v2;
3737

38+
use bitcoin::secp256k1::rand::seq::SliceRandom;
39+
use bitcoin::secp256k1::rand::{self, Rng};
3840
pub use error::{Error, RequestError, SelectionError};
3941
use error::{InternalRequestError, InternalSelectionError};
4042
use optional_parameters::Params;
41-
use rand::seq::SliceRandom;
42-
use rand::Rng;
4343

4444
use crate::input_type::InputType;
4545
use crate::psbt::PsbtExt;

payjoin/src/receive/v2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::HashMap;
22

33
use bitcoin::psbt::Psbt;
4+
use bitcoin::secp256k1::rand;
45
use bitcoin::{base64, Amount, FeeRate, OutPoint, Script, TxOut};
56
use serde::ser::SerializeStruct;
67
use serde::{Deserialize, Serialize, Serializer};

payjoin/src/send/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ use std::str::FromStr;
2929
use bitcoin::address::NetworkChecked;
3030
use bitcoin::psbt::Psbt;
3131
#[cfg(feature = "v2")]
32+
use bitcoin::secp256k1::rand;
33+
#[cfg(feature = "v2")]
3234
use bitcoin::secp256k1::PublicKey;
3335
use bitcoin::{FeeRate, Script, ScriptBuf, Sequence, TxOut, Weight};
3436
pub use error::{CreateRequestError, ResponseError, ValidationError};

0 commit comments

Comments
 (0)