Skip to content

Commit 2612017

Browse files
committed
Address post merge feedback for Taphash
1 parent d009572 commit 2612017

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/script/interpreter.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,13 +1757,21 @@ class CTransactionSignatureSerializer
17571757
}
17581758
};
17591759

1760+
/** Compute the outpoint flag(u8) for a given txin **/
1761+
template <class T>
1762+
inline unsigned char GetOutpointFlag(const T& txin)
1763+
{
1764+
return (unsigned char) ((!txin.assetIssuance.IsNull() ? (COutPoint::OUTPOINT_ISSUANCE_FLAG >> 24) : 0) |
1765+
(txin.m_is_pegin ? (COutPoint::OUTPOINT_PEGIN_FLAG >> 24) : 0));
1766+
}
1767+
17601768
/** Compute the (single) SHA256 of the concatenation of all outpoint flags of a tx. */
17611769
template <class T>
17621770
uint256 GetOutpointFlagsSHA256(const T& txTo)
17631771
{
17641772
CHashWriter ss(SER_GETHASH, 0);
17651773
for (const auto& txin : txTo.vin) {
1766-
ss << (unsigned char) ((!txin.assetIssuance.IsNull() << 7) + (txin.m_is_pegin << 6));
1774+
ss << GetOutpointFlag(txin);
17671775
}
17681776
return ss.GetSHA256();
17691777
}
@@ -2004,6 +2012,11 @@ bool SignatureHashSchnorr(uint256& hash_out, const ScriptExecutionData& execdata
20042012
ss << cache.m_outpoints_flag_single_hash;
20052013
ss << cache.m_prevouts_single_hash;
20062014
ss << cache.m_spent_asset_amounts_single_hash;
2015+
// Why is nNonce not included in sighash?(both in ACP and non ACP case)
2016+
//
2017+
// Nonces are not serialized into utxo database. As a consequence, after restarting the node,
2018+
// all nonces in the utxoset are cleared which results in a inconsistent view for nonces for
2019+
// nodes that did not restart. See https://github.com/ElementsProject/elements/issues/1004 for details
20072020
ss << cache.m_spent_scripts_single_hash;
20082021
ss << cache.m_sequences_single_hash;
20092022
ss << cache.m_issuances_single_hash;
@@ -2019,7 +2032,7 @@ bool SignatureHashSchnorr(uint256& hash_out, const ScriptExecutionData& execdata
20192032
const uint8_t spend_type = (ext_flag << 1) + (have_annex ? 1 : 0); // The low bit indicates whether an annex is present.
20202033
ss << spend_type;
20212034
if (input_type == SIGHASH_ANYONECANPAY) {
2022-
ss << (unsigned char) ((!tx_to.vin[in_pos].assetIssuance.IsNull() << 7) + (tx_to.vin[in_pos].m_is_pegin << 6));
2035+
ss << GetOutpointFlag(tx_to.vin[in_pos]);
20232036
ss << tx_to.vin[in_pos].prevout;
20242037
ss << cache.m_spent_outputs[in_pos].nAsset;
20252038
ss << cache.m_spent_outputs[in_pos].nValue;

0 commit comments

Comments
 (0)