Merge rust-bitcoin/rust-bitcoin#847: Add a method to psbt to compute find sighash type
fb04cabe1d
Add a method to psbt to compute find sighash type (Rishabh Singhal) Pull request description: Fixes #838: Add a utility method to psbt to compute find sighash type of a given input. For now, I have changed my previous implementation as discussed in #838 to functional style code as suggested by @Kixunil. ACKs for top commit: apoelstra: ACKfb04cabe1d
Kixunil: ACKfb04cabe1d
Tree-SHA512: 86184649e7a309348cb217347b82bf39c9997ae259fe7881322038a88bd04deab927bede1dd71d17496bac420353a3fd07e7d191ff4671a07754c02a38dd1319
This commit is contained in:
commit
c7ff483c1c
|
@ -191,6 +191,28 @@ impl PsbtSigHashType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
|
/// Obtains the [`EcdsaSigHashType`] for this input if one is specified.
|
||||||
|
/// If no sighash type is specified, returns ['EcdsaSigHashType::All']
|
||||||
|
///
|
||||||
|
/// Errors:
|
||||||
|
/// If the sighash type is not a standard ecdsa sighash type
|
||||||
|
pub fn ecdsa_hash_ty(&self) -> Result<EcdsaSigHashType, NonStandardSigHashType> {
|
||||||
|
self.sighash_type
|
||||||
|
.map(|sighash_type| sighash_type.ecdsa_hash_ty())
|
||||||
|
.unwrap_or(Ok(EcdsaSigHashType::All))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Obtains the [`SchnorrSigHashType`] for this input if one is specified.
|
||||||
|
/// If no sighash type is specified, returns ['SchnorrSigHashType::Default']
|
||||||
|
///
|
||||||
|
/// Errors:
|
||||||
|
/// If the sighash type is an invalid schnorr sighash type
|
||||||
|
pub fn schnorr_hash_ty(&self) -> Result<SchnorrSigHashType, sighash::Error> {
|
||||||
|
self.sighash_type
|
||||||
|
.map(|sighash_type| sighash_type.schnorr_hash_ty())
|
||||||
|
.unwrap_or(Ok(SchnorrSigHashType::Default))
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn insert_pair(&mut self, pair: raw::Pair) -> Result<(), encode::Error> {
|
pub(super) fn insert_pair(&mut self, pair: raw::Pair) -> Result<(), encode::Error> {
|
||||||
let raw::Pair {
|
let raw::Pair {
|
||||||
key: raw_key,
|
key: raw_key,
|
||||||
|
|
Loading…
Reference in New Issue