Skip to content

Commit

Permalink
Revert "consensus: correct verification of transactions pre p2sh-asse…
Browse files Browse the repository at this point in the history
…t activation (RavenProject#1019)"

This reverts commit 46aad1a.
  • Loading branch information
hans-schmidt committed Aug 15, 2022
1 parent f4f44f9 commit bcc2d87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
16 changes: 7 additions & 9 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,19 +653,17 @@ bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, c
int i = 0;
for (const auto& txout : tx.vout) {
i++;

// Values are subject to change, by isAssetScript a few lines down.
bool fIsAsset = false;
int nType = 0;
int nScriptType = 0;
int nStart = 0;
bool fIsOwner = false;
if (txout.scriptPubKey.IsAssetScript(nType, nScriptType, fIsOwner))
fIsAsset = true;

// False until BIP9 consensus activates P2SH for Assets.
bool fP2Active = AreP2SHAssetsAllowed();

// Returns true if operations on assets are found in the script.
// It will also possibly change the values of the arguments, as they are passed by reference.
bool fIsAsset = txout.scriptPubKey.IsAssetScript(nType, nScriptType, fIsOwner, nStart, fP2Active);
if (fIsAsset && nScriptType == TX_SCRIPTHASH) {
if (!AreP2SHAssetsAllowed())
return state.DoS(0, false, REJECT_INVALID, "bad-txns-p2sh-assets-not-active");
}

if (assetCache) {
if (fIsAsset && !AreAssetsDeployed())
Expand Down
8 changes: 2 additions & 6 deletions src/script/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,11 @@ bool CScript::IsAssetScript(int& nType, int& nScriptType, bool& isOwner) const
return IsAssetScript(nType, nScriptType, isOwner, start);
}

bool CScript::IsAssetScript(int& nType, int& nScriptType, bool& fIsOwner, int& nStartingIndex, bool nP2Active) const
bool CScript::IsAssetScript(int& nType, int& nScriptType, bool& fIsOwner, int& nStartingIndex) const
{
if (this->size() > 31) {
// Extra-fast test for pay-to-script-hash CScripts:
if ( (*this)[0] == OP_HASH160
&& (*this)[1] == 0x14
&& (*this)[22] == OP_EQUAL
&& nP2Active == true
) {
if ( (*this)[0] == OP_HASH160 && (*this)[1] == 0x14 && (*this)[22] == OP_EQUAL) {

// If this is of the P2SH type, we need to return this type so we know how to interact and solve it
nScriptType = TX_SCRIPTHASH;
Expand Down
2 changes: 1 addition & 1 deletion src/script/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ class CScript : public CScriptBase
bool IsAssetScript() const;
bool IsAssetScript(int& nType, bool& fIsOwner) const;
bool IsAssetScript(int& nType, int& nScriptType, bool& fIsOwner) const;
bool IsAssetScript(int& nTXType, int& nScriptType, bool& fIsOwner, int& nStartingIndex, bool nP2Active = true) const;
bool IsAssetScript(int& nTXType, int& nScriptType, bool& fIsOwner, int& nStartingIndex) const;
bool IsP2SHAssetScript() const;
bool IsNewAsset() const;
bool IsOwnerAsset() const;
Expand Down

0 comments on commit bcc2d87

Please sign in to comment.