diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-11-15 13:54:01 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-12-08 09:43:26 -0500 |
commit | eb9a1a2c595a03475fd4275b104676b7e2200f07 (patch) | |
tree | e0677f33d40f91c2ecd55e1bc90ac7d98fe5942c /src/psbt.h | |
parent | 577bd51a4b8de066466a445192c1c653872657e2 (diff) |
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.
Diffstat (limited to 'src/psbt.h')
-rw-r--r-- | src/psbt.h | 10 |
1 files changed, 6 insertions, 4 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: { |