Merge 2aff9a36c3 into merged_master (Bitcoin PR bitcoin/bitcoin#30352)

This commit is contained in:
ivanlele 2026-03-11 09:41:57 +00:00
commit cd6ec40d0f
No known key found for this signature in database
24 changed files with 202 additions and 6 deletions

View file

@ -3313,6 +3313,8 @@ static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion,
}
return set_success(serror);
}
} else if (!is_p2sh && CScript::IsPayToAnchor(witversion, program)) {
return true;
} else {
if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM) {
return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM);

View file

@ -318,6 +318,23 @@ bool CScript::IsPayToWitnessPubkeyHash() const
// END ELEMENTS
//
bool CScript::IsPayToAnchor() const
{
return (this->size() == 4 &&
(*this)[0] == OP_1 &&
(*this)[1] == 0x02 &&
(*this)[2] == 0x4e &&
(*this)[3] == 0x73);
}
bool CScript::IsPayToAnchor(int version, const std::vector<unsigned char>& program)
{
return version == 1 &&
program.size() == 2 &&
program[0] == 0x4e &&
program[1] == 0x73;
}
bool CScript::IsPayToScriptHash() const
{
// Extra-fast test for pay-to-script-hash CScripts:

View file

@ -597,6 +597,14 @@ public:
bool IsPayToPubkeyHash() const;
bool IsPayToWitnessPubkeyHash() const;
/*
* OP_1 <0x4e73>
*/
bool IsPayToAnchor() const;
/** Checks if output of IsWitnessProgram comes from a P2A output script
*/
static bool IsPayToAnchor(int version, const std::vector<unsigned char>& program);
bool IsPayToScriptHash() const;
bool IsPayToWitnessScriptHash() const;
bool IsWitnessProgram(int& version, std::vector<unsigned char>& program) const;

View file

@ -484,10 +484,10 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
// ELEMENTS
case TxoutType::FEE:
return false;
case TxoutType::OP_TRUE:
return Params().anyonecanspend_aremine;
case TxoutType::ANCHOR:
return true;
} // no default case, so the compiler can warn about missing cases
assert(false);
}

View file

@ -25,6 +25,7 @@ std::string GetTxnOutputType(TxoutType t)
case TxoutType::SCRIPTHASH: return "scripthash";
case TxoutType::MULTISIG: return "multisig";
case TxoutType::NULL_DATA: return "nulldata";
case TxoutType::ANCHOR: return "anchor";
case TxoutType::WITNESS_V0_KEYHASH: return "witness_v0_keyhash";
case TxoutType::WITNESS_V0_SCRIPTHASH: return "witness_v0_scripthash";
case TxoutType::WITNESS_V1_TAPROOT: return "witness_v1_taproot";
@ -179,6 +180,9 @@ TxoutType Solver(const CScript& scriptPubKey, std::vector<std::vector<unsigned c
vSolutionsRet.push_back(std::move(witnessprogram));
return TxoutType::WITNESS_V1_TAPROOT;
}
if (scriptPubKey.IsPayToAnchor()) {
return TxoutType::ANCHOR;
}
if (witnessversion != 0) {
vSolutionsRet.push_back(std::vector<unsigned char>{(unsigned char)witnessversion});
vSolutionsRet.push_back(std::move(witnessprogram));

View file

@ -22,6 +22,7 @@ template <typename C> class Span;
enum class TxoutType {
NONSTANDARD,
// 'standard' transaction types:
ANCHOR, //!< anyone can spend script
PUBKEY,
PUBKEYHASH,
SCRIPTHASH,