Skip to content

Commit

Permalink
Add -con_elementswitness flag and global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Feb 13, 2019
1 parent 01b03a9 commit 6ed8fd8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <chainparamsseeds.h>
#include <consensus/merkle.h>
#include <primitives/transaction.h>
#include <tinyformat.h>
#include <util.h>
#include <utilstrencodings.h>
Expand Down Expand Up @@ -523,9 +524,10 @@ class CCustomParams : public CRegTestParams {
consensus.max_block_signature_size = gArgs.GetArg("-con_max_block_sig_size", 74);
g_signed_blocks = gArgs.GetBoolArg("-con_signed_blocks", true);

// Note: This global is needed to avoid circular dependency
// Defaults to true for custom chains.
// 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);

// No subsidy for custom chains by default
consensus.genesis_subsidy = args.GetArg("-con_blocksubsidy", 0);
Expand Down
1 change: 1 addition & 0 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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_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: 2 additions & 0 deletions src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <serialize.h>
#include <uint256.h>

// ELEMENTS:
// Globals to avoid circular dependencies.
extern bool g_con_blockheightinheader;
extern bool g_signed_blocks;

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

bool g_con_elementswitness = false;

std::string COutPoint::ToString() const
{
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n);
Expand Down
4 changes: 4 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000;

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

/** An outpoint - a combination of a transaction hash and an index n into its vout */
class COutPoint
{
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("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_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 6ed8fd8

Please sign in to comment.