Helper functions to determine whether a PSBTOutput is blinded

This commit is contained in:
Andrew Chow 2021-03-18 14:31:57 -04:00
parent ee28be3018
commit 33c694f822
2 changed files with 31 additions and 0 deletions

View file

@ -395,6 +395,34 @@ void PSBTOutput::Merge(const PSBTOutput& output)
if (redeem_script.empty() && !output.redeem_script.empty()) redeem_script = output.redeem_script;
if (witness_script.empty() && !output.witness_script.empty()) witness_script = output.witness_script;
}
bool PSBTOutput::IsBlinded() const
{
return m_blinding_pubkey.IsValid();
}
bool PSBTOutput::IsPartiallyBlinded() const
{
return IsBlinded() && (!amount ||
!m_value_commitment.IsNull() ||
!m_asset_commitment.IsNull() ||
m_asset.IsNull() ||
!m_value_rangeproof.empty() ||
!m_asset_surjection_proof.empty() ||
m_ecdh_pubkey.IsValid());
}
bool PSBTOutput::IsFullyBlinded() const
{
return IsBlinded() && !amount &&
!m_value_commitment.IsNull() &&
!m_asset_commitment.IsNull() &&
m_asset.IsNull() &&
!m_value_rangeproof.empty() &&
!m_asset_surjection_proof.empty() &&
m_ecdh_pubkey.IsValid();
}
bool PSBTInputSigned(const PSBTInput& input)
{
return !input.final_script_sig.empty() || !input.final_script_witness.IsNull();

View file

@ -924,6 +924,9 @@ struct PSBTOutput
void FillSignatureData(SignatureData& sigdata) const;
void FromSignatureData(const SignatureData& sigdata);
void Merge(const PSBTOutput& output);
bool IsBlinded() const; //! This output has a blinding pubkey and is or will be blinded.
bool IsPartiallyBlinded() const; //! This output has some blinding information. This is not a good state to be in.
bool IsFullyBlinded() const; //! This output has all of the blinding information and is actually blinded.
PSBTOutput(uint32_t version) : m_psbt_version(version) {}
template <typename Stream>