simplified claim stripping, removed TX_CLAIM
This commit is contained in:
parent
a84c196916
commit
b3c5b1e88d
6 changed files with 16 additions and 31 deletions
|
@ -167,8 +167,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx)
|
|||
{
|
||||
txnouttype type;
|
||||
std::vector<std::vector<unsigned char> > vSolutions;
|
||||
const CScript& scriptPubKey = StripClaimScriptPrefix(txout.scriptPubKey);
|
||||
if (Solver(scriptPubKey, type, vSolutions) &&
|
||||
if (Solver(txout.scriptPubKey, type, vSolutions) &&
|
||||
(type == TX_PUBKEY || type == TX_MULTISIG))
|
||||
insert(COutPoint(hash, i));
|
||||
}
|
||||
|
|
|
@ -10,11 +10,9 @@
|
|||
#include <consensus/validation.h>
|
||||
#include <validation.h>
|
||||
#include <coins.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util.h>
|
||||
#include <utilstrencodings.h>
|
||||
|
||||
#include "nameclaim.h"
|
||||
#include <nameclaim.h>
|
||||
|
||||
|
||||
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
|
||||
|
@ -117,8 +115,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason)
|
|||
unsigned int nDataOut = 0;
|
||||
txnouttype whichType;
|
||||
for (const CTxOut& txout : tx.vout) {
|
||||
const CScript& scriptPubKey = StripClaimScriptPrefix(txout.scriptPubKey);
|
||||
if (!::IsStandard(scriptPubKey, whichType)) {
|
||||
if (!::IsStandard(txout.scriptPubKey, whichType)) {
|
||||
reason = "scriptpubkey";
|
||||
return false;
|
||||
}
|
||||
|
@ -171,8 +168,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
|||
std::vector<std::vector<unsigned char> > vSolutions;
|
||||
txnouttype whichType;
|
||||
// get the scriptPubKey corresponding to this input:
|
||||
const CScript& prevScript = StripClaimScriptPrefix(prev.scriptPubKey);
|
||||
if (!Solver(prevScript, whichType, vSolutions))
|
||||
if (!Solver(prev.scriptPubKey, whichType, vSolutions))
|
||||
return false;
|
||||
|
||||
if (whichType == TX_SCRIPTHASH)
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include <script/standard.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include "nameclaim.h"
|
||||
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
MutableTransactionSignatureCreator::MutableTransactionSignatureCreator(const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {}
|
||||
|
@ -102,10 +100,8 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
|
|||
ret.clear();
|
||||
std::vector<unsigned char> sig;
|
||||
|
||||
const CScript& strippedScriptPubKey = StripClaimScriptPrefix(scriptPubKey);
|
||||
|
||||
std::vector<valtype> vSolutions;
|
||||
if (!Solver(strippedScriptPubKey, whichTypeRet, vSolutions))
|
||||
if (!Solver(scriptPubKey, whichTypeRet, vSolutions))
|
||||
return false;
|
||||
|
||||
switch (whichTypeRet)
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <nameclaim.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/script.h>
|
||||
#include <util.h>
|
||||
#include <utilstrencodings.h>
|
||||
|
||||
|
||||
|
@ -30,7 +29,6 @@ const char* GetTxnOutputType(txnouttype t)
|
|||
switch (t)
|
||||
{
|
||||
case TX_NONSTANDARD: return "nonstandard";
|
||||
case TX_CLAIM: return "claim";
|
||||
case TX_PUBKEY: return "pubkey";
|
||||
case TX_PUBKEYHASH: return "pubkeyhash";
|
||||
case TX_SCRIPTHASH: return "scripthash";
|
||||
|
@ -93,19 +91,21 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
|
|||
{
|
||||
vSolutionsRet.clear();
|
||||
|
||||
auto strippedPubKey = StripClaimScriptPrefix(scriptPubKey);
|
||||
|
||||
// Shortcut for pay-to-script-hash, which are more constrained than the other types:
|
||||
// it is always OP_HASH160 20 [20 byte hash] OP_EQUAL
|
||||
if (scriptPubKey.IsPayToScriptHash())
|
||||
if (strippedPubKey.IsPayToScriptHash())
|
||||
{
|
||||
typeRet = TX_SCRIPTHASH;
|
||||
std::vector<unsigned char> hashBytes(scriptPubKey.begin()+2, scriptPubKey.begin()+22);
|
||||
std::vector<unsigned char> hashBytes(strippedPubKey.begin()+2, strippedPubKey.begin()+22);
|
||||
vSolutionsRet.push_back(hashBytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
int witnessversion;
|
||||
std::vector<unsigned char> witnessprogram;
|
||||
if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
|
||||
if (strippedPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
|
||||
if (witnessversion == 0 && witnessprogram.size() == WITNESS_V0_KEYHASH_SIZE) {
|
||||
typeRet = TX_WITNESS_V0_KEYHASH;
|
||||
vSolutionsRet.push_back(witnessprogram);
|
||||
|
@ -131,19 +131,19 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
|
|||
// So long as script passes the IsUnspendable() test and all but the first
|
||||
// byte passes the IsPushOnly() test we don't care what exactly is in the
|
||||
// script.
|
||||
if (scriptPubKey.size() >= 1 && scriptPubKey[0] == OP_RETURN && scriptPubKey.IsPushOnly(scriptPubKey.begin()+1)) {
|
||||
if (strippedPubKey.size() >= 1 && strippedPubKey[0] == OP_RETURN && strippedPubKey.IsPushOnly(strippedPubKey.begin()+1)) {
|
||||
typeRet = TX_NULL_DATA;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> data;
|
||||
if (MatchPayToPubkey(scriptPubKey, data)) {
|
||||
if (MatchPayToPubkey(strippedPubKey, data)) {
|
||||
typeRet = TX_PUBKEY;
|
||||
vSolutionsRet.push_back(std::move(data));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (MatchPayToPubkeyHash(scriptPubKey, data)) {
|
||||
if (MatchPayToPubkeyHash(strippedPubKey, data)) {
|
||||
typeRet = TX_PUBKEYHASH;
|
||||
vSolutionsRet.push_back(std::move(data));
|
||||
return true;
|
||||
|
@ -151,7 +151,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
|
|||
|
||||
unsigned int required;
|
||||
std::vector<std::vector<unsigned char>> keys;
|
||||
if (MatchMultisig(scriptPubKey, required, keys)) {
|
||||
if (MatchMultisig(strippedPubKey, required, keys)) {
|
||||
typeRet = TX_MULTISIG;
|
||||
vSolutionsRet.push_back({static_cast<unsigned char>(required)}); // safe as required is in range 1..16
|
||||
vSolutionsRet.insert(vSolutionsRet.end(), keys.begin(), keys.end());
|
||||
|
@ -160,10 +160,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
|
|||
}
|
||||
|
||||
vSolutionsRet.clear();
|
||||
|
||||
int op;
|
||||
std::vector<std::vector<unsigned char> > vvchParams;
|
||||
typeRet = (DecodeClaimScript(scriptPubKey, op, vvchParams)) ? TX_CLAIM : TX_NONSTANDARD;
|
||||
typeRet = TX_NONSTANDARD;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH;
|
|||
enum txnouttype
|
||||
{
|
||||
TX_NONSTANDARD,
|
||||
TX_CLAIM,
|
||||
// 'standard' transaction types:
|
||||
TX_PUBKEY,
|
||||
TX_PUBKEYHASH,
|
||||
|
|
|
@ -1692,9 +1692,7 @@ void CWalletTx::GetAmounts(std::list<COutputEntry>& listReceived,
|
|||
|
||||
// In either case, we need to get the destination address
|
||||
CTxDestination address;
|
||||
const CScript& scriptPubKey = StripClaimScriptPrefix(txout.scriptPubKey);
|
||||
|
||||
if (!ExtractDestination(scriptPubKey, address) && !scriptPubKey.IsUnspendable())
|
||||
if (!ExtractDestination(txout.scriptPubKey, address) && !txout.scriptPubKey.IsUnspendable())
|
||||
{
|
||||
pwallet->WalletLogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
|
||||
this->GetHash().ToString());
|
||||
|
|
Loading…
Reference in a new issue