diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 7ea77f17d..ec8b85daf 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -11,7 +11,7 @@ on: jobs: fuzz: if: ${{ !github.event.act }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -28,8 +28,8 @@ roundtrip_semantic, steps: - name: Install test dependencies run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 id: cache-fuzz with: path: | @@ -45,7 +45,7 @@ roundtrip_semantic, - name: fuzz run: cd fuzz && ./fuzz.sh "${{ matrix.fuzz_target }}" - run: echo "${{ matrix.fuzz_target }}" >executed_${{ matrix.fuzz_target }} - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: executed_${{ matrix.fuzz_target }} path: executed_${{ matrix.fuzz_target }} @@ -55,8 +55,8 @@ roundtrip_semantic, needs: fuzz runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 - name: Display structure of downloaded files run: ls -R - run: find executed_* -type f -exec cat {} + | sort > executed diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bdc2b76d0..0f48782fa 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,17 +3,29 @@ on: [push, pull_request] name: Continuous integration jobs: + Prepare: + runs-on: ubuntu-latest + 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 + Nightly: name: Nightly - Bench + Docs + Fmt + needs: Prepare runs-on: ubuntu-latest steps: - name: Checkout Crate - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: ${{ needs.Prepare.outputs.nightly_version }} override: true - name: Running benchmarks env: @@ -33,7 +45,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Crate - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: actions-rs/toolchain@v1 with: @@ -47,17 +59,18 @@ jobs: Tests: name: Tests + needs: Prepare runs-on: ubuntu-latest strategy: matrix: include: - rust: stable - rust: beta - - rust: nightly + - rust: ${{ needs.Prepare.outputs.nightly_version }} - rust: 1.48 steps: - name: Checkout Crate - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout Toolchain uses: actions-rs/toolchain@v1 with: @@ -71,17 +84,18 @@ jobs: run: ./contrib/test.sh Embedded: + needs: Prepare runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up QEMU run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi - name: Checkout Toolchain 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 @@ -89,4 +103,4 @@ jobs: env: RUSTFLAGS: "-C link-arg=-Tlink.x" CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER: "qemu-system-arm -cpu cortex-m3 -machine mps2-an385 -nographic -semihosting-config enable=on,target=native -kernel" - run: cd embedded && cargo run --target thumbv7m-none-eabi --release + run: cp Cargo-recent.lock Cargo.lock && cd embedded && cargo run --target thumbv7m-none-eabi --release diff --git a/Cargo-recent.lock b/Cargo-recent.lock new file mode 100644 index 000000000..ca851050d --- /dev/null +++ b/Cargo-recent.lock @@ -0,0 +1,561 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bech32" +version = "0.10.0-beta" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" + +[[package]] +name = "bitcoin" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae" +dependencies = [ + "base64 0.21.7", + "bech32", + "bitcoin-internals", + "bitcoin_hashes 0.13.0", + "core2", + "hex-conservative", + "hex_lit", + "secp256k1", + "serde", +] + +[[package]] +name = "bitcoin-internals" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" +dependencies = [ + "serde", +] + +[[package]] +name = "bitcoin-private" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" + +[[package]] +name = "bitcoin_hashes" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d7066118b13d4b20b23645932dfb3a81ce7e29f95726c2036fa33cd7b092501" +dependencies = [ + "bitcoin-private", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +dependencies = [ + "bitcoin-internals", + "core2", + "hex-conservative", + "serde", +] + +[[package]] +name = "bitcoincore-rpc" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb70725a621848c83b3809913d5314c0d20ca84877d99dd909504b564edab00" +dependencies = [ + "bitcoincore-rpc-json", + "jsonrpc", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "bitcoincore-rpc-json" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "856ffbee2e492c23bca715d72ea34aae80d58400f2bda26a82015d6bc2ec3662" +dependencies = [ + "bitcoin", + "serde", + "serde_json", +] + +[[package]] +name = "bitcoind" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2542fac51d8cd8fce6109f4a3ffd1acfdaa3394c36d4a8207af15b8b0540e2fc" +dependencies = [ + "anyhow", + "bitcoincore-rpc", + "log", + "tempfile", + "which", +] + +[[package]] +name = "bitcoind-tests" +version = "0.1.0" +dependencies = [ + "bitcoin-internals", + "bitcoind", + "miniscript", + "rand 0.8.5", + "secp256k1", +] + +[[package]] +name = "cc" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "core2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239fa3ae9b63c2dc74bd3fa852d4792b8b305ae64eeede946265b6af62f1fff3" +dependencies = [ + "memchr", +] + +[[package]] +name = "descriptor-fuzz" +version = "0.0.1" +dependencies = [ + "honggfuzz", + "miniscript", + "regex", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + +[[package]] +name = "hex-conservative" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" +dependencies = [ + "core2", +] + +[[package]] +name = "hex_lit" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd" + +[[package]] +name = "honggfuzz" +version = "0.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "848e9c511092e0daa0a35a63e8e6e475a3e8f870741448b9f6028d69b142f18e" +dependencies = [ + "lazy_static", + "memmap2", + "rustc_version", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "jsonrpc" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8128f36b47411cd3f044be8c1f5cc0c9e24d1d1bfdc45f0a57897b32513053f2" +dependencies = [ + "base64 0.13.1", + "serde", + "serde_json", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "log" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "memchr" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + +[[package]] +name = "miniscript" +version = "11.2.2" +dependencies = [ + "bech32", + "bitcoin", + "bitcoin-internals", + "secp256k1", + "serde", + "serde_test", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" + +[[package]] +name = "proc-macro2" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" + +[[package]] +name = "secp256k1" +version = "0.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" +dependencies = [ + "bitcoin_hashes 0.12.0", + "rand 0.8.5", + "secp256k1-sys", + "serde", +] + +[[package]] +name = "secp256k1-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" + +[[package]] +name = "serde" +version = "1.0.156" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.156" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f60a296fed15c3edbbe9aa83b646531459e565c525b0ab628deb1a4b28e4180" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_test" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "641666500e4e6fba7b91b73651a375cb53579468ab3c38389289b802797cad94" +dependencies = [ + "serde", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439d9a7c00f98b1b5ee730039bf5b1f9203d508690e3c76b509e7ad59f8f7c99" +dependencies = [ + "libc", + "rand 0.4.6", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "which" +version = "4.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" +dependencies = [ + "either", + "lazy_static", + "libc", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index e0f6d2267..f43189bdf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ base64 = ["bitcoin/base64"] [dependencies] bech32 = { version = "0.10.0-beta", default-features = false } bitcoin = { version = "0.31.0", default-features = false } -internals = { package = "bitcoin-internals", version = "0.2.0", default_features = false } +internals = { package = "bitcoin-internals", version = "0.2.0", default-features = false } # Do NOT use this as a feature! Use the `serde` feature instead. actual-serde = { package = "serde", version = "1.0.103", optional = true } @@ -65,3 +65,6 @@ required-features = ["std", "base64"] [workspace] members = ["bitcoind-tests", "fuzz"] exclude = ["embedded"] + +[lints.rust] +unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)'] } diff --git a/bitcoind-tests/Cargo.toml b/bitcoind-tests/Cargo.toml index 438ab9a8f..1e83dfd55 100644 --- a/bitcoind-tests/Cargo.toml +++ b/bitcoind-tests/Cargo.toml @@ -12,4 +12,4 @@ miniscript = {path = "../"} bitcoind = { version = "0.34.0" } actual-rand = { package = "rand", version = "0.8.4"} secp256k1 = {version = "0.28.0", features = ["rand-std"]} -internals = { package = "bitcoin-internals", version = "0.2.0", default_features = false } +internals = { package = "bitcoin-internals", version = "0.2.0", default-features = false } diff --git a/clippy.toml b/clippy.toml index 7ebfae606..65d93a510 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,3 +1,6 @@ msrv = "1.48.0" # plan API returns Self as an error type for an large-ish enum -large-error-threshold = 256 +large-error-threshold = 512 +# A couple tests have huge tuples instead of structs. This is fixed +# in a later major rev. For now we just turn down the lint. +type-complexity-threshold = 1000 diff --git a/contrib/test.sh b/contrib/test.sh index 4d9371fe8..baaa6aff0 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -17,72 +17,62 @@ fi if [ "$DO_FMT" = true ] then rustup component add rustfmt - cargo fmt -- --check + cargo fmt --check fi # Pin dependencies required to build with Rust 1.48.0 -if cargo --version | grep "1\.48\.0"; then - cargo update -p once_cell --precise 1.13.1 - cargo update -p quote --precise 1.0.28 - cargo update -p syn --precise 2.0.32 - cargo update -p proc-macro2 --precise 1.0.63 - cargo update -p serde_json --precise 1.0.99 - cargo update -p serde --precise 1.0.152 - cargo update -p log --precise 0.4.18 - cargo update -p serde_test --precise 1.0.152 - cargo update -p memchr --precise 2.5.0 -fi +cp Cargo-recent.lock Cargo.lock # Test bitcoind integration tests if told to (this only works with the stable toolchain) if [ "$DO_BITCOIND_TESTS" = true ]; then cd bitcoind-tests BITCOIND_EXE="$(git rev-parse --show-toplevel)/bitcoind-tests/bin/bitcoind" \ - cargo test --verbose + cargo --locked test --verbose # Exit integration tests, do not run other tests. exit 0 fi # Defaults / sanity checks -cargo test +cargo --locked test if [ "$DO_FEATURE_MATRIX" = true ] then # All features - cargo test --features="$FEATURES" + cargo --locked test --features="$FEATURES" # Single features for feature in ${FEATURES} do - cargo test --features="$feature" + cargo --locked test --features="$feature" done # Run all the examples - cargo build --examples - cargo run --example htlc --features=compiler - cargo run --example parse - cargo run --example sign_multisig - cargo run --example verify_tx > /dev/null - cargo run --example xpub_descriptors - cargo run --example taproot --features=compiler - cargo run --example psbt_sign_finalize --features=base64 + cargo --locked build --examples + cargo --locked run --example htlc --features=compiler + cargo --locked run --example parse + cargo --locked run --example sign_multisig + cargo --locked run --example verify_tx > /dev/null + cargo --locked run --example xpub_descriptors + cargo --locked run --example taproot --features=compiler + cargo --locked run --example psbt_sign_finalize --features=base64 fi if [ "$DO_NO_STD" = true ] then # Build no_std, to make sure that cfg(test) doesn't hide any issues - cargo build --verbose --no-default-features --features="no-std" + cargo --locked build --verbose --no-default-features --features="no-std" # Test no_std - cargo test --verbose --no-default-features --features="no-std" + cargo --locked test --verbose --no-default-features --features="no-std" # Build all features - cargo build --verbose --no-default-features --features="no-std $FEATURES" + cargo --locked build --verbose --no-default-features --features="no-std $FEATURES" # Build specific features for feature in ${FEATURES} do - cargo build --verbose --no-default-features --features="no-std $feature" + cargo --locked build --verbose --no-default-features --features="no-std $feature" done fi @@ -97,7 +87,7 @@ then fi exit 1 fi - RUSTFLAGS='--cfg=bench' cargo bench + RUSTFLAGS='--cfg=bench' cargo --locked bench fi # Build the docs if told to (this only works with the nightly toolchain) diff --git a/examples/psbt_sign_finalize.rs b/examples/psbt_sign_finalize.rs index c6974c50a..9f942466a 100644 --- a/examples/psbt_sign_finalize.rs +++ b/examples/psbt_sign_finalize.rs @@ -18,7 +18,7 @@ fn main() { let secp256k1 = secp256k1::Secp256k1::new(); let s = "wsh(t:or_c(pk(027a3565454fe1b749bccaef22aff72843a9c3efefd7b16ac54537a0c23f0ec0de),v:thresh(1,pkh(032d672a1a91cc39d154d366cd231983661b0785c7f27bc338447565844f4a6813),a:pkh(03417129311ed34c242c012cd0a3e0b9bca0065f742d0dfb63c78083ea6a02d4d9),a:pkh(025a687659658baeabdfc415164528065be7bcaade19342241941e556557f01e28))))#7hut9ukn"; - let bridge_descriptor = Descriptor::from_str(&s).unwrap(); + let bridge_descriptor = Descriptor::from_str(s).unwrap(); //let bridge_descriptor = Descriptor::::from_str(&s).expect("parse descriptor string"); assert!(bridge_descriptor.sanity_check().is_ok()); println!("Bridge pubkey script: {}", bridge_descriptor.script_pubkey()); @@ -80,10 +80,11 @@ fn main() { let (outpoint, witness_utxo) = get_vout(&depo_tx, &bridge_descriptor.script_pubkey()); - let mut txin = TxIn::default(); - txin.previous_output = outpoint; - - txin.sequence = Sequence::from_height(26); //Sequence::MAX; // + let txin = TxIn { + previous_output: outpoint, + sequence: Sequence::from_height(26), + ..TxIn::default() + }; psbt.unsigned_tx.input.push(txin); psbt.unsigned_tx.output.push(TxOut { @@ -132,7 +133,7 @@ fn main() { psbt.inputs[0] .partial_sigs - .insert(pk1, bitcoin::ecdsa::Signature { sig: sig1, hash_ty: hash_ty }); + .insert(pk1, bitcoin::ecdsa::Signature { sig: sig1, hash_ty }); println!("{:#?}", psbt); println!("{}", psbt); diff --git a/examples/sign_multisig.rs b/examples/sign_multisig.rs index 2c49828c0..89d3f4030 100644 --- a/examples/sign_multisig.rs +++ b/examples/sign_multisig.rs @@ -93,8 +93,8 @@ fn spending_transaction() -> bitcoin::Transaction { } } +#[rustfmt::skip] fn list_of_three_arbitrary_public_keys() -> Vec { - #[cfg_attr(feature="cargo-fmt", rustfmt_skip)] vec![ bitcoin::PublicKey::from_slice(&[2; 33]).expect("key 1"), bitcoin::PublicKey::from_slice(&[ diff --git a/examples/taproot.rs b/examples/taproot.rs index cb01539ac..430c2bf5f 100644 --- a/examples/taproot.rs +++ b/examples/taproot.rs @@ -136,8 +136,8 @@ fn hardcoded_xonlypubkeys() -> Vec { ], ]; let mut keys: Vec = vec![]; - for idx in 0..4 { - keys.push(XOnlyPublicKey::from_slice(&serialized_keys[idx][..]).unwrap()); + for key in &serialized_keys { + keys.push(XOnlyPublicKey::from_slice(key).unwrap()); } keys } diff --git a/examples/verify_tx.rs b/examples/verify_tx.rs index 9a41fb309..63fd9a93a 100644 --- a/examples/verify_tx.rs +++ b/examples/verify_tx.rs @@ -46,15 +46,12 @@ fn main() { for elem in interpreter.iter_assume_sigs() { // Don't bother checking signatures. - match elem.expect("no evaluation error") { - miniscript::interpreter::SatisfiedConstraint::PublicKey { key_sig } => { - let (key, sig) = key_sig - .as_ecdsa() - .expect("expected ecdsa sig, found schnorr sig"); - - println!("Signed with:\n key: {}\n sig: {}", key, sig); - } - _ => {} + if let Ok(miniscript::interpreter::SatisfiedConstraint::PublicKey { key_sig }) = elem { + let (key, sig) = key_sig + .as_ecdsa() + .expect("expected ecdsa sig, found schnorr sig"); + + println!("Signed with:\n key: {}\n sig: {}", key, sig); } } @@ -71,12 +68,9 @@ fn main() { let prevouts = sighash::Prevouts::All::(&[]); for elem in interpreter.iter(&secp, &tx, 0, &prevouts) { - match elem.expect("no evaluation error") { - miniscript::interpreter::SatisfiedConstraint::PublicKey { key_sig } => { - let (key, sig) = key_sig.as_ecdsa().unwrap(); - println!("Signed with:\n key: {}\n sig: {}", key, sig); - } - _ => {} + if let Ok(miniscript::interpreter::SatisfiedConstraint::PublicKey { key_sig }) = elem { + let (key, sig) = key_sig.as_ecdsa().unwrap(); + println!("Signed with:\n key: {}\n sig: {}", key, sig); } } @@ -104,9 +98,9 @@ fn main() { } /// Returns an arbitrary transaction. +#[rustfmt::skip] fn hard_coded_transaction() -> bitcoin::Transaction { // tx `f27eba163c38ad3f34971198687a3f1882b7ec818599ffe469a8440d82261c98` - #[cfg_attr(feature="cargo-fmt", rustfmt_skip)] let tx_bytes = vec![ 0x01, 0x00, 0x00, 0x00, 0x02, 0xc5, 0x11, 0x1d, 0xb7, 0x93, 0x50, 0xc1, 0x70, 0x28, 0x41, 0x39, 0xe8, 0xe3, 0x4e, 0xb0, 0xed, 0xba, 0x64, 0x7b, diff --git a/examples/xpub_descriptors.rs b/examples/xpub_descriptors.rs index 08f31ecee..90b0458f3 100644 --- a/examples/xpub_descriptors.rs +++ b/examples/xpub_descriptors.rs @@ -30,7 +30,7 @@ fn p2wsh(secp: &Secp256k1) -> Address { let address = Descriptor::::from_str(&s) .unwrap() - .derived_descriptor(&secp) + .derived_descriptor(secp) .unwrap() .address(Network::Bitcoin) .unwrap(); @@ -53,7 +53,7 @@ fn p2sh_p2wsh(secp: &Secp256k1) -> Address { let address = Descriptor::::from_str(&s) .unwrap() - .derived_descriptor(&secp, 5) + .derived_descriptor(secp, 5) .unwrap() .address(Network::Bitcoin) .unwrap(); diff --git a/nightly-version b/nightly-version new file mode 100644 index 000000000..ba747383d --- /dev/null +++ b/nightly-version @@ -0,0 +1 @@ +nightly-2025-03-21 diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index 1cd8852ab..c8bc4b771 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -1150,7 +1150,8 @@ mod test { DescriptorKeyParseError, DescriptorMultiXKey, DescriptorPublicKey, DescriptorSecretKey, MiniscriptKey, Wildcard, }; - use crate::{prelude::*, DefiniteDescriptorKey}; + use crate::prelude::*; + use crate::DefiniteDescriptorKey; #[test] fn parse_descriptor_key_errors() { diff --git a/src/descriptor/mod.rs b/src/descriptor/mod.rs index feea99161..a3215d59f 100644 --- a/src/descriptor/mod.rs +++ b/src/descriptor/mod.rs @@ -642,7 +642,7 @@ impl Descriptor { /// 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 /// @@ -804,7 +804,7 @@ impl Descriptor { /// /// For multipath descriptors it will return as many descriptors as there is /// "parallel" paths. For regular descriptors it will just return itself. - #[allow(clippy::blocks_in_if_conditions)] + #[allow(clippy::blocks_in_conditions)] pub fn into_single_descriptors(self) -> Result>, Error> { // All single-path descriptors contained in this descriptor. let mut descriptors = Vec::new(); @@ -1109,7 +1109,7 @@ mod tests { .push_opcode(opcodes::all::OP_DUP) .push_opcode(opcodes::all::OP_HASH160) .push_slice( - &hash160::Hash::from_str("84e9ed95a38613f0527ff685a9928abe2d4754d4",) + hash160::Hash::from_str("84e9ed95a38613f0527ff685a9928abe2d4754d4",) .unwrap() .to_byte_array() ) @@ -1133,7 +1133,7 @@ mod tests { script::Builder::new() .push_opcode(opcodes::all::OP_PUSHBYTES_0) .push_slice( - &hash160::Hash::from_str("84e9ed95a38613f0527ff685a9928abe2d4754d4",) + hash160::Hash::from_str("84e9ed95a38613f0527ff685a9928abe2d4754d4",) .unwrap() .to_byte_array() ) @@ -1155,7 +1155,7 @@ mod tests { script::Builder::new() .push_opcode(opcodes::all::OP_HASH160) .push_slice( - &hash160::Hash::from_str("f1c3b9a431134cb90a500ec06e0067cfa9b8bba7",) + hash160::Hash::from_str("f1c3b9a431134cb90a500ec06e0067cfa9b8bba7",) .unwrap() .to_byte_array() ) @@ -1178,7 +1178,7 @@ mod tests { script::Builder::new() .push_opcode(opcodes::all::OP_HASH160) .push_slice( - &hash160::Hash::from_str("aa5282151694d3f2f32ace7d00ad38f927a33ac8",) + hash160::Hash::from_str("aa5282151694d3f2f32ace7d00ad38f927a33ac8",) .unwrap() .to_byte_array() ) @@ -1201,7 +1201,7 @@ mod tests { script::Builder::new() .push_opcode(opcodes::all::OP_PUSHBYTES_0) .push_slice( - &sha256::Hash::from_str( + sha256::Hash::from_str( "\ f9379edc8983152dc781747830075bd5\ 3896e4b0ce5bff73777fd77d124ba085\ @@ -1228,7 +1228,7 @@ mod tests { script::Builder::new() .push_opcode(opcodes::all::OP_HASH160) .push_slice( - &hash160::Hash::from_str("4bec5d7feeed99e1d0a23fe32a4afe126a7ff07e",) + hash160::Hash::from_str("4bec5d7feeed99e1d0a23fe32a4afe126a7ff07e",) .unwrap() .to_byte_array() ) @@ -1323,7 +1323,7 @@ mod tests { previous_output: bitcoin::OutPoint::default(), script_sig: bitcoin::ScriptBuf::new(), sequence: Sequence::from_height(100), - witness: Witness::from_slice(&vec![sigser.clone(), pk.to_bytes(),]), + witness: Witness::from_slice(&[sigser.clone(), pk.to_bytes(),]), } ); assert_eq!(wpkh.unsigned_script_sig(), bitcoin::ScriptBuf::new()); @@ -1333,7 +1333,7 @@ mod tests { let redeem_script = script::Builder::new() .push_opcode(opcodes::all::OP_PUSHBYTES_0) .push_slice( - &hash160::Hash::from_str("d1b2a1faf62e73460af885c687dee3b7189cd8ab") + hash160::Hash::from_str("d1b2a1faf62e73460af885c687dee3b7189cd8ab") .unwrap() .to_byte_array(), ) @@ -1346,7 +1346,7 @@ mod tests { .push_slice(<&PushBytes>::try_from(redeem_script.as_bytes()).unwrap()) .into_script(), sequence: Sequence::from_height(100), - witness: Witness::from_slice(&vec![sigser.clone(), pk.to_bytes(),]), + witness: Witness::from_slice(&[sigser.clone(), pk.to_bytes(),]), } ); assert_eq!( @@ -1383,7 +1383,7 @@ mod tests { previous_output: bitcoin::OutPoint::default(), script_sig: bitcoin::ScriptBuf::new(), sequence: Sequence::from_height(100), - witness: Witness::from_slice(&vec![sigser.clone(), ms.encode().into_bytes(),]), + witness: Witness::from_slice(&[sigser.clone(), ms.encode().into_bytes(),]), } ); assert_eq!(wsh.unsigned_script_sig(), bitcoin::ScriptBuf::new()); @@ -1398,7 +1398,7 @@ mod tests { .push_slice(<&PushBytes>::try_from(ms.encode().to_p2wsh().as_bytes()).unwrap()) .into_script(), sequence: Sequence::from_height(100), - witness: Witness::from_slice(&vec![sigser.clone(), ms.encode().into_bytes(),]), + witness: Witness::from_slice(&[sigser.clone(), ms.encode().into_bytes(),]), } ); assert_eq!( diff --git a/src/descriptor/tr.rs b/src/descriptor/tr.rs index e4815d657..0209cc58d 100644 --- a/src/descriptor/tr.rs +++ b/src/descriptor/tr.rs @@ -127,7 +127,7 @@ impl TapTree { /// Iterates over all miniscripts in DFS walk order compatible with the /// PSBT requirements (BIP 371). - pub fn iter(&self) -> TapTreeIter { TapTreeIter { stack: vec![(0, self)] } } + pub fn iter(&self) -> TapTreeIter<'_, Pk> { TapTreeIter { stack: vec![(0, self)] } } // Helper function to translate keys fn translate_helper(&self, t: &mut T) -> Result, TranslateErr> @@ -194,7 +194,7 @@ impl Tr { /// Iterate over all scripts in merkle tree. If there is no script path, the iterator /// yields [`None`] - pub fn iter_scripts(&self) -> TapTreeIter { + pub fn iter_scripts(&self) -> TapTreeIter<'_, Pk> { match self.tree { Some(ref t) => t.iter(), None => TapTreeIter { stack: vec![] }, @@ -560,7 +560,7 @@ impl fmt::Display for Tr { } // Helper function to parse string into miniscript tree form -fn parse_tr_tree(s: &str) -> Result { +fn parse_tr_tree(s: &str) -> Result, Error> { expression::check_valid_chars(s)?; if s.len() > 3 && &s[..3] == "tr(" && s.as_bytes()[s.len() - 1] == b')' { diff --git a/src/interpreter/inner.rs b/src/interpreter/inner.rs index bae422b97..8383cb1e2 100644 --- a/src/interpreter/inner.rs +++ b/src/interpreter/inner.rs @@ -441,21 +441,21 @@ mod tests { KeyTestData { pk_spk: bitcoin::ScriptBuf::new_p2pk(&key), pkh_spk: bitcoin::ScriptBuf::new_p2pkh(&pkhash), - pk_sig: script::Builder::new().push_slice(&dummy_sig).into_script(), + pk_sig: script::Builder::new().push_slice(dummy_sig).into_script(), pkh_sig: script::Builder::new() - .push_slice(&dummy_sig) + .push_slice(dummy_sig) .push_key(&key) .into_script(), pkh_sig_justkey: script::Builder::new().push_key(&key).into_script(), wpkh_spk: wpkh_spk.clone(), - wpkh_stack: Witness::from_slice(&vec![dummy_sig_vec.clone(), key.to_bytes()]), - wpkh_stack_justkey: Witness::from_slice(&vec![key.to_bytes()]), + wpkh_stack: Witness::from_slice(&[dummy_sig_vec.clone(), key.to_bytes()]), + wpkh_stack_justkey: Witness::from_slice(&[key.to_bytes()]), sh_wpkh_spk: bitcoin::ScriptBuf::new_p2sh(&wpkh_scripthash), sh_wpkh_sig: script::Builder::new() .push_slice(<&PushBytes>::try_from(wpkh_spk[..].as_bytes()).unwrap()) .into_script(), - sh_wpkh_stack: Witness::from_slice(&vec![dummy_sig_vec, key.to_bytes()]), - sh_wpkh_stack_justkey: Witness::from_slice(&vec![key.to_bytes()]), + sh_wpkh_stack: Witness::from_slice(&[dummy_sig_vec, key.to_bytes()]), + sh_wpkh_stack_justkey: Witness::from_slice(&[key.to_bytes()]), } } } @@ -534,7 +534,7 @@ mod tests { assert_eq!(&err.to_string()[0..12], "parse error:"); // Witness is nonempty - let wit = Witness::from_slice(&vec![vec![]]); + let wit = Witness::from_slice(&[vec![]]); let err = from_txdata(&comp.pk_spk, &comp.pk_sig, &wit).unwrap_err(); assert_eq!(err.to_string(), "legacy spend had nonempty witness"); } @@ -583,7 +583,7 @@ mod tests { assert_eq!(script_code, Some(uncomp.pkh_spk.clone())); // Witness is nonempty - let wit = Witness::from_slice(&vec![vec![]]); + let wit = Witness::from_slice(&[vec![]]); let err = from_txdata(&comp.pkh_spk, &comp.pkh_sig, &wit).unwrap_err(); assert_eq!(err.to_string(), "legacy spend had nonempty witness"); } @@ -706,7 +706,7 @@ mod tests { assert_eq!(&err.to_string()[0..12], "parse error:"); // nonempty witness - let wit = Witness::from_slice(&vec![vec![]]); + let wit = Witness::from_slice(&[vec![]]); let err = from_txdata(&spk, &blank_script, &wit).unwrap_err(); assert_eq!(&err.to_string(), "legacy spend had nonempty witness"); } @@ -742,7 +742,7 @@ mod tests { assert_eq!(script_code, Some(redeem_script)); // nonempty witness - let wit = Witness::from_slice(&vec![vec![]]); + let wit = Witness::from_slice(&[vec![]]); let err = from_txdata(&spk, &script_sig, &wit).unwrap_err(); assert_eq!(&err.to_string(), "legacy spend had nonempty witness"); } @@ -753,7 +753,7 @@ mod tests { let hash = hash160::Hash::hash(&preimage[..]); let (miniscript, witness_script) = ms_inner_script(&format!("hash160({})", hash)); let wit_hash = sha256::Hash::hash(witness_script.as_bytes()).into(); - let wit_stack = Witness::from_slice(&vec![witness_script.to_bytes()]); + let wit_stack = Witness::from_slice(&[witness_script.to_bytes()]); let spk = ScriptBuf::new_p2wsh(&wit_hash); let blank_script = bitcoin::ScriptBuf::new(); @@ -763,7 +763,7 @@ mod tests { assert_eq!(&err.to_string(), "unexpected end of stack"); // with incorrect witness - let wit = Witness::from_slice(&vec![spk.to_bytes()]); + let wit = Witness::from_slice(&[spk.to_bytes()]); let err = from_txdata(&spk, &blank_script, &wit).unwrap_err(); assert_eq!(&err.to_string()[0..12], "parse error:"); @@ -788,7 +788,7 @@ mod tests { let hash = hash160::Hash::hash(&preimage[..]); let (miniscript, witness_script) = ms_inner_script(&format!("hash160({})", hash)); let wit_hash = sha256::Hash::hash(witness_script.as_bytes()).into(); - let wit_stack = Witness::from_slice(&vec![witness_script.to_bytes()]); + let wit_stack = Witness::from_slice(&[witness_script.to_bytes()]); let redeem_script = ScriptBuf::new_p2wsh(&wit_hash); let script_sig = script::Builder::new() @@ -808,7 +808,7 @@ mod tests { assert_eq!(&err.to_string(), "unexpected end of stack"); // with incorrect witness - let wit = Witness::from_slice(&vec![spk.to_bytes()]); + let wit = Witness::from_slice(&[spk.to_bytes()]); let err = from_txdata(&spk, &script_sig, &wit).unwrap_err(); assert_eq!(&err.to_string()[0..12], "parse error:"); diff --git a/src/iter/mod.rs b/src/iter/mod.rs index 553ae0f47..66ddc5c11 100644 --- a/src/iter/mod.rs +++ b/src/iter/mod.rs @@ -17,7 +17,7 @@ pub use tree::{ use crate::sync::Arc; use crate::{policy, Miniscript, MiniscriptKey, ScriptContext, Terminal}; -impl<'a, Pk: MiniscriptKey, Ctx: ScriptContext> TreeLike for &'a Miniscript { +impl TreeLike for &'_ Miniscript { fn as_node(&self) -> Tree { use Terminal::*; match self.node { @@ -69,7 +69,7 @@ impl TreeLike for Arc } } -impl<'a, Pk: MiniscriptKey> TreeLike for &'a policy::Concrete { +impl TreeLike for &'_ policy::Concrete { fn as_node(&self) -> Tree { use policy::Concrete::*; match *self { diff --git a/src/lib.rs b/src/lib.rs index 0f2fec080..de4bcba2c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -333,8 +333,8 @@ impl TranslateErr { /// - Legacy/Bare does not allow x_only keys /// - SegwitV0 does not allow uncompressed keys and x_only keys /// - Tapscript does not allow uncompressed keys - /// - Translating into multi-path descriptors should have same number of path - /// for all the keys in the descriptor + /// - Translating into multi-path descriptors should have same number of paths + /// for all the keys in the descriptor /// /// # Panics /// @@ -391,16 +391,6 @@ where T: Translator; } -/// Either a key or keyhash, but both contain Pk -// pub struct ForEach<'a, Pk: MiniscriptKey>(&'a Pk); - -// impl<'a, Pk: MiniscriptKey> 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 { /// Run a predicate on every key in the descriptor, returning whether diff --git a/src/miniscript/analyzable.rs b/src/miniscript/analyzable.rs index d56a6d388..cc71a4733 100644 --- a/src/miniscript/analyzable.rs +++ b/src/miniscript/analyzable.rs @@ -17,9 +17,7 @@ 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 +/// 2. It contains a unspendable path because of either resource limitation or timelock mixing. /// 3. The script is malleable and thereby some of satisfaction weight /// guarantees are not satisfied. /// 4. It has repeated public keys @@ -123,9 +121,7 @@ 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 +/// 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 diff --git a/src/miniscript/iter.rs b/src/miniscript/iter.rs index 1e8f016b7..5e7633c5a 100644 --- a/src/miniscript/iter.rs +++ b/src/miniscript/iter.rs @@ -18,12 +18,12 @@ impl Miniscript { /// 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 { 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 { 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. diff --git a/src/miniscript/lex.rs b/src/miniscript/lex.rs index c37ed6f74..dd778e400 100644 --- a/src/miniscript/lex.rs +++ b/src/miniscript/lex.rs @@ -75,7 +75,7 @@ impl<'s> TokenIter<'s> { pub fn new(v: Vec>) -> 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_ diff --git a/src/miniscript/mod.rs b/src/miniscript/mod.rs index a6b80d43b..5a38c5cc1 100644 --- a/src/miniscript/mod.rs +++ b/src/miniscript/mod.rs @@ -69,7 +69,6 @@ mod private { phantom: PhantomData, } impl Miniscript { - /// Add type information(Type and Extdata) to Miniscript based on /// `AstElem` fragment. Dependent on display and clone because of Error /// Display code of type_check. @@ -364,7 +363,7 @@ impl Miniscript { /// The type information and extra properties are implied by the AST. impl PartialOrd for Miniscript { fn partial_cmp(&self, other: &Miniscript) -> Option { - Some(self.node.cmp(&other.node)) + Some(self.cmp(other)) } } @@ -623,12 +622,11 @@ mod tests { use sync::Arc; use super::{Miniscript, ScriptContext, Segwitv0, Tap}; - use crate::miniscript::types; - use crate::miniscript::Terminal; + use crate::miniscript::{types, Terminal}; use crate::policy::Liftable; - use crate::{prelude::*, Error}; + use crate::prelude::*; use crate::test_utils::{StrKeyTranslator, StrXOnlyKeyTranslator}; - use crate::{hex_script, ExtParams, Satisfier, ToPublicKey, TranslatePk}; + use crate::{hex_script, Error, ExtParams, Satisfier, ToPublicKey, TranslatePk}; type Segwitv0Script = Miniscript; type Tapscript = Miniscript; diff --git a/src/miniscript/ms_tests.rs b/src/miniscript/ms_tests.rs index c357a6a64..19cd19026 100644 --- a/src/miniscript/ms_tests.rs +++ b/src/miniscript/ms_tests.rs @@ -68,7 +68,7 @@ mod tests { } #[test] - #[cfg_attr(feature="cargo-fmt", rustfmt_skip)] + #[rustfmt::skip] fn invalid_tests_from_alloy() { invalid_ms("or_b(or_i(0,sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(1))"); invalid_ms("or_b(s:pk_h(A),after(500000001))"); @@ -5646,7 +5646,7 @@ mod tests { invalid_ms("c:or_b(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),pk_k(A))"); } #[test] - #[cfg_attr(feature="cargo-fmt", rustfmt_skip)] + #[rustfmt::skip] fn mall_8f1e8_tests_from_alloy() { ms_test("or_d(or_d(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(500000001))", "Bf"); ms_test("andor(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),or_d(multi(2,A,B,C),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(1))", "B"); @@ -9143,7 +9143,7 @@ mod tests { } #[test] - #[cfg_attr(feature="cargo-fmt", rustfmt_skip)] + #[rustfmt::skip] fn main_tests_from_alloy() { ms_test("or_d(or_d(multi(2,A,B,C),or_d(multi(2,D,E,F),multi(2,G,I,J))),multi(2,K,L,M))", "Bdusem"); ms_test("andor(multi(2,A,B,C),or_d(multi(2,D,E,F),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),c:pk_h(G))", "Bdusem"); @@ -15044,7 +15044,7 @@ mod tests { } #[test] - #[cfg_attr(feature="cargo-fmt", rustfmt_skip)] + #[rustfmt::skip] fn malleable_tests_from_alloy() { ms_test("and_v(v:after(500000001),or_d(j:multi(2,A,B,C),multi(2,D,E,F)))", "usB"); ms_test("or_b(j:multi(2,A,B,C),a:andor(multi(2,D,E,F),multi(2,G,I,J),multi(2,K,L,M)))", "dBesu"); @@ -22076,8 +22076,8 @@ mod tests { // This does not actually test timelock mixing. See: https://github.com/rust-bitcoin/rust-miniscript/issues/514 // for details #[test] + #[rustfmt::skip] fn conflict_tests_from_alloy() { - #[cfg_attr(feature="cargo-fmt", rustfmt_skip)] { ms_test("andor(multi(2,A,B,C),andor(multi(2,D,E,F),after(500000001),n:after(1)),0)","Bedsm"); ms_test("and_v(v:after(500000001),or_d(multi(2,A,B,C),and_b(multi(2,D,E,F),a:after(1))))","Busm"); diff --git a/src/miniscript/satisfy.rs b/src/miniscript/satisfy.rs index 68ae90429..83de6bbb3 100644 --- a/src/miniscript/satisfy.rs +++ b/src/miniscript/satisfy.rs @@ -6,7 +6,7 @@ //! scriptpubkeys. //! -use core::{cmp, fmt, i64, mem}; +use core::{cmp, fmt, mem}; use bitcoin::hashes::hash160; use bitcoin::key::XOnlyPublicKey; @@ -268,7 +268,7 @@ impl_satisfier_for_map_hash_tapleafhash_to_key_taproot_sig! { impl Satisfier for HashMap<(hash160::Hash, TapLeafHash), (Pk, bitcoin::taproot::Signature)> } -impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier> Satisfier for &'a S { +impl> Satisfier for &'_ S { fn lookup_ecdsa_sig(&self, p: &Pk) -> Option { (**self).lookup_ecdsa_sig(p) } @@ -328,7 +328,7 @@ impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier> Satisfier for &' fn check_after(&self, n: absolute::LockTime) -> bool { (**self).check_after(n) } } -impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier> Satisfier for &'a mut S { +impl> Satisfier for &'_ mut S { fn lookup_ecdsa_sig(&self, p: &Pk) -> Option { (**self).lookup_ecdsa_sig(p) } diff --git a/src/miniscript/types/extra_props.rs b/src/miniscript/types/extra_props.rs index 0427e2c77..378e2d921 100644 --- a/src/miniscript/types/extra_props.rs +++ b/src/miniscript/types/extra_props.rs @@ -160,7 +160,7 @@ impl Property for ExtData { timelock_info: TimelockInfo::default(), exec_stack_elem_count_sat: Some(1), exec_stack_elem_count_dissat: None, - tree_height : 0, + tree_height: 0, } } @@ -176,7 +176,7 @@ impl Property for ExtData { timelock_info: TimelockInfo::default(), exec_stack_elem_count_sat: None, exec_stack_elem_count_dissat: Some(1), - tree_height : 0, + tree_height: 0, } } @@ -398,7 +398,7 @@ impl Property for ExtData { timelock_info: self.timelock_info, exec_stack_elem_count_sat: self.exec_stack_elem_count_sat, exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat, - tree_height : self.tree_height + 1, + tree_height: self.tree_height + 1, }) } @@ -414,7 +414,7 @@ impl Property for ExtData { timelock_info: self.timelock_info, exec_stack_elem_count_sat: self.exec_stack_elem_count_sat, exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat, - tree_height : self.tree_height + 1, + tree_height: self.tree_height + 1, }) } @@ -430,7 +430,7 @@ impl Property for ExtData { timelock_info: self.timelock_info, exec_stack_elem_count_sat: self.exec_stack_elem_count_sat, exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat, - tree_height : self.tree_height + 1, + tree_height: self.tree_height + 1, }) } @@ -449,7 +449,7 @@ impl Property for ExtData { // Even all V types push something onto the stack and then remove them exec_stack_elem_count_sat: self.exec_stack_elem_count_sat, exec_stack_elem_count_dissat: Some(1), - tree_height : self.tree_height + 1, + tree_height: self.tree_height + 1, }) } @@ -466,7 +466,7 @@ impl Property for ExtData { timelock_info: self.timelock_info, exec_stack_elem_count_sat: self.exec_stack_elem_count_sat, exec_stack_elem_count_dissat: None, - tree_height : self.tree_height + 1, + tree_height: self.tree_height + 1, }) } @@ -482,7 +482,7 @@ impl Property for ExtData { timelock_info: self.timelock_info, exec_stack_elem_count_sat: self.exec_stack_elem_count_sat, exec_stack_elem_count_dissat: Some(1), - tree_height : self.tree_height + 1, + tree_height: self.tree_height + 1, }) } @@ -499,7 +499,7 @@ impl Property for ExtData { // Technically max(1, self.exec_stack_elem_count_sat), same rationale as cast_dupif exec_stack_elem_count_sat: self.exec_stack_elem_count_sat, exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat, - tree_height : self.tree_height + 1, + tree_height: self.tree_height + 1, }) } @@ -540,7 +540,7 @@ impl Property for ExtData { l.exec_stack_elem_count_dissat, r.exec_stack_elem_count_dissat.map(|x| x + 1), ), - tree_height : cmp::max(l.tree_height, r.tree_height) + 1, + tree_height: cmp::max(l.tree_height, r.tree_height) + 1, }) } @@ -564,7 +564,7 @@ impl Property for ExtData { r.exec_stack_elem_count_sat, ), exec_stack_elem_count_dissat: None, - tree_height : cmp::max(l.tree_height, r.tree_height) + 1, + tree_height: cmp::max(l.tree_height, r.tree_height) + 1, }) } @@ -604,7 +604,7 @@ impl Property for ExtData { l.exec_stack_elem_count_dissat, r.exec_stack_elem_count_dissat.map(|x| x + 1), ), - tree_height : cmp::max(l.tree_height, r.tree_height) + 1, + tree_height: cmp::max(l.tree_height, r.tree_height) + 1, }) } @@ -642,7 +642,7 @@ impl Property for ExtData { l.exec_stack_elem_count_dissat, r.exec_stack_elem_count_dissat.map(|x| x + 1), ), - tree_height : cmp::max(l.tree_height, r.tree_height) + 1, + tree_height: cmp::max(l.tree_height, r.tree_height) + 1, }; Ok(res) } @@ -674,7 +674,7 @@ impl Property for ExtData { opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat), ), exec_stack_elem_count_dissat: None, - tree_height : cmp::max(l.tree_height, r.tree_height) + 1, + tree_height: cmp::max(l.tree_height, r.tree_height) + 1, }) } @@ -721,7 +721,7 @@ impl Property for ExtData { l.exec_stack_elem_count_dissat, r.exec_stack_elem_count_dissat, ), - tree_height : cmp::max(l.tree_height, r.tree_height) + 1, + tree_height: cmp::max(l.tree_height, r.tree_height) + 1, }) } @@ -764,7 +764,7 @@ impl Property for ExtData { a.exec_stack_elem_count_dissat, c.exec_stack_elem_count_dissat, ), - tree_height : cmp::max(a.tree_height, cmp::max(b.tree_height, c.tree_height)) + 1, + tree_height: cmp::max(a.tree_height, cmp::max(b.tree_height, c.tree_height)) + 1, }) } @@ -885,7 +885,7 @@ impl Property for ExtData { timelock_info: TimelockInfo::combine_threshold(k, timelocks), exec_stack_elem_count_sat, exec_stack_elem_count_dissat, - tree_height : max_child_height + 1, + tree_height: max_child_height + 1, }) } diff --git a/src/plan.rs b/src/plan.rs index 49b95c908..858cf190d 100644 --- a/src/plan.rs +++ b/src/plan.rs @@ -749,7 +749,7 @@ mod test { // [ (key_indexes, hash_indexes, older, after, expected) ] tests: Vec<(Vec, Vec, Option, Option, Option)>, ) { - let desc = Descriptor::::from_str(&desc).unwrap(); + let desc = Descriptor::::from_str(desc).unwrap(); for (key_indexes, hash_indexes, older, after, expected) in tests { let mut assets = Assets::new(); @@ -763,7 +763,7 @@ mod test { assets = assets.add(keys[ki].clone()); } for hi in hash_indexes { - assets = assets.add(hashes[hi].clone()); + assets = assets.add(hashes[hi]); } let result = desc.clone().plan(&assets); @@ -1027,7 +1027,7 @@ mod test { "02c2fd50ceae468857bb7eb32ae9cd4083e6c7e42fbbec179d81134b3e3830586c", ) .unwrap()]; - let hashes = vec![hash160::Hash::from_slice(&vec![0; 20]).unwrap()]; + let hashes = vec![hash160::Hash::from_slice(&[0; 20]).unwrap()]; let desc = format!("wsh(and_v(v:pk({}),hash160({})))", keys[0], hashes[0]); let tests = vec![ diff --git a/src/policy/compiler.rs b/src/policy/compiler.rs index d00e8b4ad..023749bc2 100644 --- a/src/policy/compiler.rs +++ b/src/policy/compiler.rs @@ -28,10 +28,8 @@ type PolicyCache = pub(crate) struct OrdF64(pub f64); impl Eq for OrdF64 {} -// We could derive PartialOrd, but we can't derive Ord, and clippy wants us -// to derive both or neither. Better to be explicit. impl PartialOrd for OrdF64 { - fn partial_cmp(&self, other: &OrdF64) -> Option { self.0.partial_cmp(&other.0) } + fn partial_cmp(&self, other: &OrdF64) -> Option { Some(self.cmp(other)) } } impl Ord for OrdF64 { fn cmp(&self, other: &OrdF64) -> cmp::Ordering { @@ -632,13 +630,10 @@ fn insert_elem( // 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. @@ -1183,7 +1178,7 @@ mod tests { ret.push(pk); } let sig = secp.sign_ecdsa( - &secp256k1::Message::from_digest(sk.clone()), // Not a digest but 32 bytes nonetheless. + &secp256k1::Message::from_digest(sk), // Not a digest but 32 bytes nonetheless. &secp256k1::SecretKey::from_slice(&sk[..]).expect("secret key"), ); (ret, sig) @@ -1204,7 +1199,7 @@ mod tests { Arc::new(Concrete::Key("A".to_string())), Arc::new(Concrete::And(vec![ Arc::new(Concrete::after(9)), - Arc::new(Concrete::after(1000_000_000)), + Arc::new(Concrete::after(1_000_000_000)), ])), ]); assert!(pol.compile::().is_err()); @@ -1265,7 +1260,7 @@ mod tests { let (keys, sig) = pubkeys_and_a_sig(10); let key_pol: Vec = keys.iter().map(|k| Concrete::Key(*k)).collect(); - let policy: BPolicy = Concrete::Key(keys[0].clone()); + let policy: BPolicy = Concrete::Key(keys[0]); let ms: SegwitMiniScript = policy.compile().unwrap(); assert_eq!( ms.encode(), @@ -1360,11 +1355,11 @@ mod tests { (bitcoin::PublicKey, bitcoin::ecdsa::Signature), >::new(); - for i in 0..5 { - left_sat.insert(keys[i], bitcoinsig); + for key in &keys[0..5] { + left_sat.insert(*key, bitcoinsig); } - for i in 5..8 { - right_sat.insert(keys[i].to_pubkeyhash(SigType::Ecdsa), (keys[i], bitcoinsig)); + for key in &keys[5..8] { + right_sat.insert(key.to_pubkeyhash(SigType::Ecdsa), (*key, bitcoinsig)); } assert!(ms.satisfy(no_sat).is_err()); @@ -1470,7 +1465,7 @@ mod tests { (1, Arc::new(Concrete::Threshold(keys_b.len(), keys_b))), ]) .compile(); - let script_size = thresh_res.clone().and_then(|m| Ok(m.script_size())); + let script_size = thresh_res.clone().map(|m| m.script_size()); assert_eq!( thresh_res, Err(CompilerError::LimitsExceeded), @@ -1488,7 +1483,7 @@ mod tests { Concrete::Threshold(keys.len(), keys).compile(); let n_elements = thresh_res .clone() - .and_then(|m| Ok(m.max_satisfaction_witness_elements())); + .map(|m| m.max_satisfaction_witness_elements()); assert_eq!( thresh_res, Err(CompilerError::LimitsExceeded), @@ -1507,7 +1502,7 @@ mod tests { .collect(); let thresh_res: Result = Concrete::Threshold(keys.len() - 1, keys).compile(); - let ops_count = thresh_res.clone().and_then(|m| Ok(m.ext.ops.op_count())); + let ops_count = thresh_res.clone().map(|m| m.ext.ops.op_count()); assert_eq!( thresh_res, Err(CompilerError::LimitsExceeded), @@ -1521,7 +1516,7 @@ mod tests { .map(|pubkey| Arc::new(Concrete::Key(*pubkey))) .collect(); let thresh_res = Concrete::Threshold(keys.len() - 1, keys).compile::(); - let ops_count = thresh_res.clone().and_then(|m| Ok(m.ext.ops.op_count())); + let ops_count = thresh_res.clone().map(|m| m.ext.ops.op_count()); assert_eq!( thresh_res, Err(CompilerError::LimitsExceeded), diff --git a/src/policy/concrete.rs b/src/policy/concrete.rs index 19e7771b9..950ec631d 100644 --- a/src/policy/concrete.rs +++ b/src/policy/concrete.rs @@ -1096,7 +1096,7 @@ fn with_huffman_tree( /// any one of the conditions exclusively. #[cfg(feature = "compiler")] fn generate_combination( - policy_vec: &Vec>>, + policy_vec: &[Arc>], prob: f64, k: usize, ) -> Vec<(f64, Arc>)> { @@ -1127,7 +1127,7 @@ mod compiler_tests { let policies: Vec>> = vec!["pk(A)", "pk(B)", "pk(C)", "pk(D)"] .into_iter() .map(|st| policy_str!("{}", st)) - .map(|p| Arc::new(p)) + .map(Arc::new) .collect(); let combinations = generate_combination(&policies, 1.0, 2); @@ -1157,10 +1157,7 @@ mod compiler_tests { .map(|sub_pol| { ( 0.25, - Arc::new(Policy::Threshold( - 2, - sub_pol.into_iter().map(|p| Arc::new(p)).collect(), - )), + Arc::new(Policy::Threshold(2, sub_pol.into_iter().map(Arc::new).collect())), ) }) .collect::>(); diff --git a/src/policy/mod.rs b/src/policy/mod.rs index 138ec45b7..280a4dc0d 100644 --- a/src/policy/mod.rs +++ b/src/policy/mod.rs @@ -440,7 +440,7 @@ mod tests { .iter() .zip(node_probabilities.iter()) .collect::>(); - sorted_policy_prob.sort_by(|a, b| (a.1).partial_cmp(&b.1).unwrap()); + sorted_policy_prob.sort_by(|a, b| (a.1).partial_cmp(b.1).unwrap()); let sorted_policies = sorted_policy_prob .into_iter() .map(|(x, _prob)| x) diff --git a/src/psbt/mod.rs b/src/psbt/mod.rs index f2f45e575..beeb0d510 100644 --- a/src/psbt/mod.rs +++ b/src/psbt/mod.rs @@ -368,6 +368,7 @@ impl<'psbt, Pk: MiniscriptKey + ToPublicKey> Satisfier for PsbtInputSatisfie } } +#[allow(clippy::ptr_arg)] // this signature is forced by use in `and_then` fn try_vec_as_preimage32(vec: &Vec) -> Option { if vec.len() == 32 { let mut arr = [0u8; 32]; @@ -567,7 +568,7 @@ pub trait PsbtExt { /// /// Based on the sighash /// flag specified in the [`Psbt`] sighash field. If the input sighash flag psbt field is `None` - /// the [`sighash::TapSighashType::Default`](bitcoin::sighash::TapSighashType::Default) is chosen + /// the [`sighash::TapSighashType::Default`] is chosen /// for for taproot spends, otherwise [`EcdsaSighashType::All`](bitcoin::sighash::EcdsaSighashType::All) is chosen. /// If the utxo at `idx` is a taproot output, returns a [`PsbtSighashMsg::TapSighash`] variant. /// If the utxo at `idx` is a pre-taproot segwit output, returns a [`PsbtSighashMsg::SegwitV0Sighash`] variant. @@ -878,7 +879,7 @@ impl PsbtExt for Psbt { .redeem_script .as_ref() .expect("redeem script non-empty checked earlier"); - cache.p2wpkh_signature_hash(idx, &script_code, amt, hash_ty)? + cache.p2wpkh_signature_hash(idx, script_code, amt, hash_ty)? } else { let witness_script = inp .witness_script @@ -1010,8 +1011,6 @@ trait PsbtFields { fn tap_key_origins( &mut self, ) -> &mut BTreeMap, bip32::KeySource)>; - fn proprietary(&mut self) -> &mut BTreeMap>; - fn unknown(&mut self) -> &mut BTreeMap>; // `tap_tree` only appears in psbt::Output, so it's returned as an option of a mutable ref fn tap_tree(&mut self) -> Option<&mut Option> { None } @@ -1037,10 +1036,6 @@ impl PsbtFields for psbt::Input { ) -> &mut BTreeMap, bip32::KeySource)> { &mut self.tap_key_origins } - fn proprietary(&mut self) -> &mut BTreeMap> { - &mut self.proprietary - } - fn unknown(&mut self) -> &mut BTreeMap> { &mut self.unknown } fn tap_scripts(&mut self) -> Option<&mut BTreeMap> { Some(&mut self.tap_scripts) @@ -1064,10 +1059,6 @@ impl PsbtFields for psbt::Output { ) -> &mut BTreeMap, bip32::KeySource)> { &mut self.tap_key_origins } - fn proprietary(&mut self) -> &mut BTreeMap> { - &mut self.proprietary - } - fn unknown(&mut self) -> &mut BTreeMap> { &mut self.unknown } fn tap_tree(&mut self) -> Option<&mut Option> { Some(&mut self.tap_tree) } } @@ -1584,7 +1575,7 @@ mod tests { #[test] fn test_update_input_checks() { let desc = "tr([73c5da0a/86'/0'/0']xpub6BgBgsespWvERF3LHQu6CnqdvfEvtMcQjYrcRzx53QJjSxarj2afYWcLteoGVky7D3UKDP9QyrLprQ3VCECoY49yfdDEHGCtMMj92pReUsQ/0/0)"; - let desc = Descriptor::::from_str(&desc).unwrap(); + let desc = Descriptor::::from_str(desc).unwrap(); let mut non_witness_utxo = bitcoin::Transaction { version: transaction::Version::ONE, @@ -1646,7 +1637,7 @@ mod tests { #[test] fn test_update_output_checks() { let desc = "tr([73c5da0a/86'/0'/0']xpub6BgBgsespWvERF3LHQu6CnqdvfEvtMcQjYrcRzx53QJjSxarj2afYWcLteoGVky7D3UKDP9QyrLprQ3VCECoY49yfdDEHGCtMMj92pReUsQ/0/0)"; - let desc = Descriptor::::from_str(&desc).unwrap(); + let desc = Descriptor::::from_str(desc).unwrap(); let tx = bitcoin::Transaction { version: transaction::Version::ONE, diff --git a/src/test_utils.rs b/src/test_utils.rs index 086af7932..3cc1345ae 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -168,7 +168,7 @@ impl StrXOnlyKeyTranslator { .collect(); let mut pk_map = HashMap::new(); let mut pkh_map = HashMap::new(); - for (i, c) in (b'A'..b'Z').enumerate() { + for (i, c) in (b'A'..=b'Z').enumerate() { let key = String::from_utf8(vec![c]).unwrap(); pk_map.insert(key.clone(), pks[i]); pkh_map.insert(key, pks[i].to_pubkeyhash(SigType::Schnorr));