Rename XpubIdentifier to XKeyIdentifier

The BIP-32 extended key identifier is used to identify xpubs and xprivs,
we can rename it to show this.
This commit is contained in:
Tobin C. Harding 2023-08-22 13:41:01 +10:00
parent ffd2466ad1
commit b2a7d7023c
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
2 changed files with 15 additions and 9 deletions

View File

@ -6,6 +6,8 @@
//! at <https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki>.
//!
#![allow(deprecated)] // Remove once we remove XpubIdentifier.
use core::convert::TryInto;
use core::default::Default;
use core::ops::Index;
@ -54,7 +56,11 @@ impl_bytes_newtype!(Fingerprint, 4);
hash_newtype! {
/// XpubIdentifier as defined in BIP-32.
#[deprecated(since = "0.0.0-NEXT-RELEASE", note = "use XKeyIdentifier instead")]
pub struct XpubIdentifier(hash160::Hash);
/// Extended key identifier as defined in BIP-32.
pub struct XKeyIdentifier(hash160::Hash);
}
/// Extended private key
@ -676,7 +682,7 @@ impl Xpriv {
}
/// Returns the HASH160 of the public key belonging to the xpriv
pub fn identifier<C: secp256k1::Signing>(&self, secp: &Secp256k1<C>) -> XpubIdentifier {
pub fn identifier<C: secp256k1::Signing>(&self, secp: &Secp256k1<C>) -> XKeyIdentifier {
Xpub::from_priv(secp, self).identifier()
}
@ -807,10 +813,10 @@ impl Xpub {
}
/// Returns the HASH160 of the chaincode
pub fn identifier(&self) -> XpubIdentifier {
let mut engine = XpubIdentifier::engine();
pub fn identifier(&self) -> XKeyIdentifier {
let mut engine = XKeyIdentifier::engine();
engine.write_all(&self.public_key.serialize()).expect("engines don't error");
XpubIdentifier::from_engine(engine)
XKeyIdentifier::from_engine(engine)
}
/// Returns the first four bytes of the identifier
@ -859,12 +865,12 @@ impl FromStr for Xpub {
}
}
impl From<Xpub> for XpubIdentifier {
fn from(key: Xpub) -> XpubIdentifier { key.identifier() }
impl From<Xpub> for XKeyIdentifier {
fn from(key: Xpub) -> XKeyIdentifier { key.identifier() }
}
impl From<&Xpub> for XpubIdentifier {
fn from(key: &Xpub) -> XpubIdentifier { key.identifier() }
impl From<&Xpub> for XKeyIdentifier {
fn from(key: &Xpub) -> XKeyIdentifier { key.identifier() }
}
#[cfg(test)]

View File

@ -129,7 +129,7 @@ use core2::io;
pub use crate::address::{Address, AddressType};
pub use crate::amount::{Amount, Denomination, SignedAmount};
pub use crate::bip32::XpubIdentifier;
pub use crate::bip32::XKeyIdentifier;
pub use crate::blockdata::block::{self, Block};
pub use crate::blockdata::fee_rate::FeeRate;
pub use crate::blockdata::locktime::{self, absolute, relative};