Skip to content

Commit 1339dae

Browse files
committed
Merge ElementsProject#1167: Add native support for liquidtestnet
c6e074e liquidtestnet: Fix chain name in windows installer (Pablo Greco) d0f391c liquidtestnet: Add style for Elements-Qt (Pablo Greco) 48ddfbf liquidtestnet: Add fixed seeds (Pablo Greco) 3b34c8e liquidtestnet: Add seed nodes (Pablo Greco) 0d19647 liquidtestnet: Accept multi OP_RETURN (Pablo Greco) f955cb3 liquidtestnet: Add chainparams (Pablo Greco) 0fa20d0 CCustomParams: Move some defaults away from UpdateFromArgs (Pablo Greco) e9df511 Add text version of the fixed seeds for liquidv1 and liquidtestnet (Pablo Greco) Pull request description: Currently using liquidtestnet requires a big config file, which is error-prone and uncomfortable for users, this MR adds support for just using `-chain=liquidtestnet`. There are a few things that need to be discussed/addressed 1. Main port (currently set to 18891 because that's the one used originally, and the one that's configured in `liquidtestnet.com`) 1. RPC and extra ports, I just chose some non-overlapping ports that are "close" to the ones in the other liquid/elements networks. 1. Icon color, I just used something different than `liquidv1` and `elementsregtest`, suggestions accepted 😉 1. `liquid-testnet.blockstream.com` is still using port 18892, it will be changed to 18891 soon. 1. both seeds are just CNAME dns records at the moment, they should be changed to real seed nodes (no changes in code required, but important for review) ACKs for top commit: delta1: ACK c6e074e wintercooled: ACK ElementsProject@c6e074e apoelstra: utACK c6e074e Tree-SHA512: 48c17b8b90ba5a33ae987935ffb368737167f6ca5ae772f6dd8c0c5e7efb39355d81e2677cd02d3e22984f2592fdd67caaf838003902b3c827f6ade01f18a040
2 parents 58b5fa0 + c6e074e commit 1339dae

File tree

9 files changed

+121
-21
lines changed

9 files changed

+121
-21
lines changed

contrib/seeds/liquid/nodes_main.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# List of fixed seed nodes for liquidv1
2+
3+
35.196.16.254:7042
4+
35.237.176.63:7042
5+
35.237.81.14:7042
6+
35.237.147.21:7042
7+
35.227.95.109:7042
8+
35.231.141.173:7042
9+
104.196.48.184:7042
10+
35.231.10.147:7042

contrib/seeds/liquid/nodes_test.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# List of fixed seed nodes for liquidtestnet
2+
3+
34.68.67.175:18891
4+
79.98.30.13:18891

share/setup.nsi.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Section -post SEC0001
9393
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
9494
CreateDirectory $SMPROGRAMS\$StartMenuGroup
9595
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" $INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@
96-
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\@PACKAGE_NAME@ (testnet, 64-bit).lnk" "$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" "-testnet" "$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" 1
96+
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\@PACKAGE_NAME@ (testnet, 64-bit).lnk" "$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" "-chain=liquidtestnet" "$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" 1
9797
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe
9898
!insertmacro MUI_STARTMENU_WRITE_END
9999
WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"

src/chainparams.cpp

Lines changed: 95 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,9 @@ void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
735735
* Custom params for testing.
736736
*/
737737
class CCustomParams : public CRegTestParams {
738+
protected:
739+
std::string default_magic_str = "5319F20E";
740+
std::string default_signblockscript = "51";
738741
void UpdateFromArgs(const ArgsManager& args)
739742
{
740743
UpdateActivationParametersFromArgs(args);
@@ -757,7 +760,7 @@ class CCustomParams : public CRegTestParams {
757760
consensus.nMinimumChainWork = uint256S(args.GetArg("-con_nminimumchainwork", "0x0"));
758761
consensus.defaultAssumeValid = uint256S(args.GetArg("-con_defaultassumevalid", "0x00"));
759762
// TODO: Embed in genesis block in nTime field with new genesis block type
760-
consensus.dynamic_epoch_length = args.GetArg("-dynamic_epoch_length", 10);
763+
consensus.dynamic_epoch_length = args.GetArg("-dynamic_epoch_length", consensus.dynamic_epoch_length);
761764
// Default junk keys for testing
762765
consensus.first_extension_space = {ParseHex("02fcba7ecf41bc7e1be4ee122d9d22e3333671eb0a3a87b5cdf099d59874e1940f02fcba7ecf41bc7e1be4ee122d9d22e3333671eb0a3a87b5cdf099d59874e1940f")};
763766
std::vector<std::string> pak_list_str = args.GetArgs("-pak");
@@ -772,12 +775,16 @@ class CCustomParams : public CRegTestParams {
772775
fDefaultConsistencyChecks = args.GetBoolArg("-fdefaultconsistencychecks", fDefaultConsistencyChecks);
773776
m_is_test_chain = args.GetBoolArg("-fmineblocksondemand", m_is_test_chain);
774777

775-
bech32_hrp = args.GetArg("-bech32_hrp", "ert");
776-
blech32_hrp = args.GetArg("-blech32_hrp", "el");
777-
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-pubkeyprefix", 235));
778-
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-scriptprefix", 75));
779-
base58Prefixes[BLINDED_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-blindedprefix", 4));
780-
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, args.GetArg("-secretprefix", 239));
778+
bech32_hrp = args.GetArg("-bech32_hrp", bech32_hrp);
779+
blech32_hrp = args.GetArg("-blech32_hrp", blech32_hrp);
780+
assert(base58Prefixes[PUBKEY_ADDRESS].size() == 1);
781+
assert(base58Prefixes[SCRIPT_ADDRESS].size() == 1);
782+
assert(base58Prefixes[BLINDED_ADDRESS].size() == 1);
783+
assert(base58Prefixes[SECRET_KEY].size() == 1);
784+
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-pubkeyprefix", base58Prefixes[PUBKEY_ADDRESS][0]));
785+
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-scriptprefix", base58Prefixes[SCRIPT_ADDRESS][0]));
786+
base58Prefixes[BLINDED_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-blindedprefix", base58Prefixes[BLINDED_ADDRESS][0]));
787+
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, args.GetArg("-secretprefix", base58Prefixes[SECRET_KEY][0]));
781788
base58Prefixes[PARENT_PUBKEY_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-parentpubkeyprefix", 111));
782789
base58Prefixes[PARENT_SCRIPT_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-parentscriptprefix", 196));
783790
parent_bech32_hrp = args.GetArg("-parent_bech32_hrp", "bcrt");
@@ -792,7 +799,7 @@ class CCustomParams : public CRegTestParams {
792799
assert(IsHex(extprvprefix) && extprvprefix.size() == 8 && "-extprvkeyprefix must be hex string of length 8");
793800
base58Prefixes[EXT_SECRET_KEY] = ParseHex(extprvprefix);
794801

795-
const std::string magic_str = args.GetArg("-pchmessagestart", "5319F20E");
802+
const std::string magic_str = args.GetArg("-pchmessagestart", default_magic_str);
796803
assert(IsHex(magic_str) && magic_str.size() == 8 && "-pchmessagestart must be hex string of length 8");
797804
const std::vector<unsigned char> magic_byte = ParseHex(magic_str);
798805
std::copy(begin(magic_byte), end(magic_byte), pchMessageStart);
@@ -812,10 +819,9 @@ class CCustomParams : public CRegTestParams {
812819
consensus.genesis_style = args.GetArg("-con_genesis_style", "elements");
813820

814821
// Block signing encumberance script, default of 51 aka OP_TRUE
815-
std::vector<unsigned char> sign_bytes = ParseHex(args.GetArg("-signblockscript", "51"));
822+
std::vector<unsigned char> sign_bytes = ParseHex(args.GetArg("-signblockscript", default_signblockscript));
816823
consensus.signblockscript = CScript(sign_bytes.begin(), sign_bytes.end());
817-
// Default signature size is the size of dummy push, and single 72 byte DER signature
818-
consensus.max_block_signature_size = args.GetArg("-con_max_block_sig_size", 74);
824+
consensus.max_block_signature_size = args.GetArg("-con_max_block_sig_size", consensus.max_block_signature_size);
819825
g_signed_blocks = args.GetBoolArg("-con_signed_blocks", true);
820826

821827
// Note: These globals are needed to avoid circular dependencies.
@@ -834,19 +840,19 @@ class CCustomParams : public CRegTestParams {
834840
// Custom chains connect coinbase outputs to db by default
835841
consensus.connect_genesis_outputs = args.GetArg("-con_connect_genesis_outputs", true);
836842

837-
initialFreeCoins = args.GetArg("-initialfreecoins", 0);
843+
initialFreeCoins = args.GetArg("-initialfreecoins", initialFreeCoins);
838844

839-
anyonecanspend_aremine = args.GetBoolArg("-anyonecanspendaremine", true);
845+
anyonecanspend_aremine = args.GetBoolArg("-anyonecanspendaremine", anyonecanspend_aremine);
840846

841-
consensus.has_parent_chain = args.GetBoolArg("-con_has_parent_chain", true);
847+
consensus.has_parent_chain = args.GetBoolArg("-con_has_parent_chain", consensus.has_parent_chain);
842848

843849
enforce_pak = args.GetBoolArg("-enforce_pak", false);
844850

845851
// Allow multiple op_return outputs by relay policy
846852
multi_data_permitted = args.GetBoolArg("-multi_data_permitted", enforce_pak);
847853

848854
// bitcoin regtest is the parent chain by default
849-
parentGenesisBlockHash = uint256S(args.GetArg("-parentgenesisblockhash", "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
855+
parentGenesisBlockHash = uint256S(args.GetArg("-parentgenesisblockhash", parentGenesisBlockHash.GetHex()));
850856
// Either it has a parent chain or not
851857
const bool parent_genesis_is_null = parentGenesisBlockHash == uint256();
852858
assert(consensus.has_parent_chain != parent_genesis_is_null);
@@ -880,11 +886,6 @@ class CCustomParams : public CRegTestParams {
880886
consensus.subsidy_asset = CAsset(uint256S(args.GetArg("-subsidyasset", "0x00")));
881887
}
882888

883-
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].bit = 25;
884-
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
885-
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
886-
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].min_activation_height = 0; // No activation delay
887-
888889
UpdateElementsActivationParametersFromArgs(consensus, args);
889890
// END ELEMENTS fields
890891
}
@@ -914,9 +915,81 @@ class CCustomParams : public CRegTestParams {
914915
CCustomParams(const std::string& chain, const ArgsManager& args) : CRegTestParams(args)
915916
{
916917
strNetworkID = chain;
918+
919+
//default settings
920+
initialFreeCoins = 0;
921+
anyonecanspend_aremine = true;
922+
// Default signature size is the size of dummy push, and single 72 byte DER signature
923+
consensus.max_block_signature_size = 74;
924+
consensus.dynamic_epoch_length = 10;
925+
// bitcoin regtest is the parent chain by default
926+
consensus.has_parent_chain = true;
927+
parentGenesisBlockHash = uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206");
928+
929+
bech32_hrp = "ert";
930+
blech32_hrp = "el";
931+
932+
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 235);
933+
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 75);
934+
base58Prefixes[BLINDED_ADDRESS] = std::vector<unsigned char>(1, 4);
935+
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, 239);
936+
937+
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].bit = 25;
938+
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
939+
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
940+
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].min_activation_height = 0; // No activation delay
941+
942+
UpdateFromArgs(args);
943+
SetGenesisBlock();
944+
consensus.hashGenesisBlock = genesis.GetHash();
945+
}
946+
};
947+
948+
/**
949+
* Liquid testnet (customparams with a few defaults).
950+
*/
951+
class CLiquidTestNetParams : public CCustomParams {
952+
public:
953+
CLiquidTestNetParams(const std::string& chain, const ArgsManager& args) : CCustomParams(chain, args)
954+
{
955+
strNetworkID = chain;
956+
// not a debug chain
957+
fDefaultConsistencyChecks = false;
958+
959+
initialFreeCoins = 2100000000000000;
960+
anyonecanspend_aremine = false;
961+
consensus.max_block_signature_size = 150;
962+
consensus.dynamic_epoch_length = 1000;
963+
964+
// no parent chain by default
965+
consensus.has_parent_chain = false;
966+
parentGenesisBlockHash = uint256();
967+
968+
bech32_hrp = "tex";
969+
blech32_hrp = "tlq";
970+
971+
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 36);
972+
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 19);
973+
base58Prefixes[BLINDED_ADDRESS] = std::vector<unsigned char>(1, 23);
974+
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, base58Prefixes[SECRET_KEY][0]);
975+
976+
// disable automatic dynafed
977+
consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nStartTime = 0;
978+
979+
nDefaultPort = 18891;
980+
vSeeds.clear();
981+
vFixedSeeds = std::vector<uint8_t>(std::begin(pnSeed6_liquidtestnet), std::end(pnSeed6_liquidtestnet));
982+
983+
default_magic_str = "410EDD62";
984+
default_signblockscript = "51210217e403ddb181872c32a0cd468c710040b2f53d8cac69f18dad07985ee37e9a7151ae";
917985
UpdateFromArgs(args);
986+
multi_data_permitted = true;
918987
SetGenesisBlock();
919988
consensus.hashGenesisBlock = genesis.GetHash();
989+
if (!args.IsArgSet("-seednode")) {
990+
vSeeds.emplace_back("seed.liquid-testnet.blockstream.com");
991+
vSeeds.emplace_back("seed.liquidtestnet.com");
992+
}
920993
}
921994
};
922995

@@ -1461,6 +1534,8 @@ std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, c
14611534
return std::unique_ptr<CChainParams>(new CLiquidV1Params());
14621535
} else if (chain == CBaseChainParams::LIQUID1TEST) {
14631536
return std::unique_ptr<CChainParams>(new CLiquidV1TestParams(args));
1537+
} else if (chain == CBaseChainParams::LIQUIDTESTNET) {
1538+
return std::unique_ptr<CChainParams>(new CLiquidTestNetParams(chain, args));
14641539
}
14651540

14661541
return std::unique_ptr<CChainParams>(new CCustomParams(chain, args));

src/chainparamsbase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const std::string CBaseChainParams::SIGNET = "signet";
1616
const std::string CBaseChainParams::REGTEST = "regtest";
1717
const std::string CBaseChainParams::LIQUID1 = "liquidv1";
1818
const std::string CBaseChainParams::LIQUID1TEST = "liquidv1test";
19+
const std::string CBaseChainParams::LIQUIDTESTNET = "liquidtestnet";
1920

2021
const std::string CBaseChainParams::DEFAULT = CBaseChainParams::LIQUID1;
2122

@@ -89,6 +90,8 @@ std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain
8990
return std::make_unique<CBaseChainParams>("liquidv1", 7041, 8332, 37041);
9091
} else if (chain == CBaseChainParams::LIQUID1TEST) {
9192
return std::make_unique<CBaseChainParams>("liquidv1test", 7040, 18332, 37040); // Use same ports as customparams
93+
} else if (chain == CBaseChainParams::LIQUIDTESTNET) {
94+
return std::make_unique<CBaseChainParams>(chain, 7039, 18331, 37039);
9295
}
9396

9497
// ELEMENTS:

src/chainparamsbase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CBaseChainParams
2525
static const std::string REGTEST;
2626
static const std::string LIQUID1;
2727
static const std::string LIQUID1TEST;
28+
static const std::string LIQUIDTESTNET;
2829
///@}
2930

3031
static const std::string DEFAULT;

src/chainparamsseeds.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,4 +718,9 @@ static uint8_t pnSeed6_liquidv1[] = {
718718
0x01,0x04,0x68,0xc4,0x30,0xb8,0x1b,0x82,
719719
0x01,0x04,0x23,0xe7,0x0a,0x93,0x1b,0x82,
720720
};
721+
722+
static uint8_t pnSeed6_liquidtestnet[] = {
723+
0x01,0x04,0x22,0x44,0x43,0xaf,0x49,0xcb,
724+
0x01,0x04,0x4f,0x62,0x1e,0x0d,0x49,0xcb,
725+
};
721726
#endif // BITCOIN_CHAINPARAMSSEEDS_H

src/qt/guiconstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80;
5050
#define QAPP_APP_NAME_SIGNET "Elements-Qt-signet"
5151
#define QAPP_APP_NAME_REGTEST "Elements-Qt-regtest"
5252
#define QAPP_APP_NAME_LIQUID "Elements-Qt (Liquid)"
53+
#define QAPP_APP_NAME_LIQUIDTESTNET "Elements-Qt (liquidtestnet)"
5354

5455
/* One gigabyte (GB) in bytes */
5556
static constexpr uint64_t GB_BYTES{1000000000};

src/qt/networkstyle.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static const struct {
2020
{"main", QAPP_APP_NAME_DEFAULT, 0, 0},
2121
{"test", QAPP_APP_NAME_TESTNET, 70, 30},
2222
{"liquidv1", QAPP_APP_NAME_LIQUID, 0, 0},
23+
{"liquidtestnet", QAPP_APP_NAME_LIQUIDTESTNET, 80, 80},
2324
{"signet", QAPP_APP_NAME_SIGNET, 35, 15},
2425
{"regtest", QAPP_APP_NAME_REGTEST, 160, 30}
2526
};

0 commit comments

Comments
 (0)