Skip to content

Commit

Permalink
chore: update to new amplify ByteArray APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 6, 2023
1 parent f1cdb38 commit a23d9e7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ edition = "2021"
license = "Apache-2.0"

[workspace.dependencies]
amplify = "4.0.2"
amplify = "4.2.0"
strict_encoding = "2.5.0"
commit_verify = "0.10.5"
single_use_seals = "0.10.0"
Expand Down
4 changes: 2 additions & 2 deletions dbc/src/tapret/tapscript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ impl CommitVerify<TapretCommitment, Lnpbp12> for TapScript {

#[cfg(test)]
mod test {
use amplify::RawArray;
use amplify::ByteArray;
use commit_verify::{Digest, Sha256};

use super::*;

pub fn commitment() -> TapretCommitment {
let msg = Sha256::digest("test data");
TapretCommitment {
mpc: mpc::Commitment::from_raw_array(msg),
mpc: mpc::Commitment::from_byte_array(msg),
nonce: 8,
}
}
Expand Down
8 changes: 4 additions & 4 deletions primitives/src/coding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::io::{self, Cursor, Read, Write};

use amplify::confinement::{Confined, U32};
use amplify::hex::{self, FromHex, ToHex};
use amplify::{confinement, Bytes32, IoError, RawArray, Wrapper};
use amplify::{confinement, ByteArray, Bytes32, IoError, Wrapper};

use crate::{
ControlBlock, InternalPk, LockTime, Outpoint, RedeemScript, Sats, ScriptBytes, ScriptPubkey,
Expand Down Expand Up @@ -313,7 +313,7 @@ impl ConsensusDecode for Outpoint {

impl ConsensusEncode for Txid {
fn consensus_encode(&self, writer: &mut impl Write) -> Result<usize, IoError> {
writer.write_all(&self.to_raw_array())?;
writer.write_all(&self.to_byte_array())?;
Ok(32)
}
}
Expand Down Expand Up @@ -453,7 +453,7 @@ impl ConsensusEncode for InternalPk {

impl ConsensusEncode for TapBranchHash {
fn consensus_encode(&self, writer: &mut impl Write) -> Result<usize, IoError> {
writer.write_all(&self.to_raw_array())?;
writer.write_all(&self.to_byte_array())?;
Ok(32)
}
}
Expand All @@ -462,7 +462,7 @@ impl ConsensusDecode for TapBranchHash {
fn consensus_decode(reader: &mut impl Read) -> Result<Self, ConsensusDecodeError> {
let mut buf = [0u8; 32];
reader.read_exact(&mut buf)?;
Ok(TapBranchHash::from_raw_array(buf))
Ok(TapBranchHash::from_byte_array(buf))
}
}

Expand Down
10 changes: 5 additions & 5 deletions primitives/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::num::ParseIntError;
use std::str::FromStr;

use amplify::hex::{self, FromHex, ToHex};
use amplify::{Bytes32StrRev, RawArray, Wrapper};
use amplify::{ByteArray, Bytes32StrRev, Wrapper};
use commit_verify::{DigestExt, Sha256};

use crate::{
Expand Down Expand Up @@ -57,7 +57,7 @@ impl Txid {
#[inline]
pub const fn coinbase() -> Self { Self(Bytes32StrRev::zero()) }
#[inline]
pub fn is_coinbase(&self) -> bool { self.to_raw_array() == [0u8; 32] }
pub fn is_coinbase(&self) -> bool { self.to_byte_array() == [0u8; 32] }
}

impl FromHex for Txid {
Expand Down Expand Up @@ -529,7 +529,7 @@ impl Tx {
///
/// This gives a way to identify a transaction that is "the same" as
/// another in the sense of having same inputs and outputs.
pub fn ntxid(&self) -> [u8; 32] { self.to_unsigned_tx().txid().to_raw_array() }
pub fn ntxid(&self) -> [u8; 32] { self.to_unsigned_tx().txid().to_byte_array() }

/// Computes the [`Txid`].
///
Expand All @@ -553,7 +553,7 @@ impl Tx {
.expect("engines don't error");
let mut double = Sha256::default();
double.input_raw(&enc.finish());
Txid::from_raw_array(double.finish())
Txid::from_byte_array(double.finish())
}

/// Computes the segwit version of the transaction id.
Expand All @@ -568,7 +568,7 @@ impl Tx {
.expect("engines don't error");
let mut double = Sha256::default();
double.input_raw(&enc.finish());
Wtxid::from_raw_array(double.finish())
Wtxid::from_byte_array(double.finish())
}
}

Expand Down

0 comments on commit a23d9e7

Please sign in to comment.