Skip to content

Commit

Permalink
SFT-3392: Update bitcoin to 0.31.
Browse files Browse the repository at this point in the history
* Cargo.toml (workspace.dependencies) <bitcoin>: Update to 0.31.
* test-vectors/src/lib.rs: Adapt to bitcoin 0.31.
* urtypes/src/registry/crypto_address.rs: Ditto.
* urtypes/src/registry/crypto_hdkey.rs: Ditto.

Signed-off-by: Jean-Pierre De Jesus DIAZ <[email protected]>
  • Loading branch information
jeandudey committed Feb 19, 2024
1 parent 71f4b9e commit 31aae33
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ homepage = "https://github.com/Foundation-Devices/foundation-rs"
arbitrary = { version = "1", features = ["derive"] }
bech32 = { version = "0.9", default-features = false }
bip39 = { version = "2", default-features = false }
bitcoin = { version = "0.30", default-features = false }
bitcoin = { version = "0.31", default-features = false }
bitcoin_hashes = { version = "0.13", default-features = false }
bs58 = "0.5"
crc = "3"
Expand Down
4 changes: 2 additions & 2 deletions test-vectors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ mod blockchain_commons {
#[serde(rename_all = "kebab-case")]
pub enum CryptoHDKeyVector {
Xpub {
key: bitcoin::bip32::ExtendedPubKey,
key: bitcoin::bip32::Xpub,
origin: Option<bitcoin::bip32::DerivationPath>,
},
Xprv {
key: bitcoin::bip32::ExtendedPrivKey,
key: bitcoin::bip32::Xpriv,
},
}

Expand Down
12 changes: 6 additions & 6 deletions urtypes/src/registry/crypto_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ impl<'a> TryFrom<&'a bitcoin::Address<bitcoin::address::NetworkUnchecked>> for C
fn try_from(
address: &'a bitcoin::Address<bitcoin::address::NetworkUnchecked>,
) -> Result<Self, Self::Error> {
let kind = AddressKind::try_from(&address.payload).ok();
let data = data_from_payload(&address.payload)?;
let kind = AddressKind::try_from(address.payload()).ok();
let data = data_from_payload(address.payload())?;

Ok(Self {
info: None,
Expand All @@ -66,14 +66,14 @@ impl<'a> TryFrom<&'a bitcoin::Address<bitcoin::address::NetworkChecked>> for Cry
use crate::registry::CoinType;
use bitcoin::Network;

let network = match address.network {
let network = match address.network() {
Network::Bitcoin => CryptoCoinInfo::NETWORK_MAINNET,
Network::Testnet => CryptoCoinInfo::NETWORK_BTC_TESTNET,
_ => return Err(InterpretAddressError::UnsupportedNetwork),
};
let info = CryptoCoinInfo::new(CoinType::BTC, network);
let kind = AddressKind::try_from(&address.payload).ok();
let data = data_from_payload(&address.payload)?;
let kind = AddressKind::try_from(address.payload()).ok();
let data = data_from_payload(address.payload())?;

Ok(Self {
info: Some(info),
Expand Down Expand Up @@ -212,7 +212,7 @@ impl TryFrom<&bitcoin::address::Payload> for AddressKind {
type Error = UnknownAddressType;

fn try_from(value: &bitcoin::address::Payload) -> Result<Self, Self::Error> {
use bitcoin::address::{Payload, WitnessVersion};
use bitcoin::{address::Payload, blockdata::script::witness_version::WitnessVersion};

let kind = match value {
Payload::PubkeyHash(_) => AddressKind::P2PKH,
Expand Down
8 changes: 4 additions & 4 deletions urtypes/src/registry/crypto_hdkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ impl<'a> CryptoHDKey<'a> {
}

#[cfg(feature = "bitcoin")]
impl<'a> TryFrom<&'a bitcoin::bip32::ExtendedPrivKey> for CryptoHDKey<'a> {
impl<'a> TryFrom<&'a bitcoin::bip32::Xpriv> for CryptoHDKey<'a> {
type Error = InterpretExtendedKeyError;

fn try_from(xprv: &'a bitcoin::bip32::ExtendedPrivKey) -> Result<Self, Self::Error> {
fn try_from(xprv: &'a bitcoin::bip32::Xpriv) -> Result<Self, Self::Error> {
use crate::registry::CoinType;

if xprv.depth == 0 {
Expand Down Expand Up @@ -67,10 +67,10 @@ impl<'a> TryFrom<&'a bitcoin::bip32::ExtendedPrivKey> for CryptoHDKey<'a> {
}

#[cfg(feature = "bitcoin")]
impl<'a> TryFrom<&'a bitcoin::bip32::ExtendedPubKey> for CryptoHDKey<'a> {
impl<'a> TryFrom<&'a bitcoin::bip32::Xpub> for CryptoHDKey<'a> {
type Error = InterpretExtendedKeyError;

fn try_from(xpub: &'a bitcoin::bip32::ExtendedPubKey) -> Result<Self, Self::Error> {
fn try_from(xpub: &'a bitcoin::bip32::Xpub) -> Result<Self, Self::Error> {
use crate::registry::CoinType;

Ok(Self::DerivedKey(DerivedKey {
Expand Down

0 comments on commit 31aae33

Please sign in to comment.