Skip to content

Commit daf0eac

Browse files
committed
Improve NonStandardSigHashType
1 parent c36a3da commit daf0eac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/blockdata/transaction.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,11 @@ impl Decodable for Transaction {
666666
/// This type is consensus valid but an input including it would prevent the transaction from
667667
/// being relayed on today's Bitcoin network.
668668
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
669-
pub struct NonStandardSigHashType;
669+
pub struct NonStandardSigHashType(pub u32);
670670

671671
impl fmt::Display for NonStandardSigHashType {
672672
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
673-
write!(f, "Non standard sighash type")
673+
write!(f, "Non standard sighash type {}", self.0)
674674
}
675675
}
676676

@@ -789,7 +789,7 @@ impl EcdsaSigHashType {
789789
0x81 => Ok(EcdsaSigHashType::AllPlusAnyoneCanPay),
790790
0x82 => Ok(EcdsaSigHashType::NonePlusAnyoneCanPay),
791791
0x83 => Ok(EcdsaSigHashType::SinglePlusAnyoneCanPay),
792-
_ => Err(NonStandardSigHashType)
792+
non_standard => Err(NonStandardSigHashType(non_standard))
793793
}
794794
}
795795

@@ -1151,7 +1151,7 @@ mod tests {
11511151
assert_eq!(EcdsaSigHashType::from_u32(nonstandard_hashtype), EcdsaSigHashType::All);
11521152
assert_eq!(EcdsaSigHashType::from_u32_consensus(nonstandard_hashtype), EcdsaSigHashType::All);
11531153
// But it's policy-invalid to use it!
1154-
assert_eq!(EcdsaSigHashType::from_u32_standard(nonstandard_hashtype), Err(NonStandardSigHashType));
1154+
assert_eq!(EcdsaSigHashType::from_u32_standard(nonstandard_hashtype), Err(NonStandardSigHashType(0x04)));
11551155
}
11561156

11571157
// These test vectors were stolen from libbtc, which is Copyright 2014 Jonas Schnelli MIT

0 commit comments

Comments
 (0)