mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Change network settings commitment to sha2, include in asset type def
This commit is contained in:
parent
8c1ba39a02
commit
b76b0b2270
4 changed files with 17 additions and 15 deletions
|
|
@ -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("694d95345fcd292329b5fb4e465a48484c7e218f4d4f1f7a3bfea26dd2d8fc3d")
|
||||
e1.getwalletinfo("b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23")
|
||||
|
||||
# We can also issue our own assets, 1 asset and 1 reissuance token in this case
|
||||
issue = e1.issueasset(1, 1)
|
||||
|
|
|
|||
|
|
@ -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 694d95345fcd292329b5fb4e465a48484c7e218f4d4f1f7a3bfea26dd2d8fc3d
|
||||
e1-cli getwalletinfo b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23
|
||||
|
||||
# We can also issue our own assets, 1 asset and 1 reissuance token in this case
|
||||
ISSUE=$(e1-cli issueasset 1 1)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
#include "amount.h"
|
||||
#include "crypto/ripemd160.h"
|
||||
#include "crypto/sha256.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
|
@ -22,13 +22,13 @@
|
|||
// 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)
|
||||
{
|
||||
CRIPEMD160 ripemd;
|
||||
unsigned char commitment[20];
|
||||
ripemd.Write((const unsigned char*)networkID.c_str(), networkID.length());
|
||||
ripemd.Write((const unsigned char*)HexStr(params.fedpegScript).c_str(), HexStr(params.fedpegScript).length());
|
||||
ripemd.Write((const unsigned char*)HexStr(signblockscript).c_str(), HexStr(signblockscript).length());
|
||||
ripemd.Finalize(commitment);
|
||||
return std::vector<unsigned char>(commitment, commitment + 20);
|
||||
CSHA256 sha2;
|
||||
unsigned char commitment[32];
|
||||
sha2.Write((const unsigned char*)networkID.c_str(), networkID.length());
|
||||
sha2.Write((const unsigned char*)HexStr(params.fedpegScript).c_str(), HexStr(params.fedpegScript).length());
|
||||
sha2.Write((const unsigned char*)HexStr(signblockscript).c_str(), HexStr(signblockscript).length());
|
||||
sha2.Finalize(commitment);
|
||||
return std::vector<unsigned char>(commitment, commitment + 32);
|
||||
}
|
||||
|
||||
static CScript StrHexToScriptWithDefault(std::string strScript, const CScript defaultScript)
|
||||
|
|
@ -50,9 +50,9 @@ static CBlock CreateGenesisBlock(const Consensus::Params& params, const std::str
|
|||
CMutableTransaction txNew;
|
||||
txNew.nVersion = 1;
|
||||
txNew.vin.resize(1);
|
||||
txNew.vout.resize(rewardShards);
|
||||
// Any consensus-related values that are command-line set can be added here for anti-footgun
|
||||
txNew.vin[0].scriptSig = CScript(CommitToArguments(params, networkID, scriptChallenge));
|
||||
txNew.vout.resize(rewardShards);
|
||||
for (unsigned int i = 0; i < rewardShards; i++) {
|
||||
txNew.vout[i].nValue = genesisReward/rewardShards;
|
||||
txNew.vout[i].nAsset = asset;
|
||||
|
|
@ -145,8 +145,9 @@ public:
|
|||
parentGenesisBlockHash = uint256S("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943");
|
||||
|
||||
// Generate pegged Bitcoin asset
|
||||
std::vector<unsigned char> commit = CommitToArguments(consensus, strNetworkID, genesisChallengeScript);
|
||||
uint256 entropy;
|
||||
GenerateAssetEntropy(entropy, COutPoint() /* blank prevout to simulate coinbase */, parentGenesisBlockHash);
|
||||
GenerateAssetEntropy(entropy, COutPoint(uint256(commit), 0), parentGenesisBlockHash);
|
||||
CalculateAsset(consensus.pegged_asset, entropy);
|
||||
|
||||
CScript scriptDestination(CScript() << std::vector<unsigned char>(parentGenesisBlockHash.begin(), parentGenesisBlockHash.end()) << OP_WITHDRAWPROOFVERIFY);
|
||||
|
|
@ -254,8 +255,9 @@ public:
|
|||
parentGenesisBlockHash = uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206");
|
||||
|
||||
// Generate pegged Bitcoin asset
|
||||
std::vector<unsigned char> commit = CommitToArguments(consensus, strNetworkID, genesisChallengeScript);
|
||||
uint256 entropy;
|
||||
GenerateAssetEntropy(entropy, COutPoint() /* blank prevout to simulate coinbase */, parentGenesisBlockHash);
|
||||
GenerateAssetEntropy(entropy, COutPoint(uint256(commit), 0), parentGenesisBlockHash);
|
||||
CalculateAsset(consensus.pegged_asset, entropy);
|
||||
|
||||
genesis = CreateGenesisBlock(consensus, strNetworkID, defaultRegtestScript, 1296688602, genesisChallengeScript, 1, MAX_MONEY, 100, consensus.pegged_asset);
|
||||
|
|
|
|||
|
|
@ -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 \"694d95345fcd292329b5fb4e465a48484c7e218f4d4f1f7a3bfea26dd2d8fc3d\"") +
|
||||
+ HelpExampleCli("getbalance", "\"*\" 6 false \"b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23\"") +
|
||||
"\nAs a json rpc call\n"
|
||||
+ HelpExampleRpc("getbalance", "\"*\", 6 false \"694d95345fcd292329b5fb4e465a48484c7e218f4d4f1f7a3bfea26dd2d8fc3d\"")
|
||||
+ HelpExampleRpc("getbalance", "\"*\", 6 false \"b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23\"")
|
||||
);
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue