Expand description
§xyz-pub
Convert xpubs and xprvs to different versions.
§Example
use xyzpub::{convert_version, Version};
let xpub = "xpub6BosfCnifzxcFwrSzQiqu2DBVTshkCXacvNsWGYJVVhhawA7d4R5WSWGFNbi8Aw6ZRc1brxMyWMzG3DSSSSoekkudhUd9yLb6qx39T9nMdj";
let expected_zpub = "zpub6qUQGY8YyN3ZxYEgf8J6KCQBqQAbdSWaT9RK54L5FWTTh8na8NkCkZpYHnWt7zEwNhqd6p9Utq562cSZsqGqFE87NNsUKnyZeJ5KvbhfC8E";
let result = convert_version(xpub, &Version::Zpub).unwrap();
assert_eq!(result, expected_zpub);
Enums§
Constants§
- VERSION_
TPRV - Version bytes tprv: bitcoin testnet private key for P2PKH or P2SH
- VERSION_
TPUB - Version bytes tpub: bitcoin testnet public key for P2PKH or P2SH
- VERSION_
UPRV - Version bytes uprv: bitcoin testnet private key for P2WPKH in P2SH
- VERSION_
UPRV_ MULTISIG - Version bytes Uprv: bitcoin testnet private key for multi-signature P2WSH in P2SH
- VERSION_
UPUB - Version bytes upub: bitcoin testnet public key for P2WPKH in P2SH
- VERSION_
UPUB_ MULTISIG - Version bytes Upub: bitcoin testnet public key for multi-signature P2WSH in P2SH
- VERSION_
VPRV - Version bytes vprv: bitcoin testnet private key for P2WPKH
- VERSION_
VPRV_ MULTISIG - Version bytes Vprv: bitcoin testnet private key for multi-signature P2WSH
- VERSION_
VPUB - Version bytes vpub: bitcoin testnet public key for P2WPKH
- VERSION_
VPUB_ MULTISIG - Version bytes Vpub: bitcoin testnet public key for multi-signature P2WSH
- VERSION_
XPRV - Version bytes xprv: bitcoin mainnet private key P2PKH or P2SH
- VERSION_
XPUB - Version bytes xpub: bitcoin mainnet public key P2PKH or P2SH
- VERSION_
YPRV - Version bytes yprv: bitcoin mainnet private key P2WPKH in P2SH
- VERSION_
YPRV_ MULTISIG - Version bytes Yprv: bitcoin mainnet private key for multi-signature P2WSH in P2SH
- VERSION_
YPUB - Version bytes ypub: bitcoin mainnet public key P2WPKH in P2SH
- VERSION_
YPUB_ MULTISIG - Version bytes Ypub: bitcoin mainnet public key for multi-signature P2WSH in P2SH
- VERSION_
ZPRV - Version bytes zprv: bitcoin mainnet private key P2WPKH
- VERSION_
ZPRV_ MULTISIG - Version bytes Zprv: bitcoin mainnet private key for multi-signature P2WSH
- VERSION_
ZPUB - Version bytes zpub: bitcoin mainnet public key P2WPKH
- VERSION_
ZPUB_ MULTISIG - Version bytes Zpub: bitcoin mainnet public key for multi-signature P2WSH
Functions§
- convert_
version - Replaces the first 4 bytes of a base58 string with the target’s version and returns the new string. Also checks if the input is a correct address.
- replace_
version_ bytes - Replaces the first 4 bytes of a byte slice with the target’s version and returns a new byte vec. Does not check if extended public/private key is valid and only replaces the version bytes.