mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-12 19:52:34 +02:00
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:
10
src/psbt.h
10
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:
|
||||
{
|
||||
|
Reference in New Issue
Block a user