We call them Hush Smart Chains around here

This commit is contained in:
Duke Leto
2020-11-15 11:54:06 -05:00
parent ebf0df633b
commit c737c0dfaf
58 changed files with 422 additions and 421 deletions

View File

@@ -892,7 +892,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk)
LOCK(cs_main);
if ( (keylen= (int32_t)strlen(params[0].get_str().c_str())) > 0 )
{
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL)));
ret.push_back(Pair("currentheight", (int64_t)chainActive.LastTip()->GetHeight()));
ret.push_back(Pair("key",params[0].get_str()));
ret.push_back(Pair("keylen",keylen));
@@ -1596,7 +1596,7 @@ void NetworkUpgradeDescPushBack(
UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height;
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,hushnotarized_height,txid_height;
if (fHelp || params.size() != 0)
throw runtime_error(
"getblockchaininfo\n"
@@ -1648,7 +1648,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my
LOCK(cs_main);
double progress;
if ( ASSETCHAINS_SYMBOL[0] == 0 ) {
if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
progress = Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.LastTip());
} else {
int32_t longestchain = KOMODO_LONGESTCHAIN;//komodo_longestchain();

View File

@@ -109,7 +109,7 @@ UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
}
//fprintf(stderr,"height_MoM height.%d\n",height);
depth = komodo_MoM(&notarized_height,&MoM,&kmdtxid,height,&MoMoM,&MoMoMoffset,&MoMoMdepth,&kmdstarti,&kmdendi);
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL)));
ret.push_back(Pair("height",height));
ret.push_back(Pair("timestamp",(uint64_t)timestamp));
if ( depth > 0 )
@@ -118,7 +118,7 @@ UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
ret.push_back(Pair("notarized_height",notarized_height));
ret.push_back(Pair("MoM",MoM.GetHex()));
ret.push_back(Pair("kmdtxid",kmdtxid.GetHex()));
if ( ASSETCHAINS_SYMBOL[0] != 0 )
if ( SMART_CHAIN_SYMBOL[0] != 0 )
{
ret.push_back(Pair("MoMoM",MoMoM.GetHex()));
ret.push_back(Pair("MoMoMoffset",MoMoMoffset));
@@ -170,7 +170,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk)
throw runtime_error("calc_MoM illegal height or MoMdepth\n");
//fprintf(stderr,"height_MoM height.%d\n",height);
MoM = komodo_calcMoM(height,MoMdepth);
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
ret.push_back(Pair("coin",(char *)(SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL)));
ret.push_back(Pair("height",height));
ret.push_back(Pair("MoMdepth",MoMdepth));
ret.push_back(Pair("MoM",MoM.GetHex()));
@@ -195,7 +195,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp, const CPubK
if (ASSETCHAINS_CC < KOMODO_FIRSTFUNGIBLEID)
throw runtime_error("-ac_cc < KOMODO_FIRSTFUNGIBLEID");
if (ASSETCHAINS_SYMBOL[0] == 0)
if (SMART_CHAIN_SYMBOL[0] == 0)
throw runtime_error("Must be called on assetchain");
vector<uint8_t> txData(ParseHexV(params[0], "argument 1"));
@@ -207,7 +207,7 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp, const CPubK
if (targetSymbol.size() == 0 || targetSymbol.size() > 32)
throw runtime_error("targetSymbol length must be >0 and <=32");
if (strcmp(ASSETCHAINS_SYMBOL,targetSymbol.c_str()) == 0)
if (strcmp(SMART_CHAIN_SYMBOL,targetSymbol.c_str()) == 0)
throw runtime_error("cant send a coin to the same chain");
/// Tested 44 vins p2pkh inputs as working. Set this at 25, but its a tx size limit.
@@ -226,11 +226,11 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp, const CPubK
throw JSONRPCError(RPC_TYPE_ERROR, "Cannot export more than 1 million coins per export.");
/* note: we marshal to rawproof in a different way (to be able to add other objects)
rawproof.resize(strlen(ASSETCHAINS_SYMBOL));
rawproof.resize(strlen(SMART_CHAIN_SYMBOL));
ptr = rawproof.data();
for (i=0; i<rawproof.size(); i++)
ptr[i] = ASSETCHAINS_SYMBOL[i]; */
const std::string chainSymbol(ASSETCHAINS_SYMBOL);
ptr[i] = SMART_CHAIN_SYMBOL[i]; */
const std::string chainSymbol(SMART_CHAIN_SYMBOL);
rawproof = E_MARSHAL(ss << chainSymbol); // add src chain name
CTxOut burnOut = MakeBurnOutput(burnAmount+txfee, ccid, targetSymbol, tx.vout,rawproof);
@@ -269,7 +269,7 @@ UniValue migrate_createburntransaction(const UniValue& params, bool fHelp, const
if (ASSETCHAINS_CC < KOMODO_FIRSTFUNGIBLEID)
throw runtime_error("-ac_cc < KOMODO_FIRSTFUNGIBLEID");
if (ASSETCHAINS_SYMBOL[0] == 0)
if (SMART_CHAIN_SYMBOL[0] == 0)
throw runtime_error("Must be called on assetchain");
// if -pubkey not set it sends change to null pubkey.
@@ -281,7 +281,7 @@ UniValue migrate_createburntransaction(const UniValue& params, bool fHelp, const
if (targetSymbol.size() == 0 || targetSymbol.size() > 32)
throw runtime_error("targetSymbol length must be >0 and <=32");
if (strcmp(ASSETCHAINS_SYMBOL, targetSymbol.c_str()) == 0)
if (strcmp(SMART_CHAIN_SYMBOL, targetSymbol.c_str()) == 0)
throw runtime_error("cant send a coin to the same chain");
std::string dest_addr_or_pubkey = params[1].get_str();
@@ -307,7 +307,7 @@ UniValue migrate_createburntransaction(const UniValue& params, bool fHelp, const
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
const std::string chainSymbol(ASSETCHAINS_SYMBOL);
const std::string chainSymbol(SMART_CHAIN_SYMBOL);
std::vector<uint8_t> rawproof; //(chainSymbol.begin(), chainSymbol.end());
if (tokenid.IsNull()) { // coins
@@ -502,13 +502,13 @@ void CheckBurnTxSource(uint256 burntxid, UniValue &info) {
throw std::runtime_error("No opreturn in burn tx");
if (sourceSymbol != ASSETCHAINS_SYMBOL)
if (sourceSymbol != SMART_CHAIN_SYMBOL)
throw std::runtime_error("Incorrect source chain in rawproof");
if (targetCCid != ASSETCHAINS_CC)
throw std::runtime_error("Incorrect CCid in burn tx");
if (targetSymbol == ASSETCHAINS_SYMBOL)
if (targetSymbol == SMART_CHAIN_SYMBOL)
throw std::runtime_error("Must not be called on the destination chain");
// fill info to return for the notary operator (if manual notarization) or user
@@ -548,7 +548,7 @@ UniValue migrate_createimporttransaction(const UniValue& params, bool fHelp, con
if (ASSETCHAINS_CC < KOMODO_FIRSTFUNGIBLEID)
throw runtime_error("-ac_cc < KOMODO_FIRSTFUNGIBLEID");
if (ASSETCHAINS_SYMBOL[0] == 0)
if (SMART_CHAIN_SYMBOL[0] == 0)
throw runtime_error("Must be called on assetchain");
vector<uint8_t> txData(ParseHexV(params[0], "argument 1"));
@@ -602,10 +602,10 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp, c
throw runtime_error("migrate_completeimporttransaction importTx [offset]\n\n"
"Takes a cross chain import tx with proof generated on assetchain "
"and extends proof to target chain proof root\n"
"offset is optional, use it to increase the used KMD height, use when import fails.");
"offset is optional, use it to increase the used HUSH height, use when import fails.");
if (ASSETCHAINS_SYMBOL[0] != 0)
throw runtime_error("Must be called on KMD");
if (SMART_CHAIN_SYMBOL[0] != 0)
throw runtime_error("Must be called on HUSH");
CTransaction importTx;
if (!E_UNMARSHAL(ParseHexV(params[0], "argument 1"), ss >> importTx))
@@ -644,7 +644,7 @@ UniValue migrate_checkburntransactionsource(const UniValue& params, bool fHelp,
throw runtime_error("migrate_checkburntransactionsource burntxid\n\n"
"checks if params stored in the burn tx match to its tx chain");
if (ASSETCHAINS_SYMBOL[0] == 0)
if (SMART_CHAIN_SYMBOL[0] == 0)
throw runtime_error("Must be called on asset chain");
uint256 burntxid = Parseuint256(params[0].get_str().c_str());
@@ -672,7 +672,7 @@ UniValue migrate_createnotaryapprovaltransaction(const UniValue& params, bool fH
"Creates a tx for destination chain with burn tx proof\n"
"txoutproof should be retrieved by komodo-cli migrate_checkburntransactionsource call on the source chain\n" );
if (ASSETCHAINS_SYMBOL[0] == 0)
if (SMART_CHAIN_SYMBOL[0] == 0)
throw runtime_error("Must be called on asset chain");
uint256 burntxid = Parseuint256(params[0].get_str().c_str());

View File

@@ -388,7 +388,7 @@ UniValue genminingCSV(const UniValue& params, bool fHelp, const CPubKey& mypk)
if (fHelp || params.size() != 0 )
throw runtime_error("genminingCSV\n");
LOCK(cs_main);
sprintf(fname,"%s_mining.csv",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL);
sprintf(fname,"%s_mining.csv",SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL);
if ( (fp= fopen(fname,"wb")) != 0 )
{
fprintf(fp,"height,nTime,nBits,bnTarget,bnTargetB,diff,solvetime\n");

View File

@@ -67,14 +67,14 @@ uint32_t komodo_chainactive_timestamp();
int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC;
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
uint32_t komodo_segid32(char *coinaddr);
int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp);
uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount);
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
// This is the last version of KMD upstream that was merged in
// This is the last version of upstream that was merged in
// We only cherry-pick since then
#define KOMODO_VERSION "0.5.0"
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
@@ -187,7 +187,7 @@ UniValue geterablockheights(const UniValue& params, bool fHelp, const CPubKey& m
UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height;
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,hushnotarized_height,txid_height;
if (fHelp || params.size() != 0)
throw runtime_error(
"getinfo\n"
@@ -241,18 +241,19 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString()));
if ( KOMODO_NSPV_FULLNODE )
{
txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height);
txid_height = notarizedtxid_height(SMART_CHAIN_SYMBOL[0] != 0 ? (char *)"HUSH" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&hushnotarized_height);
if ( txid_height > 0 )
obj.push_back(Pair("notarizedtxid_height", txid_height));
else obj.push_back(Pair("notarizedtxid_height", "mempool"));
if ( ASSETCHAINS_SYMBOL[0] != 0 )
obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height));
obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0));
if ( SMART_CHAIN_SYMBOL[0] != 0 ) {
obj.push_back(Pair("HUSHnotarized_height", hushnotarized_height));
}
obj.push_back(Pair("notarized_confirms", txid_height < hushnotarized_height ? (hushnotarized_height - txid_height + 1) : 0));
//fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
if ( ASSETCHAINS_SYMBOL[0] == 0 )
if ( SMART_CHAIN_SYMBOL[0] == 0 )
{
obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM)));
obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance()
@@ -301,13 +302,13 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
}
if ( ASSETCHAINS_CC != 0 )
obj.push_back(Pair("CCid", (int)ASSETCHAINS_CC));
obj.push_back(Pair("name", ASSETCHAINS_SYMBOL[0] == 0 ? "HUSH" : ASSETCHAINS_SYMBOL));
obj.push_back(Pair("name", SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL));
obj.push_back(Pair("p2pport", ASSETCHAINS_P2PPORT));
obj.push_back(Pair("rpcport", ASSETCHAINS_RPCPORT));
if ( ASSETCHAINS_SYMBOL[0] != 0 )
if ( SMART_CHAIN_SYMBOL[0] != 0 )
{
//obj.push_back(Pair("name", ASSETCHAINS_SYMBOL));
//obj.push_back(Pair("name", SMART_CHAIN_SYMBOL));
obj.push_back(Pair("magic", (int)ASSETCHAINS_MAGIC));
obj.push_back(Pair("premine", ASSETCHAINS_SUPPLY));
@@ -434,7 +435,7 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( (supply= komodo_coinsupply(&zfunds,&sproutfunds,height)) > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("coin", ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL));
result.push_back(Pair("coin", SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL));
result.push_back(Pair("height", (int)height));
result.push_back(Pair("supply", ValueFromAmount(supply)));
result.push_back(Pair("zfunds", ValueFromAmount(zfunds)));

View File

@@ -217,7 +217,7 @@ int32_t komodo_longestchain()
if ( num > (n >> 1) )
{
if ( 0 && height != KOMODO_LONGESTCHAIN )
fprintf(stderr,"set %s KOMODO_LONGESTCHAIN <- %d\n",ASSETCHAINS_SYMBOL,height);
fprintf(stderr,"set %s KOMODO_LONGESTCHAIN <- %d\n",SMART_CHAIN_SYMBOL,height);
KOMODO_LONGESTCHAIN = height;
return(height);
}

View File

@@ -56,7 +56,7 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *
using namespace std;
extern char ASSETCHAINS_SYMBOL[];
extern char SMART_CHAIN_SYMBOL[];
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex)
@@ -217,7 +217,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue&
const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ);
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
if ( ASSETCHAINS_SYMBOL[0] == 0 && pindex != 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 )
if ( SMART_CHAIN_SYMBOL[0] == 0 && pindex != 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 )
{
int64_t interest; int32_t txheight; uint32_t locktime;
interest = komodo_accrued_interest(&txheight,&locktime,tx.GetHash(),i,0,txout.nValue,(int32_t)tipindex->GetHeight());
@@ -316,7 +316,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ);
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
if ( KOMODO_NSPV_FULLNODE && ASSETCHAINS_SYMBOL[0] == 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 )
if ( KOMODO_NSPV_FULLNODE && SMART_CHAIN_SYMBOL[0] == 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 )
{
int64_t interest; int32_t txheight; uint32_t locktime;
interest = komodo_accrued_interest(&txheight,&locktime,tx.GetHash(),i,0,txout.nValue,(int32_t)tipindex->GetHeight());

View File

@@ -255,7 +255,7 @@ UniValue help(const UniValue& params, bool fHelp, const CPubKey& mypk)
return tableRPC.help(strCommand);
}
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
#ifdef ENABLE_WALLET
void GenerateBitcoins(bool b, CWallet *pw, int t);
@@ -282,10 +282,10 @@ UniValue stop(const UniValue& params, bool fHelp, const CPubKey& mypk)
// Shutdown will take long enough that the response should get back
StartShutdown();
if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3", 5) == 0) ) {
if ((strncmp(SMART_CHAIN_SYMBOL, "HUSH3", 5) == 0) ) {
sprintf(buf,"Hush server stopping...");
} else {
sprintf(buf,"%s server stopping...",ASSETCHAINS_SYMBOL);
sprintf(buf,"%s server stopping...",SMART_CHAIN_SYMBOL);
}
return buf;
}
@@ -872,12 +872,12 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params
std::string HelpExampleCli(const std::string& methodname, const std::string& args)
{
if ( ASSETCHAINS_SYMBOL[0] == 0 ) {
if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
return "> komodo-cli " + methodname + " " + args + "\n";
} else if ((strncmp(ASSETCHAINS_SYMBOL, "HUSH3", 5) == 0) ) {
} else if ((strncmp(SMART_CHAIN_SYMBOL, "HUSH3", 5) == 0) ) {
return "> hush-cli " + methodname + " " + args + "\n";
} else {
return "> komodo-cli -ac_name=" + strprintf("%s", ASSETCHAINS_SYMBOL) + " " + methodname + " " + args + "\n";
return "> komodo-cli -ac_name=" + strprintf("%s", SMART_CHAIN_SYMBOL) + " " + methodname + " " + args + "\n";
}
}
@@ -889,8 +889,8 @@ std::string HelpExampleRpc(const std::string& methodname, const std::string& arg
string experimentalDisabledHelpMsg(const string& rpc, const string& enableArg)
{
string daemon = ASSETCHAINS_SYMBOL[0] == 0 ? "komodod" : "hushd";
string ticker = ASSETCHAINS_SYMBOL[0] == 0 ? "komodo" : ASSETCHAINS_SYMBOL;
string daemon = SMART_CHAIN_SYMBOL[0] == 0 ? "komodod" : "hushd";
string ticker = SMART_CHAIN_SYMBOL[0] == 0 ? "komodo" : SMART_CHAIN_SYMBOL;
return "\nWARNING: " + rpc + " is disabled.\n"
"To enable it, restart " + daemon + " with the -experimentalfeatures and\n"