Skip to content

Commit 628de85

Browse files
authored
Merge pull request #231 from sanket1729/add_inners
[descriptors] Expose inner
2 parents c3764be + b989511 commit 628de85

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "miniscript"
3-
version = "5.0.1"
3+
version = "5.0.2"
44
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>, Sanket Kanjalkar <sanket1729@gmail.com>"]
55
repository = "https://github.com/apoelstra/miniscript"
66
description = "Miniscript: a subset of Bitcoin Script designed for analysis"

src/descriptor/bare.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
5252
Ok(Self { ms: ms })
5353
}
5454

55+
/// get the inner
56+
pub fn into_inner(self) -> Miniscript<Pk, BareCtx> {
57+
self.ms
58+
}
59+
5560
/// get the inner
5661
pub fn as_inner(&self) -> &Miniscript<Pk, BareCtx> {
5762
&self.ms
@@ -211,10 +216,15 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
211216
Self { pk: pk }
212217
}
213218

214-
/// Get the inner key
219+
/// Get a reference to the inner key
215220
pub fn as_inner(&self) -> &Pk {
216221
&self.pk
217222
}
223+
224+
/// Get the inner key
225+
pub fn into_inner(self) -> Pk {
226+
self.pk
227+
}
218228
}
219229

220230
impl<Pk: MiniscriptKey> fmt::Debug for Pkh<Pk> {

src/descriptor/segwitv0.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ pub struct Wsh<Pk: MiniscriptKey> {
4141
}
4242

4343
impl<Pk: MiniscriptKey> Wsh<Pk> {
44+
/// Get the Inner
45+
pub fn into_inner(self) -> WshInner<Pk> {
46+
self.inner
47+
}
48+
49+
/// Get a reference to inner
50+
pub fn as_inner(&self) -> &WshInner<Pk> {
51+
&self.inner
52+
}
53+
4454
/// Create a new wsh descriptor
4555
pub fn new(ms: Miniscript<Pk, Segwitv0>) -> Result<Self, Error> {
4656
// do the top-level checks
@@ -59,11 +69,6 @@ impl<Pk: MiniscriptKey> Wsh<Pk> {
5969
})
6070
}
6171

62-
/// Get the inner key
63-
pub fn as_inner(&self) -> &WshInner<Pk> {
64-
&self.inner
65-
}
66-
6772
/// Get the descriptor without the checksum
6873
pub fn to_string_no_checksum(&self) -> String {
6974
match self.inner {
@@ -294,6 +299,11 @@ impl<Pk: MiniscriptKey> Wpkh<Pk> {
294299
}
295300
}
296301

302+
/// Get the inner key
303+
pub fn into_inner(self) -> Pk {
304+
self.pk
305+
}
306+
297307
/// Get the inner key
298308
pub fn as_inner(&self) -> &Pk {
299309
&self.pk

src/descriptor/sh.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub struct Sh<Pk: MiniscriptKey> {
4646

4747
/// Sh Inner
4848
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq)]
49-
enum ShInner<Pk: MiniscriptKey> {
49+
pub enum ShInner<Pk: MiniscriptKey> {
5050
/// Nested Wsh
5151
Wsh(Wsh<Pk>),
5252
/// Nested Wpkh
@@ -139,6 +139,16 @@ where
139139
}
140140

141141
impl<Pk: MiniscriptKey> Sh<Pk> {
142+
/// Get the Inner
143+
pub fn into_inner(self) -> ShInner<Pk> {
144+
self.inner
145+
}
146+
147+
/// Get a reference to inner
148+
pub fn as_inner(&self) -> &ShInner<Pk> {
149+
&self.inner
150+
}
151+
142152
/// Create a new p2sh descriptor with the raw miniscript
143153
pub fn new(ms: Miniscript<Pk, Legacy>) -> Result<Self, Error> {
144154
// do the top-level checks

0 commit comments

Comments
 (0)