Created
November 2, 2020 10:43
-
-
Save sanket1729/7cc1392c27a43d5580edeee2f33d835f to your computer and use it in GitHub Desktop.
Sorted Multi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] | |
pub struct SortedMultiVec<Pk: MiniscriptKey, Ctx: ScriptContext>{ | |
/// public keys inside sorted Multi | |
pub pks: Vec<Pk>, | |
/// The current ScriptContext for sortedmulti | |
pub(crate) phantom: PhantomData<Ctx> | |
} | |
impl SortedMultiVec{ | |
fn new(pks: &[Pk]) -> Result<Self, Error>{ | |
// Check the limits before creating a new SortedMultiVec | |
// For example, under p2sh context the scriptlen can only be | |
// upto 520 bytes. | |
let ms = Miniscript::from_ast(Terminal::Multi(Vec::from(pks))); | |
// This would check all the consensus rules for p2sh/p2wsh and | |
// even tapscript in future | |
Ctx::check_frag_validity(&ms)?; | |
// Create new self | |
} | |
} | |
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] | |
pub enum Descriptor<Pk: MiniscriptKey> { | |
/// Sorted Multi under P2SH | |
ShSortedMulti(SortedMultiVec<Pk, Legacy>), | |
/// Sorted Multi under P2WSH | |
WshSortedMulti(SortedMultiVec<Pk, Segwitv0>), | |
/// Sorted Multi under P2SH-P2WSH | |
ShWshSortedMulti(SortedMultiVec<Pk, Segwitv0>), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment