mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge #469: Add TX_TRUE output format, accept in wallet with anyonecanspendaremine
9908f9a Add TX_TRUE output format, accept in wallet with `anyonecanspendaremine` (Gregory Sanders)
This commit is contained in:
commit
cc4b98f854
9 changed files with 28 additions and 0 deletions
|
|
@ -106,6 +106,7 @@ public:
|
|||
|
||||
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.
|
||||
|
|
@ -223,6 +224,7 @@ public:
|
|||
|
||||
consensus.genesis_subsidy = 50*COIN;
|
||||
consensus.connect_genesis_outputs = false;
|
||||
anyonecanspend_aremine = false;
|
||||
|
||||
pchMessageStart[0] = 0x0b;
|
||||
pchMessageStart[1] = 0x11;
|
||||
|
|
@ -315,6 +317,7 @@ public:
|
|||
|
||||
consensus.genesis_subsidy = 50*COIN;
|
||||
consensus.connect_genesis_outputs = false;
|
||||
anyonecanspend_aremine = false;
|
||||
|
||||
pchMessageStart[0] = 0xfa;
|
||||
pchMessageStart[1] = 0xbf;
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ public:
|
|||
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() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <keystore.h>
|
||||
#include <script/script.h>
|
||||
#include <script/sign.h>
|
||||
#include <chainparams.h>
|
||||
|
||||
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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) {}
|
||||
|
|
@ -157,6 +159,9 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
|
|||
}
|
||||
return false;
|
||||
|
||||
case TX_TRUE:
|
||||
return Params().anyonecanspend_aremine;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include <util.h>
|
||||
#include <utilstrencodings.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
|
||||
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue