Sync with latest Komodo changes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef SCRIPT_CC_H
|
||||
#define SCRIPT_CC_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "pubkey.h"
|
||||
#include "script/script.h"
|
||||
#include "cryptoconditions/include/cryptoconditions.h"
|
||||
@@ -79,5 +81,4 @@ bool GetPushData(const CScript &sig, std::vector<unsigned char> &data);
|
||||
*/
|
||||
bool GetOpReturnData(const CScript &sig, std::vector<unsigned char> &data);
|
||||
|
||||
|
||||
#endif /* SCRIPT_CC_H */
|
||||
|
||||
@@ -3,17 +3,20 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <cryptoconditions.h>
|
||||
|
||||
#include "interpreter.h"
|
||||
|
||||
#include "consensus/upgrades.h"
|
||||
#include "primitives/transaction.h"
|
||||
#include "cc/eval.h"
|
||||
#include "crypto/ripemd160.h"
|
||||
#include "crypto/sha1.h"
|
||||
#include "crypto/sha256.h"
|
||||
#include "pubkey.h"
|
||||
#include "script/script.h"
|
||||
#include "uint256.h"
|
||||
#include "cryptoconditions/include/cryptoconditions.h"
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
@@ -1310,6 +1313,14 @@ int TransactionSignatureChecker::CheckCryptoCondition(
|
||||
} catch (logic_error ex) {
|
||||
return 0;
|
||||
}
|
||||
//int32_t z; uint8_t *ptr;
|
||||
//ptr = (uint8_t *)scriptCode.data();
|
||||
//for (z=0; z<scriptCode.size(); z++)
|
||||
// fprintf(stderr,"%02x",ptr[z]);
|
||||
//fprintf(stderr," <- CScript\n");
|
||||
//for (z=0; z<32; z++)
|
||||
// fprintf(stderr,"%02x",((uint8_t *)&sighash)[z]);
|
||||
//fprintf(stderr," sighash nIn.%d nHashType.%d %.8f id.%d\n",(int32_t)nIn,(int32_t)nHashType,(double)amount/COIN,(int32_t)consensusBranchId);
|
||||
|
||||
VerifyEval eval = [] (CC *cond, void *checker) {
|
||||
return ((TransactionSignatureChecker*)checker)->CheckEvalCondition(cond);
|
||||
@@ -1317,6 +1328,7 @@ int TransactionSignatureChecker::CheckCryptoCondition(
|
||||
|
||||
int out = cc_verify(cond, (const unsigned char*)&sighash, 32, 0,
|
||||
condBin.data(), condBin.size(), eval, (void*)this);
|
||||
//fprintf(stderr,"out.%d from cc_verify\n",(int32_t)out);
|
||||
cc_free(cond);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -186,5 +186,4 @@ bool VerifyScript(
|
||||
const BaseSignatureChecker& checker,
|
||||
uint32_t consensusBranchId,
|
||||
ScriptError* serror = NULL);
|
||||
|
||||
#endif // BITCOIN_SCRIPT_INTERPRETER_H
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
#include "tinyformat.h"
|
||||
#include "utilstrencodings.h"
|
||||
#include "script/cc.h"
|
||||
#include "cc/eval.h"
|
||||
#include "cryptoconditions/include/cryptoconditions.h"
|
||||
|
||||
|
||||
namespace {
|
||||
inline std::string ValueString(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
@@ -227,6 +229,14 @@ bool CScript::IsPayToPublicKeyHash() const
|
||||
(*this)[24] == OP_CHECKSIG);
|
||||
}
|
||||
|
||||
bool CScript::IsPayToPublicKey() const
|
||||
{
|
||||
// Extra-fast test for pay-to-pubkey CScripts:
|
||||
return (this->size() == 35 &&
|
||||
(*this)[0] == 33 &&
|
||||
(*this)[34] == OP_CHECKSIG);
|
||||
}
|
||||
|
||||
bool CScript::IsPayToScriptHash() const
|
||||
{
|
||||
// Extra-fast test for pay-to-script-hash CScripts:
|
||||
@@ -266,6 +276,17 @@ bool CScript::MayAcceptCryptoCondition() const
|
||||
return out;
|
||||
}
|
||||
|
||||
bool CScript::IsCoinImport() const
|
||||
{
|
||||
const_iterator pc = this->begin();
|
||||
vector<unsigned char> data;
|
||||
opcodetype opcode;
|
||||
if (this->GetOp(pc, opcode, data))
|
||||
if (opcode > OP_0 && opcode <= OP_PUSHDATA4)
|
||||
return data.begin()[0] == EVAL_IMPORTCOIN;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CScript::IsPushOnly() const
|
||||
{
|
||||
const_iterator pc = begin();
|
||||
|
||||
@@ -569,9 +569,11 @@ public:
|
||||
unsigned int GetSigOpCount(const CScript& scriptSig) const;
|
||||
|
||||
bool IsPayToPublicKeyHash() const;
|
||||
bool IsPayToPublicKey() const;
|
||||
|
||||
bool IsPayToScriptHash() const;
|
||||
bool IsPayToCryptoCondition() const;
|
||||
bool IsCoinImport() const;
|
||||
bool MayAcceptCryptoCondition() const;
|
||||
|
||||
/** Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical). */
|
||||
|
||||
@@ -31,6 +31,8 @@ const char* GetTxnOutputType(txnouttype t)
|
||||
case TX_SCRIPTHASH: return "scripthash";
|
||||
case TX_MULTISIG: return "multisig";
|
||||
case TX_NULL_DATA: return "nulldata";
|
||||
case TX_CRYPTOCONDITION: return "cryptocondition";
|
||||
default: return "invalid";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -74,6 +76,14 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
|
||||
if (scriptPubKey.IsPayToCryptoCondition()) {
|
||||
if (scriptPubKey.MayAcceptCryptoCondition()) {
|
||||
typeRet = TX_CRYPTOCONDITION;
|
||||
vector<unsigned char> hashBytes; uint160 x; int32_t i; uint8_t hash20[20],*ptr;;
|
||||
x = Hash160(scriptPubKey);
|
||||
memcpy(hash20,&x,20);
|
||||
hashBytes.resize(20);
|
||||
ptr = hashBytes.data();
|
||||
for (i=0; i<20; i++)
|
||||
ptr[i] = hash20[i];
|
||||
vSolutionsRet.push_back(hashBytes);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -263,6 +273,12 @@ bool ExtractDestination(const CScript& _scriptPubKey, CTxDestination& addressRet
|
||||
addressRet = CScriptID(uint160(vSolutions[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (IsCryptoConditionsEnabled() != 0 && whichType == TX_CRYPTOCONDITION)
|
||||
{
|
||||
addressRet = CKeyID(uint160(vSolutions[0]));
|
||||
return true;
|
||||
}
|
||||
// Multisig txns have more than one address...
|
||||
return false;
|
||||
}
|
||||
@@ -314,7 +330,9 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
|
||||
nRequiredRet = 1;
|
||||
CTxDestination address;
|
||||
if (!ExtractDestination(scriptPubKey, address))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
addressRet.push_back(address);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user