mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Add regtest mode with a very large OP_TRUE output
This commit is contained in:
parent
a31395b5da
commit
c3ab6a374a
6 changed files with 43 additions and 9 deletions
|
|
@ -247,6 +247,17 @@ public:
|
|||
genesis.proof = CProof(0x207fffff, 2);
|
||||
nDefaultPort = 18444;
|
||||
|
||||
CMutableTransaction txNew(genesis.vtx[0]);
|
||||
txNew.vout.resize(2);
|
||||
txNew.vout[0].nValue = MAX_MONEY / 2;
|
||||
txNew.vout[1].nValue = MAX_MONEY / 2;
|
||||
txNew.vout[1].scriptPubKey = CScript() << OP_TRUE;
|
||||
genesis.vtx[0] = CTransaction(txNew);
|
||||
|
||||
CScript scriptDestination(CScript() << OP_TRUE);
|
||||
genesis.proof = CProof(scriptDestination, CScript()); // genesis block gets a PoW pass
|
||||
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
|
||||
|
||||
hashGenesisBlock = genesis.GetHash();
|
||||
mapCheckpointsRegtest[0] = hashGenesisBlock;
|
||||
|
||||
|
|
|
|||
|
|
@ -1191,7 +1191,6 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
strErrors << _("Cannot downgrade wallet") << "\n";
|
||||
pwalletMain->SetMaxVersion(nMaxVersion);
|
||||
}
|
||||
|
||||
if (fFirstRun)
|
||||
{
|
||||
// Create new keyUser and set as default key
|
||||
|
|
@ -1212,6 +1211,11 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
|
||||
RegisterValidationInterface(pwalletMain);
|
||||
|
||||
CBlock block = Params().GenesisBlock();
|
||||
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
||||
SyncWithWallets(tx, &block);
|
||||
}
|
||||
|
||||
CBlockIndex *pindexRescan = chainActive.Tip();
|
||||
if (GetBoolArg("-rescan", false))
|
||||
pindexRescan = chainActive.Genesis();
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
|
|||
case TX_MULTISIG:
|
||||
scriptSigRet << OP_0; // workaround CHECKMULTISIG bug
|
||||
return (SignN(vSolutions, creator, scriptPubKey, scriptSigRet));
|
||||
case TX_TRUE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -229,6 +231,7 @@ static CScript CombineSignatures(const CScript& scriptPubKey, const BaseSignatur
|
|||
case TX_NONSTANDARD:
|
||||
case TX_NULL_DATA:
|
||||
case TX_WITHDRAW_LOCK:
|
||||
case TX_TRUE:
|
||||
// Don't know anything about this, assume bigger one is correct:
|
||||
if (sigs1.size() >= sigs2.size())
|
||||
return PushAll(sigs1);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ const char* GetTxnOutputType(txnouttype t)
|
|||
case TX_NULL_DATA: return "nulldata";
|
||||
case TX_WITHDRAW_LOCK: return "withdraw";
|
||||
case TX_WITHDRAW_OUT: return "withdrawout";
|
||||
case TX_TRUE: return "true";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -58,6 +59,9 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
|
|||
if (GetBoolArg("-datacarrier", true))
|
||||
mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN << OP_SMALLDATA));
|
||||
mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN));
|
||||
|
||||
// OP_TRUE scriptPubKey
|
||||
mTemplates.insert(make_pair(TX_TRUE, CScript() << OP_TRUE));
|
||||
}
|
||||
|
||||
// Shortcut for pay-to-script-hash, which are more constrained than the other types:
|
||||
|
|
@ -192,6 +196,8 @@ int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned c
|
|||
return vSolutions[0][0] + 1;
|
||||
case TX_SCRIPTHASH:
|
||||
return 1; // doesn't include args needed by the script
|
||||
case TX_TRUE:
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -202,15 +208,22 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
|
|||
if (!Solver(scriptPubKey, whichType, vSolutions))
|
||||
return false;
|
||||
|
||||
if (whichType == TX_MULTISIG)
|
||||
{
|
||||
unsigned char m = vSolutions.front()[0];
|
||||
unsigned char n = vSolutions.back()[0];
|
||||
// Support up to x-of-3 multisig txns as standard
|
||||
if (n < 1 || n > 3)
|
||||
return false;
|
||||
if (m < 1 || m > n)
|
||||
switch (whichType) {
|
||||
case TX_MULTISIG:
|
||||
{
|
||||
unsigned char m = vSolutions.front()[0];
|
||||
unsigned char n = vSolutions.back()[0];
|
||||
// Support up to x-of-3 multisig txns as standard
|
||||
if (n < 1 || n > 3)
|
||||
return false;
|
||||
if (m < 1 || m > n)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case TX_TRUE:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return whichType != TX_NONSTANDARD;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ enum txnouttype
|
|||
TX_NULL_DATA,
|
||||
TX_WITHDRAW_LOCK,
|
||||
TX_WITHDRAW_OUT,
|
||||
TX_TRUE,
|
||||
};
|
||||
|
||||
class CNoDestination {
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
|
|||
return ISMINE_SPENDABLE;
|
||||
break;
|
||||
}
|
||||
case TX_TRUE:
|
||||
return ISMINE_SPENDABLE;
|
||||
}
|
||||
|
||||
if (keystore.HaveWatchOnly(scriptPubKey))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue