mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge 510ac41eac into merged_master (Bitcoin PR bitcoin/bitcoin#25331)
This commit is contained in:
commit
28d35f619e
15 changed files with 68 additions and 56 deletions
|
|
@ -542,9 +542,9 @@ static bool EvalChecksig(const valtype& sig, const valtype& pubkey, CScript::con
|
|||
assert(false);
|
||||
}
|
||||
|
||||
const CHashWriter HASHER_TAPLEAF_ELEMENTS = TaggedHash("TapLeaf/elements");
|
||||
const CHashWriter HASHER_TAPBRANCH_ELEMENTS = TaggedHash("TapBranch/elements");
|
||||
const CHashWriter HASHER_TAPSIGHASH_ELEMENTS = TaggedHash("TapSighash/elements");
|
||||
const HashWriter HASHER_TAPLEAF_ELEMENTS = TaggedHash("TapLeaf/elements");
|
||||
const HashWriter HASHER_TAPBRANCH_ELEMENTS = TaggedHash("TapBranch/elements");
|
||||
const HashWriter HASHER_TAPSIGHASH_ELEMENTS = TaggedHash("TapSighash/elements");
|
||||
|
||||
bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptExecutionData& execdata, ScriptError* serror)
|
||||
{
|
||||
|
|
@ -2373,7 +2373,7 @@ uint256 GetOutpointFlagsSHA256(const T& txTo)
|
|||
template <class T>
|
||||
uint256 GetPrevoutsSHA256(const T& txTo)
|
||||
{
|
||||
CHashWriter ss(SER_GETHASH, 0);
|
||||
HashWriter ss{};
|
||||
for (const auto& txin : txTo.vin) {
|
||||
ss << txin.prevout;
|
||||
}
|
||||
|
|
@ -2384,7 +2384,7 @@ uint256 GetPrevoutsSHA256(const T& txTo)
|
|||
template <class T>
|
||||
uint256 GetSequencesSHA256(const T& txTo)
|
||||
{
|
||||
CHashWriter ss(SER_GETHASH, 0);
|
||||
HashWriter ss{};
|
||||
for (const auto& txin : txTo.vin) {
|
||||
ss << txin.nSequence;
|
||||
}
|
||||
|
|
@ -2437,7 +2437,7 @@ uint256 GetIssuanceRangeproofsSHA256(const T& txTo)
|
|||
template <class T>
|
||||
uint256 GetOutputsSHA256(const T& txTo)
|
||||
{
|
||||
CHashWriter ss(SER_GETHASH, 0);
|
||||
HashWriter ss{};
|
||||
for (const auto& txout : txTo.vout) {
|
||||
ss << txout;
|
||||
}
|
||||
|
|
@ -2448,7 +2448,7 @@ uint256 GetOutputsSHA256(const T& txTo)
|
|||
// Elements TapHash only
|
||||
uint256 GetSpentAssetsAmountsSHA256(const std::vector<CTxOut>& outputs_spent)
|
||||
{
|
||||
CHashWriter ss(SER_GETHASH, 0);
|
||||
HashWriter ss{};
|
||||
for (const auto& txout : outputs_spent) {
|
||||
ss << txout.nAsset;
|
||||
ss << txout.nValue;
|
||||
|
|
@ -2459,7 +2459,7 @@ uint256 GetSpentAssetsAmountsSHA256(const std::vector<CTxOut>& outputs_spent)
|
|||
/** Compute the (single) SHA256 of the concatenation of all scriptPubKeys spent by a tx. */
|
||||
uint256 GetSpentScriptsSHA256(const std::vector<CTxOut>& outputs_spent)
|
||||
{
|
||||
CHashWriter ss(SER_GETHASH, 0);
|
||||
HashWriter ss{};
|
||||
for (const auto& txout : outputs_spent) {
|
||||
ss << txout.scriptPubKey;
|
||||
}
|
||||
|
|
@ -2589,7 +2589,7 @@ template PrecomputedTransactionData::PrecomputedTransactionData(const CTransacti
|
|||
template PrecomputedTransactionData::PrecomputedTransactionData(const CMutableTransaction& txTo);
|
||||
|
||||
PrecomputedTransactionData::PrecomputedTransactionData(const uint256& hash_genesis_block)
|
||||
: m_tapsighash_hasher(CHashWriter(HASHER_TAPSIGHASH_ELEMENTS) << hash_genesis_block << hash_genesis_block) {}
|
||||
: m_tapsighash_hasher(HashWriter(HASHER_TAPSIGHASH_ELEMENTS) << hash_genesis_block << hash_genesis_block) {}
|
||||
|
||||
static bool HandleMissingData(MissingDataBehavior mdb)
|
||||
{
|
||||
|
|
@ -2628,7 +2628,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
|
|||
return HandleMissingData(mdb);
|
||||
}
|
||||
|
||||
CHashWriter ss = cache.m_tapsighash_hasher;
|
||||
HashWriter ss = cache.m_tapsighash_hasher;
|
||||
|
||||
// no epoch in elements taphash
|
||||
// static constexpr uint8_t EPOCH = 0;
|
||||
|
|
@ -2693,7 +2693,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
|
|||
if (output_type == SIGHASH_SINGLE) {
|
||||
if (in_pos >= tx_to.vout.size()) return false;
|
||||
if (!execdata.m_output_hash) {
|
||||
CHashWriter sha_single_output(SER_GETHASH, 0);
|
||||
HashWriter sha_single_output{};
|
||||
sha_single_output << tx_to.vout[in_pos];
|
||||
execdata.m_output_hash = sha_single_output.GetSHA256();
|
||||
}
|
||||
|
|
@ -2754,7 +2754,7 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
|
|||
hashRangeproofs = cacheready ? cache->hashRangeproofs : GetRangeproofsHash(txTo);
|
||||
}
|
||||
} else if ((nHashType & 0x1f) == SIGHASH_SINGLE && nIn < txTo.vout.size()) {
|
||||
CHashWriter ss(SER_GETHASH, 0);
|
||||
HashWriter ss{};
|
||||
ss << txTo.vout[nIn];
|
||||
hashOutputs = ss.GetHash();
|
||||
|
||||
|
|
@ -2771,7 +2771,7 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
|
|||
}
|
||||
}
|
||||
|
||||
CHashWriter ss(SER_GETHASH, 0);
|
||||
HashWriter ss{};
|
||||
// Version
|
||||
ss << txTo.nVersion;
|
||||
// Input prevouts/nSequence (none/all, depending on flags)
|
||||
|
|
@ -2822,7 +2822,7 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
|
|||
CTransactionSignatureSerializer<T> txTmp(txTo, scriptCode, nIn, nHashType, flags);
|
||||
|
||||
// Serialize and hash
|
||||
CHashWriter ss(SER_GETHASH, 0);
|
||||
HashWriter ss{};
|
||||
ss << txTmp << nHashType;
|
||||
return ss.GetHash();
|
||||
}
|
||||
|
|
@ -3058,7 +3058,7 @@ static bool ExecuteWitnessScript(const Span<const valtype>& stack_span, const CS
|
|||
|
||||
uint256 ComputeTapleafHash(uint8_t leaf_version, const CScript& script)
|
||||
{
|
||||
return (CHashWriter(HASHER_TAPLEAF_ELEMENTS) << leaf_version << script).GetSHA256();
|
||||
return (HashWriter(HASHER_TAPLEAF_ELEMENTS) << leaf_version << script).GetSHA256();
|
||||
}
|
||||
|
||||
uint256 ComputeTaprootMerkleRoot(Span<const unsigned char> control, const uint256& tapleaf_hash)
|
||||
|
|
@ -3070,7 +3070,7 @@ uint256 ComputeTaprootMerkleRoot(Span<const unsigned char> control, const uint25
|
|||
const int path_len = (control.size() - TAPROOT_CONTROL_BASE_SIZE) / TAPROOT_CONTROL_NODE_SIZE;
|
||||
uint256 k = tapleaf_hash;
|
||||
for (int i = 0; i < path_len; ++i) {
|
||||
CHashWriter ss_branch = CHashWriter{HASHER_TAPBRANCH_ELEMENTS};
|
||||
HashWriter ss_branch{HASHER_TAPBRANCH_ELEMENTS};
|
||||
Span node{Span{control}.subspan(TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * i, TAPROOT_CONTROL_NODE_SIZE)};
|
||||
if (std::lexicographical_compare(k.begin(), k.end(), node.begin(), node.end())) {
|
||||
ss_branch << k << node;
|
||||
|
|
@ -3133,7 +3133,7 @@ static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion,
|
|||
if (stack.size() >= 2 && !stack.back().empty() && stack.back()[0] == ANNEX_TAG) {
|
||||
// Drop annex (this is non-standard; see IsWitnessStandard)
|
||||
const valtype& annex = SpanPopBack(stack);
|
||||
execdata.m_annex_hash = (CHashWriter(SER_GETHASH, 0) << annex).GetSHA256();
|
||||
execdata.m_annex_hash = (HashWriter{} << annex).GetSHA256();
|
||||
execdata.m_annex_present = true;
|
||||
} else {
|
||||
execdata.m_annex_present = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue