Skip to content

Enable edition 2018 #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 2, 2022
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
9 changes: 1 addition & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
strategy:
matrix:
rust:
- 1.29.0
- 1.41.1
- beta
steps:
- name: Checkout Crate
Expand All @@ -65,13 +65,6 @@ jobs:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Pin deps if rust 1.29
if: matrix.rust == '1.29.0'
run: |
cargo generate-lockfile --verbose && \
cargo update --verbose --package "cc" --precise "1.0.41" && \
cargo update --verbose --package "serde" --precise "1.0.98" && \
cargo update --verbose --package "serde_derive" --precise "1.0.98"
- name: Running cargo
run: ./contrib/test.sh

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repository = "https://github.com/rust-bitcoin/rust-miniscript/"
description = "Miniscript: a subset of Bitcoin Script designed for analysis"
keywords = [ "crypto", "bitcoin"]
readme = "README.md"
edition = "2018"

[features]
compiler = []
Expand Down
22 changes: 2 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
![Build](https://github.com/rust-bitcoin/rust-miniscript/workflows/Continuous%20integration/badge.svg)

**Minimum Supported Rust Version:** 1.29.0

*This crate uses "2015" edition and won't be ported over "2018" edition
in the near future as this will change the MSRV to 1.31.*
**Minimum Supported Rust Version:** 1.41.1

# Miniscript

Expand Down Expand Up @@ -36,22 +33,7 @@ or in [the `examples/` directory](https://github.com/apoelstra/rust-miniscript/t


## Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on **Rust 1.29**.

Because some dependencies have broken the build in minor/patch releases, to compile with 1.29.0 you will need to
generate the lockfile and run the following version-pinning command:
```
cargo generate-lockfile --verbose
cargo update -p cc --precise "1.0.41" --verbose
```

In order to use the `use-serde` feature or to build the unit tests with 1.29.0,
the following version-pinning commands are also needed:
```
cargo update --package "serde" --precise "1.0.98"
cargo update --package "serde_derive" --precise "1.0.98"
```

This library should always compile with any combination of features on **Rust 1.41.1**.

## Contributing
Contributions are generally welcome. If you intend to make larger changes please
Expand Down
4 changes: 2 additions & 2 deletions examples/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

//! Example: Parsing a descriptor from a string
extern crate bitcoin;
extern crate miniscript;
use bitcoin;
use miniscript;

use miniscript::{descriptor::DescriptorType, Descriptor, DescriptorTrait};
use std::str::FromStr;
Expand Down
3 changes: 1 addition & 2 deletions examples/psbt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate bitcoin;
extern crate miniscript;
use bitcoin;

use bitcoin::consensus::encode::deserialize;
use bitcoin::hashes::hex::FromHex;
Expand Down
4 changes: 2 additions & 2 deletions examples/sign_multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

//! Example: Signing a 2-of-3 multisignature
extern crate bitcoin;
extern crate miniscript;
use bitcoin;
use miniscript;

use bitcoin::blockdata::witness::Witness;
use bitcoin::secp256k1; // secp256k1 re-exported from rust-bitcoin
Expand Down
4 changes: 2 additions & 2 deletions examples/verify_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

//! Example: Verifying a signed transaction
extern crate bitcoin;
extern crate miniscript;
use bitcoin;
use miniscript;

use bitcoin::consensus::Decodable;
use bitcoin::util::sighash;
Expand Down
2 changes: 0 additions & 2 deletions examples/xpub_descriptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

//! Example: Parsing a xpub and getting address
extern crate miniscript;

use miniscript::bitcoin::{self, secp256k1};
use miniscript::{Descriptor, DescriptorPublicKey, DescriptorTrait, TranslatePk2};

Expand Down
2 changes: 1 addition & 1 deletion integration_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ miniscript = {path = "../"}

# Until 0.26 support is released on rust-bitcoincore-rpc
bitcoincore-rpc = {git = "https://github.com/sanket1729/rust-bitcoincore-rpc",rev = "1ee9a3e808815702ac1a4b974689fcb33b5648c3"}
bitcoin = {ver = "0.28.0-rc.1", features = ["rand"]}
bitcoin = { version = "0.28", features = ["rand"]}
log = "0.4"
rand = "0.8.4"
2 changes: 1 addition & 1 deletion integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bitcoincore_rpc::{Auth, Client, RpcApi};
mod test_cpp;
mod test_desc;
mod test_util;
use test_util::TestData;
use crate::test_util::TestData;

struct StdLogger;

Expand Down
10 changes: 5 additions & 5 deletions src/descriptor/bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use std::{fmt, str::FromStr};

use bitcoin::{self, blockdata::script, Script};

use expression::{self, FromTree};
use miniscript::context::ScriptContext;
use policy::{semantic, Liftable};
use util::{varint_len, witness_to_scriptsig};
use {
use crate::expression::{self, FromTree};
use crate::miniscript::context::ScriptContext;
use crate::policy::{semantic, Liftable};
use crate::util::{varint_len, witness_to_scriptsig};
use crate::{
BareCtx, Error, ForEach, ForEachKey, Miniscript, MiniscriptKey, Satisfier, ToPublicKey,
TranslatePk,
};
Expand Down
2 changes: 1 addition & 1 deletion src/descriptor/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::iter::FromIterator;

use Error;
use crate::Error;

const INPUT_CHARSET: &str = "0123456789()[],'/*abcdefgh@:$%{}IJKLMNOPQRSTUVWXYZ&+-.;<=>?!^_|~ijklmnopqrstuvwxyzABCDEFGH`#\"\\ ";
const CHECKSUM_CHARSET: &str = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
Expand Down
2 changes: 1 addition & 1 deletion src/descriptor/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bitcoin::{
XOnlyPublicKey, XpubIdentifier,
};

use {MiniscriptKey, ToPublicKey};
use crate::{MiniscriptKey, ToPublicKey};

/// The descriptor pubkey, either a single pubkey or an xpub.
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)]
Expand Down
18 changes: 9 additions & 9 deletions src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ use bitcoin::util::address::WitnessVersion;
use bitcoin::{self, secp256k1, Script};

use self::checksum::verify_checksum;
use expression;
use miniscript;
use miniscript::{Legacy, Miniscript, Segwitv0};
use {
use crate::expression;
use crate::miniscript;
use crate::miniscript::{Legacy, Miniscript, Segwitv0};
use crate::{
BareCtx, Error, ForEach, ForEachKey, MiniscriptKey, Satisfier, ToPublicKey, TranslatePk,
TranslatePk2,
};
Expand Down Expand Up @@ -870,23 +870,23 @@ mod tests {
use super::checksum::desc_checksum;
use super::tr::Tr;
use super::*;
use crate::descriptor::key::Wildcard;
use crate::descriptor::{DescriptorPublicKey, DescriptorSecretKey, DescriptorXKey, SinglePub};
use crate::hex_script;
use crate::{Descriptor, DummyKey, Error, Miniscript, Satisfier, TranslatePk2};
use bitcoin::blockdata::opcodes::all::{OP_CLTV, OP_CSV};
use bitcoin::blockdata::script::Instruction;
use bitcoin::blockdata::{opcodes, script};
use bitcoin::hashes::hex::{FromHex, ToHex};
use bitcoin::hashes::{hash160, sha256};
use bitcoin::util::bip32;
use bitcoin::{self, secp256k1, EcdsaSighashType, PublicKey};
use descriptor::key::Wildcard;
use descriptor::{DescriptorPublicKey, DescriptorSecretKey, DescriptorXKey, SinglePub};
use hex_script;
use std::cmp;
use std::collections::HashMap;
use std::str::FromStr;
use {Descriptor, DummyKey, Error, Miniscript, Satisfier, TranslatePk2};

#[cfg(feature = "compiler")]
use policy;
use crate::policy;

type StdDescriptor = Descriptor<PublicKey>;
const TEST_PK: &'static str =
Expand Down
4 changes: 2 additions & 2 deletions src/descriptor/pretaproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
use bitcoin::{self, Script};

use super::{checksum::verify_checksum, Bare, Pkh, Sh, Wpkh, Wsh};
use {expression, DescriptorTrait, Error, MiniscriptKey, Satisfier, ToPublicKey};
use crate::{expression, DescriptorTrait, Error, MiniscriptKey, Satisfier, ToPublicKey};

/// Script descriptor
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down Expand Up @@ -241,7 +241,7 @@ serde_string_impl_pk!(PreTaprootDescriptor, "a pre-taproot script descriptor");
pub(crate) mod traits {
use bitcoin::Script;

use {
use crate::{
descriptor::{Pkh, Sh, Wpkh, Wsh},
DescriptorTrait, MiniscriptKey, ToPublicKey,
};
Expand Down
10 changes: 5 additions & 5 deletions src/descriptor/segwitv0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use std::{fmt, str::FromStr};

use bitcoin::{self, Script};

use expression::{self, FromTree};
use miniscript::context::{ScriptContext, ScriptContextError};
use policy::{semantic, Liftable};
use util::varint_len;
use {
use crate::expression::{self, FromTree};
use crate::miniscript::context::{ScriptContext, ScriptContextError};
use crate::policy::{semantic, Liftable};
use crate::util::varint_len;
use crate::{
Error, ForEach, ForEachKey, Miniscript, MiniscriptKey, Satisfier, Segwitv0, ToPublicKey,
TranslatePk,
};
Expand Down
12 changes: 6 additions & 6 deletions src/descriptor/sh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use std::{fmt, str::FromStr};

use bitcoin::{self, blockdata::script, Script};

use expression::{self, FromTree};
use miniscript::context::ScriptContext;
use policy::{semantic, Liftable};
use push_opcode_size;
use util::{varint_len, witness_to_scriptsig};
use {
use crate::expression::{self, FromTree};
use crate::miniscript::context::ScriptContext;
use crate::policy::{semantic, Liftable};
use crate::push_opcode_size;
use crate::util::{varint_len, witness_to_scriptsig};
use crate::{
Error, ForEach, ForEachKey, Legacy, Miniscript, MiniscriptKey, Satisfier, Segwitv0,
ToPublicKey, TranslatePk,
};
Expand Down
12 changes: 7 additions & 5 deletions src/descriptor/sortedmulti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ use std::{fmt, marker::PhantomData, str::FromStr};

use bitcoin::blockdata::script;

use expression;
use miniscript::{
use crate::expression;
use crate::miniscript::{
self, context::ScriptContext, decode::Terminal, limits::MAX_PUBKEYS_PER_MULTISIG,
};
use policy;
use script_num_size;
use {errstr, Error, ForEach, ForEachKey, Miniscript, MiniscriptKey, Satisfier, ToPublicKey};
use crate::policy;
use crate::script_num_size;
use crate::{
errstr, Error, ForEach, ForEachKey, Miniscript, MiniscriptKey, Satisfier, ToPublicKey,
};

/// Contents of a "sortedmulti" descriptor
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down
25 changes: 11 additions & 14 deletions src/descriptor/tr.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Tapscript

use policy::semantic::Policy;
use policy::Liftable;
use util::{varint_len, witness_size};
use {DescriptorTrait, ForEach, ForEachKey, Satisfier, ToPublicKey, TranslatePk};
use crate::policy::semantic::Policy;
use crate::policy::Liftable;
use crate::util::{varint_len, witness_size};
use crate::{DescriptorTrait, ForEach, ForEachKey, Satisfier, ToPublicKey, TranslatePk};

use super::checksum::{desc_checksum, verify_checksum};
use crate::errstr;
use crate::expression::{self, FromTree};
use crate::miniscript::Miniscript;
use crate::Tap;
use crate::{Error, MiniscriptKey};
use bitcoin::blockdata::opcodes;
use bitcoin::util::taproot::{
LeafVersion, TaprootBuilder, TaprootBuilderError, TaprootSpendInfo, TAPROOT_CONTROL_BASE_SIZE,
TAPROOT_CONTROL_MAX_NODE_COUNT, TAPROOT_CONTROL_NODE_SIZE,
};
use bitcoin::{self, secp256k1, Script};
use errstr;
use expression::{self, FromTree};
use miniscript::Miniscript;
use std::cmp::{self, max};
use std::hash;
use std::sync::{Arc, Mutex};
use std::{fmt, str::FromStr};
use Tap;
use {Error, MiniscriptKey};

/// A Taproot Tree representation.
// Hidden leaves are not yet supported in descriptor spec. Conceptually, it should
Expand Down Expand Up @@ -309,10 +309,7 @@ impl<Pk: MiniscriptKey + ToPublicKey> Tr<Pk> {
/// would yield (2, A), (2, B), (2,C), (3, D), (3, E).
///
#[derive(Debug, Clone)]
pub struct TapTreeIter<'a, Pk: MiniscriptKey>
where
Pk: 'a,
{
pub struct TapTreeIter<'a, Pk: MiniscriptKey> {
stack: Vec<(u8, &'a TapTree<Pk>)>,
}

Expand Down Expand Up @@ -749,7 +746,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use ForEachKey;
use crate::ForEachKey;

#[test]
fn test_for_each() {
Expand Down
6 changes: 3 additions & 3 deletions src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

use std::str::FromStr;

use errstr;
use Error;
use crate::errstr;
use crate::Error;

use MAX_RECURSION_DEPTH;
use crate::MAX_RECURSION_DEPTH;

#[derive(Debug)]
/// A token of the form `x(...)` or `x`
Expand Down
6 changes: 3 additions & 3 deletions src/interpreter/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub enum Error {
/// Last byte of this signature isn't a standard sighash type
NonStandardSighash(Vec<u8>),
/// Miniscript error
Miniscript(::Error),
Miniscript(crate::Error),
/// MultiSig requires 1 extra zero element apart from the `k` signatures
MissingExtraZeroMultiSig,
/// Script abortion because of incorrect dissatisfaction for multisig.
Expand Down Expand Up @@ -173,8 +173,8 @@ impl From<bitcoin::SchnorrSigError> for Error {
}

#[doc(hidden)]
impl From<::Error> for Error {
fn from(e: ::Error) -> Error {
impl From<crate::Error> for Error {
fn from(e: crate::Error) -> Error {
Error::Miniscript(e)
}
}
Expand Down
Loading