Merge rust-bitcoin/rust-bitcoin#2227: add conversions from TXIDs to merkle nodes

32eb461523 add conversions from TXIDs to merkle nodes (conduition)

Pull request description:

  Fixes https://github.com/rust-bitcoin/rust-bitcoin/issues/2220.

  Also adds the equivalent conversion trait from `Wtxid` -> `WitnessMerkleNode`.

ACKs for top commit:
  Kixunil:
    ACK 32eb461523
  apoelstra:
    ACK 32eb461523

Tree-SHA512: 61cf5548874388dd927feaa50f3c7c7e9f3ac4f7498f6335835499dec93916b5f7ed2bdf91ec27edc977fb5e811f946364d477d4aa25d0aa51b0c618f727d3d2
This commit is contained in:
Andrew Poelstra 2023-11-27 18:27:40 +00:00
commit 64bd34cffb
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 13 additions and 1 deletions

View File

@ -65,7 +65,7 @@ mod newtypes {
/// other [`sha256d::Hash`] types, are serialized in reverse
/// byte order when converted to a hex string via [`std::fmt::Display`] trait operations.
/// See [`hashes::Hash::DISPLAY_BACKWARD`] for more details.
pub struct Txid(sha256d::Hash);
pub struct Txid(sha256d::Hash);
/// A bitcoin witness transaction ID.
pub struct Wtxid(sha256d::Hash);
@ -94,4 +94,16 @@ mod newtypes {
impl_hashencode!(FilterHash);
impl_hashencode!(FilterHeader);
impl From<Txid> for TxMerkleNode {
fn from(txid: Txid) -> Self {
Self::from(txid.0)
}
}
impl From<Wtxid> for WitnessMerkleNode {
fn from(wtxid: Wtxid) -> Self {
Self::from(wtxid.0)
}
}
}