Skip to content

Commit cffb308

Browse files
committed
Add -con_elementswitness flag and global variable
1 parent 1285105 commit cffb308

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

src/chainparams.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <chainparamsseeds.h>
99
#include <consensus/merkle.h>
10+
#include <primitives/transaction.h>
1011
#include <tinyformat.h>
1112
#include <util.h>
1213
#include <utilstrencodings.h>
@@ -523,9 +524,10 @@ class CCustomParams : public CRegTestParams {
523524
consensus.max_block_signature_size = gArgs.GetArg("-con_max_block_sig_size", 74);
524525
g_signed_blocks = gArgs.GetBoolArg("-con_signed_blocks", true);
525526

526-
// Note: This global is needed to avoid circular dependency
527-
// Defaults to true for custom chains.
527+
// Note: These globals are needed to avoid circular dependencies.
528+
// Default to true for custom chains.
528529
g_con_blockheightinheader = args.GetBoolArg("-con_blockheightinheader", true);
530+
g_con_elementswitness = args.GetBoolArg("-con_elementswitness", true);
529531

530532
// No subsidy for custom chains by default
531533
consensus.genesis_subsidy = args.GetArg("-con_blocksubsidy", 0);

src/chainparamsbase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void SetupChainParamsBaseOptions()
2626
gArgs.AddArg("-con_mandatorycoinbase", "All non-zero valued coinbase outputs must go to this scriptPubKey, if set.", false, OptionsCategory::ELEMENTS);
2727
gArgs.AddArg("-con_blocksubsidy", "Defines the amount of block subsidy to start with, at genesis block.", false, OptionsCategory::ELEMENTS);
2828
gArgs.AddArg("-con_connect_coinbase", "Connect outputs in genesis block to utxo database.", false, OptionsCategory::ELEMENTS);
29+
gArgs.AddArg("-con_elementswitness", "Use Elements-like instead of Core-like witness encoding. This is required for CA/CT. (default: true)", false, OptionsCategory::ELEMENTS);
2930
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);
3031
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);
3132
gArgs.AddArg("-con_signed_blocks", "Signed blockchain. Uses input of `-signblockscript` to define what signatures are necessary to solve it.", false, OptionsCategory::CHAINPARAMS);

src/primitives/block.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <serialize.h>
1212
#include <uint256.h>
1313

14+
// ELEMENTS:
15+
// Globals to avoid circular dependencies.
1416
extern bool g_con_blockheightinheader;
1517
extern bool g_signed_blocks;
1618

src/primitives/transaction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <tinyformat.h>
1010
#include <utilstrencodings.h>
1111

12+
bool g_con_elementswitness = false;
13+
1214
std::string COutPoint::ToString() const
1315
{
1416
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n);

src/primitives/transaction.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000;
1616

17+
// ELEMENTS:
18+
// Globals to avoid circular dependencies.
19+
extern bool g_con_elementswitness;
20+
1721
/** An outpoint - a combination of a transaction hash and an index n into its vout */
1822
class COutPoint
1923
{

test/bitcoin_functional/functional/test_framework/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ def initialize_datadir(dirname, n, chain):
307307
f.write("con_connect_coinbase=0\n")
308308
f.write("anyonecanspendaremine=0\n")
309309
f.write("con_blockheightinheader=0\n")
310+
f.write("con_elementswitness=0\n")
310311
f.write("con_signed_blocks=0\n")
311312
f.write("multi_data_permitted=0\n")
312313
f.write("walletrbf=0\n") # Default is 1 in Elements

0 commit comments

Comments
 (0)