psbt: Make sighash_type std::optional<int>

It is better to ues an optional to determine whether the sighash type
is set rather than using 0 as a magic number.
This commit is contained in:
Andrew Chow
2021-11-15 13:54:01 -05:00
parent 577bd51a4b
commit eb9a1a2c59
3 changed files with 10 additions and 8 deletions

View File

@@ -633,7 +633,7 @@ TransactionError LegacyScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psb
}
// Get the Sighash type
if (sign && input.sighash_type > 0 && input.sighash_type != sighash_type) {
if (sign && input.sighash_type != std::nullopt && *input.sighash_type != sighash_type) {
return TransactionError::SIGHASH_MISMATCH;
}
@@ -2114,7 +2114,7 @@ TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction&
}
// Get the Sighash type
if (sign && input.sighash_type > 0 && input.sighash_type != sighash_type) {
if (sign && input.sighash_type != std::nullopt && *input.sighash_type != sighash_type) {
return TransactionError::SIGHASH_MISMATCH;
}