aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/psbt.h10
-rw-r--r--src/rpc/rawtransaction.cpp4
-rw-r--r--src/wallet/scriptpubkeyman.cpp4
3 files changed, 10 insertions, 8 deletions
diff --git a/src/psbt.h b/src/psbt.h
index 1171ecf1dd..21daa050ea 100644
--- a/src/psbt.h
+++ b/src/psbt.h
@@ -57,7 +57,7 @@ struct PSBTInput
std::map<CPubKey, KeyOriginInfo> hd_keypaths;
std::map<CKeyID, SigPair> partial_sigs;
std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown;
- int sighash_type = 0;
+ std::optional<int> sighash_type;
bool IsNull() const;
void FillSignatureData(SignatureData& sigdata) const;
@@ -86,9 +86,9 @@ struct PSBTInput
}
// Write the sighash type
- if (sighash_type > 0) {
+ if (sighash_type != std::nullopt) {
SerializeToVector(s, PSBT_IN_SIGHASH);
- SerializeToVector(s, sighash_type);
+ SerializeToVector(s, *sighash_type);
}
// Write the redeem script
@@ -201,7 +201,9 @@ struct PSBTInput
} else if (key.size() != 1) {
throw std::ios_base::failure("Sighash type key is more than one byte type");
}
- UnserializeFromVector(s, sighash_type);
+ int sighash;
+ UnserializeFromVector(s, sighash);
+ sighash_type = sighash;
break;
case PSBT_IN_REDEEMSCRIPT:
{
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index a3583e7f12..713b0afcdc 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -1255,8 +1255,8 @@ static RPCHelpMan decodepsbt()
}
// Sighash
- if (input.sighash_type > 0) {
- in.pushKV("sighash", SighashToStr((unsigned char)input.sighash_type));
+ if (input.sighash_type != std::nullopt) {
+ in.pushKV("sighash", SighashToStr((unsigned char)*input.sighash_type));
}
// Redeem script and witness script
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 1769429efe..a9e2624188 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -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;
}