Skip to content

Commit 5dad2d8

Browse files
committed
Constructing descriptors from inner types
1 parent 75ff627 commit 5dad2d8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/descriptor/mod.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,48 @@ pub enum Descriptor<Pk: MiniscriptKey> {
190190
Tr(Tr<Pk>),
191191
}
192192

193+
impl<Pk: MiniscriptKey> From<Bare<Pk>> for Descriptor<Pk> {
194+
#[inline]
195+
fn from(inner: Bare<Pk>) -> Self {
196+
Descriptor::Bare(inner)
197+
}
198+
}
199+
200+
impl<Pk: MiniscriptKey> From<Pkh<Pk>> for Descriptor<Pk> {
201+
#[inline]
202+
fn from(inner: Pkh<Pk>) -> Self {
203+
Descriptor::Pkh(inner)
204+
}
205+
}
206+
207+
impl<Pk: MiniscriptKey> From<Wpkh<Pk>> for Descriptor<Pk> {
208+
#[inline]
209+
fn from(inner: Wpkh<Pk>) -> Self {
210+
Descriptor::Wpkh(inner)
211+
}
212+
}
213+
214+
impl<Pk: MiniscriptKey> From<Sh<Pk>> for Descriptor<Pk> {
215+
#[inline]
216+
fn from(inner: Sh<Pk>) -> Self {
217+
Descriptor::Sh(inner)
218+
}
219+
}
220+
221+
impl<Pk: MiniscriptKey> From<Wsh<Pk>> for Descriptor<Pk> {
222+
#[inline]
223+
fn from(inner: Wsh<Pk>) -> Self {
224+
Descriptor::Wsh(inner)
225+
}
226+
}
227+
228+
impl<Pk: MiniscriptKey> From<Tr<Pk>> for Descriptor<Pk> {
229+
#[inline]
230+
fn from(inner: Tr<Pk>) -> Self {
231+
Descriptor::Tr(inner)
232+
}
233+
}
234+
193235
/// Descriptor Type of the descriptor
194236
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
195237
pub enum DescriptorType {

0 commit comments

Comments
 (0)