Rename ToWalletDescriptor to IntoWalletDescriptor

This commit is contained in:
Steve Myers 2021-02-12 22:34:43 -08:00
parent 2f7513753c
commit d638da2f10
No known key found for this signature in database
GPG Key ID: 8105A46B22C2D051
6 changed files with 19 additions and 19 deletions

View File

@ -27,7 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Wallet ### Wallet
#### Changed #### Changed
- Removed the explicit `id` argument from `Wallet::add_signer()` since that's now part of `Signer` itself - Removed the explicit `id` argument from `Wallet::add_signer()` since that's now part of `Signer` itself
- Renamed `ToWalletDescriptor::to_wallet_descriptor` to `ToWalletDescriptor::into_wallet_descriptor` - Renamed `ToWalletDescriptor::to_wallet_descriptor` to `IntoWalletDescriptor::into_wallet_descriptor`
### Policy ### Policy
#### Changed #### Changed

View File

@ -72,7 +72,7 @@ pub type DerivedDescriptor<'s> = Descriptor<DerivedDescriptorKey<'s>>;
pub type HDKeyPaths = BTreeMap<PublicKey, KeySource>; pub type HDKeyPaths = BTreeMap<PublicKey, KeySource>;
/// Trait for types which can be converted into an [`ExtendedDescriptor`] and a [`KeyMap`] usable by a wallet in a specific [`Network`] /// Trait for types which can be converted into an [`ExtendedDescriptor`] and a [`KeyMap`] usable by a wallet in a specific [`Network`]
pub trait ToWalletDescriptor { pub trait IntoWalletDescriptor {
/// Convert to wallet descriptor /// Convert to wallet descriptor
fn into_wallet_descriptor( fn into_wallet_descriptor(
self, self,
@ -81,7 +81,7 @@ pub trait ToWalletDescriptor {
) -> Result<(ExtendedDescriptor, KeyMap), DescriptorError>; ) -> Result<(ExtendedDescriptor, KeyMap), DescriptorError>;
} }
impl ToWalletDescriptor for &str { impl IntoWalletDescriptor for &str {
fn into_wallet_descriptor( fn into_wallet_descriptor(
self, self,
secp: &SecpCtx, secp: &SecpCtx,
@ -107,7 +107,7 @@ impl ToWalletDescriptor for &str {
} }
} }
impl ToWalletDescriptor for &String { impl IntoWalletDescriptor for &String {
fn into_wallet_descriptor( fn into_wallet_descriptor(
self, self,
secp: &SecpCtx, secp: &SecpCtx,
@ -117,7 +117,7 @@ impl ToWalletDescriptor for &String {
} }
} }
impl ToWalletDescriptor for ExtendedDescriptor { impl IntoWalletDescriptor for ExtendedDescriptor {
fn into_wallet_descriptor( fn into_wallet_descriptor(
self, self,
secp: &SecpCtx, secp: &SecpCtx,
@ -127,7 +127,7 @@ impl ToWalletDescriptor for ExtendedDescriptor {
} }
} }
impl ToWalletDescriptor for (ExtendedDescriptor, KeyMap) { impl IntoWalletDescriptor for (ExtendedDescriptor, KeyMap) {
fn into_wallet_descriptor( fn into_wallet_descriptor(
self, self,
secp: &SecpCtx, secp: &SecpCtx,
@ -160,7 +160,7 @@ impl ToWalletDescriptor for (ExtendedDescriptor, KeyMap) {
} }
} }
impl ToWalletDescriptor for DescriptorTemplateOut { impl IntoWalletDescriptor for DescriptorTemplateOut {
fn into_wallet_descriptor( fn into_wallet_descriptor(
self, self,
_secp: &SecpCtx, _secp: &SecpCtx,
@ -637,7 +637,7 @@ mod test {
assert_eq!(wallet_desc.to_string(), "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)#y8p7e8kk"); assert_eq!(wallet_desc.to_string(), "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)#y8p7e8kk");
} }
// test ToWalletDescriptor trait from &str with and without checksum appended // test IntoWalletDescriptor trait from &str with and without checksum appended
#[test] #[test]
fn test_descriptor_from_str_with_checksum() { fn test_descriptor_from_str_with_checksum() {
let secp = Secp256k1::new(); let secp = Secp256k1::new();
@ -673,7 +673,7 @@ mod test {
)); ));
} }
// test ToWalletDescriptor trait from &str with keys from right and wrong network // test IntoWalletDescriptor trait from &str with keys from right and wrong network
#[test] #[test]
fn test_descriptor_from_str_with_keys_network() { fn test_descriptor_from_str_with_keys_network() {
let secp = Secp256k1::new(); let secp = Secp256k1::new();
@ -717,7 +717,7 @@ mod test {
)); ));
} }
// test ToWalletDescriptor trait from the output of the descriptor!() macro // test IntoWalletDescriptor trait from the output of the descriptor!() macro
#[test] #[test]
fn test_descriptor_from_str_from_output_of_macro() { fn test_descriptor_from_str_from_output_of_macro() {
let secp = Secp256k1::new(); let secp = Secp256k1::new();

View File

@ -888,7 +888,7 @@ impl ExtractPolicy for Descriptor<DescriptorPublicKey> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::descriptor; use crate::descriptor;
use crate::descriptor::{ExtractPolicy, ToWalletDescriptor}; use crate::descriptor::{ExtractPolicy, IntoWalletDescriptor};
use super::*; use super::*;
use crate::descriptor::policy::SatisfiableItem::{Multisig, Signature, Thresh}; use crate::descriptor::policy::SatisfiableItem::{Multisig, Signature, Thresh};

View File

@ -32,7 +32,7 @@ use bitcoin::Network;
use miniscript::{Legacy, Segwitv0}; use miniscript::{Legacy, Segwitv0};
use super::{ExtendedDescriptor, KeyMap, ToWalletDescriptor}; use super::{ExtendedDescriptor, IntoWalletDescriptor, KeyMap};
use crate::descriptor::DescriptorError; use crate::descriptor::DescriptorError;
use crate::keys::{DerivableKey, ToDescriptorKey, ValidNetworks}; use crate::keys::{DerivableKey, ToDescriptorKey, ValidNetworks};
use crate::wallet::utils::SecpCtx; use crate::wallet::utils::SecpCtx;
@ -43,7 +43,7 @@ pub type DescriptorTemplateOut = (ExtendedDescriptor, KeyMap, ValidNetworks);
/// Trait for descriptor templates that can be built into a full descriptor /// Trait for descriptor templates that can be built into a full descriptor
/// ///
/// Since [`ToWalletDescriptor`] is implemented for any [`DescriptorTemplate`], they can also be /// Since [`IntoWalletDescriptor`] is implemented for any [`DescriptorTemplate`], they can also be
/// passed directly to the [`Wallet`](crate::Wallet) constructor. /// passed directly to the [`Wallet`](crate::Wallet) constructor.
/// ///
/// ## Example /// ## Example
@ -69,7 +69,7 @@ pub trait DescriptorTemplate {
/// Turns a [`DescriptorTemplate`] into a valid wallet descriptor by calling its /// Turns a [`DescriptorTemplate`] into a valid wallet descriptor by calling its
/// [`build`](DescriptorTemplate::build) method /// [`build`](DescriptorTemplate::build) method
impl<T: DescriptorTemplate> ToWalletDescriptor for T { impl<T: DescriptorTemplate> IntoWalletDescriptor for T {
fn into_wallet_descriptor( fn into_wallet_descriptor(
self, self,
secp: &SecpCtx, secp: &SecpCtx,

View File

@ -67,7 +67,7 @@ use crate::database::{BatchDatabase, BatchOperations, DatabaseUtils};
use crate::descriptor::derived::AsDerived; use crate::descriptor::derived::AsDerived;
use crate::descriptor::{ use crate::descriptor::{
get_checksum, DerivedDescriptor, DerivedDescriptorMeta, DescriptorMeta, DescriptorScripts, get_checksum, DerivedDescriptor, DerivedDescriptorMeta, DescriptorMeta, DescriptorScripts,
ExtendedDescriptor, ExtractPolicy, Policy, ToWalletDescriptor, XKeyUtils, ExtendedDescriptor, ExtractPolicy, IntoWalletDescriptor, Policy, XKeyUtils,
}; };
use crate::error::Error; use crate::error::Error;
use crate::psbt::PSBTUtils; use crate::psbt::PSBTUtils;
@ -110,7 +110,7 @@ where
D: BatchDatabase, D: BatchDatabase,
{ {
/// Create a new "offline" wallet /// Create a new "offline" wallet
pub fn new_offline<E: ToWalletDescriptor>( pub fn new_offline<E: IntoWalletDescriptor>(
descriptor: E, descriptor: E,
change_descriptor: Option<E>, change_descriptor: Option<E>,
network: Network, network: Network,
@ -124,7 +124,7 @@ impl<B, D> Wallet<B, D>
where where
D: BatchDatabase, D: BatchDatabase,
{ {
fn _new<E: ToWalletDescriptor>( fn _new<E: IntoWalletDescriptor>(
descriptor: E, descriptor: E,
change_descriptor: Option<E>, change_descriptor: Option<E>,
network: Network, network: Network,
@ -1247,7 +1247,7 @@ where
{ {
/// Create a new "online" wallet /// Create a new "online" wallet
#[maybe_async] #[maybe_async]
pub fn new<E: ToWalletDescriptor>( pub fn new<E: IntoWalletDescriptor>(
descriptor: E, descriptor: E,
change_descriptor: Option<E>, change_descriptor: Option<E>,
network: Network, network: Network,

View File

@ -560,7 +560,7 @@ impl Eq for SignersContainerKey {}
mod signers_container_tests { mod signers_container_tests {
use super::*; use super::*;
use crate::descriptor; use crate::descriptor;
use crate::descriptor::ToWalletDescriptor; use crate::descriptor::IntoWalletDescriptor;
use crate::keys::{DescriptorKey, ToDescriptorKey}; use crate::keys::{DescriptorKey, ToDescriptorKey};
use bitcoin::secp256k1::{All, Secp256k1}; use bitcoin::secp256k1::{All, Secp256k1};
use bitcoin::util::bip32; use bitcoin::util::bip32;