Repository navigation
Conversation
| - Breaking: `DescriptorKeyParseError` is a `#[non_exhaustive]` enum instead of a struct holding a string, and no longer derives `Copy`. The new `MalformedKeyDataKind` enum describes malformed key data. Messages start with a lowercase letter and follow rust-miniscript. The Elements-only `HexPrivateKey` variant reports a bad hex view key in a `ct()` descriptor. Ported from rust-miniscript 497c5a3 and bd5db6a. | ||
| - Breaking: `ConversionError` is replaced by the `#[non_exhaustive]` `NonDefiniteKeyError`, with `Wildcard`, `Multipath`, `HardenedStep` and `MaximumDepthExceeded` variants. It is returned by `DefiniteDescriptorKey::new`, `DescriptorPublicKey::at_derivation_index`, `Descriptor::at_derivation_index`, `Descriptor::derived_descriptor`, `Descriptor::find_derivation_index_for_spk`, `confidential::Descriptor::at_derivation_index` and the PSET `update_with_descriptor_unchecked` methods, and held by `UtxoUpdateError::DerivationError` and `OutputUpdateError::DerivationError`. `Error::Conversion` becomes `Error::NonDefiniteKey`. Ported from rust-miniscript 258873f, dad3532, 7b3b3a8, 4930ccb and 613ed0d. | ||
| - Breaking: `DefiniteDescriptorKey::new` is public and returns `Result<Self, NonDefiniteKeyError>`. Keys with a wildcard were already rejected. It now also rejects a hardened derivation step after an xpub (`HardenedStep`), several derivation paths (`Multipath`), and a derivation deeper than BIP32's maximum depth of 255 (`MaximumDepthExceeded`), checked in the order wildcard, hardened step, multipath, depth. `DescriptorPublicKey::at_derivation_index`, and the descriptor methods built on it, return the same errors. `DefiniteDescriptorKey::from_str` wraps them in `DescriptorKeyParseError::NonDefiniteKey`, so `Descriptor::<DefiniteDescriptorKey>::from_str` now rejects hardened and multipath keys, which previously parsed and panicked when derived, for example in `script_pubkey`. A `ct()` descriptor whose bare blinding key has a hardened wildcard now fails in `at_derivation_index` instead of `address`. Ported from rust-miniscript dad3532, 7b3b3a8, 97c948d and 613ed0d. | ||
| - Parsing an xpub or xprv whose derivation goes deeper than BIP32's maximum depth of 255 fails with `DescriptorKeyParseError::MalformedKeyData(MalformedKeyDataKind::MaximumDepthExceeded)`, so such a string never reaches the constructor. A wildcard or multipath step counts as one step, and origin steps don't count. The constructor's `NonDefiniteKeyError::MaximumDepthExceeded` is only returned for keys built in code. Ported from rust-miniscript f2862f7. | ||
| - Breaking: `DefiniteDescriptorKey::derive_public_key` returns a `bitcoin::PublicKey` and `Descriptor::<DefiniteDescriptorKey>::derived_descriptor` returns a descriptor, instead of a `Result`. Ported from rust-miniscript c169af0. | ||
| - Breaking: the deprecated `DescriptorPublicKey::is_deriveable`, `DescriptorPublicKey::derive`, `Descriptor::is_deriveable` and `Descriptor::derive` are removed. Use `has_wildcard` and `at_derivation_index`. Ported from rust-miniscript 77ed78b. | ||
| - Breaking: `UtxoUpdateError` and `OutputUpdateError` derive only `Debug`, `PartialEq`, `Eq` and `Clone`. `NonDefiniteKeyError`, `MalformedKeyDataKind` and `DescriptorKeyParseError` derive `Eq`. Ported from rust-miniscript 627d963. | ||
| - Add `DescriptorPublicKey::has_hardened_step`. Ported from rust-miniscript 7b3b3a8 and, for its doc line, 4906bed (partial). | ||
| - `DescriptorSecretKey::to_public` converts a multi-xpriv into a multi-xpub when all hardened derivation steps are shared among its paths, instead of always failing. Ported from rust-miniscript 7d3e1e8. | ||
|
|
There was a problem hiding this comment.
There is no way around with this changelog
Maybe the reorg will help, but the total number of already introduced changes does not help
Will be grateful for the advice regarding this
|
If/when this merged I will be able to fully resolve the #107 |
|
Hah, thanks for doing all this work. I'd suggest that we just copy/paste the whole key module, reapply the elements changes (if any) and not attempt to cherry-pick the individual changes. Actually, what I'd suggest is that we delete the I believe that keys between rust-miniscript and elements-miniscript should be literally identical types now. Historically they needed to be distinct because secp256k1-zkp keys were different from secp256k1 keys, but that should be fixed with the next release of rust-secp-zkp. And historically we needed rust-secp-zkp to get musig2, but that shouldn't be needed either as soon as https://git.rust-bitcoin.org/rust-bitcoin/rust-secp256k1/pulls/952 merges. |
|
07aefaf needs rebase |
07aefaf to
93abf33
Compare
Rebased |
93abf33 to
f345bdf
Compare
Port of upstream "psbt: remove derives from UtxoUpdateError and OutputUpdateError". Source: rust-miniscript 627d963 Co-authored-by: Andrew Poelstra <apoelstra@wpsoftware.net>
Use the name and variant names of the equivalent rust-miniscript error, so that the key module can be replaced with rust-miniscript's
Give confidential/mod.rs a copy of a maybe_fmt_master_id, so that the key module can be replaced with rust-miniscript's, which does not export it
Port of upstream "key.rs: remove a bunch of unwrap()s which are impossible", for its descriptor and PSET part. Source: rust-miniscript c169af0 Co-authored-by: Andrew Poelstra <apoelstra@wpsoftware.net>
Port of upstream "key.rs: remove some deprecated methods", for its descriptor part. Source: rust-miniscript 77ed78b Co-authored-by: Andrew Poelstra <apoelstra@wpsoftware.net>
Port of upstream "fuzz: add fuzz test for parsing definite descriptor keys". Source: rust-miniscript f09bf48 Co-authored-by: Andrew Poelstra <apoelstra@wpsoftware.net>
f345bdf to
fb283f3
Compare
|
Reworked as you suggested: |
Part of #107.
As suggested in review, this deletes
src/descriptor/key.rs, our fork of rust-miniscript's key module, and re-exports the key types from rust-miniscript 13.2 instead of porting its changes one by one. The types are already identical underneath, since secp256k1-zkp 0.11 re-exports secp256k1.Commits:
ConversionErrortoNonDefiniteKeyError, and giveconfidentialits own copy ofmaybe_fmt_master_id.ct()view keys inconfidential, then deletekey.rsand re-export.derived_descriptorbecomes infallible (c169af0), the deprecatedis_deriveableandderiveare removed (77ed78b), and aparse_descriptor_definitefuzz target is added (f09bf48).Breaking changes are listed in the CHANGELOG. The main ones:
ConversionErroris nowNonDefiniteKeyError, andError::Conversionis nowError::NonDefiniteKey.SinglePub,DescriptorXKeyandDescriptorMultiXKeylose theMiniscriptKeyandDisplayimpls added in Implement MiniscriptKey for each variant of DescriptorPublicKey #100. rust-miniscript has them only on master (#938), and they can't be added back on re-exported types.This does not close #107:
ct(elip151, …)with a hardened key still panics inelip151.rs. That fix comes in a separate PR on top of this one.