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

@@ -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