diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index e003a28..0cc40c4 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -8,6 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +[[package]] +name = "arbitrary" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237430fd6ed3740afe94eefcc278ae21e050285be882804e0d6e8695f0c94691" + [[package]] name = "arrayvec" version = "0.7.2" @@ -186,6 +192,7 @@ name = "psbt-v2" version = "0.2.0" dependencies = [ "anyhow", + "arbitrary", "bitcoin", "miniscript", "serde", diff --git a/Cargo-recent.lock b/Cargo-recent.lock index 6afd677..1eadc05 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -8,6 +8,12 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + [[package]] name = "arrayvec" version = "0.7.6" @@ -189,6 +195,7 @@ name = "psbt-v2" version = "0.2.0" dependencies = [ "anyhow", + "arbitrary", "bitcoin", "miniscript", "serde", diff --git a/Cargo.toml b/Cargo.toml index 064d186..3793731 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,7 @@ silent-payments = [] # Silent Payments support [dependencies] bitcoin = { version = "0.32.8", default-features = false } +arbitrary = { version = "1.0.1", optional = true } miniscript = { version = "12.3.5", default-features = false, optional = true } serde = { version = "1.0.195", default-features = false, features = ["derive", "alloc"], optional = true } diff --git a/api/all-features.txt b/api/all-features.txt index 0d3ccab..b91d49f 100644 --- a/api/all-features.txt +++ b/api/all-features.txt @@ -263,6 +263,8 @@ pub fn psbt_v2::v0::bitcoin::raw::Key::hash<__H: core::hash::Hasher>(&self, stat impl core::marker::StructuralPartialEq for psbt_v2::v0::bitcoin::raw::Key impl serde::ser::Serialize for psbt_v2::v0::bitcoin::raw::Key pub fn psbt_v2::v0::bitcoin::raw::Key::serialize<__S>(&self, __serializer: __S) -> core::result::Result<<__S as serde::ser::Serializer>::Ok, <__S as serde::ser::Serializer>::Error> where __S: serde::ser::Serializer +impl<'a> arbitrary::Arbitrary<'a> for psbt_v2::v0::bitcoin::raw::Key +pub fn psbt_v2::v0::bitcoin::raw::Key::arbitrary(u: &mut arbitrary::unstructured::Unstructured<'a>) -> arbitrary::error::Result impl<'de> serde::de::Deserialize<'de> for psbt_v2::v0::bitcoin::raw::Key pub fn psbt_v2::v0::bitcoin::raw::Key::deserialize<__D>(__deserializer: __D) -> core::result::Result::Error> where __D: serde::de::Deserializer<'de> impl core::convert::TryFrom for psbt_v2::v0::bitcoin::raw::ProprietaryKey where Subtype: core::marker::Copy + core::convert::From + core::convert::Into @@ -347,6 +349,8 @@ pub psbt_v2::v0::bitcoin::raw::ProprietaryKey::prefix: alloc::vec::Vec pub psbt_v2::v0::bitcoin::raw::ProprietaryKey::subtype: Subtype impl psbt_v2::v0::bitcoin::raw::ProprietaryKey where Subtype: core::marker::Copy + core::convert::From + core::convert::Into pub fn psbt_v2::v0::bitcoin::raw::ProprietaryKey::to_key(&self) -> psbt_v2::v0::bitcoin::raw::Key +impl<'a> arbitrary::Arbitrary<'a> for psbt_v2::v0::bitcoin::raw::ProprietaryKey +pub fn psbt_v2::v0::bitcoin::raw::ProprietaryKey::arbitrary(u: &mut arbitrary::unstructured::Unstructured<'a>) -> arbitrary::error::Result impl<'de, Subtype> serde::de::Deserialize<'de> for psbt_v2::v0::bitcoin::raw::ProprietaryKey where Subtype: core::marker::Copy + core::convert::From + core::convert::Into + serde::de::Deserialize<'de> pub fn psbt_v2::v0::bitcoin::raw::ProprietaryKey::deserialize<__D>(__deserializer: __D) -> core::result::Result::Error> where __D: serde::de::Deserializer<'de> impl bitcoin::consensus::encode::Decodable for psbt_v2::v0::bitcoin::raw::ProprietaryKey where Subtype: core::marker::Copy + core::convert::From + core::convert::Into diff --git a/src/v0/bitcoin/raw.rs b/src/v0/bitcoin/raw.rs index 06bd449..9f35548 100644 --- a/src/v0/bitcoin/raw.rs +++ b/src/v0/bitcoin/raw.rs @@ -196,3 +196,21 @@ where Ok(deserialize(&key.key)?) } } + +#[cfg(feature = "arbitrary")] +impl<'a> arbitrary::Arbitrary<'a> for ProprietaryKey { + fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { + Ok(ProprietaryKey { + prefix: Vec::::arbitrary(u)?, + subtype: u8::arbitrary(u)?, + key: Vec::::arbitrary(u)?, + }) + } +} + +#[cfg(feature = "arbitrary")] +impl<'a> arbitrary::Arbitrary<'a> for Key { + fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { + Ok(Key { type_value: u.arbitrary()?, key: Vec::::arbitrary(u)? }) + } +}