You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2ad6555 Rename "derive" things that are not doing derivation (LLFourn)
6dc6aca Make DerivedDescriptorKey first-class citizen (LLFourn)
Pull request description:
This PR further develops the idea introduced in #345. It has two commits both with relatively detailed commit messages that can be reviewed separately. In summary:
1. Develop the `DerivedDescriptorKey` (a key that is guaranteed not to have wildcard in it) idea more by adding missing functionality and refining the API. In addition, I removed the error cases from `ConversionError` which seems to have been omitted from #345.
2. Since the introduction of `DerivedDescriptorKey`, the overlapping usage of the term "derive" has become quite confusing. In addition to the usual definition of "derive" we have also used it to mean "replace a wildcard with a particular derivation index". I deprecated and renamed everything that uses the latter definition.
ACKs for top commit:
apoelstra:
ACK 2ad6555
sanket1729:
ACK 2ad6555. Thanks for the clean changes.
Tree-SHA512: 0198404a1bfecab2324a8785117248fc566cfbb53decbd234928e378f102bdc5c5de6d31b437b8f1b0ba90ef524a362a46150028f80a4b029589406233abd2fe
let public_key = DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/2").unwrap();
let public_key = DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*").unwrap();
let public_key = DescriptorPublicKey::from_str("[abcdef00/0'/1']tpubDBrgjcxBxnXyL575sHdkpKohWu5qHKoQ7TJXKNrYznh5fVEGBv89hA8ENW7A8MFVpFUSvgLqc4Nj1WZcpePX6rrxviVtPowvMuGF5rdT2Vi/*h").unwrap();
let secret_key = DescriptorSecretKey::from_str("tprv8ZgxMBicQKsPcwcD4gSnMti126ZiETsuX7qwrtMypr6FBwAP65puFn4v6c3jrN9VwtMRMph6nyT63NrfUL4C3nBzPcduzVSuHD7zbX2JKVc/0'/1'/2'").unwrap();
985
1005
let public_key = secret_key.to_public(&secp).unwrap();
/// Convert all the public keys in the descriptor to [`bitcoin::PublicKey`] by deriving them or
555
+
/// otherwise converting them. All [`bitcoin::XOnlyPublicKey`]s are converted to by adding a
556
+
/// default(0x02) y-coordinate.
547
557
///
548
-
/// # Examples
558
+
/// This is a shorthand for:
549
559
///
550
560
/// ```
551
-
/// use miniscript::descriptor::{Descriptor, DescriptorPublicKey};
552
-
/// use miniscript::bitcoin::secp256k1;
553
-
/// use std::str::FromStr;
554
-
///
555
-
/// // test from bip 86
556
-
/// let secp = secp256k1::Secp256k1::verification_only();
557
-
/// let descriptor = Descriptor::<DescriptorPublicKey>::from_str("tr(xpub6BgBgsespWvERF3LHQu6CnqdvfEvtMcQjYrcRzx53QJjSxarj2afYWcLteoGVky7D3UKDP9QyrLprQ3VCECoY49yfdDEHGCtMMj92pReUsQ/0/*)")
561
+
/// # use miniscript::{Descriptor, DescriptorPublicKey, bitcoin::secp256k1::Secp256k1};
562
+
/// # use core::str::FromStr;
563
+
/// # let descriptor = Descriptor::<DescriptorPublicKey>::from_str("tr(xpub6BgBgsespWvERF3LHQu6CnqdvfEvtMcQjYrcRzx53QJjSxarj2afYWcLteoGVky7D3UKDP9QyrLprQ3VCECoY49yfdDEHGCtMMj92pReUsQ/0/*)")
558
564
/// .expect("Valid ranged descriptor");
559
-
/// let result = descriptor.derived_descriptor(&secp, 0).expect("Non-hardened derivation");
/// Convert all the public keys in the descriptor to [`bitcoin::PublicKey`] by deriving them or
741
+
/// otherwise converting them. All [`bitcoin::XOnlyPublicKey`]s are converted to by adding a
742
+
/// default(0x02) y-coordinate.
743
+
///
744
+
/// # Examples
745
+
///
746
+
/// ```
747
+
/// use miniscript::descriptor::{Descriptor, DescriptorPublicKey};
748
+
/// use miniscript::bitcoin::secp256k1;
749
+
/// use std::str::FromStr;
750
+
///
751
+
/// // test from bip 86
752
+
/// let secp = secp256k1::Secp256k1::verification_only();
753
+
/// let descriptor = Descriptor::<DescriptorPublicKey>::from_str("tr(xpub6BgBgsespWvERF3LHQu6CnqdvfEvtMcQjYrcRzx53QJjSxarj2afYWcLteoGVky7D3UKDP9QyrLprQ3VCECoY49yfdDEHGCtMMj92pReUsQ/0/*)")
754
+
/// .expect("Valid ranged descriptor");
755
+
/// let result = descriptor.at_derivation_index(0).derived_descriptor(&secp).expect("Non-hardened derivation");
let derived = descriptor.translate_pk(&mut bip32_derivation)?;
1077
1076
@@ -1439,7 +1438,7 @@ mod tests {
1439
1438
#[test]
1440
1439
fntest_update_input_checks(){
1441
1440
let desc = format!("tr([73c5da0a/86'/0'/0']xpub6BgBgsespWvERF3LHQu6CnqdvfEvtMcQjYrcRzx53QJjSxarj2afYWcLteoGVky7D3UKDP9QyrLprQ3VCECoY49yfdDEHGCtMMj92pReUsQ/0/0)");
1442
-
let desc = Descriptor::<DescriptorPublicKey>::from_str(&desc).unwrap();
1441
+
let desc = Descriptor::<DefiniteDescriptorKey>::from_str(&desc).unwrap();
0 commit comments