Skip to content

Commit 1a22725

Browse files
committed
Remove generic in Pegin descriptor for fed_desc
Since the `Pk` generic on `fed_desc` is the same as in `elem_desc` this binds the kind of user descriptor accepted. `fed_desc` always come in the form with `PublicKey`, thus by removing the generic we can support different `elem_desc`.
1 parent d3037cc commit 1a22725

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/descriptor/pegin/dynafed_pegin.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::convert::TryFrom;
2424
use std::fmt;
2525

2626
use bitcoin::blockdata::script::{self, PushBytes};
27-
use bitcoin::{self, ScriptBuf as BtcScript, Weight};
27+
use bitcoin::{self, PublicKey, ScriptBuf as BtcScript, Weight};
2828
use elements::secp256k1_zkp;
2929

3030
use crate::descriptor::checksum::{self, verify_checksum};
@@ -41,7 +41,7 @@ use crate::{
4141
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq)]
4242
pub struct Pegin<Pk: MiniscriptKey> {
4343
/// The untweaked pegin bitcoin descriptor
44-
pub fed_desc: BtcDescriptor<Pk>,
44+
pub fed_desc: BtcDescriptor<PublicKey>,
4545
/// The redeem elements descriptor
4646
///
4747
/// TODO: Allow pegin redeem descriptor with extensions
@@ -51,7 +51,7 @@ pub struct Pegin<Pk: MiniscriptKey> {
5151
impl<Pk: MiniscriptKey> Pegin<Pk> {
5252
/// Create a new LegacyPegin descriptor
5353
pub fn new(
54-
fed_desc: BtcDescriptor<Pk>,
54+
fed_desc: BtcDescriptor<PublicKey>,
5555
elem_desc: Descriptor<Pk, CovenantExt<CovExtArgs>>,
5656
) -> Self {
5757
Self {
@@ -76,15 +76,15 @@ impl<Pk: MiniscriptKey> fmt::Display for Pegin<Pk> {
7676
}
7777
}
7878

79-
impl<Pk: MiniscriptKey> Liftable<Pk> for Pegin<Pk> {
80-
fn lift(&self) -> Result<semantic::Policy<Pk>, Error> {
79+
impl<Pk: MiniscriptKey> Liftable<PublicKey> for Pegin<Pk> {
80+
fn lift(&self) -> Result<semantic::Policy<PublicKey>, Error> {
8181
let btc_pol = BtcLiftable::lift(&self.fed_desc)?;
8282
Liftable::lift(&btc_pol)
8383
}
8484
}
8585

86-
impl<Pk: MiniscriptKey> BtcLiftable<Pk> for Pegin<Pk> {
87-
fn lift(&self) -> Result<BtcPolicy<Pk>, BtcError> {
86+
impl<Pk: MiniscriptKey> BtcLiftable<PublicKey> for Pegin<Pk> {
87+
fn lift(&self) -> Result<BtcPolicy<PublicKey>, BtcError> {
8888
self.fed_desc.lift()
8989
}
9090
}
@@ -101,7 +101,7 @@ impl_from_tree!(
101101
// TODO: Confirm with Andrew about the descriptor type for dynafed
102102
// Assuming sh(wsh) for now.
103103

104-
let fed_desc = BtcDescriptor::<Pk>::from_tree(&ms_expr)?;
104+
let fed_desc = BtcDescriptor::<PublicKey>::from_tree(&ms_expr)?;
105105
let elem_desc = Descriptor::<Pk, CovenantExt<CovExtArgs>>::from_tree(&top.args[1])?;
106106
Ok(Pegin::new(fed_desc, elem_desc))
107107
} else {

0 commit comments

Comments
 (0)