Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,8 @@ impl error::Error for Error {
}

#[doc(hidden)]
impl<Pk, Ctx> From<miniscript::types::Error<Pk, Ctx>> for Error
where
Pk: MiniscriptKey,
Ctx: ScriptContext,
{
fn from(e: miniscript::types::Error<Pk, Ctx>) -> Error { Error::TypeCheck(e.to_string()) }
impl From<miniscript::types::Error> for Error {
fn from(e: miniscript::types::Error) -> Error { Error::TypeCheck(e.to_string()) }
}

#[doc(hidden)]
Expand Down
20 changes: 10 additions & 10 deletions src/miniscript/types/extra_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ impl Property for ExtData {
fn type_check_with_child<Pk, Ctx, C>(
_fragment: &Terminal<Pk, Ctx>,
mut _child: C,
) -> Result<Self, Error<Pk, Ctx>>
) -> Result<Self, Error>
where
C: FnMut(usize) -> Self,
Pk: MiniscriptKey,
Expand All @@ -871,13 +871,13 @@ impl Property for ExtData {

/// Compute the type of a fragment assuming all the children of
/// Miniscript have been computed already.
fn type_check<Pk, Ctx>(fragment: &Terminal<Pk, Ctx>) -> Result<Self, Error<Pk, Ctx>>
fn type_check<Pk, Ctx>(fragment: &Terminal<Pk, Ctx>) -> Result<Self, Error>
where
Ctx: ScriptContext,
Pk: MiniscriptKey,
{
let wrap_err = |result: Result<Self, ErrorKind>| {
result.map_err(|kind| Error { fragment: fragment.clone(), error: kind })
result.map_err(|kind| Error { fragment_string: fragment.to_string(), error: kind })
};

let ret = match *fragment {
Expand All @@ -888,13 +888,13 @@ impl Property for ExtData {
Terminal::Multi(k, ref pks) | Terminal::MultiA(k, ref pks) => {
if k == 0 {
return Err(Error {
fragment: fragment.clone(),
fragment_string: fragment.to_string(),
error: ErrorKind::ZeroThreshold,
});
}
if k > pks.len() {
return Err(Error {
fragment: fragment.clone(),
fragment_string: fragment.to_string(),
error: ErrorKind::OverThreshold(k, pks.len()),
});
}
Expand All @@ -910,7 +910,7 @@ impl Property for ExtData {
// only consumes 4 bytes from the stack.
if t == absolute::LockTime::ZERO.into() {
return Err(Error {
fragment: fragment.clone(),
fragment_string: fragment.to_string(),
error: ErrorKind::InvalidTime,
});
}
Expand All @@ -919,7 +919,7 @@ impl Property for ExtData {
Terminal::Older(t) => {
if t == Sequence::ZERO || !t.is_relative_lock_time() {
return Err(Error {
fragment: fragment.clone(),
fragment_string: fragment.to_string(),
error: ErrorKind::InvalidTime,
});
}
Expand Down Expand Up @@ -975,20 +975,20 @@ impl Property for ExtData {
Terminal::Thresh(k, ref subs) => {
if k == 0 {
return Err(Error {
fragment: fragment.clone(),
fragment_string: fragment.to_string(),
error: ErrorKind::ZeroThreshold,
});
}
if k > subs.len() {
return Err(Error {
fragment: fragment.clone(),
fragment_string: fragment.to_string(),
error: ErrorKind::OverThreshold(k, subs.len()),
});
}

let res = Self::threshold(k, subs.len(), |n| Ok(subs[n].ext));

res.map_err(|kind| Error { fragment: fragment.clone(), error: kind })
res.map_err(|kind| Error { fragment_string: fragment.to_string(), error: kind })
}
};
if let Ok(ref ret) = ret {
Expand Down
Loading