Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class CMainParams : public CChainParams {

consensus.genesis_subsidy = 50*COIN;
consensus.connect_genesis_outputs = false;
anyonecanspend_aremine = false;

/**
* The message start string is designed to be unlikely to occur in normal data.
Expand Down Expand Up @@ -223,6 +224,7 @@ class CTestNetParams : public CChainParams {

consensus.genesis_subsidy = 50*COIN;
consensus.connect_genesis_outputs = false;
anyonecanspend_aremine = false;

pchMessageStart[0] = 0x0b;
pchMessageStart[1] = 0x11;
Expand Down Expand Up @@ -315,6 +317,7 @@ class CRegTestParams : public CChainParams {

consensus.genesis_subsidy = 50*COIN;
consensus.connect_genesis_outputs = false;
anyonecanspend_aremine = false;

pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
Expand Down Expand Up @@ -439,6 +442,8 @@ class CCustomParams : public CRegTestParams {
// Custom chains connect coinbase outputs to db by default
consensus.connect_genesis_outputs = gArgs.GetArg("-con_connect_coinbase", true);

anyonecanspend_aremine = gArgs.GetBoolArg("-anyonecanspendaremine", true);

nPruneAfterHeight = (uint64_t)args.GetArg("-npruneafterheight", nPruneAfterHeight);
fDefaultConsistencyChecks = args.GetBoolArg("-fdefaultconsistencychecks", fDefaultConsistencyChecks);
fMineBlocksOnDemand = args.GetBoolArg("-fmineblocksondemand", fMineBlocksOnDemand);
Expand Down
1 change: 1 addition & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class CChainParams
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
const CCheckpointData& Checkpoints() const { return checkpointData; }
const ChainTxData& TxData() const { return chainTxData; }
bool anyonecanspend_aremine;
protected:
CChainParams() {}

Expand Down
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ void SetupServerArgs()
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)), false, OptionsCategory::NODE_RELAY);
gArgs.AddArg("-whitelistforcerelay", strprintf("Force relay of transactions from whitelisted peers even if they violate local relay policy (default: %d)", DEFAULT_WHITELISTFORCERELAY), false, OptionsCategory::NODE_RELAY);
gArgs.AddArg("-whitelistrelay", strprintf("Accept relayed transactions received from whitelisted peers even when not relaying transactions (default: %d)", DEFAULT_WHITELISTRELAY), false, OptionsCategory::NODE_RELAY);
gArgs.AddArg("-anyonecanspendaremine", strprintf("Treat OP_TRUE outputs as funds for the wallet. Default true for custom chains."), true, OptionsCategory::DEBUG_TEST);


gArgs.AddArg("-blockmaxweight=<n>", strprintf("Set maximum BIP141 block weight (default: %d)", DEFAULT_BLOCK_MAX_WEIGHT), false, OptionsCategory::BLOCK_CREATION);
Expand Down
5 changes: 5 additions & 0 deletions src/script/ismine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <keystore.h>
#include <script/script.h>
#include <script/sign.h>
#include <chainparams.h>


typedef std::vector<unsigned char> valtype;
Expand Down Expand Up @@ -163,6 +164,10 @@ IsMineResult IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey,
}
break;
}
case TX_TRUE:
if (Params().anyonecanspend_aremine) {
return IsMineResult::SPENDABLE;
}
}

if (ret == IsMineResult::NO && keystore.HaveWatchOnly(scriptPubKey)) {
Expand Down
5 changes: 5 additions & 0 deletions src/script/sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <script/standard.h>
#include <uint256.h>

#include <chainparams.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) {}
Expand Down Expand Up @@ -157,6 +159,9 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
}
return false;

case TX_TRUE:
return Params().anyonecanspend_aremine;

default:
return false;
}
Expand Down
8 changes: 8 additions & 0 deletions src/script/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <util.h>
#include <utilstrencodings.h>

#include <chainparams.h>


typedef std::vector<unsigned char> valtype;

Expand All @@ -37,6 +39,7 @@ const char* GetTxnOutputType(txnouttype t)
case TX_WITNESS_V0_KEYHASH: return "witness_v0_keyhash";
case TX_WITNESS_V0_SCRIPTHASH: return "witness_v0_scripthash";
case TX_WITNESS_UNKNOWN: return "witness_unknown";
case TX_TRUE: return "true";
}
return nullptr;
}
Expand Down Expand Up @@ -91,6 +94,11 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
{
vSolutionsRet.clear();

if (Params().anyonecanspend_aremine && scriptPubKey == CScript() << OP_TRUE) {
typeRet = TX_TRUE;
return true;
}

// 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())
Expand Down
1 change: 1 addition & 0 deletions src/script/standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ enum txnouttype
TX_WITNESS_V0_SCRIPTHASH,
TX_WITNESS_V0_KEYHASH,
TX_WITNESS_UNKNOWN, //!< Only for Witness versions not already defined above
TX_TRUE, // For testing purposes only
};

class CNoDestination {
Expand Down
1 change: 1 addition & 0 deletions test/bitcoin_functional/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def initialize_datadir(dirname, n, chain):
f.write("printtoconsole=0\n")
f.write("con_blocksubsidy=5000000000\n")
f.write("con_connect_coinbase=0\n")
f.write("anyonecanspendaremine=0\n")
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
return datadir
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def initialize_datadir(dirname, n, chain):
f.write("printtoconsole=0\n")
f.write("con_blocksubsidy=5000000000\n")
f.write("con_connect_coinbase=0\n")
f.write("anyonecanspendaremine=0\n")
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
return datadir
Expand Down