Remove more CC stuff
This commit is contained in:
@@ -2899,10 +2899,6 @@ int8_t GetAddressType(const CScript &scriptPubKey, CTxDestination &vDest, txnout
|
|||||||
{
|
{
|
||||||
keyType = 2;
|
keyType = 2;
|
||||||
}
|
}
|
||||||
else if (txType == TX_CRYPTOCONDITION )
|
|
||||||
{
|
|
||||||
keyType = 3;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return keyType;
|
return keyType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -957,37 +957,6 @@ bool EvalScript(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
|
||||||
case OP_CHECKCRYPTOCONDITION:
|
|
||||||
case OP_CHECKCRYPTOCONDITIONVERIFY:
|
|
||||||
{
|
|
||||||
if (!IsCryptoConditionsEnabled()) {
|
|
||||||
goto INTERPRETER_DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stack.size() < 2)
|
|
||||||
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
|
|
||||||
//fprintf(stderr,"check cryptocondition\n");
|
|
||||||
int fResult = checker.CheckCryptoCondition(stacktop(-1), stacktop(-2), script, consensusBranchId);
|
|
||||||
if (fResult == -1) {
|
|
||||||
return set_error(serror, SCRIPT_ERR_CRYPTOCONDITION_INVALID_FULFILLMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
popstack(stack);
|
|
||||||
popstack(stack);
|
|
||||||
|
|
||||||
stack.push_back(fResult == 1 ? vchTrue : vchFalse);
|
|
||||||
|
|
||||||
if (opcode == OP_CHECKCRYPTOCONDITIONVERIFY)
|
|
||||||
{
|
|
||||||
if (fResult == 1)
|
|
||||||
popstack(stack);
|
|
||||||
else
|
|
||||||
return set_error(serror, SCRIPT_ERR_CRYPTOCONDITION_VERIFY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
|
|
||||||
INTERPRETER_DEFAULT:
|
INTERPRETER_DEFAULT:
|
||||||
default:
|
default:
|
||||||
@@ -1356,15 +1325,6 @@ bool TransactionSignatureChecker::CheckSig(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TransactionSignatureChecker::CheckCryptoCondition(
|
|
||||||
const std::vector<unsigned char>& condBin,
|
|
||||||
const std::vector<unsigned char>& ffillBin,
|
|
||||||
const CScript& scriptCode,
|
|
||||||
uint32_t consensusBranchId) const
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TransactionSignatureChecker::CheckLockTime(const CScriptNum& nLockTime) const
|
bool TransactionSignatureChecker::CheckLockTime(const CScriptNum& nLockTime) const
|
||||||
{
|
{
|
||||||
// There are two times of nLockTime: lock-by-blockheight
|
// There are two times of nLockTime: lock-by-blockheight
|
||||||
@@ -1407,38 +1367,6 @@ bool TransactionSignatureChecker::CheckLockTime(const CScriptNum& nLockTime) con
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allow larger opcode in case of crypto condition scriptSig
|
|
||||||
*/
|
|
||||||
bool EvalCryptoConditionSig(
|
|
||||||
vector<vector<unsigned char> >& stack,
|
|
||||||
const CScript& scriptSig,
|
|
||||||
ScriptError* serror)
|
|
||||||
{
|
|
||||||
CScript::const_iterator pc = scriptSig.begin();
|
|
||||||
opcodetype opcode;
|
|
||||||
valtype vchPushValue;
|
|
||||||
set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR);
|
|
||||||
|
|
||||||
if (!scriptSig.GetOp(pc, opcode, vchPushValue))
|
|
||||||
return set_error(serror, SCRIPT_ERR_BAD_OPCODE);
|
|
||||||
|
|
||||||
if (opcode == 0 || opcode > OP_PUSHDATA4)
|
|
||||||
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
|
|
||||||
|
|
||||||
if (pc != scriptSig.end())
|
|
||||||
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
|
|
||||||
|
|
||||||
if (vchPushValue.size() > MAX_SCRIPT_CRYPTOCONDITION_FULFILLMENT_SIZE)
|
|
||||||
return set_error(serror, SCRIPT_ERR_PUSH_SIZE);
|
|
||||||
|
|
||||||
stack.push_back(vchPushValue);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool VerifyScript(
|
bool VerifyScript(
|
||||||
const CScript& scriptSig,
|
const CScript& scriptSig,
|
||||||
const CScript& scriptPubKey,
|
const CScript& scriptPubKey,
|
||||||
@@ -1454,12 +1382,7 @@ bool VerifyScript(
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector<vector<unsigned char> > stack, stackCopy;
|
vector<vector<unsigned char> > stack, stackCopy;
|
||||||
if (IsCryptoConditionsEnabled() && scriptPubKey.IsPayToCryptoCondition()) {
|
if (!EvalScript(stack, scriptSig, flags, checker, consensusBranchId, serror))
|
||||||
if (!EvalCryptoConditionSig(stack, scriptSig, serror))
|
|
||||||
// serror is set
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!EvalScript(stack, scriptSig, flags, checker, consensusBranchId, serror))
|
|
||||||
// serror is set
|
// serror is set
|
||||||
return false;
|
return false;
|
||||||
if (flags & SCRIPT_VERIFY_P2SH)
|
if (flags & SCRIPT_VERIFY_P2SH)
|
||||||
|
|||||||
@@ -147,15 +147,6 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int CheckCryptoCondition(
|
|
||||||
const std::vector<unsigned char>& condBin,
|
|
||||||
const std::vector<unsigned char>& ffillBin,
|
|
||||||
const CScript& scriptCode,
|
|
||||||
uint32_t consensusBranchId) const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~BaseSignatureChecker() {}
|
virtual ~BaseSignatureChecker() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -174,11 +165,6 @@ public:
|
|||||||
TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, const PrecomputedTransactionData& txdataIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {}
|
TransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, const PrecomputedTransactionData& txdataIn) : txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {}
|
||||||
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, uint32_t consensusBranchId) const;
|
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, uint32_t consensusBranchId) const;
|
||||||
bool CheckLockTime(const CScriptNum& nLockTime) const;
|
bool CheckLockTime(const CScriptNum& nLockTime) const;
|
||||||
int CheckCryptoCondition(
|
|
||||||
const std::vector<unsigned char>& condBin,
|
|
||||||
const std::vector<unsigned char>& ffillBin,
|
|
||||||
const CScript& scriptCode,
|
|
||||||
uint32_t consensusBranchId) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MutableTransactionSignatureChecker : public TransactionSignatureChecker
|
class MutableTransactionSignatureChecker : public TransactionSignatureChecker
|
||||||
|
|||||||
@@ -183,40 +183,6 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsCryptoConditionsEnabled()) {
|
|
||||||
// Shortcut for pay-to-crypto-condition
|
|
||||||
CScript ccSubScript = CScript();
|
|
||||||
std::vector<std::vector<unsigned char>> vParams;
|
|
||||||
if (scriptPubKey.IsPayToCryptoCondition(&ccSubScript, vParams))
|
|
||||||
{
|
|
||||||
if (scriptPubKey.MayAcceptCryptoCondition())
|
|
||||||
{
|
|
||||||
typeRet = TX_CRYPTOCONDITION;
|
|
||||||
vector<unsigned char> hashBytes; uint160 x; int32_t i; uint8_t hash20[20],*ptr;;
|
|
||||||
x = Hash160(ccSubScript);
|
|
||||||
memcpy(hash20,&x,20);
|
|
||||||
hashBytes.resize(20);
|
|
||||||
ptr = hashBytes.data();
|
|
||||||
for (i=0; i<20; i++)
|
|
||||||
ptr[i] = hash20[i];
|
|
||||||
vSolutionsRet.push_back(hashBytes);
|
|
||||||
if (vParams.size())
|
|
||||||
{
|
|
||||||
COptCCParams cp = COptCCParams(vParams[0]);
|
|
||||||
if (cp.IsValid())
|
|
||||||
{
|
|
||||||
for (auto k : cp.vKeys)
|
|
||||||
{
|
|
||||||
vSolutionsRet.push_back(std::vector<unsigned char>(k.begin(), k.end()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scan templates
|
// Scan templates
|
||||||
const CScript& script1 = scriptPubKey;
|
const CScript& script1 = scriptPubKey;
|
||||||
BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates)
|
BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates)
|
||||||
@@ -404,21 +370,6 @@ bool ExtractDestination(const CScript& _scriptPubKey, CTxDestination& addressRet
|
|||||||
addressRet = CScriptID(uint160(vSolutions[0]));
|
addressRet = CScriptID(uint160(vSolutions[0]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (IsCryptoConditionsEnabled() != 0 && whichType == TX_CRYPTOCONDITION)
|
|
||||||
{
|
|
||||||
if (vSolutions.size() > 1)
|
|
||||||
{
|
|
||||||
CPubKey pk = CPubKey((vSolutions[1]));
|
|
||||||
addressRet = pk;
|
|
||||||
return pk.IsValid();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addressRet = CKeyID(uint160(vSolutions[0]));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Multisig txns have more than one address...
|
// Multisig txns have more than one address...
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -464,30 +415,7 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
|
|||||||
|
|
||||||
if (addressRet.empty())
|
if (addressRet.empty())
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
// Removed to get CC address printed in getrawtransaction and decoderawtransaction
|
|
||||||
// else if (IsCryptoConditionsEnabled() != 0 && typeRet == TX_CRYPTOCONDITION)
|
|
||||||
// {
|
|
||||||
// nRequiredRet = vSolutions.front()[0];
|
|
||||||
// for (unsigned int i = 1; i < vSolutions.size()-1; i++)
|
|
||||||
// {
|
|
||||||
// CTxDestination address;
|
|
||||||
// if (vSolutions[i].size() == 20)
|
|
||||||
// {
|
|
||||||
// address = CKeyID(uint160(vSolutions[i]));
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// address = CPubKey(vSolutions[i]);
|
|
||||||
// }
|
|
||||||
// addressRet.push_back(address);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (addressRet.empty())
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nRequiredRet = 1;
|
nRequiredRet = 1;
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
if (!ExtractDestination(scriptPubKey, address))
|
if (!ExtractDestination(scriptPubKey, address))
|
||||||
|
|||||||
16
src/txdb.cpp
16
src/txdb.cpp
@@ -456,7 +456,7 @@ uint32_t hush_segid32(char *coinaddr);
|
|||||||
bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, UniValue *ret)
|
bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, UniValue *ret)
|
||||||
{
|
{
|
||||||
int64_t total = 0; int64_t totalAddresses = 0; std::string address;
|
int64_t total = 0; int64_t totalAddresses = 0; std::string address;
|
||||||
int64_t utxos = 0; int64_t ignoredAddresses = 0, cryptoConditionsUTXOs = 0, cryptoConditionsTotals = 0;
|
int64_t utxos = 0; int64_t ignoredAddresses = 0;
|
||||||
DECLARE_IGNORELIST
|
DECLARE_IGNORELIST
|
||||||
boost::scoped_ptr<CDBIterator> iter(NewIterator());
|
boost::scoped_ptr<CDBIterator> iter(NewIterator());
|
||||||
//std::map <std::string, CAmount> addressAmounts;
|
//std::map <std::string, CAmount> addressAmounts;
|
||||||
@@ -479,13 +479,7 @@ bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, Un
|
|||||||
if ( nValue == 0 )
|
if ( nValue == 0 )
|
||||||
continue;
|
continue;
|
||||||
getAddressFromIndex(indexKey.type, indexKey.hashBytes, address);
|
getAddressFromIndex(indexKey.type, indexKey.hashBytes, address);
|
||||||
if ( indexKey.type == 3 )
|
|
||||||
{
|
|
||||||
cryptoConditionsUTXOs++;
|
|
||||||
cryptoConditionsTotals += nValue;
|
|
||||||
total += nValue;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::map <std::string, int>::iterator ignored = ignoredMap.find(address);
|
std::map <std::string, int>::iterator ignored = ignoredMap.find(address);
|
||||||
if (ignored != ignoredMap.end())
|
if (ignored != ignoredMap.end())
|
||||||
{
|
{
|
||||||
@@ -540,12 +534,6 @@ bool CBlockTreeDB::Snapshot2(std::map <std::string, CAmount> &addressAmounts, Un
|
|||||||
ret->push_back(make_pair("total_addresses", totalAddresses ));
|
ret->push_back(make_pair("total_addresses", totalAddresses ));
|
||||||
// Total number of ignored addresses in this snaphot
|
// Total number of ignored addresses in this snaphot
|
||||||
ret->push_back(make_pair("ignored_addresses", ignoredAddresses));
|
ret->push_back(make_pair("ignored_addresses", ignoredAddresses));
|
||||||
// Total number of crypto condition utxos we skipped
|
|
||||||
ret->push_back(make_pair("skipped_cc_utxos", cryptoConditionsUTXOs));
|
|
||||||
// Total value of skipped crypto condition utxos
|
|
||||||
ret->push_back(make_pair("cc_utxo_value", (double) cryptoConditionsTotals / COIN));
|
|
||||||
// total of all the address's, does not count coins in CC vouts.
|
|
||||||
ret->push_back(make_pair("total_includeCCvouts", (double) (total+cryptoConditionsTotals)/ COIN ));
|
|
||||||
// The snapshot finished at this block height
|
// The snapshot finished at this block height
|
||||||
ret->push_back(make_pair("ending_height", chainActive.Height()));
|
ret->push_back(make_pair("ending_height", chainActive.Height()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1977,17 +1977,6 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum)
|
|||||||
case TX_NULL_DATA:
|
case TX_NULL_DATA:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TX_CRYPTOCONDITION:
|
|
||||||
// for now, default is that the first value returned will be the script, subsequent values will be
|
|
||||||
// pubkeys. if we have the first pub key in our wallet, we consider this spendable
|
|
||||||
if (vSolutions.size() > 1)
|
|
||||||
{
|
|
||||||
keyID = CPubKey(vSolutions[1]).GetID();
|
|
||||||
if (this->HaveKey(keyID))
|
|
||||||
return ISMINE_SPENDABLE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TX_PUBKEY:
|
case TX_PUBKEY:
|
||||||
keyID = CPubKey(vSolutions[0]).GetID();
|
keyID = CPubKey(vSolutions[0]).GetID();
|
||||||
if (this->HaveKey(keyID))
|
if (this->HaveKey(keyID))
|
||||||
|
|||||||
Reference in New Issue
Block a user