Replace static BITCOINID with generated pegged_asset using standard issuance derivation

This commit is contained in:
Gregory Sanders 2017-08-09 16:48:13 -04:00
parent ae1f058433
commit 8c1ba39a02
7 changed files with 22 additions and 17 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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<unsigned char> 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<unsigned char>(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

View file

@ -460,7 +460,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
strUsage += HelpMessageOpt("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
}
strUsage += HelpMessageOpt("-feeasset=<hex>", strprintf(_("Asset ID (hex) for mempool/relay fees (default: %s)"), DEFAULT_FEE_ASSET));
strUsage += HelpMessageOpt("-feeasset=<hex>", strprintf(_("Asset ID (hex) for mempool/relay fees (default: %s)"), defaultChainParams->GetConsensus().pegged_asset.GetHex()));
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", 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=<amt>", 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:

View file

@ -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 **/

View file

@ -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));

View file

@ -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);