Skip to content

Commit

Permalink
script: move CScriptID to script
Browse files Browse the repository at this point in the history
  • Loading branch information
div72 committed Apr 8, 2022
1 parent 4096ece commit 4f702e9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
8 changes: 0 additions & 8 deletions src/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ class CKeyID : public uint160
CKeyID(const uint160 &in) : uint160(in) { }
};

/** A reference to a CScript: the Hash160 of its serialization (see script.h) */
class CScriptID : public uint160
{
public:
CScriptID() : uint160() { }
CScriptID(const uint160 &in) : uint160(in) { }
};

/** An encapsulated public key. */
class CPubKey {
private:
Expand Down
1 change: 1 addition & 0 deletions src/keystore.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <boost/signals2/signal.hpp>

class CScript;
class CScriptID;

/** A virtual base class for key stores */
class CKeyStore
Expand Down
5 changes: 4 additions & 1 deletion src/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ using namespace std;
#include "sync.h"
#include "util.h"

CScriptID::CScriptID(const CScript& in) : BaseHash(Hash160(in)) {}
//CScriptID::CScriptID(const ScriptHash& in) : BaseHash(static_cast<uint160>(in)) {}

bool CheckSig(vector<unsigned char> vchSig, vector<unsigned char> vchPubKey, CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);

static const valtype vchFalse(0);
Expand Down Expand Up @@ -1491,7 +1494,7 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash
}
return true;
case TX_SCRIPTHASH:
return keystore.GetCScript(uint160(vSolutions[0]), scriptSigRet);
return keystore.GetCScript(CScriptID(uint160(vSolutions[0])), scriptSigRet);

case TX_MULTISIG:
scriptSigRet << OP_0; // workaround CHECKMULTISIG bug
Expand Down
11 changes: 11 additions & 0 deletions src/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@
#include "keystore.h"
#include "bignum.h"
#include "prevector.h"
#include <util/hash_type.h>
#include "wallet/ismine.h"

typedef std::vector<unsigned char> valtype;

class CTransaction;

/** A reference to a CScript: the Hash160 of its serialization (see script.h) */
class CScriptID : public BaseHash<uint160>
{
public:
CScriptID() : BaseHash() {}
explicit CScriptID(const CScript& in);
explicit CScriptID(const uint160& in) : BaseHash(in) {}
// explicit CScriptID(const ScriptHash& in);
};

static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
static const unsigned int MAX_OP_RETURN_RELAY = 80; // bytes

Expand Down
2 changes: 1 addition & 1 deletion src/test/base58_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class TestPayloadVisitor
bool operator()(const CScriptID &id) const
{
uint160 exp_key(exp_payload);
return exp_key == id;
return CScriptID(exp_key) == id;
}
bool operator()(const CNoDestination &no) const
{
Expand Down

0 comments on commit 4f702e9

Please sign in to comment.