Skip to content

Commit

Permalink
Rename con_elementswitness to con_elementsmode
Browse files Browse the repository at this point in the history
It will have effect on more than just witness structure from now on.
  • Loading branch information
stevenroose committed Mar 20, 2019
1 parent 484d83c commit 04d0691
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class CMainParams : public CChainParams {
multi_data_permitted = false;
consensus.has_parent_chain = false;
g_signed_blocks = false;
g_con_elementswitness = false;
g_con_elementsmode = false;
g_con_blockheightinheader = false;

/**
Expand Down Expand Up @@ -277,7 +277,7 @@ class CTestNetParams : public CChainParams {
multi_data_permitted = false;
consensus.has_parent_chain = false;
g_signed_blocks = false;
g_con_elementswitness = false;
g_con_elementsmode = false;
g_con_blockheightinheader = false;

pchMessageStart[0] = 0x0b;
Expand Down Expand Up @@ -378,7 +378,7 @@ class CRegTestParams : public CChainParams {
multi_data_permitted = false;
consensus.has_parent_chain = false;
g_signed_blocks = false;
g_con_elementswitness = false;
g_con_elementsmode = false;
g_con_blockheightinheader = false;

pchMessageStart[0] = 0xfa;
Expand Down Expand Up @@ -543,7 +543,7 @@ class CCustomParams : public CRegTestParams {
// Note: These globals are needed to avoid circular dependencies.
// Default to true for custom chains.
g_con_blockheightinheader = args.GetBoolArg("-con_blockheightinheader", true);
g_con_elementswitness = args.GetBoolArg("-con_elementswitness", true);
g_con_elementsmode = args.GetBoolArg("-con_elementsmode", true);

// No subsidy for custom chains by default
consensus.genesis_subsidy = args.GetArg("-con_blocksubsidy", 0);
Expand Down Expand Up @@ -591,7 +591,7 @@ class CCustomParams : public CRegTestParams {
GenerateAssetEntropy(entropy, COutPoint(uint256(commit), 0), parentGenesisBlockHash);

// Elements serialization uses derivation, bitcoin serialization uses 0x00
if (g_con_elementswitness) {
if (g_con_elementsmode) {
CalculateAsset(consensus.pegged_asset, entropy);
} else {
assert(consensus.pegged_asset == CAsset());
Expand Down Expand Up @@ -712,7 +712,7 @@ class CLiquidV1Params : public CChainParams {
g_signed_blocks = true;

g_con_blockheightinheader = true;
g_con_elementswitness = true;
g_con_elementsmode = true;

consensus.genesis_subsidy = 0;

Expand Down Expand Up @@ -750,7 +750,7 @@ class CLiquidV1Params : public CChainParams {
GenerateAssetEntropy(entropy, COutPoint(uint256(commit), 0), parentGenesisBlockHash);

// Elements serialization uses derivation, bitcoin serialization uses 0x00
if (g_con_elementswitness) {
if (g_con_elementsmode) {
CalculateAsset(consensus.pegged_asset, entropy);
} else {
assert(consensus.pegged_asset == CAsset());
Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void SetupChainParamsBaseOptions()
gArgs.AddArg("-con_mandatorycoinbase", "All non-zero valued coinbase outputs must go to this scriptPubKey, if set.", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-con_blocksubsidy", "Defines the amount of block subsidy to start with, at genesis block.", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-con_connect_coinbase", "Connect outputs in genesis block to utxo database.", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-con_elementswitness", "Use Elements-like instead of Core-like witness encoding. This is required for CA/CT. (default: true)", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-con_elementsmode", "Use Elements-like instead of Core-like witness encoding. This is required for CA/CT. (default: true)", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-con_blockheightinheader", "Whether the chain includes the block height directly in the header, for easier validation of block height in low-resource environments. (default: true)", false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-con_genesis_style=<style>", "Use genesis style <style> (default: elements). Results in genesis block compatibility with various networks. Allowed values: elements, bitcoin", true, OptionsCategory::ELEMENTS);
gArgs.AddArg("-con_signed_blocks", "Signed blockchain. Uses input of `-signblockscript` to define what signatures are necessary to solve it.", false, OptionsCategory::CHAINPARAMS);
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/merkle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated)
leaves.resize(block.vtx.size());
leaves[0].SetNull(); // The witness hash of the coinbase is 0.
for (size_t s = 1; s < block.vtx.size(); s++) {
if (g_con_elementswitness) {
if (g_con_elementsmode) {
leaves[s] = block.vtx[s]->GetWitnessOnlyHash();
} else {
leaves[s] = block.vtx[s]->GetWitnessHash();
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static inline int64_t GetTransactionInputWeight(const CTransaction& tx, const si
{
// scriptWitness size is added here because witnesses and txins are split up in segwit serialization.
assert(tx.witness.vtxinwit.size() > nIn);
//TODO(rebase) only count CA/CT witnesses when g_con_elementswitness is true
//TODO(rebase) only count CA/CT witnesses when g_con_elementsmode is true
return ::GetSerializeSize(tx.vin[nIn], PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1)
+ ::GetSerializeSize(tx.vin[nIn], PROTOCOL_VERSION)
+ ::GetSerializeSize(tx.witness.vtxinwit[nIn].scriptWitness.stack, PROTOCOL_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
{
entry.pushKV("txid", tx.GetHash().GetHex());
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
if (g_con_elementswitness) {
if (g_con_elementsmode) {
entry.pushKV("wtxid", tx.GetWitnessHash().GetHex());
entry.pushKV("withash", tx.GetWitnessOnlyHash().GetHex());
}
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void SetupServerArgs()
gArgs.AddArg("-blech32_hrp", strprintf("The human-readable part of the chain's blech32 encoding. Used in confidential addresses.(default: %s)", defaultChainParams->Blech32HRP()), false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-assetdir", "Entries of pet names of assets, in this format:asset=<hex>:<label>. There can be any number of entries.", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-defaultpeggedassetname", "Default name of the pegged asset. (default: bitcoin)", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-blindedaddresses", "Give blind addresses by default via getnewaddress and getrawchangeaddress. (default: -con_elementswitness value)", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-blindedaddresses", "Give blind addresses by default via getnewaddress and getrawchangeaddress. (default: -con_elementsmode value)", false, OptionsCategory::ELEMENTS);

#if HAVE_DECL_DAEMON
gArgs.AddArg("-daemon", "Run in the background as a daemon and accept commands", false, OptionsCategory::OPTIONS);
Expand Down
6 changes: 3 additions & 3 deletions src/primitives/confidential.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <uint256.h>
#include <utilstrencodings.h>

extern bool g_con_elementswitness;
extern bool g_con_elementsmode;

/**
* Confidential assets, values, and nonces all share enough code in common
Expand Down Expand Up @@ -104,7 +104,7 @@ class CConfidentialAsset : public CConfidentialCommitment<33, 10, 11>
vchCommitment.clear();

// Set to dummy asset when not doing CA.
if (!g_con_elementswitness) {
if (!g_con_elementsmode) {
SetToAsset(CAsset());
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ class CConfidentialValue : public CConfidentialCommitment<9, 8, 9>
* a 64-bit big-endian integer. */
CAmount GetAmount() const
{
if (!g_con_elementswitness && IsNull()) {
if (!g_con_elementsmode && IsNull()) {
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions src/primitives/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <tinyformat.h>
#include <utilstrencodings.h>

bool g_con_elementswitness = false;
bool g_con_elementsmode = false;

std::string COutPoint::ToString() const
{
Expand Down Expand Up @@ -83,7 +83,7 @@ uint256 CTransaction::ComputeWitnessHash() const
// ELEMENTS ONLY
uint256 CTransaction::GetWitnessOnlyHash() const
{
assert(g_con_elementswitness);
assert(g_con_elementsmode);

std::vector<uint256> leaves;
leaves.reserve(std::max(vin.size(), vout.size()));
Expand Down
6 changes: 3 additions & 3 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000;

// ELEMENTS:
// Globals to avoid circular dependencies.
extern bool g_con_elementswitness;
extern bool g_con_elementsmode;

/** An outpoint - a combination of a transaction hash and an index n into its vout */
class COutPoint
Expand Down Expand Up @@ -310,7 +310,7 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {

// Witness serialization is different between Elements and Core.
// See code comments in SerializeTransaction for details about the differences.
if (g_con_elementswitness) {
if (g_con_elementsmode) {
s >> flags;
s >> tx.vin;
s >> tx.vout;
Expand Down Expand Up @@ -378,7 +378,7 @@ inline void SerializeTransaction(const TxType& tx, Stream& s) {
}

// Witness serialization is different between Elements and Core.
if (g_con_elementswitness) {
if (g_con_elementsmode) {
// In Elements-style serialization, all normal data is serialized first and the
// witnesses all in the end.
s << flags;
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static UniValue getnewaddress(const JSONRPCRequest& request)
}
pwallet->LearnRelatedScripts(newKey, output_type);
CTxDestination dest = GetDestinationForKey(newKey, output_type);
if (g_con_elementswitness) {
if (g_con_elementsmode) {
CPubKey blinding_pubkey = pwallet->GetBlindingPubKey(GetScriptForDestination(dest));
dest = GetDestinationForKey(newKey, output_type, blinding_pubkey);
}
Expand Down Expand Up @@ -262,7 +262,7 @@ static UniValue getrawchangeaddress(const JSONRPCRequest& request)

pwallet->LearnRelatedScripts(vchPubKey, output_type);
CTxDestination dest = GetDestinationForKey(vchPubKey, output_type);
if (g_con_elementswitness) {
if (g_con_elementsmode) {
CPubKey blinding_pubkey = pwallet->GetBlindingPubKey(GetScriptForDestination(dest));
dest = GetDestinationForKey(vchPubKey, output_type, blinding_pubkey);
}
Expand Down
2 changes: 1 addition & 1 deletion test/bitcoin_functional/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def initialize_datadir(dirname, n, chain):
f.write("con_connect_coinbase=0\n")
f.write("anyonecanspendaremine=0\n")
f.write("con_blockheightinheader=0\n")
f.write("con_elementswitness=0\n")
f.write("con_elementsmode=0\n")
f.write("con_signed_blocks=0\n")
f.write("multi_data_permitted=0\n")
f.write("walletrbf=0\n") # Default is 1 in Elements
Expand Down

0 comments on commit 04d0691

Please sign in to comment.