Add `Transaction` accessors to `SighashCache`

It may be useful to access the transaction stored in `SighashCache`
during signing or afterwards, especially when the transaction is stored
without indirection (to enable long-lived storage).

This change adds the appropriate accessors.
This commit is contained in:
Martin Habovstiak 2023-02-06 12:01:10 +01:00
parent 7c6854fe02
commit b3188bbac3
1 changed files with 10 additions and 0 deletions

View File

@ -499,6 +499,16 @@ impl<R: Borrow<Transaction>> SighashCache<R> {
SighashCache { tx, common_cache: None, taproot_cache: None, segwit_cache: None }
}
/// Returns the reference to the cached transaction.
pub fn transaction(&self) -> &Transaction {
self.tx.borrow()
}
/// Destroys the cache and recovers the stored transaction.
pub fn into_transaction(self) -> R {
self.tx
}
/// Encodes the BIP341 signing data for any flag type into a given object implementing a
/// [`io::Write`] trait.
pub fn taproot_encode_signing_data_to<Write: io::Write, T: Borrow<TxOut>>(