|
7 | 7 |
|
8 | 8 | #include <chainparamsseeds.h> |
9 | 9 | #include <consensus/merkle.h> |
| 10 | +#include <crypto/sha256.h> |
10 | 11 | #include <deploymentinfo.h> |
11 | 12 | #include <hash.h> // for signet block challenge hash |
12 | 13 | #include <issuance.h> |
13 | 14 | #include <primitives/transaction.h> |
| 15 | +#include <util/moneystr.h> |
14 | 16 | #include <util/system.h> |
15 | | -#include <crypto/sha256.h> |
16 | 17 |
|
17 | 18 | #include <assert.h> |
18 | 19 |
|
@@ -232,6 +233,8 @@ class CMainParams : public CChainParams { |
232 | 233 | multi_data_permitted = false; |
233 | 234 | accept_discount_ct = false; |
234 | 235 | create_discount_ct = false; |
| 236 | + pegin_subsidy = PeginSubsidy(); |
| 237 | + pegin_minimum = PeginMinimum(); |
235 | 238 | consensus.has_parent_chain = false; |
236 | 239 | g_signed_blocks = false; |
237 | 240 | g_con_elementsmode = false; |
@@ -379,6 +382,8 @@ class CTestNetParams : public CChainParams { |
379 | 382 | multi_data_permitted = false; |
380 | 383 | accept_discount_ct = false; |
381 | 384 | create_discount_ct = false; |
| 385 | + pegin_subsidy = PeginSubsidy(); |
| 386 | + pegin_minimum = PeginMinimum(); |
382 | 387 | consensus.has_parent_chain = false; |
383 | 388 | g_signed_blocks = false; |
384 | 389 | g_con_elementsmode = false; |
@@ -544,6 +549,8 @@ class SigNetParams : public CChainParams { |
544 | 549 | multi_data_permitted = false; |
545 | 550 | accept_discount_ct = false; |
546 | 551 | create_discount_ct = false; |
| 552 | + pegin_subsidy = PeginSubsidy(); |
| 553 | + pegin_minimum = PeginMinimum(); |
547 | 554 | consensus.has_parent_chain = false; |
548 | 555 | g_signed_blocks = false; // lol |
549 | 556 | g_con_elementsmode = false; |
@@ -648,6 +655,8 @@ class CRegTestParams : public CChainParams { |
648 | 655 | multi_data_permitted = false; |
649 | 656 | accept_discount_ct = false; |
650 | 657 | create_discount_ct = false; |
| 658 | + pegin_subsidy = PeginSubsidy(); |
| 659 | + pegin_minimum = PeginMinimum(); |
651 | 660 | consensus.has_parent_chain = false; |
652 | 661 | g_signed_blocks = false; |
653 | 662 | g_con_elementsmode = false; |
@@ -792,6 +801,39 @@ void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args) |
792 | 801 | } |
793 | 802 | } |
794 | 803 |
|
| 804 | +// ELEMENTS |
| 805 | +PeginSubsidy ParsePeginSubsidy(const ArgsManager& args) { |
| 806 | + PeginSubsidy pegin_subsidy; |
| 807 | + |
| 808 | + pegin_subsidy.height = args.GetIntArg("-peginsubsidyheight", std::numeric_limits<int>::max()); |
| 809 | + if (pegin_subsidy.height < 0) { |
| 810 | + throw std::runtime_error(strprintf("Invalid block height (%d) for -peginsubsidyheight. Must be positive.", pegin_subsidy.height)); |
| 811 | + } |
| 812 | + if (std::optional<CAmount> amount = ParseMoney(args.GetArg("-peginsubsidythreshold", "0"))) { |
| 813 | + pegin_subsidy.threshold = amount.value(); |
| 814 | + } else { |
| 815 | + throw std::runtime_error("Invalid -peginsubsidythreshold"); |
| 816 | + } |
| 817 | + |
| 818 | + return pegin_subsidy; |
| 819 | +}; |
| 820 | + |
| 821 | +PeginMinimum ParsePeginMinimum(const ArgsManager& args) { |
| 822 | + PeginMinimum pegin_minimum; |
| 823 | + |
| 824 | + pegin_minimum.height = args.GetIntArg("-peginminheight", std::numeric_limits<int>::max()); |
| 825 | + if (pegin_minimum.height < 0) { |
| 826 | + throw std::runtime_error(strprintf("Invalid block height (%d) for -peginminheight. Must be positive.", pegin_minimum.height)); |
| 827 | + } |
| 828 | + if (std::optional<CAmount> amount = ParseMoney(args.GetArg("-peginminamount", "0"))) { |
| 829 | + pegin_minimum.amount = amount.value(); |
| 830 | + } else { |
| 831 | + throw std::runtime_error("Invalid -peginminamount"); |
| 832 | + } |
| 833 | + |
| 834 | + return pegin_minimum; |
| 835 | +}; |
| 836 | + |
795 | 837 | /** |
796 | 838 | * Custom params for testing. |
797 | 839 | */ |
@@ -932,6 +974,11 @@ class CCustomParams : public CRegTestParams { |
932 | 974 | consensus.start_p2wsh_script = args.GetIntArg("-con_start_p2wsh_script", consensus.start_p2wsh_script); |
933 | 975 | create_discount_ct = args.GetBoolArg("-creatediscountct", create_discount_ct); |
934 | 976 | accept_discount_ct = args.GetBoolArg("-acceptdiscountct", accept_discount_ct) || create_discount_ct; |
| 977 | + pegin_subsidy = ParsePeginSubsidy(args); |
| 978 | + pegin_minimum = ParsePeginMinimum(args); |
| 979 | + if (pegin_subsidy.threshold < pegin_minimum.amount) { |
| 980 | + throw std::runtime_error(strprintf("Peg-in subsidy threshold (%s) must be greater than or equal to peg-in minimum amount (%s)", FormatMoney(pegin_subsidy.threshold), FormatMoney(pegin_minimum.amount))); |
| 981 | + } |
935 | 982 |
|
936 | 983 | // Calculate pegged Bitcoin asset |
937 | 984 | std::vector<unsigned char> commit = CommitToArguments(consensus, strNetworkID); |
@@ -1178,6 +1225,11 @@ class CLiquidV1Params : public CChainParams { |
1178 | 1225 | multi_data_permitted = true; |
1179 | 1226 | create_discount_ct = args.GetBoolArg("-creatediscountct", false); |
1180 | 1227 | accept_discount_ct = args.GetBoolArg("-acceptdiscountct", true) || create_discount_ct; |
| 1228 | + pegin_subsidy = ParsePeginSubsidy(args); |
| 1229 | + pegin_minimum = ParsePeginMinimum(args); |
| 1230 | + if (pegin_subsidy.threshold < pegin_minimum.amount) { |
| 1231 | + throw std::runtime_error(strprintf("Peg-in subsidy threshold (%s) must be greater than or equal to peg-in minimum amount (%s)", FormatMoney(pegin_subsidy.threshold), FormatMoney(pegin_minimum.amount))); |
| 1232 | + } |
1181 | 1233 |
|
1182 | 1234 | parentGenesisBlockHash = uint256S("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"); |
1183 | 1235 | const bool parent_genesis_is_null = parentGenesisBlockHash == uint256(); |
@@ -1538,6 +1590,11 @@ class CLiquidV1TestParams : public CLiquidV1Params { |
1538 | 1590 | multi_data_permitted = args.GetBoolArg("-multi_data_permitted", multi_data_permitted); |
1539 | 1591 | create_discount_ct = args.GetBoolArg("-creatediscountct", create_discount_ct); |
1540 | 1592 | accept_discount_ct = args.GetBoolArg("-acceptdiscountct", accept_discount_ct) || create_discount_ct; |
| 1593 | + pegin_subsidy = ParsePeginSubsidy(args); |
| 1594 | + pegin_minimum = ParsePeginMinimum(args); |
| 1595 | + if (pegin_subsidy.threshold < pegin_minimum.amount) { |
| 1596 | + throw std::runtime_error(strprintf("Peg-in subsidy threshold (%s) must be greater than or equal to peg-in minimum amount (%s)", FormatMoney(pegin_subsidy.threshold), FormatMoney(pegin_minimum.amount))); |
| 1597 | + } |
1541 | 1598 |
|
1542 | 1599 | if (args.IsArgSet("-parentgenesisblockhash")) { |
1543 | 1600 | parentGenesisBlockHash = uint256S(args.GetArg("-parentgenesisblockhash", "")); |
|
0 commit comments