diff --git a/src/util/psbt/map/input.rs b/src/util/psbt/map/input.rs index 9d275cbe..e7132834 100644 --- a/src/util/psbt/map/input.rs +++ b/src/util/psbt/map/input.rs @@ -184,8 +184,19 @@ impl PsbtSigHashType { } } - /// Obtains the inner sighash byte from this [`PsbtSigHashType`]. - pub fn inner(self) -> u32 { + /// Creates a [`PsbtSigHashType`] from a raw `u32`. + /// + /// Allows construction of a non-standard or non-valid sighash flag + /// ([`EcdsaSigHashType`], [`SchnorrSigHashType`] respectively). + pub fn from_u32(n: u32) -> PsbtSigHashType { + PsbtSigHashType { inner: n } + } + + + /// Converts [`PsbtSigHashType`] to a raw `u32` sighash flag. + /// + /// No guarantees are made as to the standardness or validity of the returned value. + pub fn to_u32(self) -> u32 { self.inner } } diff --git a/src/util/psbt/serialize.rs b/src/util/psbt/serialize.rs index 0ee01fdf..8492e8af 100644 --- a/src/util/psbt/serialize.rs +++ b/src/util/psbt/serialize.rs @@ -193,7 +193,7 @@ impl Deserialize for Vec { impl Serialize for PsbtSigHashType { fn serialize(&self) -> Vec { - serialize(&self.inner()) + serialize(&self.to_u32()) } }