Skip to content

Commit 8fd8a45

Browse files
committed
Merge #568: Adapt Elements default adress prefix bytes to elements-0.14 style
91294ca Adapt Elements default adress prefix bytes to elements-0.14 style (Gregory Sanders) 410d5fa sendtomainchain_base should be decoding parent destination (Gregory Sanders) Pull request description: Also chose `ert` as bech32 hrp, just to make it distinct. Clustered the various address parameters for ease of the reader. resolves #567 Tree-SHA512: aae4b31b0c5ead9801dad13a50ddfc934216df783d6294bb4e2ae515bba27960a9643ccaae87a60c9637c44aeb6d4b0329eeb70846b07e6e88e9133edcd74315
2 parents 6fa3976 + 91294ca commit 8fd8a45

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

src/chainparams.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,17 @@ class CCustomParams : public CRegTestParams {
481481
fMineBlocksOnDemand = args.GetBoolArg("-fmineblocksondemand", fMineBlocksOnDemand);
482482
m_fallback_fee_enabled = args.GetBoolArg("-fallback_fee_enabled", m_fallback_fee_enabled);
483483

484-
bech32_hrp = args.GetArg("-bech32_hrp", bech32_hrp);
484+
bech32_hrp = args.GetArg("-bech32_hrp", "ert");
485485
blech32_hrp = args.GetArg("-blech32_hrp", "el");
486-
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-pubkeyprefix", 111));
487-
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-scriptprefix", 196));
486+
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-pubkeyprefix", 235));
487+
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-scriptprefix", 75));
488+
base58Prefixes[BLINDED_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-blindedprefix", 4));
488489
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, args.GetArg("-secretprefix", 239));
490+
base58Prefixes[PARENT_PUBKEY_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-parentpubkeyprefix", 111));
491+
base58Prefixes[PARENT_SCRIPT_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-parentscriptprefix", 196));
492+
parent_bech32_hrp = args.GetArg("-parent_bech32_hrp", "bcrt");
493+
parent_blech32_hrp = args.GetArg("-parent_blech32_hrp", "bcrt");
494+
489495

490496
std::string extpubprefix = args.GetArg("-extpubkeyprefix", "043587CF");
491497
assert(IsHex(extpubprefix) && extpubprefix.size() == 8 && "-extpubkeyprefix must be hex string of length 8");
@@ -559,13 +565,6 @@ class CCustomParams : public CRegTestParams {
559565
const CScript default_script(CScript() << OP_TRUE);
560566
consensus.fedpegScript = StrHexToScriptWithDefault(args.GetArg("-fedpegscript", ""), default_script);
561567

562-
base58Prefixes[PARENT_PUBKEY_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-parentpubkeyprefix", 111));
563-
base58Prefixes[PARENT_SCRIPT_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-parentscriptprefix", 196));
564-
parent_bech32_hrp = args.GetArg("-parent_bech32_hrp", "bcrt");
565-
parent_blech32_hrp = args.GetArg("-parent_blech32_hrp", "bcrt");
566-
567-
base58Prefixes[BLINDED_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-blindedprefix", 4));
568-
569568
// Calculate pegged Bitcoin asset
570569
std::vector<unsigned char> commit = CommitToArguments(consensus, strNetworkID);
571570
uint256 entropy;

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4744,7 +4744,7 @@ UniValue sendtomainchain_base(const JSONRPCRequest& request)
47444744

47454745
EnsureWalletIsUnlocked(pwallet);
47464746

4747-
CTxDestination parent_address = DecodeDestination(request.params[0].get_str());
4747+
CTxDestination parent_address = DecodeParentDestination(request.params[0].get_str());
47484748
if (!IsValidDestination(parent_address))
47494749
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
47504750

test/bitcoin_functional/functional/test_framework/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ def initialize_datadir(dirname, n, chain):
319319
f.write("con_genesis_style=bitcoin\n")
320320
f.write("con_csv_deploy_start=0\n") # Default is -1 (always active)
321321
f.write("blindedaddresses=0\n")
322+
f.write("pubkeyprefix=111\n")
323+
f.write("scriptprefix=196\n")
324+
f.write("bech32_hrp=bcrt\n")
322325
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
323326
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
324327
return datadir

test/functional/feature_fedpeg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def setup_network(self, split=False):
6868
"-anyonecanspendaremine",
6969
"-signblockscript=51", # OP_TRUE
7070
'-con_blocksubsidy=5000000000',
71+
"-pubkeyprefix=111",
72+
"-scriptprefix=196",
7173
])
7274

7375
self.add_nodes(1, [extra_args], chain=[parent_chain], binary=parent_binary, chain_in_args=[not self.options.parent_bitcoin])

test/functional/test_framework/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ def initialize_datadir(dirname, n, chain):
330330
f.write("con_bip66height=1251\n")
331331
f.write("con_csv_deploy_start=0\n") # Enhance tests if removing this line
332332
f.write("blindedaddresses=0\n") # Set to minimize broken tests in favor of custom
333+
f.write("pubkeyprefix=111\n")
334+
f.write("scriptprefix=196\n")
335+
f.write("bech32_hrp=bcrt\n")
333336
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
334337
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
335338
return datadir

0 commit comments

Comments
 (0)