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
29 changes: 25 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ on: # yamllint disable-line rule:truthy
name: Continuous integration

jobs:
Prepare:
runs-on: ubuntu-24.04
outputs:
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Read nightly version"
id: read_toolchain
run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT

Stable: # 2 jobs, one per lock file.
name: Test - stable toolchain
runs-on: ubuntu-latest
Expand All @@ -33,6 +44,7 @@ jobs:

Nightly: # 2 jobs, one per lock file.
name: Test - nightly toolchain
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -47,7 +59,9 @@ jobs:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@nightly
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
Expand Down Expand Up @@ -79,6 +93,7 @@ jobs:

Lint:
name: Lint - nightly toolchain
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -93,7 +108,9 @@ jobs:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@nightly
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: "Install clippy"
run: rustup component add clippy
- name: "Set dependencies"
Expand Down Expand Up @@ -125,6 +142,7 @@ jobs:

Docsrs:
name: Docs - nightly toolchain
needs: Prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -139,7 +157,9 @@ jobs:
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@nightly
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
Expand Down Expand Up @@ -198,6 +218,7 @@ jobs:
run: ./contrib/integration_test.sh

Embedded:
needs: Prepare
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -208,7 +229,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
override: true
components: rust-src
target: thumbv7m-none-eabi
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
msrv = "1.56.1"
# plan API returns Self as an error type for an large-ish enum
large-error-threshold = 256
large-error-threshold = 512
1 change: 1 addition & 0 deletions nightly-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2025-03-21
2 changes: 1 addition & 1 deletion src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ impl Descriptor<DescriptorPublicKey> {
/// See [`at_derivation_index`] and `[derived_descriptor`] for more documentation.
///
/// [`at_derivation_index`]: Self::at_derivation_index
/// [`derived_descriptor`]: crate::DerivedDescriptor::derived_descriptor
/// [`derived_descriptor`]: crate::Descriptor::derived_descriptor
///
/// # Errors
///
Expand Down
6 changes: 3 additions & 3 deletions src/descriptor/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<Pk: MiniscriptKey> TapTree<Pk> {

/// Iterates over all miniscripts in DFS walk order compatible with the
/// PSBT requirements (BIP 371).
pub fn iter(&self) -> TapTreeIter<Pk> { TapTreeIter { stack: vec![(0, self)] } }
pub fn iter(&self) -> TapTreeIter<'_, Pk> { TapTreeIter { stack: vec![(0, self)] } }

// Helper function to translate keys
fn translate_helper<T, Q, E>(&self, t: &mut T) -> Result<TapTree<Q>, TranslateErr<E>>
Expand Down Expand Up @@ -196,7 +196,7 @@ impl<Pk: MiniscriptKey> Tr<Pk> {

/// Iterate over all scripts in merkle tree. If there is no script path, the iterator
/// yields [`None`]
pub fn iter_scripts(&self) -> TapTreeIter<Pk> {
pub fn iter_scripts(&self) -> TapTreeIter<'_, Pk> {
match self.tree {
Some(ref t) => t.iter(),
None => TapTreeIter { stack: vec![] },
Expand Down Expand Up @@ -565,7 +565,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Tr<Pk> {
}

// Helper function to parse string into miniscript tree form
fn parse_tr_tree(s: &str) -> Result<expression::Tree, Error> {
fn parse_tr_tree(s: &str) -> Result<expression::Tree<'_>, Error> {
expression::check_valid_chars(s)?;

if s.len() > 3 && &s[..3] == "tr(" && s.as_bytes()[s.len() - 1] == b')' {
Expand Down
2 changes: 1 addition & 1 deletion src/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub use tree::{
use crate::sync::Arc;
use crate::{Miniscript, MiniscriptKey, ScriptContext, Terminal};

impl<'a, Pk: MiniscriptKey, Ctx: ScriptContext> TreeLike for &'a Miniscript<Pk, Ctx> {
impl<Pk: MiniscriptKey, Ctx: ScriptContext> TreeLike for &'_ Miniscript<Pk, Ctx> {
fn as_node(&self) -> Tree<Self> {
use Terminal::*;
match self.node {
Expand Down
10 changes: 0 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,6 @@ where
T: Translator<P, Q, E>;
}

/// Either a key or keyhash, but both contain Pk
// pub struct ForEach<'a, Pk: MiniscriptKey>(&'a Pk);

// impl<'a, Pk: MiniscriptKey<Hash = Pk>> ForEach<'a, Pk> {
// /// Convenience method to avoid distinguishing between keys and hashes when these are the same type
// pub fn as_key(&self) -> &'a Pk {
// self.0
// }
// }

/// Trait describing the ability to iterate over every key
pub trait ForEachKey<Pk: MiniscriptKey> {
/// Run a predicate on every key in the descriptor, returning whether
Expand Down
14 changes: 4 additions & 10 deletions src/miniscript/analyzable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ use crate::{Miniscript, MiniscriptKey, ScriptContext, Terminal};
///
/// This allows parsing miniscripts if
/// 1. It is unsafe(does not require a digital signature to spend it)
/// 2. It contains a unspendable path because of either
/// a. Resource limitations
/// b. Timelock Mixing
/// 3. The script is malleable and thereby some of satisfaction weight
/// guarantees are not satisfied.
/// 2. It contains a unspendable path because of either resource limitations or timelock mixing.
/// 3. The script is malleable and thereby some of satisfaction weight guarantees are not satisfied.
/// 4. It has repeated public keys
/// 5. raw pkh fragments without the pk. This could be obtained when parsing miniscript from script
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
Expand Down Expand Up @@ -123,11 +120,8 @@ impl ExtParams {
/// Possible reasons Miniscript guarantees can fail
/// We currently mark Miniscript as Non-Analyzable if
/// 1. It is unsafe(does not require a digital signature to spend it)
/// 2. It contains a unspendable path because of either
/// a. Resource limitations
/// b. Timelock Mixing
/// 3. The script is malleable and thereby some of satisfaction weight
/// guarantees are not satisfied.
/// 2. It contains a unspendable path because of either resource limitations or timelock mixing.
/// 3. The script is malleable and thereby some of satisfaction weight guarantees are not satisfied.
/// 4. It has repeated publickeys
#[derive(Debug, PartialEq)]
pub enum AnalysisError {
Expand Down
4 changes: 2 additions & 2 deletions src/miniscript/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
/// Creates a new [Iter] iterator that will iterate over all [Miniscript] items within
/// AST by traversing its branches. For the specific algorithm please see
/// [Iter::next] function.
pub fn iter(&self) -> Iter<Pk, Ctx> { Iter::new(self) }
pub fn iter(&self) -> Iter<'_, Pk, Ctx> { Iter::new(self) }

/// Creates a new [PkIter] iterator that will iterate over all plain public keys (and not
/// key hash values) present in [Miniscript] items within AST by traversing all its branches.
/// For the specific algorithm please see [PkIter::next] function.
pub fn iter_pk(&self) -> PkIter<Pk, Ctx> { PkIter::new(self) }
pub fn iter_pk(&self) -> PkIter<'_, Pk, Ctx> { PkIter::new(self) }

/// Enumerates all child nodes of the current AST node (`self`) and returns a `Vec` referencing
/// them.
Expand Down
2 changes: 1 addition & 1 deletion src/miniscript/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'s> TokenIter<'s> {
pub fn new(v: Vec<Token<'s>>) -> TokenIter<'s> { TokenIter(v) }

/// Look at the top at Iterator
pub fn peek(&self) -> Option<&'s Token> { self.0.last() }
pub fn peek(&self) -> Option<&'s Token<'_>> { self.0.last() }

/// Push a value to the iterator
/// This will be first value consumed by popun_
Expand Down
4 changes: 2 additions & 2 deletions src/miniscript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl<Ctx: ScriptContext> Miniscript<Ctx::Key, Ctx> {
/// The type information and extra properties are implied by the AST.
impl<Pk: MiniscriptKey, Ctx: ScriptContext> PartialOrd for Miniscript<Pk, Ctx> {
fn partial_cmp(&self, other: &Miniscript<Pk, Ctx>) -> Option<cmp::Ordering> {
Some(self.node.cmp(&other.node))
Some(self.cmp(other))
}
}

Expand Down Expand Up @@ -551,7 +551,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
///
/// Returns the fragment name (right of the `:`) and a list of wrappers
/// (left of the `:`).
fn split_expression_name(name: &str) -> Result<(&str, Cow<str>), Error> {
fn split_expression_name(name: &str) -> Result<(&str, Cow<'_, str>), Error> {
let mut aliased_wrap;
let frag_name;
let frag_wrap;
Expand Down
4 changes: 2 additions & 2 deletions src/miniscript/satisfy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl_satisfier_for_map_hash_tapleafhash_to_key_taproot_sig! {
impl Satisfier<Pk> for HashMap<(hash160::Hash, TapLeafHash), (Pk, bitcoin::taproot::Signature)>
}

impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'a S {
impl<Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'_ S {
fn lookup_ecdsa_sig(&self, p: &Pk) -> Option<bitcoin::ecdsa::Signature> {
(**self).lookup_ecdsa_sig(p)
}
Expand Down Expand Up @@ -319,7 +319,7 @@ impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'
fn check_after(&self, n: absolute::LockTime) -> bool { (**self).check_after(n) }
}

impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'a mut S {
impl<Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'_ mut S {
fn lookup_ecdsa_sig(&self, p: &Pk) -> Option<bitcoin::ecdsa::Signature> {
(**self).lookup_ecdsa_sig(p)
}
Expand Down
11 changes: 4 additions & 7 deletions src/policy/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,13 +671,10 @@ fn insert_elem<Pk: MiniscriptKey, Ctx: ScriptContext>(
// Check whether the new element is worse than any existing element. If there
// is an element which is a subtype of the current element and has better
// cost, don't consider this element.
let is_worse = map
.iter()
.map(|(existing_key, existing_elem)| {
let existing_elem_cost = existing_elem.cost_1d(sat_prob, dissat_prob);
existing_key.is_subtype(elem_key) && existing_elem_cost <= elem_cost
})
.any(|x| x);
let is_worse = map.iter().any(|(existing_key, existing_elem)| {
let existing_elem_cost = existing_elem.cost_1d(sat_prob, dissat_prob);
existing_key.is_subtype(elem_key) && existing_elem_cost <= elem_cost
});
if !is_worse {
// If the element is not worse any element in the map, remove elements
// whose subtype is the current element and have worse cost.
Expand Down
2 changes: 1 addition & 1 deletion src/policy/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ fn generate_combination<Pk: MiniscriptKey>(
ret
}

impl<'a, Pk: MiniscriptKey> TreeLike for &'a Policy<Pk> {
impl<Pk: MiniscriptKey> TreeLike for &'_ Policy<Pk> {
fn as_node(&self) -> Tree<Self> {
use Policy::*;

Expand Down
2 changes: 1 addition & 1 deletion src/policy/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
}
}

impl<'a, Pk: MiniscriptKey> TreeLike for &'a Policy<Pk> {
impl<Pk: MiniscriptKey> TreeLike for &'_ Policy<Pk> {
fn as_node(&self) -> Tree<Self> {
use Policy::*;

Expand Down
2 changes: 1 addition & 1 deletion src/primitives/threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl<T, const MAX: usize> Threshold<T, MAX> {
pub fn into_data(self) -> Vec<T> { self.inner }

/// Passthrough to an iterator on the underlying vector.
pub fn iter(&self) -> core::slice::Iter<T> { self.inner.iter() }
pub fn iter(&self) -> core::slice::Iter<'_, T> { self.inner.iter() }
}

impl<T> Threshold<T, 0> {
Expand Down
Loading