Skip to content

Commit a20dd4e

Browse files
committed
Merge #154: Add PeginData::mainchain_tx inspector
72afb47 Release 0.21.1 (Steven Roose) 9413d88 Add PeginData::parse_merkle_proof inspector (Steven Roose) 41d5030 Add PeginData::parse_tx inspector (Steven Roose) Pull request description: Just a nice utility for the mainchain tx. ACKs for top commit: sanket1729: utACK 72afb47. Looks good, but would be good to have some fixed test vector here. apoelstra: ACK 72afb47 Tree-SHA512: 8dc44a7875627922d5209860865273a2788d0783c36f22c71b8a703ffdd9dbfb14d2d100dcb53ecff38188e96b3b763d59d8b5ac779843f52cfce1074da8fe89
2 parents 06a109e + 72afb47 commit a20dd4e

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2+
# 0.21.1 - 2022-10-21
3+
4+
- Add `PeginData::parse_tx`
5+
- Add `PeginData::parse_merkle_proof`
6+
17
# 0.21.0 - 2022-10-19
28

39
- Copy `Sequence` and `LockTime` structures from rust-bitcoin 0.29.1

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "elements"
3-
version = "0.21.0"
3+
version = "0.21.1"
44
authors = ["Andrew Poelstra <apoelstra@blockstream.com>"]
55
description = "Library with support for de/serialization, parsing and executing on data structures and network messages related to Elements"
66
license = "CC0-1.0"

src/transaction.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,16 @@ impl<'tx> PeginData<'tx> {
432432
self.merkle_proof.to_vec(),
433433
]
434434
}
435+
436+
/// Parse the mainchain tx provided as pegin data.
437+
pub fn parse_tx(&self) -> Result<bitcoin::Transaction, bitcoin::consensus::encode::Error> {
438+
bitcoin::consensus::encode::deserialize(self.tx)
439+
}
440+
441+
/// Parse the merkle inclusion proof provided as pegin data.
442+
pub fn parse_merkle_proof(&self) -> Result<bitcoin::MerkleBlock, bitcoin::consensus::encode::Error> {
443+
bitcoin::consensus::encode::deserialize(self.merkle_proof)
444+
}
435445
}
436446

437447
/// A transaction input, which defines old coins to be consumed

0 commit comments

Comments
 (0)