Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consensus, rpc: Kermit's mom hardfork (2671700) #2551

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
run: |
./ci/test_run_all.sh
test-macos:
name: macOS 10.15 native [GOAL install] [GUI] [no depends]
runs-on: macos-10.15
name: macOS 11 native [GOAL install] [GUI] [no depends]
runs-on: macos-11
env:
DANGER_RUN_CI_ON_HOST: true
CI_USE_APT_INSTALL: no
Expand Down
32 changes: 23 additions & 9 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class CMainParams : public CChainParams {
consensus.BlockV9TallyHeight = 1144120;
consensus.BlockV10Height = 1420000;
consensus.BlockV11Height = 2053000;
consensus.BlockV12Height = std::numeric_limits<int>::max();
consensus.PollV3Height = std::numeric_limits<int>::max();
consensus.ProjectV2Height = std::numeric_limits<int>::max();
consensus.BlockV12Height = 2671700;
consensus.PollV3Height = 2671700;
consensus.ProjectV2Height = 2671700;
// Immediately post zero payment interval fees 40% for mainnet
consensus.InitialMRCFeeFractionPostZeroInterval = Fraction(2, 5);
// Zero day interval is 14 days on mainnet
Expand All @@ -84,7 +84,6 @@ class CMainParams : public CChainParams {
pchMessageStart[1] = 0x35;
pchMessageStart[2] = 0x22;
pchMessageStart[3] = 0x05;
vAlertPubKey = ParseHex("049ac003b3318d9fe28b2830f6a95a2624ce2a69fb0c0c7ac0b513efcc1e93a6a6e8eba84481155dd82f2f1104e0ff62c69d662b0094639b7106abc5d84f948c0a");
nDefaultPort = 32749;
m_assumed_blockchain_size = 4;

Expand Down Expand Up @@ -141,8 +140,16 @@ class CMainParams : public CChainParams {
}
};

// Master and alert keys other than the original are shorter because they are compressed.

// The original alert key was the same as the "master" (administrative contract) key For
// before Kermit's Mom (< 5.3.3.12, < 5.4.0.0)
// TestNet alerts public key for Kermit's Mom and beyond (>= 5.3.3.12, >= 5.4.0.0):
vAlertPubKey = ParseHex("0352063cf6cf0317cc848ae24f3ed8b525334d2f059f242d27975f8c3a2e91b446");

masterkeys = {
{0, ParseHex("049ac003b3318d9fe28b2830f6a95a2624ce2a69fb0c0c7ac0b513efcc1e93a6a6e8eba84481155dd82f2f1104e0ff62c69d662b0094639b7106abc5d84f948c0a")}
{0, ParseHex("049ac003b3318d9fe28b2830f6a95a2624ce2a69fb0c0c7ac0b513efcc1e93a6a6e8eba84481155dd82f2f1104e0ff62c69d662b0094639b7106abc5d84f948c0a")},
{2671700, ParseHex("0288b33697c4c752f922764bf1a5075fa96bad46aaf4f0579bf7d19ab048e200f0")}
};
}
};
Expand Down Expand Up @@ -175,9 +182,6 @@ class CTestNetParams : public CChainParams {
pchMessageStart[1] = 0xf2;
pchMessageStart[2] = 0xc0;
pchMessageStart[3] = 0xef;
vAlertPubKey = ParseHex("0471dc165db490094d35cde15b1f5d755fa6ad6f2b5ed0f340e3f17f57389c3c2af113a8cbcc885bde73305a553b5640c83021128008ddf882e856336269080496");
// TestNet alerts private key
// "308201130201010420b665cff1884e53da26376fd1b433812c9a5a8a4d5221533b15b9629789bb7e42a081a53081a2020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a1440342000471dc165db490094d35cde15b1f5d755fa6ad6f2b5ed0f340e3f17f57389c3c2af113a8cbcc885bde73305a553b5640c83021128008ddf882e856336269080496"
nDefaultPort = 32748;
m_assumed_blockchain_size = 2;

Expand All @@ -198,8 +202,18 @@ class CTestNetParams : public CChainParams {
}
};


// Master and keys other than the original are shorter because they are compressed.

// TestNet alerts private key for before Kermit's Mom (< 5.3.3.12, < 5.4.0.0):
// "308201130201010420b665cff1884e53da26376fd1b433812c9a5a8a4d5221533b15b9629789bb7e42a081a53081a2020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a1440342000471dc165db490094d35cde15b1f5d755fa6ad6f2b5ed0f340e3f17f57389c3c2af113a8cbcc885bde73305a553b5640c83021128008ddf882e856336269080496"
// TestNet alerts private key for Kermit's Mom and beyond (>= 5.3.3.12, >= 5.4.0.0):
// "925ekjvCRKuwEzu2WuqifVFE2T3r755rwBNN3ck7Fr8esTdQdrA"
vAlertPubKey = ParseHex("02bf4aa6330f525ab91a25cd5c1362481d16d8c039b3d27cb48ac0870176202462");

masterkeys = {
{0, ParseHex("049ac003b3318d9fe28b2830f6a95a2624ce2a69fb0c0c7ac0b513efcc1e93a6a6e8eba84481155dd82f2f1104e0ff62c69d662b0094639b7106abc5d84f948c0a")}
{0, ParseHex("049ac003b3318d9fe28b2830f6a95a2624ce2a69fb0c0c7ac0b513efcc1e93a6a6e8eba84481155dd82f2f1104e0ff62c69d662b0094639b7106abc5d84f948c0a")},
{1964600, ParseHex("031886a6776699cbd6362df7641c5d128146afabc769dfa36f1630889c706ce730")}
};
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CChainParams
}

assert(false && "No master key specified or height is negative.");
};
}
int GetDefaultPort() const { return nDefaultPort; }

// const CBlock& GenesisBlock() const { return genesis; }
Expand All @@ -71,7 +71,6 @@ class CChainParams

Consensus::Params consensus;
CMessageHeader::MessageStartChars pchMessageStart;
std::vector<unsigned char> vAlertPubKey;
int nDefaultPort;
uint64_t m_assumed_blockchain_size;
unsigned char base58Prefix[MAX_BASE58_TYPES];
Expand All @@ -80,6 +79,7 @@ class CChainParams
bool m_is_test_chain;
bool m_is_mockable_chain;
CCheckpointData checkpointData;
std::vector<unsigned char> vAlertPubKey;
MapMasterKeys masterkeys;
};

Expand Down
1 change: 1 addition & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "consolidatemsunspent" , 4 },
{ "consolidateunspent" , 3 },
{ "consolidateunspent" , 4 },
{ "dumpprivkey" , 1 },
{ "getbalance" , 1 },
{ "getbalance" , 2 },
{ "getbalancedetail" , 0 },
Expand Down
59 changes: 59 additions & 0 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
#include "wallet/walletdb.h"
#include "net.h"
#include "banman.h"
#include "logging.h"

using namespace std;

extern std::map<uint256, CAlert> mapAlerts;
extern CCriticalSection cs_mapAlerts;

UniValue getconnectioncount(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
Expand Down Expand Up @@ -384,6 +388,61 @@ UniValue getnettotals(const UniValue& params, bool fHelp)
return obj;
}

UniValue listalerts(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 0)
throw runtime_error(
"listalerts\n"
"\n"
"Returns information about alerts.\n");

LOCK(cs_mapAlerts);

UniValue result(UniValue::VOBJ);
UniValue alerts(UniValue::VARR);


for (const auto& iter_alert : mapAlerts) {
UniValue alert(UniValue::VOBJ);

alert.pushKV("version", iter_alert.second.nVersion);
alert.pushKV("relay_until", DateTimeStrFormat(iter_alert.second.nRelayUntil));
alert.pushKV("expiration", DateTimeStrFormat(iter_alert.second.nExpiration));
alert.pushKV("id", iter_alert.second.nID);
alert.pushKV("cancel_upto", iter_alert.second.nCancel);

UniValue set_cancel(UniValue::VARR);
for (const auto& cancel : iter_alert.second.setCancel) {
set_cancel.push_back(cancel);
}
alert.pushKV("cancels", set_cancel);

alert.pushKV("minimum_version", iter_alert.second.nMinVer);
alert.pushKV("maximum_version", iter_alert.second.nMaxVer);

UniValue set_subver(UniValue::VARR);
for (const auto& subver : iter_alert.second.setSubVer) {
set_subver.push_back(subver);
}
alert.pushKV("subversions", set_subver);

alert.pushKV("priority", iter_alert.second.nPriority);

alert.pushKV("comment", iter_alert.second.strComment);
alert.pushKV("status_bar", iter_alert.second.strStatusBar);
alert.pushKV("reserved", iter_alert.second.strReserved);

alert.pushKV("hash", iter_alert.second.GetHash().GetHex());
alert.pushKV("in_effect", iter_alert.second.IsInEffect());
alert.pushKV("applies_to_me", iter_alert.second.AppliesToMe());

alerts.push_back(alert);
}

result.pushKV("alerts", alerts);

return result;
}


// ppcoin: send alert.
Expand Down
1 change: 1 addition & 0 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ static const CRPCCommand vRPCCommands[] =
{ "getlistof", &getlistof, cat_developer },
{ "getrecentblocks", &rpc_getrecentblocks, cat_developer },
{ "inspectaccrualsnapshot", &inspectaccrualsnapshot, cat_developer },
{ "listalerts", &listalerts, cat_developer },
{ "listdata", &listdata, cat_developer },
{ "listprojects", &listprojects, cat_developer },
{ "listresearcheraccounts", &listresearcheraccounts, cat_developer },
Expand Down
1 change: 1 addition & 0 deletions src/rpc/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ extern UniValue dumpcontracts(const UniValue& params, bool fHelp);
extern UniValue rpc_getblockstats(const UniValue& params, bool fHelp);
extern UniValue getlistof(const UniValue& params, bool fHelp);
extern UniValue inspectaccrualsnapshot(const UniValue& params, bool fHelp);
extern UniValue listalerts(const UniValue& params, bool fHelp);
extern UniValue listdata(const UniValue& params, bool fHelp);
extern UniValue listprojects(const UniValue& params, bool fHelp);
extern UniValue listresearcheraccounts(const UniValue& params, bool fHelp);
Expand Down
21 changes: 19 additions & 2 deletions src/wallet/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,12 @@ UniValue importwallet(const UniValue& params, bool fHelp)

UniValue dumpprivkey(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"dumpprivkey <gridcoinaddress>\n"
"dumpprivkey <gridcoinaddress> [bool:dump hex]\n"
"<gridcoinaddress> -> Address of requested key\n"
"[bool:dump hex] -> Optional; default false boolean to dump private and public key\n"
" as hex strings to JSON in addition to private key base58 encoded"
"\n"
"Reveals the private key corresponding to <gridcoinaddress>\n");

Expand All @@ -299,6 +301,21 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp)
bool fCompressed;
if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed))
throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");


if (params.size() == 2 && params[1].isBool() && params[1].get_bool()) {
CKey key_out;
pwalletMain->GetKey(keyID, key_out);

UniValue result(UniValue::VOBJ);

result.pushKV("private_key", CBitcoinSecret(vchSecret, fCompressed).ToString());
result.pushKV("private_key_hex", HexStr(key_out.GetPrivKey()));
result.pushKV("public_key_hex", HexStr(key_out.GetPubKey()));

return result;
}

return CBitcoinSecret(vchSecret, fCompressed).ToString();
}

Expand Down