Skip to content

Commit

Permalink
descriptors: rename DescriptorStd into StdDescr
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 18, 2023
1 parent 3b2227a commit a799eed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
31 changes: 15 additions & 16 deletions descriptors/src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub trait Descriptor<K = XpubDerivable, V = ()>: DeriveScripts {
)
)]
#[non_exhaustive]
pub enum DescriptorStd<S: DeriveSet = XpubDerivable> {
pub enum StdDescr<S: DeriveSet = XpubDerivable> {
/*
#[from]
Bare(Bare<S::Legacy>),
Expand Down Expand Up @@ -139,24 +139,23 @@ pub enum DescriptorStd<S: DeriveSet = XpubDerivable> {
*/
}

impl<S: DeriveSet> Derive<DerivedScript> for DescriptorStd<S> {
impl<S: DeriveSet> Derive<DerivedScript> for StdDescr<S> {
fn keychains(&self) -> Range<u8> {
match self {
DescriptorStd::Wpkh(d) => d.keychains(),
DescriptorStd::TrKey(d) => d.keychains(),
StdDescr::Wpkh(d) => d.keychains(),
StdDescr::TrKey(d) => d.keychains(),

Check warning on line 146 in descriptors/src/descriptor.rs

View check run for this annotation

Codecov / codecov/patch

descriptors/src/descriptor.rs#L145-L146

Added lines #L145 - L146 were not covered by tests
}
}

fn derive(&self, keychain: u8, index: impl Into<NormalIndex>) -> DerivedScript {
match self {
DescriptorStd::Wpkh(d) => d.derive(keychain, index),
DescriptorStd::TrKey(d) => d.derive(keychain, index),
StdDescr::Wpkh(d) => d.derive(keychain, index),
StdDescr::TrKey(d) => d.derive(keychain, index),

Check warning on line 153 in descriptors/src/descriptor.rs

View check run for this annotation

Codecov / codecov/patch

descriptors/src/descriptor.rs#L152-L153

Added lines #L152 - L153 were not covered by tests
}
}
}

impl<K: DeriveSet<Compr = K, XOnly = K> + DeriveCompr + DeriveXOnly> Descriptor<K>
for DescriptorStd<K>
impl<K: DeriveSet<Compr = K, XOnly = K> + DeriveCompr + DeriveXOnly> Descriptor<K> for StdDescr<K>
where Self: Derive<DerivedScript>
{
type KeyIter<'k> = vec::IntoIter<&'k K> where Self: 'k, K: 'k;
Expand All @@ -165,8 +164,8 @@ where Self: Derive<DerivedScript>

fn keys(&self) -> Self::KeyIter<'_> {
match self {
DescriptorStd::Wpkh(d) => d.keys().collect::<Vec<_>>(),
DescriptorStd::TrKey(d) => d.keys().collect::<Vec<_>>(),
StdDescr::Wpkh(d) => d.keys().collect::<Vec<_>>(),
StdDescr::TrKey(d) => d.keys().collect::<Vec<_>>(),

Check warning on line 168 in descriptors/src/descriptor.rs

View check run for this annotation

Codecov / codecov/patch

descriptors/src/descriptor.rs#L167-L168

Added lines #L167 - L168 were not covered by tests
}
.into_iter()
}
Expand All @@ -175,23 +174,23 @@ where Self: Derive<DerivedScript>

fn xpubs(&self) -> Self::XpubIter<'_> {
match self {
DescriptorStd::Wpkh(d) => d.xpubs().collect::<Vec<_>>(),
DescriptorStd::TrKey(d) => d.xpubs().collect::<Vec<_>>(),
StdDescr::Wpkh(d) => d.xpubs().collect::<Vec<_>>(),
StdDescr::TrKey(d) => d.xpubs().collect::<Vec<_>>(),

Check warning on line 178 in descriptors/src/descriptor.rs

View check run for this annotation

Codecov / codecov/patch

descriptors/src/descriptor.rs#L177-L178

Added lines #L177 - L178 were not covered by tests
}
.into_iter()
}

fn compr_keyset(&self, terminal: Terminal) -> IndexMap<CompressedPk, KeyOrigin> {
match self {
DescriptorStd::Wpkh(d) => d.compr_keyset(terminal),
DescriptorStd::TrKey(d) => d.compr_keyset(terminal),
StdDescr::Wpkh(d) => d.compr_keyset(terminal),
StdDescr::TrKey(d) => d.compr_keyset(terminal),

Check warning on line 186 in descriptors/src/descriptor.rs

View check run for this annotation

Codecov / codecov/patch

descriptors/src/descriptor.rs#L185-L186

Added lines #L185 - L186 were not covered by tests
}
}

fn xonly_keyset(&self, terminal: Terminal) -> IndexMap<XOnlyPk, TapDerivation> {
match self {
DescriptorStd::Wpkh(d) => d.xonly_keyset(terminal),
DescriptorStd::TrKey(d) => d.xonly_keyset(terminal),
StdDescr::Wpkh(d) => d.xonly_keyset(terminal),
StdDescr::TrKey(d) => d.xonly_keyset(terminal),

Check warning on line 193 in descriptors/src/descriptor.rs

View check run for this annotation

Codecov / codecov/patch

descriptors/src/descriptor.rs#L192-L193

Added lines #L192 - L193 were not covered by tests
}
}
}
2 changes: 1 addition & 1 deletion descriptors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mod multisig;
mod segwit;
mod taproot;

pub use descriptor::{Descriptor, DescriptorStd};
pub use descriptor::{Descriptor, StdDescr};
pub use factory::AddressFactory;
pub use segwit::Wpkh;
pub use taproot::TrKey;

0 comments on commit a799eed

Please sign in to comment.