From c3ab6a374a69d06b5fd0f5c343ddbb3bb57394db Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 3 Jun 2015 12:47:29 -0700 Subject: [PATCH] Add regtest mode with a very large OP_TRUE output --- src/chainparams.cpp | 11 +++++++++++ src/init.cpp | 6 +++++- src/script/sign.cpp | 3 +++ src/script/standard.cpp | 29 +++++++++++++++++++++-------- src/script/standard.h | 1 + src/wallet_ismine.cpp | 2 ++ 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index bb5d5519c2..a5b4b488c4 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -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; diff --git a/src/init.cpp b/src/init.cpp index a80ba01cd9..8025ddcf6c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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(); diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 515818ed44..7375f9ac26 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -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); diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 1c8afa3488..6818afc476 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -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 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; diff --git a/src/script/standard.h b/src/script/standard.h index b521274e03..05e736c316 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -66,6 +66,7 @@ enum txnouttype TX_NULL_DATA, TX_WITHDRAW_LOCK, TX_WITHDRAW_OUT, + TX_TRUE, }; class CNoDestination { diff --git a/src/wallet_ismine.cpp b/src/wallet_ismine.cpp index 37de89abf1..342b0ede24 100644 --- a/src/wallet_ismine.cpp +++ b/src/wallet_ismine.cpp @@ -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))