diff --git a/contrib/assets_tutorial/assets_tutorial.py b/contrib/assets_tutorial/assets_tutorial.py index c2d2652a38..2e55882768 100755 --- a/contrib/assets_tutorial/assets_tutorial.py +++ b/contrib/assets_tutorial/assets_tutorial.py @@ -211,7 +211,7 @@ e1.dumpassetlabels() # You can also filter calls using specific asset hex or labels: e1.getwalletinfo("bitcoin") # bitcoin's hex asset type -e1.getwalletinfo("09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621") +e1.getwalletinfo("694d95345fcd292329b5fb4e465a48484c7e218f4d4f1f7a3bfea26dd2d8fc3d") # We can also issue our own assets, 1 asset and 1 reissuance token in this case issue = e1.issueasset(1, 1) diff --git a/contrib/assets_tutorial/assets_tutorial.sh b/contrib/assets_tutorial/assets_tutorial.sh index cecc6017be..c058517d15 100755 --- a/contrib/assets_tutorial/assets_tutorial.sh +++ b/contrib/assets_tutorial/assets_tutorial.sh @@ -144,7 +144,7 @@ e1-cli dumpassetlabels # You can also filter calls using specific asset hex or labels: e1-cli getwalletinfo bitcoin # bitcoin's hex asset type -e1-cli getwalletinfo 09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621 +e1-cli getwalletinfo 694d95345fcd292329b5fb4e465a48484c7e218f4d4f1f7a3bfea26dd2d8fc3d # We can also issue our own assets, 1 asset and 1 reissuance token in this case ISSUE=$(e1-cli issueasset 1 1) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index abb784f3d3..1dc9f63693 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -5,6 +5,7 @@ #include "chainparams.h" #include "consensus/merkle.h" +#include "issuance.h" #include "tinyformat.h" #include "util.h" @@ -18,9 +19,6 @@ #include "chainparamsseeds.h" -/** The sha256 of Bitcoin genesis block, for easy reference **/ -static const CAsset BITCOINID(uint256S("09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621")); - // Safer for users if they load incorrect parameters via arguments. static std::vector CommitToArguments(const Consensus::Params& params, const std::string& networkID, const CScript& signblockscript) { @@ -100,8 +98,6 @@ public: consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931 consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); - consensus.pegged_asset = BITCOINID; - // Peg-ins Bitcoin headers must have higher difficulty target than this field // This value must be sufficiently small to not preclude realistic parent // chain difficulty during network lifespan yet sufficiently large to @@ -147,8 +143,14 @@ public: nPruneAfterHeight = 100000; parentGenesisBlockHash = uint256S("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"); + + // Generate pegged Bitcoin asset + uint256 entropy; + GenerateAssetEntropy(entropy, COutPoint() /* blank prevout to simulate coinbase */, parentGenesisBlockHash); + CalculateAsset(consensus.pegged_asset, entropy); + CScript scriptDestination(CScript() << std::vector(parentGenesisBlockHash.begin(), parentGenesisBlockHash.end()) << OP_WITHDRAWPROOFVERIFY); - genesis = CreateGenesisBlock(consensus, strNetworkID, scriptDestination, 1231006505, genesisChallengeScript, 1, MAX_MONEY, 100, BITCOINID); + genesis = CreateGenesisBlock(consensus, strNetworkID, scriptDestination, 1231006505, genesisChallengeScript, 1, MAX_MONEY, 100, consensus.pegged_asset); consensus.hashGenesisBlock = genesis.GetHash(); scriptCoinbaseDestination = CScript() << ParseHex("0229536c4c83789f59c30b93eb40d4abbd99b8dcc99ba8bd748f29e33c1d279e3c") << OP_CHECKSIG; @@ -249,12 +251,16 @@ public: nDefaultPort = 7042; nPruneAfterHeight = 1000; - consensus.pegged_asset = BITCOINID; + parentGenesisBlockHash = uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"); - genesis = CreateGenesisBlock(consensus, strNetworkID, defaultRegtestScript, 1296688602, genesisChallengeScript, 1, MAX_MONEY, 100, BITCOINID); + // Generate pegged Bitcoin asset + uint256 entropy; + GenerateAssetEntropy(entropy, COutPoint() /* blank prevout to simulate coinbase */, parentGenesisBlockHash); + CalculateAsset(consensus.pegged_asset, entropy); + + genesis = CreateGenesisBlock(consensus, strNetworkID, defaultRegtestScript, 1296688602, genesisChallengeScript, 1, MAX_MONEY, 100, consensus.pegged_asset); consensus.hashGenesisBlock = genesis.GetHash(); - parentGenesisBlockHash = uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"); scriptCoinbaseDestination = CScript(); // Allow any coinbase destination diff --git a/src/init.cpp b/src/init.cpp index a61c391382..5dc9ee6e56 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -460,7 +460,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-maxsigcachesize=", strprintf("Limit size of signature cache to MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE)); strUsage += HelpMessageOpt("-maxtipage=", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE)); } - strUsage += HelpMessageOpt("-feeasset=", strprintf(_("Asset ID (hex) for mempool/relay fees (default: %s)"), DEFAULT_FEE_ASSET)); + strUsage += HelpMessageOpt("-feeasset=", strprintf(_("Asset ID (hex) for mempool/relay fees (default: %s)"), defaultChainParams->GetConsensus().pegged_asset.GetHex())); strUsage += HelpMessageOpt("-minrelaytxfee=", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE))); strUsage += HelpMessageOpt("-maxtxfee=", strprintf(_("Maximum total fees (in %s) to use in a single wallet transaction or raw transaction; setting this too low may abort large transactions (default: %s)"), @@ -1011,7 +1011,7 @@ bool AppInitParameterInteraction() if (nConnectTimeout <= 0) nConnectTimeout = DEFAULT_CONNECT_TIMEOUT; - policyAsset = CAsset(uint256S(GetArg("-feeasset", DEFAULT_FEE_ASSET))); + policyAsset = CAsset(uint256S(GetArg("-feeasset", chainparams.GetConsensus().pegged_asset.GetHex()))); // Fee-per-kilobyte amount considered the same as "free" // If you are mining, be careful setting this: diff --git a/src/policy/policy.h b/src/policy/policy.h index 3b97bc9fcf..a52b278def 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -17,7 +17,6 @@ class CCoinsViewCache; /** The sha256 of Bitcoin genesis block, for easy reference **/ extern CAsset policyAsset; -static const std::string DEFAULT_FEE_ASSET = "09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621"; /** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/ static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 1000000; /** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/ diff --git a/src/test/assetsdir_tests.cpp b/src/test/assetsdir_tests.cpp index cb76871941..7706735e36 100644 --- a/src/test/assetsdir_tests.cpp +++ b/src/test/assetsdir_tests.cpp @@ -15,7 +15,7 @@ BOOST_AUTO_TEST_CASE(assetsdirTests) { CAssetsDir tAssetsDir; const std::string defaultPeggedLabel = "bitcoin"; - const std::string defaultPeggedAssetHex = "09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621"; + const std::string defaultPeggedAssetHex = Params().GetConsensus().pegged_asset.GetHex(); const CAsset defaultPeggedAsset = Params().GetConsensus().pegged_asset; const std::string exampleAssetHex = "fa821b0be5e1387adbcb69dbb3ad33edb5e470831c7c938c4e7b344edbe8bb11"; const CAsset exampleAsset = CAsset(uint256S(exampleAssetHex)); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ec31ceb948..bf29c3bc24 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -892,9 +892,9 @@ UniValue getbalance(const JSONRPCRequest& request) "\nThe total amount in the wallet\n" + HelpExampleCli("getbalance", "") + "\nThe total amount in the wallet of the specified asset (leading 3 arguments are ignored)\n" - + HelpExampleCli("getbalance", "\"*\" 6 false \"09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621\"") + + + HelpExampleCli("getbalance", "\"*\" 6 false \"694d95345fcd292329b5fb4e465a48484c7e218f4d4f1f7a3bfea26dd2d8fc3d\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("getbalance", "\"*\", 6 false \"09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621\"") + + HelpExampleRpc("getbalance", "\"*\", 6 false \"694d95345fcd292329b5fb4e465a48484c7e218f4d4f1f7a3bfea26dd2d8fc3d\"") ); LOCK2(cs_main, pwalletMain->cs_wallet);