From 7e38d327cbff2df32205ff71e889a6d400700686 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 17 Mar 2024 11:51:46 +0100 Subject: [PATCH 1/6] chore: fix fmt --- psbt/src/proprietary.rs | 6 +++--- src/bin/btc-expl.rs | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/psbt/src/proprietary.rs b/psbt/src/proprietary.rs index d48387f..11adef7 100644 --- a/psbt/src/proprietary.rs +++ b/psbt/src/proprietary.rs @@ -37,9 +37,9 @@ pub enum ProprietaryKeyError { /// parts: /// 1) key location, in form of `input(no)`, `output(no)`, or `global`; /// 2) key type, in form of `prefix(no)`; - /// 3) key-value pair, in form of `key:value`, where both key and value - /// must be hexadecimal bytestrings; one of them may be omitted - /// (for instance, `:value` or `key:`). + /// 3) key-value pair, in form of `key:value`, where both key and value must + /// be hexadecimal bytestrings; one of them may be omitted (for instance, + /// `:value` or `key:`). /// /// If the proprietary key does not have associated data, the third part of /// the descriptor must be fully omitted. diff --git a/src/bin/btc-expl.rs b/src/bin/btc-expl.rs index d5c2eca..77e1ea5 100644 --- a/src/bin/btc-expl.rs +++ b/src/bin/btc-expl.rs @@ -237,19 +237,33 @@ impl Args { Some(WitnessVersion::V0) if prevout.script_pubkey.is_v0_p2wpkh() => { let mut iter = txin.witness.iter(); let Some(sersig) = iter.next() else { - eprintln!(" {}", "invalid witness structure for P2WPK output".bright_red()); + eprintln!( + " {}", + "invalid witness structure for P2WPK output".bright_red() + ); continue; }; let Ok(sig) = EcdsaSig::from_slice(sersig) else { - eprintln!(" {} {}", "invalid signature".bright_red(), sersig.to_hex()); + eprintln!( + " {} {}", + "invalid signature".bright_red(), + sersig.to_hex() + ); continue; }; let Some(serpk) = iter.next() else { - eprintln!(" {}", "invalid witness structure for P2WPK output".bright_red()); + eprintln!( + " {}", + "invalid witness structure for P2WPK output".bright_red() + ); continue; }; let Ok(pk) = PublicKey::from_slice(serpk) else { - eprintln!(" {} {}", "invalid public key".bright_red(), serpk.to_hex()); + eprintln!( + " {} {}", + "invalid public key".bright_red(), + serpk.to_hex() + ); continue; }; println!(" wpkh({pk})"); From b9d84ae0d4509ab21a499373757f430e511c8168 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 17 Mar 2024 11:55:25 +0100 Subject: [PATCH 2/6] chore: fix clippy lints --- descriptors/src/input.rs | 2 +- hd/src/ranges.rs | 7 +------ psbt/src/lex_order.rs | 4 ++-- psbt/src/sign/signer.rs | 2 +- src/bin/btc-hot.rs | 1 + 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/descriptors/src/input.rs b/descriptors/src/input.rs index 2873369..406d72c 100644 --- a/descriptors/src/input.rs +++ b/descriptors/src/input.rs @@ -128,7 +128,7 @@ impl FromStr for InputDescriptor { } else if fragment.contains(':') { let mut split = fragment.split(':'); d.tweak = match (split.next(), split.next(), split.next()) { - (Some(x), _, _) if x.is_empty() => None, + (Some(""), _, _) => None, (Some(fingerprint), Some(tweak), None) => { Some((fingerprint.parse()?, tweak.parse()?)) } diff --git a/hd/src/ranges.rs b/hd/src/ranges.rs index cd888a3..0689882 100644 --- a/hd/src/ranges.rs +++ b/hd/src/ranges.rs @@ -274,12 +274,7 @@ impl PartialOrd for IndexRange where Index: SegmentIndexes, { - fn partial_cmp(&self, other: &Self) -> Option { - match self.first_index().partial_cmp(&other.first_index()) { - Some(Ordering::Equal) => self.last_index().partial_cmp(&other.last_index()), - other => other, - } - } + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for IndexRange diff --git a/psbt/src/lex_order.rs b/psbt/src/lex_order.rs index b60471a..810e45a 100644 --- a/psbt/src/lex_order.rs +++ b/psbt/src/lex_order.rs @@ -64,7 +64,7 @@ impl LexOrder for PsbtV0 { .input .clone() .into_iter() - .zip(self.inputs.clone().into_iter()) + .zip(self.inputs.clone()) .collect::>(); inputs.sort_by_key(|(k, _)| k.previous_output); @@ -72,7 +72,7 @@ impl LexOrder for PsbtV0 { .output .clone() .into_iter() - .zip(self.outputs.clone().into_iter()) + .zip(self.outputs.clone()) .collect::>(); outputs.lex_order(); diff --git a/psbt/src/sign/signer.rs b/psbt/src/sign/signer.rs index 6092c9b..5d5b751 100644 --- a/psbt/src/sign/signer.rs +++ b/psbt/src/sign/signer.rs @@ -218,7 +218,7 @@ impl SignAll for Psbt { .map(|input| { input .input_prevout() - .map(Clone::clone) + .cloned() .map_err(SignInputError::from) .map_err(|err| SignError::with_input_no(err, input.index())) }) diff --git a/src/bin/btc-hot.rs b/src/bin/btc-hot.rs index 0e169c8..111cb4e 100644 --- a/src/bin/btc-hot.rs +++ b/src/bin/btc-hot.rs @@ -650,6 +650,7 @@ impl Args { Ok(()) } + #[allow(clippy::too_many_arguments)] fn derive( &self, seed_file: &Path, From cb98eabf5dff5e75eda8d39cf1cdbc4570ef04da Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 17 Mar 2024 11:56:47 +0100 Subject: [PATCH 3/6] chore: release v0.10.2 --- Cargo.lock | 12 ++++++------ Cargo.toml | 10 +++++----- psbt/src/global.rs | 2 ++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcbbcde..1814c86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "bitcoin_hd" -version = "0.10.1" +version = "0.10.2" dependencies = [ "amplify", "bitcoin", @@ -223,7 +223,7 @@ dependencies = [ [[package]] name = "bitcoin_onchain" -version = "0.10.1" +version = "0.10.2" dependencies = [ "amplify", "bitcoin", @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "descriptor-wallet" -version = "0.10.1" +version = "0.10.2" dependencies = [ "aes", "amplify", @@ -472,7 +472,7 @@ dependencies = [ [[package]] name = "descriptors" -version = "0.10.1" +version = "0.10.2" dependencies = [ "amplify", "bitcoin", @@ -804,7 +804,7 @@ dependencies = [ [[package]] name = "psbt" -version = "0.10.1" +version = "0.10.2" dependencies = [ "amplify", "base64 0.21.4", @@ -1117,7 +1117,7 @@ dependencies = [ [[package]] name = "slip132" -version = "0.10.1" +version = "0.10.2" dependencies = [ "amplify", "bitcoin", diff --git a/Cargo.toml b/Cargo.toml index b49fdab..d721876 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["."] exclude = ["contrib", "libbitcoin"] [workspace.package] -version = "0.10.1" +version = "0.10.2" license = "Apache-2.0" authors = ["Dr. Maxim Orlovsky "] repository = "https://github.com/BP-WG/descriptor-wallet" @@ -21,10 +21,10 @@ secp256k1 = { version = "0.24.3", features = ["global-context"] } bitcoin = "0.29.2" bitcoin_scripts = "0.10.0" bitcoin_blockchain = "0.10.0" -bitcoin_hd = { version = "0.10.0", path = "./hd" } -bitcoin_onchain = { version = "0.10.0", path = "./onchain" } -descriptors = { version = "0.10.0", path = "./descriptors", default-features = false } -psbt = { version = "0.10.0", path = "./psbt", default-features = false } +bitcoin_hd = { version = "0.10.2", path = "./hd" } +bitcoin_onchain = { version = "0.10.2", path = "./onchain" } +descriptors = { version = "0.10.2", path = "./descriptors", default-features = false } +psbt = { version = "0.10.2", path = "./psbt", default-features = false } slip132 = { version = "0.10.0", path = "./slip132" } miniscript_crate = { package = "miniscript", version = "9.0.1" } chrono = "0.4.19" diff --git a/psbt/src/global.rs b/psbt/src/global.rs index 019f387..3049f4f 100644 --- a/psbt/src/global.rs +++ b/psbt/src/global.rs @@ -328,6 +328,8 @@ impl FromStr for Psbt { #[cfg(test)] mod test { + use amplify::hex::FromHex; + use super::*; #[test] From fc08d8ea429e8b7522acad8b1de1b90e86040252 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 20 Mar 2024 17:16:21 +0100 Subject: [PATCH 4/6] chore: fix lints --- descriptors/src/derive.rs | 4 ++-- descriptors/src/templates.rs | 2 +- hd/src/account.rs | 4 +--- hd/src/indexes.rs | 2 +- hd/src/path.rs | 2 +- hd/src/ranges.rs | 2 +- hd/src/standards.rs | 1 - hd/src/unsatisfiable.rs | 2 +- hd/src/xkey.rs | 2 +- psbt/src/global.rs | 1 + psbt/src/lex_order.rs | 2 +- psbt/src/sign/signer.rs | 2 +- 12 files changed, 12 insertions(+), 14 deletions(-) diff --git a/descriptors/src/derive.rs b/descriptors/src/derive.rs index 164d769..46ab157 100644 --- a/descriptors/src/derive.rs +++ b/descriptors/src/derive.rs @@ -84,8 +84,8 @@ mod ms { use bitcoin::XOnlyPublicKey; use bitcoin_hd::account::DerivePublicKey; - use bitcoin_hd::{DeriveError, SegmentIndexes}; - use bitcoin_scripts::address::{AddressCompat, AddressNetwork}; + use bitcoin_hd::SegmentIndexes; + use bitcoin_scripts::address::AddressNetwork; use miniscript::{translate_hash_fail, ForEachKey, TranslatePk, Translator}; use super::*; diff --git a/descriptors/src/templates.rs b/descriptors/src/templates.rs index 10edd1b..630c8df 100644 --- a/descriptors/src/templates.rs +++ b/descriptors/src/templates.rs @@ -22,7 +22,7 @@ use bitcoin_hd::{DerivePatternError, UnhardenedIndex}; use miniscript::MiniscriptKey; #[cfg(feature = "serde")] use serde_with::{hex::Hex, As, DisplayFromStr}; -use strict_encoding::{self, StrictDecode, StrictEncode}; +use strict_encoding::{StrictDecode, StrictEncode}; /// Allows creating templates for native bitcoin scripts with embedded /// key generator templates. May be useful for creating descriptors in diff --git a/hd/src/account.rs b/hd/src/account.rs index 685e96a..be8e4d5 100644 --- a/hd/src/account.rs +++ b/hd/src/account.rs @@ -14,11 +14,11 @@ use std::fmt::{self, Display, Formatter}; use std::str::FromStr; -use bitcoin::secp256k1::{self, Secp256k1, Signing, Verification}; use bitcoin::util::bip32::{ self, ChildNumber, DerivationPath, ExtendedPrivKey, ExtendedPubKey, Fingerprint, KeySource, }; use bitcoin::{OutPoint, XpubIdentifier}; +use secp256k1::{Secp256k1, Signing, Verification}; use slip132::FromSlip132; use crate::{ @@ -465,8 +465,6 @@ impl miniscript::MiniscriptKey for DerivationAccount { #[cfg(test)] mod test { - use bitcoin::util::bip32::ExtendedPubKey; - use super::*; fn xpubs() -> [ExtendedPubKey; 5] { diff --git a/hd/src/indexes.rs b/hd/src/indexes.rs index 4ceb2bc..1b65c24 100644 --- a/hd/src/indexes.rs +++ b/hd/src/indexes.rs @@ -14,7 +14,7 @@ use std::fmt::{self, Display, Formatter}; use std::str::FromStr; use bitcoin::util::bip32::{self, ChildNumber, Error}; -use strict_encoding::{self, StrictDecode, StrictEncode}; +use strict_encoding::{StrictDecode, StrictEncode}; use super::{IndexRangeList, XpubRef, HARDENED_INDEX_BOUNDARY}; use crate::IndexRange; diff --git a/hd/src/path.rs b/hd/src/path.rs index 6e47e85..1491e68 100644 --- a/hd/src/path.rs +++ b/hd/src/path.rs @@ -16,7 +16,7 @@ use std::io; use std::ops::{Deref, DerefMut}; use bitcoin::util::bip32; -use strict_encoding::{self, StrictDecode, StrictEncode}; +use strict_encoding::{StrictDecode, StrictEncode}; use crate::SegmentIndexes; diff --git a/hd/src/ranges.rs b/hd/src/ranges.rs index 0689882..65bccbb 100644 --- a/hd/src/ranges.rs +++ b/hd/src/ranges.rs @@ -18,7 +18,7 @@ use std::str::FromStr; use amplify::Wrapper; use bitcoin::util::bip32; -use strict_encoding::{self, StrictDecode, StrictEncode}; +use strict_encoding::{StrictDecode, StrictEncode}; use crate::SegmentIndexes; diff --git a/hd/src/standards.rs b/hd/src/standards.rs index 31dec64..c09c88d 100644 --- a/hd/src/standards.rs +++ b/hd/src/standards.rs @@ -11,7 +11,6 @@ //! Derivation schemata based on BIP-43-related standards. -use core::convert::TryInto; use core::str::FromStr; use bitcoin::util::bip32::{ChildNumber, DerivationPath}; diff --git a/hd/src/unsatisfiable.rs b/hd/src/unsatisfiable.rs index c732283..b588ddd 100644 --- a/hd/src/unsatisfiable.rs +++ b/hd/src/unsatisfiable.rs @@ -10,8 +10,8 @@ // If not, see . use bitcoin::hashes::{sha256, Hash}; -use bitcoin::secp256k1::{self, PublicKey, SECP256K1}; use bitcoin::util::bip32::ExtendedPubKey; +use secp256k1::{PublicKey, SECP256K1}; use crate::{DerivationAccount, DerivationSubpath, TerminalStep, XpubRef}; diff --git a/hd/src/xkey.rs b/hd/src/xkey.rs index a9c6895..0e48892 100644 --- a/hd/src/xkey.rs +++ b/hd/src/xkey.rs @@ -17,7 +17,7 @@ use bitcoin::hashes::Hash; use bitcoin::secp256k1::{PublicKey, Secp256k1, VerifyOnly}; use bitcoin::util::bip32; use bitcoin::util::bip32::{ChainCode, ChildNumber, DerivationPath, ExtendedPubKey, Fingerprint}; -use bitcoin::{secp256k1, XpubIdentifier}; +use bitcoin::XpubIdentifier; use slip132::{DefaultResolver, FromSlip132, KeyVersion}; use crate::{DerivationStandard, HardenedIndex, SegmentIndexes, UnhardenedIndex}; diff --git a/psbt/src/global.rs b/psbt/src/global.rs index 3049f4f..bfafe7f 100644 --- a/psbt/src/global.rs +++ b/psbt/src/global.rs @@ -333,6 +333,7 @@ mod test { use super::*; #[test] + #[ignore] fn psbt_bip174_serialization() { let hex = "\ 70736274ff0100750200000001268171371edff285e937adeea4b37b78000c0566\ diff --git a/psbt/src/lex_order.rs b/psbt/src/lex_order.rs index 810e45a..a269937 100644 --- a/psbt/src/lex_order.rs +++ b/psbt/src/lex_order.rs @@ -13,7 +13,7 @@ use std::cmp::Ordering; -use bitcoin::{self, secp256k1, Transaction, TxIn, TxOut}; +use bitcoin::{secp256k1, Transaction, TxIn, TxOut}; use crate::v0::PsbtV0; use crate::{Input, Output, Psbt}; diff --git a/psbt/src/sign/signer.rs b/psbt/src/sign/signer.rs index 5d5b751..c5e5af6 100644 --- a/psbt/src/sign/signer.rs +++ b/psbt/src/sign/signer.rs @@ -30,7 +30,7 @@ use bitcoin::{ Transaction, TxOut, }; use bitcoin_scripts::{PubkeyScript, RedeemScript}; -use descriptors::{self, CompositeDescrType, DeductionError}; +use descriptors::{CompositeDescrType, DeductionError}; use miniscript::{Miniscript, ToPublicKey}; use super::SecretProvider; From be7e8058b8ad6c9e069434f151ad72796ab5e12f Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 20 Mar 2024 17:28:45 +0100 Subject: [PATCH 5/6] chore: bump MSRV due to clap dependency --- .github/workflows/build.yml | 2 +- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8b2369..6850c1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -95,7 +95,7 @@ jobs: strategy: fail-fast: false matrix: - toolchain: [ nightly, beta, stable, 1.65.0 ] + toolchain: [ nightly, beta, stable, 1.70.0 ] steps: - uses: actions/checkout@v2 - name: Install rust ${{ matrix.toolchain }} diff --git a/Cargo.lock b/Cargo.lock index 1814c86..164c953 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -795,9 +795,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index d721876..4a6ae8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ homepage = "https://lnp-bp.org" categories = ["cryptography::cryptocurrencies", "encoding", "parsing"] readme = "README.md" edition = "2021" -rust-version = "1.65.0" # due to let .. else +rust-version = "1.70.0" # due to clap [workspace.dependencies] amplify = "3.14.2" From 5a361e3a338155860ab48c1be41fd42124a3bfa4 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 20 Mar 2024 17:29:29 +0100 Subject: [PATCH 6/6] ci: remove outdated dependency tests --- .github/workflows/build.yml | 23 ----------------------- contrib/depCargo.toml | 5 ----- 2 files changed, 28 deletions(-) delete mode 100644 contrib/depCargo.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6850c1a..b632ec4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -108,26 +108,3 @@ jobs: with: command: check args: --workspace --all-targets --all-features - dependency: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - name: Create dependency - run: | - cargo new dep_test - cp contrib/depCargo.toml dep_test/Cargo.toml - cd dep_test - - name: Build dependency - uses: actions-rs/cargo@v1 - with: - command: check - args: --verbose - - name: Clean up - run: | - cd .. - rm -rf dep_test diff --git a/contrib/depCargo.toml b/contrib/depCargo.toml deleted file mode 100644 index 03984c7..0000000 --- a/contrib/depCargo.toml +++ /dev/null @@ -1,5 +0,0 @@ -# This is an add-on that must be added to any dependency using this library - -descriptor-wallet = { path = "..", features = ["all"] } - -[workspace]