diff --git a/src/psbt.cpp b/src/psbt.cpp index 72c091c193..08286fbe1c 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -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(); diff --git a/src/psbt.h b/src/psbt.h index a82fcb53f3..b1c3f3ceea 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -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