From c62e83bbe62a786693ab59aa9042c7f18c74b9a3 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 26 Aug 2025 15:23:16 +0000 Subject: [PATCH 1/4] clippy: introduce nightly-version and fix all clippy issues with it Copy nightly-version from rust-elements. The next commit will use it in Github CI. I won't bother making a cronjob for it because this crate is so unused that it doesn't seem worthwhile opening constant PRs for CI updates. We will try to do this manually every several months, or add a cronjob if/when this becomes used. I added an #[allow(unused)] tag on the elementsd test crate. Maybe this trait is actually unused and should be deleted. But the elementsd tests are old and bitrotted and I'd prefer to avoid touching them for purposes of this PR. This commit also introduces a lockfile. Basically, from this commit onward I want my local CI to pass, so I am throwing in several things at once. --- Cargo-latest.lock | 1002 +++++++++++++++++++++++++ Cargo.toml | 4 + bitcoind-tests/tests/setup/mod.rs | 1 + bitcoind-tests/tests/test_desc.rs | 2 +- clippy.toml | 2 + nightly-version | 1 + src/descriptor/key.rs | 2 +- src/descriptor/pegin/dynafed_pegin.rs | 4 +- src/miniscript/analyzable.rs | 8 +- src/miniscript/mod.rs | 2 +- src/miniscript/satisfy.rs | 4 +- src/policy/compiler.rs | 5 +- src/policy/semantic.rs | 1 - 13 files changed, 1021 insertions(+), 17 deletions(-) create mode 100644 Cargo-latest.lock create mode 100644 nightly-version diff --git a/Cargo-latest.lock b/Cargo-latest.lock new file mode 100644 index 00000000..e64fbe7a --- /dev/null +++ b/Cargo-latest.lock @@ -0,0 +1,1002 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "base58ck" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c8d66485a3a2ea485c1913c4572ce0256067a5377ac8c75c4960e1cda98605f" +dependencies = [ + "bitcoin-internals 0.3.0", + "bitcoin_hashes 0.14.0", +] + +[[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 = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + +[[package]] +name = "bitcoin" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae" +dependencies = [ + "bech32 0.10.0-beta", + "bitcoin-internals 0.2.0", + "bitcoin_hashes 0.13.0", + "hex-conservative 0.1.2", + "hex_lit", + "secp256k1 0.28.2", + "serde", +] + +[[package]] +name = "bitcoin" +version = "0.32.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda569d741b895131a88ee5589a467e73e9c4718e958ac9308e4f7dc44b6945" +dependencies = [ + "base58ck", + "base64 0.21.7", + "bech32 0.11.0", + "bitcoin-internals 0.3.0", + "bitcoin-io", + "bitcoin-units", + "bitcoin_hashes 0.14.0", + "hex-conservative 0.2.1", + "hex_lit", + "secp256k1 0.29.1", + "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-internals" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bdbe14aa07b06e6cfeffc529a1f099e5fbe249524f8125358604df99a4bed2" +dependencies = [ + "serde", +] + +[[package]] +name = "bitcoin-io" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf" + +[[package]] +name = "bitcoin-private" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" + +[[package]] +name = "bitcoin-units" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5285c8bcaa25876d07f37e3d30c303f2609179716e11d688f51e8f1fe70063e2" +dependencies = [ + "bitcoin-internals 0.3.0", + "serde", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +dependencies = [ + "bitcoin-internals 0.2.0", + "hex-conservative 0.1.2", + "serde", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16" +dependencies = [ + "bitcoin-io", + "hex-conservative 0.2.1", + "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 0.31.2", + "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 = [ + "elements-miniscript", + "elementsd", + "rand", + "secp256k1 0.29.1", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34efbcccd345379ca2868b2b2c9d3782e9cc58ba87bc7d79d5b53d9c9ae6f25d" + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42bc4aea80032b7bf409b0bc7ccad88853858911b7713a8062fdc0623867bedc" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" + +[[package]] +name = "descriptor-fuzz" +version = "0.0.1" +dependencies = [ + "elements-miniscript", + "honggfuzz", + "regex", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "elements" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81b2569d3495bfdfce36c504fd4d78752ff4a7699f8a33e6f3ee523bddf9f6ad" +dependencies = [ + "bech32 0.11.0", + "bitcoin 0.32.7", + "secp256k1-zkp", + "serde", + "serde_json", +] + +[[package]] +name = "elements-miniscript" +version = "0.4.0" +dependencies = [ + "base64 0.13.1", + "bitcoin 0.32.7", + "elements", + "getrandom", + "miniscript", + "rand", + "secp256k1 0.29.1", + "serde", + "serde_json", + "serde_test", + "simplicity-lang", +] + +[[package]] +name = "elementsd" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b08013ae0b60e4a3ac9d126e230338dec55575ddf7811aeaebb096f7c3abbf" +dependencies = [ + "bitcoind", +] + +[[package]] +name = "errno" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "hex-conservative" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" + +[[package]] +name = "hex-conservative" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "hex_lit" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd" + +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "honggfuzz" +version = "0.5.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc563d4f41b17364d5c48ded509f2bcf1c3f6ae9c7f203055b4a5c325072d57e" +dependencies = [ + "lazy_static", + "memmap2", + "rustc_version", + "semver", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[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.175" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "memmap2" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843a98750cd611cc2965a8213b53b43e715f13c37a9e096c6408e69990961db7" +dependencies = [ + "libc", +] + +[[package]] +name = "miniscript" +version = "12.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487906208f38448e186e3deb02f2b8ef046a9078b0de00bdb28bf4fb9b76951c" +dependencies = [ + "bech32 0.11.0", + "bitcoin 0.32.7", +] + +[[package]] +name = "once_cell" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[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", +] + +[[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", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[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 = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.9.3", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "santiago" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de36022292bc2086eb8f55bffa460fef3475e4459b478820711f4c421feb87ec" +dependencies = [ + "regex", +] + +[[package]] +name = "secp256k1" +version = "0.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" +dependencies = [ + "bitcoin_hashes 0.13.0", + "rand", + "secp256k1-sys 0.9.2", + "serde", +] + +[[package]] +name = "secp256k1" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +dependencies = [ + "bitcoin_hashes 0.14.0", + "rand", + "secp256k1-sys 0.10.1", + "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 = "secp256k1-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" +dependencies = [ + "cc", +] + +[[package]] +name = "secp256k1-zkp" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a44aed3002b5ae975f8624c5df3a949cfbf00479e18778b6058fcd213b76e3" +dependencies = [ + "bitcoin-private", + "rand", + "secp256k1 0.29.1", + "secp256k1-zkp-sys", + "serde", +] + +[[package]] +name = "secp256k1-zkp-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57f08b2d0b143a22e07f798ae4f0ab20d5590d7c68e0d090f2088a48a21d1654" +dependencies = [ + "cc", + "secp256k1-sys 0.10.1", +] + +[[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.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.143" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_test" +version = "1.0.177" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f901ee573cab6b3060453d2d5f0bae4e6d628c23c0a962ff9b5f1d7c8d4f1ed" +dependencies = [ + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "simplicity-lang" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75c8fb4a18e63fbce4cf16026c36a6c38066e4f4a09ce5e81be817d0e36d8f8" +dependencies = [ + "bitcoin 0.32.7", + "bitcoin_hashes 0.14.0", + "byteorder", + "elements", + "getrandom", + "hex-conservative 0.1.2", + "miniscript", + "santiago", + "simplicity-sys", +] + +[[package]] +name = "simplicity-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd2cc5d458a8032d328ea85e824f54f61664ab84c3d42b3b7f8804fb9b81572" +dependencies = [ + "bitcoin_hashes 0.14.0", + "cc", +] + +[[package]] +name = "syn" +version = "2.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if", + "libc", + "rand", + "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.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[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" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index f7596550..de53f2e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ keywords = [ "crypto", "bitcoin", "miniscript", "script" ] readme = "README.md" homepage = "https://github.com/rust-bitcoin/rust-miniscript/" edition = "2018" +rust-version = "1.63.0" [features] compiler = [] @@ -61,3 +62,6 @@ required-features = ["base64"] [workspace] members = ["bitcoind-tests", "fuzz"] + +[lints.rust] +unexpected_cfgs = { level = "deny", check-cfg = ['cfg(miniscript_bench)'] } diff --git a/bitcoind-tests/tests/setup/mod.rs b/bitcoind-tests/tests/setup/mod.rs index b443fddd..aa966fb4 100644 --- a/bitcoind-tests/tests/setup/mod.rs +++ b/bitcoind-tests/tests/setup/mod.rs @@ -60,6 +60,7 @@ pub fn setup(validate_pegin: bool) -> (ElementsD, Option, elements::Bl (elementsd, bitcoind, genesis_hash) } // Upstream all common methods later +#[allow(unused)] pub trait Call { fn call(&self, cmd: &str, args: &[Value]) -> Value; fn get_new_address(&self) -> elements::Address; diff --git a/bitcoind-tests/tests/test_desc.rs b/bitcoind-tests/tests/test_desc.rs index 8a0a52f4..fae4977e 100644 --- a/bitcoind-tests/tests/test_desc.rs +++ b/bitcoind-tests/tests/test_desc.rs @@ -322,7 +322,7 @@ fn find_sks_ms( .iter_pk() .filter_map(|pk| { let i = pks.iter().position(|&x| x.to_public_key() == pk); - i.map(|idx| (sks[idx])) + i.map(|idx| sks[idx]) }) .collect(); sks diff --git a/clippy.toml b/clippy.toml index b3c3a24c..dfe5dd9b 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1,3 @@ msrv = "1.63.0" +# PSBT API returns Self as an error type for an large-ish enum +large-error-threshold = 289 diff --git a/nightly-version b/nightly-version new file mode 100644 index 00000000..732c1d66 --- /dev/null +++ b/nightly-version @@ -0,0 +1 @@ +nightly-2025-08-19 diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index b17b1fde..30ec21a0 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -969,7 +969,7 @@ impl DescriptorXKey { if &compare_fingerprint == fingerprint && compare_path .into_iter() - .eq(path_excluding_wildcard.into_iter()) + .eq(&path_excluding_wildcard) { Some(path_excluding_wildcard) } else { diff --git a/src/descriptor/pegin/dynafed_pegin.rs b/src/descriptor/pegin/dynafed_pegin.rs index a2f0805f..22d57fc0 100644 --- a/src/descriptor/pegin/dynafed_pegin.rs +++ b/src/descriptor/pegin/dynafed_pegin.rs @@ -69,7 +69,7 @@ impl Pegin { secp: &secp256k1_zkp::Secp256k1, ) -> Result, Error> { let elem_desc = self.elem_desc.at_derivation_index(arg)?; - let elem_desc = elem_desc.derived_descriptor(&secp)?; + let elem_desc = elem_desc.derived_descriptor(secp)?; Ok(Pegin::new(self.fed_desc.clone(), elem_desc)) } } @@ -172,7 +172,7 @@ impl Pegin { .expect("DO this cleanly after TR. Pay to taproot pegins unspecified till now"), network, )), - _ => return Err(Error::UnsupportedAddressForPegin), + _ => Err(Error::UnsupportedAddressForPegin), } } diff --git a/src/miniscript/analyzable.rs b/src/miniscript/analyzable.rs index 41d8ae68..e3c8dc13 100644 --- a/src/miniscript/analyzable.rs +++ b/src/miniscript/analyzable.rs @@ -16,9 +16,7 @@ use crate::{error, Extension, 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 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 @@ -123,9 +121,7 @@ impl ExtParams { /// 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/mod.rs b/src/miniscript/mod.rs index 8d4e2cae..9e783bc4 100644 --- a/src/miniscript/mod.rs +++ b/src/miniscript/mod.rs @@ -67,7 +67,7 @@ impl PartialOrd for Miniscript { fn partial_cmp(&self, other: &Miniscript) -> Option { - Some(self.node.cmp(&other.node)) + Some(self.cmp(other)) } } diff --git a/src/miniscript/satisfy.rs b/src/miniscript/satisfy.rs index 60217b2a..a30f3307 100644 --- a/src/miniscript/satisfy.rs +++ b/src/miniscript/satisfy.rs @@ -326,7 +326,7 @@ where } } -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) } @@ -460,7 +460,7 @@ impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier> Satisfier for &' } } -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/policy/compiler.rs b/src/policy/compiler.rs index ceff7a49..dfce2ea6 100644 --- a/src/policy/compiler.rs +++ b/src/policy/compiler.rs @@ -850,11 +850,10 @@ fn insert_elem( // cost, don't consider this element. let is_worse = map .iter() - .map(|(existing_key, existing_elem)| { + .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 - }) - .any(|x| x); + }); 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. diff --git a/src/policy/semantic.rs b/src/policy/semantic.rs index 16dc1208..77193a5f 100644 --- a/src/policy/semantic.rs +++ b/src/policy/semantic.rs @@ -138,7 +138,6 @@ impl Policy { /// A |- B means every satisfaction of A is also a satisfaction of B. /// This implementation will run slow for larger policies but should be sufficient for /// most practical policies. - // This algorithm has a naive implementation. It is possible to optimize this // by memoizing and maintaining a hashmap. pub fn entails(self, other: Policy) -> Result { From 92fc444bf710f4e57bf26dbe75e2f3586a1d9960 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 26 Aug 2025 15:23:16 +0000 Subject: [PATCH 2/4] ci: copy workflow and contrib/ scripts from rust-elements This introduces the rust-bitcoin-maintainer-tools CI setup, which ensures that all tool versions are pinned, tests all examples, etc. I had to tweak a couple things (replacing the list of features, renaming elementsd-tests to bitcoind-tests) but otherwise this was a straight copy/paste. We also update all our CI actions to v4 from the now-deleted v2. --- .../checkout-maintainer-tools/action.yml | 11 + .github/workflows/rust.yml | 217 +++++++++++++----- Cargo.toml | 3 + contrib/crates.sh | 9 + contrib/extra_tests.sh | 60 +++++ contrib/test.sh | 74 ------ contrib/test_vars.sh | 14 ++ 7 files changed, 254 insertions(+), 134 deletions(-) create mode 100644 .github/actions/checkout-maintainer-tools/action.yml create mode 100755 contrib/crates.sh create mode 100755 contrib/extra_tests.sh delete mode 100755 contrib/test.sh create mode 100644 contrib/test_vars.sh diff --git a/.github/actions/checkout-maintainer-tools/action.yml b/.github/actions/checkout-maintainer-tools/action.yml new file mode 100644 index 00000000..d675edf0 --- /dev/null +++ b/.github/actions/checkout-maintainer-tools/action.yml @@ -0,0 +1,11 @@ +name: Checkout Maintainer Tools +description: Checks out the rust-bitcoin maintainer tools repo +runs: + using: "composite" + steps: + - name: Checkout maintainer tools + uses: actions/checkout@v4 + with: + repository: rust-bitcoin/rust-bitcoin-maintainer-tools + ref: f92b2766865ce5327eca5cf72f86ceaa6be58ca4 + path: maintainer-tools diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 940f282f..afe786f8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,86 +1,183 @@ -on: +on: # yamllint disable-line rule:truthy + pull_request: push: branches: - master - pull_request: {} + - 'test-ci/**' name: Continuous integration jobs: - lint_fuzz_stable: - name: Lint + Prepare: runs-on: ubuntu-latest + outputs: + nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }} + msrv_version: ${{ steps.read_msrv.outputs.msrv_version }} steps: - - name: Checkout Crate - uses: actions/checkout@v2 - - name: Install hongfuzz dependancies - run: sudo apt-get update -y && sudo apt install -y build-essential binutils-dev libunwind-dev libblocksruntime-dev liblzma-dev - - name: Checkout Toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.63.0 - override: true - - name: Running fuzzer - env: - DO_LINT: true - run: ./contrib/test.sh + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Read nightly version" + id: read_toolchain + run: | + set -euo pipefail + version=$(cat nightly-version) + echo "nightly_version=$version" >> $GITHUB_OUTPUT + - name: Read MSRV from clippy.toml + id: read_msrv + run: | + set -euo pipefail + msrv=$(grep '^msrv *= *"' clippy.toml | sed -E 's/.*"([^"]+)".*/\1/') + echo "msrv_version=$msrv" >> "$GITHUB_OUTPUT" + + Stable: + name: Test - stable toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: ./.github/actions/checkout-maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + - name: "Set dependencies" + run: cp Cargo-latest.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh stable Nightly: - name: Nightly - Bench + Docs + Fmt + name: Test - nightly toolchain + needs: Prepare runs-on: ubuntu-latest + strategy: + fail-fast: false steps: - - name: Checkout Crate - uses: actions/checkout@v2 - - name: Checkout Toolchain - uses: actions-rs/toolchain@v1 + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: ./.github/actions/checkout-maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@v1 with: - profile: minimal - toolchain: nightly - override: true - - name: Running benchmarks - env: - DO_BENCH: true - run: ./contrib/test.sh - - name: Building docs - env: - DO_DOCS: true - run: ./contrib/test.sh + toolchain: ${{ needs.Prepare.outputs.nightly_version }} + - name: "Set dependencies" + run: cp Cargo-latest.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh nightly - Int-tests: - name: Integration tests + MSRV: + name: Test - MSRV + needs: Prepare runs-on: ubuntu-latest + strategy: + fail-fast: false steps: - - name: Checkout Crate - uses: actions/checkout@v2 - - name: Checkout Toolchain - uses: actions-rs/toolchain@v1 + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: ./.github/actions/checkout-maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - override: true - - name: Running integration tests - env: - DO_BITCOIND_TESTS: true - run: ./contrib/test.sh + toolchain: ${{ needs.Prepare.outputs.msrv_version }} + - name: "Set dependencies" + run: cp Cargo-latest.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh msrv - Tests: - name: Tests + Lint: + name: Lint - nightly toolchain + needs: Prepare runs-on: ubuntu-latest strategy: fail-fast: false matrix: - rust: [stable, beta, nightly, 1.63.0] + dep: [recent] + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: ./.github/actions/checkout-maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ needs.Prepare.outputs.nightly_version }} + - name: Install clippy + run: rustup component add clippy + - name: "Set dependencies" + run: cp Cargo-latest.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh lint + + Docs: + name: Docs - stable toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dep: [recent] + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: ./.github/actions/checkout-maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + - name: "Set dependencies" + run: cp Cargo-latest.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh docs + + Docsrs: + name: Docs - nightly toolchain + needs: Prepare + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dep: [recent] + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: ./.github/actions/checkout-maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ needs.Prepare.outputs.nightly_version }} + - name: "Set dependencies" + run: cp Cargo-latest.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh docsrs + +# Format: +# name: Format - nightly toolchain +# needs: Prepare +# runs-on: ubuntu-latest +# strategy: +# fail-fast: false +# steps: +# - name: "Checkout repo" +# uses: actions/checkout@v4 +# - name: "Select toolchain" +# uses: dtolnay/rust-toolchain@v1 +# with: +# toolchain: ${{ needs.Prepare.outputs.nightly_version }} +# - name: "Install rustfmt" +# run: rustup component add rustfmt +# - name: "Check formatting" +# run: cargo fmt --all -- --check + + Wasm: + name: Check WASM + runs-on: ubuntu-latest + strategy: + fail-fast: false steps: - name: Checkout Crate - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Checkout Toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - - name: Running cargo - env: - DO_FEATURE_MATRIX: true - run: ./contrib/test.sh + uses: dtolnay/rust-toolchain@stable + - run: rustup target add wasm32-unknown-unknown + - run: cargo check --target wasm32-unknown-unknown diff --git a/Cargo.toml b/Cargo.toml index de53f2e9..8526ed68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,9 @@ simplicity = { package = "simplicity-lang", version = "0.3.0", optional = true } # Do NOT use this as a feature! Use the `serde` feature instead. actual-serde = { package = "serde", version = "1.0", optional = true } +[target.wasm32-unknown-unknown.dev-dependencies] +getrandom = { version = "0.2", features = ["js"] } + [dev-dependencies] serde_json = "1.0" actual-rand = { package = "rand", version = "0.8.4"} diff --git a/contrib/crates.sh b/contrib/crates.sh new file mode 100755 index 00000000..91b96d0d --- /dev/null +++ b/contrib/crates.sh @@ -0,0 +1,9 @@ +# Sourced by `rust-bitcoin-maintainer-tools/ci/run_task.sh`. +# +# No shebang, this file should not be executed. +# shellcheck disable=SC2148 +# +# disable verify unused vars, despite the fact that they are used when sourced +# shellcheck disable=SC2034 + +CRATES=(. bitcoind-tests) \ No newline at end of file diff --git a/contrib/extra_tests.sh b/contrib/extra_tests.sh new file mode 100755 index 00000000..759b74a3 --- /dev/null +++ b/contrib/extra_tests.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +set -ex + +REPO_DIR=$(git rev-parse --show-toplevel) + +# Make all cargo invocations verbose. +export CARGO_TERM_VERBOSE=true + +# Set to false to turn off verbose output. +flag_verbose=true + +main() { + source_test_vars # Get feature list. + + BITCOIND_EXE_DEFAULT="$(git rev-parse --show-toplevel)/bitcoind-tests/bin/bitcoind" + ELEMENTSD_EXE_DEFAULT="$(git rev-parse --show-toplevel)/bitcoind-tests/bin/elementsd" + + cd bitcoind-tests + BITCOIND_EXE=${BITCOIND_EXE:=${BITCOIND_EXE_DEFAULT}} \ + ELEMENTSD_EXE=${ELEMENTSD_EXE:=${ELEMENTSD_EXE_DEFAULT}} \ + cargo --locked test + cd .. +} + +# ShellCheck can't follow non-constant source, `test_vars_script` is correct. +# shellcheck disable=SC1090 +source_test_vars() { + local test_vars_script="$REPO_DIR/contrib/test_vars.sh" + + verbose_say "Sourcing $test_vars_script" + + if [ -e "$test_vars_script" ]; then + # Set crate specific variables. + . "$test_vars_script" + else + err "Missing $test_vars_script" + fi +} + +say() { + echo "extra_tests: $1" +} + +verbose_say() { + if [ "$flag_verbose" = true ]; then + say "$1" + fi +} + +err() { + echo "$1" >&2 + exit 1 +} + +# +# Main script +# +main "$@" +exit 0 diff --git a/contrib/test.sh b/contrib/test.sh deleted file mode 100755 index b5fbc5d9..00000000 --- a/contrib/test.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh - -set -ex - -FEATURES="compiler serde rand base64 simplicity" - -cargo --version -rustc --version - -# Pin dependencies required to build with Rust 1.63 -if cargo --version | grep "1\.63"; then - cargo update -p regex --precise 1.8.4 -fi - -# Format if told to -if [ "$DO_FMT" = true ] -then - rustup component add rustfmt - cargo fmt -- --check -fi - -# Test bitcoind integration tests if told to (this only works with the stable toolchain) -if [ "$DO_BITCOIND_TESTS" = true ]; then - - BITCOIND_EXE_DEFAULT="$(git rev-parse --show-toplevel)/bitcoind-tests/bin/bitcoind" - ELEMENTSD_EXE_DEFAULT="$(git rev-parse --show-toplevel)/bitcoind-tests/bin/elementsd" - - cd bitcoind-tests - - BITCOIND_EXE=${BITCOIND_EXE:=${BITCOIND_EXE_DEFAULT}} \ - ELEMENTSD_EXE=${ELEMENTSD_EXE:=${ELEMENTSD_EXE_DEFAULT}} \ - cargo test --verbose - - # Exit integration tests, do not run other tests. - exit 0 -fi - -# Defaults / sanity checks -cargo test - -if [ "$DO_FEATURE_MATRIX" = true ] -then - # All features - cargo test --features="$FEATURES" - - # Single features - for feature in ${FEATURES} - do - cargo 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 -fi - -# Bench if told to (this only works with the nightly toolchain) -if [ "$DO_BENCH" = true ] -then - RUSTFLAGS=--cfg=miniscript_bench cargo bench --features="compiler" -fi - -# Build the docs if told to (this only works with the nightly toolchain) -if [ "$DO_DOCS" = true ]; then - RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --features="$FEATURES" -- -D rustdoc::broken-intra-doc-links -fi - -exit 0 diff --git a/contrib/test_vars.sh b/contrib/test_vars.sh new file mode 100644 index 00000000..227b292c --- /dev/null +++ b/contrib/test_vars.sh @@ -0,0 +1,14 @@ +# No shebang, this file should not be executed. +# shellcheck disable=SC2148 +# +# disable verify unused vars, despite the fact that they are used when sourced +# shellcheck disable=SC2034 + +# Test all these features with "std" enabled. Empty because we do not have a 'std' feature. +FEATURES_WITH_STD="" + +# Test all these features without "std" enabled. +FEATURES_WITHOUT_STD="compiler trace serde rand base64 simplicity" + +# Run these examples. +EXAMPLES="htlc:compiler parse: sign_multisig: verify_tx: xpub_descriptors: taproot:compiler psbt_sign_finalize:base64" From 8dd5e755eb0a9a994061022d0f707d6bf5f7a83e Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 26 Aug 2025 15:42:36 +0000 Subject: [PATCH 3/4] clippy: enable a bunch of casting and safety lints Also enable a grab bag of other lints; I basically copied the giant list from rust-elements and removed the ones that seemed too annoying to fix and not very important. --- Cargo.toml | 44 ++++++++++++++++++++++++++++ src/descriptor/mod.rs | 8 ++--- src/extensions/introspect_ops.rs | 8 ++--- src/interpreter/mod.rs | 12 ++------ src/interpreter/stack.rs | 24 +++++++-------- src/lib.rs | 2 +- src/miniscript/astelem.rs | 4 +-- src/miniscript/context.rs | 2 +- src/miniscript/lex.rs | 11 ++++--- src/miniscript/satisfy.rs | 2 +- src/miniscript/types/correctness.rs | 4 +-- src/miniscript/types/malleability.rs | 4 +-- src/policy/compiler.rs | 2 ++ src/policy/concrete.rs | 6 ++-- src/psbt/finalizer.rs | 2 +- 15 files changed, 87 insertions(+), 48 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8526ed68..fcce1038 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,3 +68,47 @@ members = ["bitcoind-tests", "fuzz"] [lints.rust] unexpected_cfgs = { level = "deny", check-cfg = ['cfg(miniscript_bench)'] } + +[lints.clippy] +# Exclude lints we don't think are valuable. +needless_question_mark = "allow" # https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 +manual_range_contains = "allow" # More readable than clippy's format. +uninlined_format_args = "allow" # This is a subjective style choice. +float_cmp = "allow" # Bitcoin floats are typically limited to 8 decimal places and we want them exact. +match_bool = "allow" # Adds extra indentation and LOC. +match_same_arms = "allow" # Collapses things that are conceptually unrelated to each other. +must_use_candidate = "allow" # Useful for audit but many false positives. +similar_names = "allow" # Too many (subjectively) false positives. +# Exhaustive list of pedantic clippy lints +assigning_clones = "warn" +borrow_as_ptr = "warn" +cast_lossless = "warn" +cast_possible_truncation = "allow" # All casts should include a code comment (except test code). +cast_possible_wrap = "allow" # Same as above re code comment. +cast_precision_loss = "warn" +cast_ptr_alignment = "warn" +cast_sign_loss = "allow" # All casts should include a code comment (except in test code). +invalid_upcast_comparisons = "warn" +option_as_ref_cloned = "warn" +ptr_as_ptr = "warn" +ptr_cast_constness = "warn" +ref_as_ptr = "warn" +ref_binding_to_reference = "warn" +ref_option_ref = "warn" +same_functions_in_if_condition = "warn" +should_panic_without_expect = "warn" +single_char_pattern = "warn" +stable_sort_primitive = "warn" +str_split_at_newline = "warn" +string_add_assign = "warn" +transmute_ptr_to_ptr = "warn" +trivially_copy_pass_by_ref = "warn" +unchecked_duration_subtraction = "warn" +unicode_not_nfc = "warn" +unnecessary_box_returns = "warn" +unnecessary_join = "warn" +unnecessary_literal_bound = "warn" +unnecessary_wraps = "warn" +unsafe_derive_deserialize = "warn" +unused_async = "warn" +unused_self = "warn" diff --git a/src/descriptor/mod.rs b/src/descriptor/mod.rs index 61823b21..c6f56286 100644 --- a/src/descriptor/mod.rs +++ b/src/descriptor/mod.rs @@ -969,7 +969,7 @@ impl Descriptor { impl<'a> Translator for KeyMapLookUp<'a> { fn pk(&mut self, pk: &DescriptorPublicKey) -> Result { - key_to_string(pk, self.0) + Ok(key_to_string(pk, self.0)) } fn sha256(&mut self, sha256: &sha256::Hash) -> Result { @@ -989,11 +989,11 @@ impl Descriptor { } } - fn key_to_string(pk: &DescriptorPublicKey, key_map: &KeyMap) -> Result { - Ok(match key_map.get(pk) { + fn key_to_string(pk: &DescriptorPublicKey, key_map: &KeyMap) -> String { + match key_map.get(pk) { Some(secret) => secret.to_string(), None => pk.to_string(), - }) + } } let descriptor = self diff --git a/src/extensions/introspect_ops.rs b/src/extensions/introspect_ops.rs index 32c02929..fcb943c0 100644 --- a/src/extensions/introspect_ops.rs +++ b/src/extensions/introspect_ops.rs @@ -623,7 +623,7 @@ fn spk(pref: i8, prog: &[u8]) -> Option { } else if pref <= 16 && pref >= 0 { Some( script::Builder::new() - .push_int(pref as i64) + .push_int(i64::from(pref)) .push_slice(prog) .into_script(), ) @@ -664,7 +664,7 @@ impl AssetExpr { Asset::Explicit(a) => builder.push_slice(a.into_inner().as_ref()).push_int(1), // explicit prefix Asset::Confidential(c) => { let ser = c.serialize(); - builder.push_slice(&ser[1..]).push_int(ser[0] as i64) + builder.push_slice(&ser[1..]).push_int(i64::from(ser[0])) } } } @@ -752,7 +752,7 @@ impl ValueExpr { } // explicit prefix confidential::Value::Confidential(c) => { let ser = c.serialize(); - builder.push_slice(&ser[1..]).push_int(ser[0] as i64) + builder.push_slice(&ser[1..]).push_int(i64::from(ser[0])) } } } @@ -838,7 +838,7 @@ impl SpkExpr { SpkInner::Script(s) => spk_to_components(s), SpkInner::Hashed(h) => (-1, h.to_byte_array().to_vec()), }; - builder.push_slice(&prog).push_int(ver as i64) + builder.push_slice(&prog).push_int(i64::from(ver)) } SpkExpr::Const(_) => unreachable!( "Both constructors from_str and from_token_iter diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index 4a768ca5..c186f3a7 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -701,20 +701,12 @@ where Terminal::After(ref n) => { debug_assert_eq!(node_state.n_evaluated, 0); debug_assert_eq!(node_state.n_satisfied, 0); - let res = self - .stack - .evaluate_after(&LockTime::from(*n), self.lock_time); - if res.is_some() { - return res; - } + return Some(self.stack.evaluate_after(LockTime::from(*n), self.lock_time)); } Terminal::Older(ref n) => { debug_assert_eq!(node_state.n_evaluated, 0); debug_assert_eq!(node_state.n_satisfied, 0); - let res = self.stack.evaluate_older(n, self.age); - if res.is_some() { - return res; - } + return Some(self.stack.evaluate_older(*n, self.age)); } Terminal::Sha256(ref hash) => { debug_assert_eq!(node_state.n_evaluated, 0); diff --git a/src/interpreter/stack.rs b/src/interpreter/stack.rs index deda9afa..5238d4c4 100644 --- a/src/interpreter/stack.rs +++ b/src/interpreter/stack.rs @@ -245,27 +245,27 @@ impl<'txin> Stack<'txin> { /// booleans pub(super) fn evaluate_after( &mut self, - n: &LockTime, + n: LockTime, lock_time: LockTime, - ) -> Option, Error>> { + ) -> Result, Error> { use LockTime::*; - let is_satisfied = match (*n, lock_time) { + let is_satisfied = match (n, lock_time) { (Blocks(n), Blocks(lock_time)) => n <= lock_time, (Seconds(n), Seconds(lock_time)) => n <= lock_time, _ => { - return Some(Err(Error::AbsoluteLocktimeComparisonInvalid( + return Err(Error::AbsoluteLocktimeComparisonInvalid( n.to_consensus_u32(), lock_time.to_consensus_u32(), - ))) + )) } }; if is_satisfied { self.push(Element::Satisfied); - Some(Ok(SatisfiedConstraint::AbsoluteTimelock { n: *n })) + Ok(SatisfiedConstraint::AbsoluteTimelock { n }) } else { - Some(Err(Error::AbsoluteLocktimeNotMet(n.to_consensus_u32()))) + Err(Error::AbsoluteLocktimeNotMet(n.to_consensus_u32())) } } @@ -277,14 +277,14 @@ impl<'txin> Stack<'txin> { /// booleans pub(super) fn evaluate_older( &mut self, - n: &Sequence, + n: Sequence, age: Sequence, - ) -> Option, Error>> { - if age >= *n { + ) -> Result, Error> { + if age >= n { self.push(Element::Satisfied); - Some(Ok(SatisfiedConstraint::RelativeTimelock { n: *n })) + Ok(SatisfiedConstraint::RelativeTimelock { n }) } else { - Some(Err(Error::RelativeLocktimeNotMet(n.to_consensus_u32()))) + Err(Error::RelativeLocktimeNotMet(n.to_consensus_u32())) } } diff --git a/src/lib.rs b/src/lib.rs index b3826088..8ed37443 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -534,7 +534,7 @@ impl fmt::Display for Error { Error::BareDescriptorAddr => write!(f, "Bare descriptors don't have address"), Error::BtcError(ref e) => write!(f, " Bitcoin Miniscript Error {}", e), Error::CovError(ref e) => write!(f, "Covenant Error: {}", e), - Error::PubKeyCtxError(ref pk, ref ctx) => { + Error::PubKeyCtxError(ref pk, ctx) => { write!(f, "Pubkey error: {} under {} scriptcontext", pk, ctx) } Error::MultiATooManyKeys(k) => write!(f, "MultiA too many keys {}", k), diff --git a/src/miniscript/astelem.rs b/src/miniscript/astelem.rs index 13bd9d8a..18b06341 100644 --- a/src/miniscript/astelem.rs +++ b/src/miniscript/astelem.rs @@ -740,7 +740,7 @@ pub trait StackCtxOperations: Sized { impl StackCtxOperations for script::Builder { fn check_item_eq(self, idx: u32, target: &[u8]) -> Self { self.push_opcode(opcodes::all::OP_DEPTH) - .push_int(idx as i64) + .push_int(i64::from(idx)) .push_opcode(opcodes::all::OP_SUB) .push_opcode(opcodes::all::OP_PICK) .push_slice(target) @@ -764,7 +764,7 @@ impl StackCtxOperations for script::Builder { builder .push_opcode(opcodes::all::OP_DEPTH) - .push_int(idx as i64) + .push_int(i64::from(idx)) .push_opcode(opcodes::all::OP_SUB) .push_opcode(opcodes::all::OP_PICK) .push_opcode(opcodes::all::OP_EQUAL) diff --git a/src/miniscript/context.rs b/src/miniscript/context.rs index dafc8247..705e10c7 100644 --- a/src/miniscript/context.rs +++ b/src/miniscript/context.rs @@ -111,7 +111,7 @@ impl fmt::Display for ScriptContextError { pk ) } - ScriptContextError::XOnlyKeysNotAllowed(ref pk, ref ctx) => { + ScriptContextError::XOnlyKeysNotAllowed(ref pk, ctx) => { write!(f, "x-only key {} not allowed in {}", pk, ctx) } ScriptContextError::UncompressedKeysNotAllowed => { diff --git a/src/miniscript/lex.rs b/src/miniscript/lex.rs index 3d567f99..5841afcb 100644 --- a/src/miniscript/lex.rs +++ b/src/miniscript/lex.rs @@ -180,20 +180,19 @@ impl<'s> Iterator for TokenIter<'s> { pub fn lex(script: &script::Script) -> Result>, Error> { let mut ret = Vec::with_capacity(script.len()); - fn process_candidate_push(ret: &mut [Token<'_>]) -> Result<(), Error> { + fn process_candidate_push(ret: &mut [Token<'_>]) { let ret_len = ret.len(); if ret_len < 2 || ret[ret_len - 1] != Token::Swap { - return Ok(()); + return; } let token = match &ret[ret_len - 2] { Token::Hash20(x) => Token::Push(x.to_vec()), Token::Bytes32(x) | Token::Bytes33(x) | Token::Bytes65(x) => Token::Push(x.to_vec()), - Token::Num(k) => Token::Push(build_scriptint(*k as i64)), - _x => return Ok(()), // no change required + Token::Num(k) => Token::Push(build_scriptint(i64::from(*k))), + _x => return, // no change required }; ret[ret_len - 2] = token; - Ok(()) } for ins in script.instructions_minimal() { @@ -329,7 +328,7 @@ pub fn lex(script: &script::Script) -> Result>, Error> { ret.push(Token::Dup2); } script::Instruction::Op(opcodes::all::OP_CAT) => { - process_candidate_push(&mut ret)?; + process_candidate_push(&mut ret); ret.push(Token::Cat); } script::Instruction::Op(opcodes::all::OP_CODESEPARATOR) => { diff --git a/src/miniscript/satisfy.rs b/src/miniscript/satisfy.rs index a30f3307..903bb684 100644 --- a/src/miniscript/satisfy.rs +++ b/src/miniscript/satisfy.rs @@ -41,7 +41,7 @@ pub fn elementssig_to_rawsig(sig: &ElementsSig) -> Vec { /// Returns underlying secp if the Signature is not of correct format pub fn elementssig_from_rawsig(rawsig: &[u8]) -> Result { let (flag, sig) = rawsig.split_last().unwrap(); - let flag = elements::EcdsaSighashType::from_u32(*flag as u32); + let flag = elements::EcdsaSighashType::from_u32(u32::from(*flag)); let sig = secp256k1_zkp::ecdsa::Signature::from_der(sig)?; Ok((sig, flag)) } diff --git a/src/miniscript/types/correctness.rs b/src/miniscript/types/correctness.rs index 34ab0ca1..eeb676f2 100644 --- a/src/miniscript/types/correctness.rs +++ b/src/miniscript/types/correctness.rs @@ -51,8 +51,8 @@ impl Input { /// Check whether given `Input` is a subtype of `other`. That is, /// if some Input is `OneNonZero` then it must be `One`, hence `OneNonZero` is /// a subtype if `One`. Returns `true` for `a.is_subtype(a)`. - fn is_subtype(&self, other: Self) -> bool { - match (*self, other) { + fn is_subtype(self, other: Self) -> bool { + match (self, other) { (x, y) if x == y => true, (Input::OneNonZero, Input::One) | (Input::OneNonZero, Input::AnyNonZero) diff --git a/src/miniscript/types/malleability.rs b/src/miniscript/types/malleability.rs index d690a957..b22336b6 100644 --- a/src/miniscript/types/malleability.rs +++ b/src/miniscript/types/malleability.rs @@ -30,8 +30,8 @@ pub enum Dissat { impl Dissat { /// Check whether given `Dissat` is a subtype of `other`. That is, /// if some Dissat is `Unique` then it must be `Unknown`. - fn is_subtype(&self, other: Self) -> bool { - match (*self, other) { + fn is_subtype(self, other: Self) -> bool { + match (self, other) { (x, y) if x == y => true, (_, Dissat::Unknown) => true, _ => false, diff --git a/src/policy/compiler.rs b/src/policy/compiler.rs index dfce2ea6..0704d823 100644 --- a/src/policy/compiler.rs +++ b/src/policy/compiler.rs @@ -6,6 +6,8 @@ //! Optimizing compiler from concrete policies to Miniscript. //! Currently the policy compiler does not support any extensions +#![allow(clippy::cast_precision_loss)] // we repeatedly cast sizes to f64s, which truncates at 2^52 elements + use std::collections::vec_deque::VecDeque; use std::collections::BTreeMap; use std::convert::From; diff --git a/src/policy/concrete.rs b/src/policy/concrete.rs index 85f90b01..949e8e87 100644 --- a/src/policy/concrete.rs +++ b/src/policy/concrete.rs @@ -4,6 +4,8 @@ //! Concrete Policies //! +#![allow(clippy::cast_precision_loss)] // we repeatedly cast sizes to f64s, which truncates at 2^52 elements + use std::collections::HashSet; use std::{error, fmt, str}; @@ -979,8 +981,8 @@ impl Policy { .map(|sub| sub.is_safe_nonmalleable()) .fold((0, 0), |(safe_count, non_mall_count), (safe, non_mall)| { ( - safe_count + safe as usize, - non_mall_count + non_mall as usize, + safe_count + usize::from(safe), + non_mall_count + usize::from(non_mall), ) }); ( diff --git a/src/psbt/finalizer.rs b/src/psbt/finalizer.rs index 7bc1e2b3..a78b23a1 100644 --- a/src/psbt/finalizer.rs +++ b/src/psbt/finalizer.rs @@ -360,7 +360,7 @@ fn input_sanity_checks(psbt: &Psbt, index: usize) -> Result<(), super::Error> { )); } let (flag, sig) = rawsig.split_last().unwrap(); - let flag = elements::EcdsaSighashType::from_u32(*flag as u32); + let flag = elements::EcdsaSighashType::from_u32(u32::from(*flag)); if target != flag { return Err(Error::InputError( InputError::WrongSighashFlag { From a4ec6fba7953f74068e8d15ef91e5c03f8309c24 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 26 Aug 2025 16:30:54 +0000 Subject: [PATCH 4/4] ci: fix doclinks --- src/confidential/elip151.rs | 2 +- src/confidential/slip77.rs | 2 +- src/descriptor/mod.rs | 3 +-- src/extensions/arith.rs | 4 ++-- src/psbt/mod.rs | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/confidential/elip151.rs b/src/confidential/elip151.rs index 227f068c..14622781 100644 --- a/src/confidential/elip151.rs +++ b/src/confidential/elip151.rs @@ -14,7 +14,7 @@ //! ELIP151 //! //! Implementation of the ELIP151 protocol, documented at -//! https://github.com/ElementsProject/ELIPs/blob/main/elip-0151.md +//! //! use bitcoin::hashes::{sha256t_hash_newtype, Hash}; diff --git a/src/confidential/slip77.rs b/src/confidential/slip77.rs index 198a59b2..da19e568 100644 --- a/src/confidential/slip77.rs +++ b/src/confidential/slip77.rs @@ -15,7 +15,7 @@ //! SLIP77 //! //! Implementation of the SLIP77 protocol, documented at -//! https://github.com/satoshilabs/slips/blob/master/slip-0077.md +//! //! use std::{borrow, fmt}; diff --git a/src/descriptor/mod.rs b/src/descriptor/mod.rs index c6f56286..d9917ea5 100644 --- a/src/descriptor/mod.rs +++ b/src/descriptor/mod.rs @@ -870,10 +870,9 @@ impl Descriptor { /// ``` /// /// and is only here really here for backwards compatbility. - /// See [`at_derivation_index`] and `[derived_descriptor`] for more documentation. + /// See [`at_derivation_index`] for more documentation. /// /// [`at_derivation_index`]: Self::at_derivation_index - /// [`derived_descriptor`]: crate::DerivedDescriptor::derived_descriptor /// /// # Errors /// diff --git a/src/extensions/arith.rs b/src/extensions/arith.rs index 3ae55bd8..583a57db 100644 --- a/src/extensions/arith.rs +++ b/src/extensions/arith.rs @@ -915,8 +915,8 @@ pub enum ArithInner { Geq(Expr, Expr), } -/// Wrapper around [`ArithInner`] that ensures that the expression is valid. -/// See [`ArithInner`] for more details. +/// Wrapper around `ArithInner` that ensures that the expression is valid. +/// See `ArithInner` for more details. /// /// Note that the library allows construction of unchecked [`Expr], but /// [`Arith`] is always checked. diff --git a/src/psbt/mod.rs b/src/psbt/mod.rs index 18230ca3..e20c795b 100644 --- a/src/psbt/mod.rs +++ b/src/psbt/mod.rs @@ -613,7 +613,7 @@ pub trait PsbtExt { /// Get the sighash message(data to sign) at input index `idx` based on the sighash /// flag specified in the [`Psbt`] sighash field. If the input sighash flag psbt field is `None` - /// the [`SchnorrSighashType::Default`](elements::sighash::SchnorrSighashType::Default) is chosen + /// the [`SchnorrSighashType::Default`] is chosen /// for for taproot spends, otherwise [`EcdsaSignatureHashType::All`](elements::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 output, returns a [`PsbtSighashMsg::EcdsaSighash`] variant.