diff --git a/src/Makefile.am b/src/Makefile.am index 874c3a8b4..e6cc5d756 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -300,7 +300,7 @@ libbitcoin_server_a_SOURCES = \ cc/oracles.cpp \ cc/prices.cpp \ cc/pegs.cpp \ - cc/triggers.cpp \ + cc/marmara.cpp \ cc/payments.cpp \ cc/gateways.cpp \ cc/channels.cpp \ diff --git a/src/cc/CCTriggers.h b/src/cc/CCMarmara.h similarity index 90% rename from src/cc/CCTriggers.h rename to src/cc/CCMarmara.h index a75806dce..45fda83bd 100644 --- a/src/cc/CCTriggers.h +++ b/src/cc/CCMarmara.h @@ -19,9 +19,9 @@ #include "CCinclude.h" -bool TriggersValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); // CCcustom -UniValue TriggersInfo(); +UniValue MarmaraInfo(); #endif diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 3e42109fc..7fdd1b920 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -27,7 +27,7 @@ #include "CCOracles.h" #include "CCPrices.h" #include "CCPegs.h" -#include "CCTriggers.h" +#include "CCMarmara.h" #include "CCPayments.h" #include "CCGateways.h" @@ -189,13 +189,13 @@ uint8_t PegsCCpriv[32] = { 0x52, 0x56, 0x4c, 0x78, 0x87, 0xf7, 0xa2, 0x39, 0xb0, #undef FUNCNAME #undef EVALCODE -// Triggers -#define FUNCNAME IsTriggersInput -#define EVALCODE EVAL_TRIGGERS -const char *TriggersCCaddr = "RGLSRDnUqTB43bYtRtNVgmwSSd1sun2te8"; -const char *TriggersNormaladdr = "RMN25Tn8NNzcyQDiQNuMp8UmwLMFd9thYc"; -char TriggersCChexstr[67] = { "03afc5be570d0ff419425cfcc580cc762ab82baad88c148f5b028d7db7bfeee61d" }; -uint8_t TriggersCCpriv[32] = { 0x7c, 0x0b, 0x54, 0x9b, 0x65, 0xd4, 0x89, 0x57, 0xdf, 0x05, 0xfe, 0xa2, 0x62, 0x41, 0xa9, 0x09, 0x0f, 0x2a, 0x6b, 0x11, 0x2c, 0xbe, 0xbd, 0x06, 0x31, 0x8d, 0xc0, 0xb9, 0x96, 0x76, 0x3f, 0x24 }; +// Marmara +#define FUNCNAME IsMarmaraInput +#define EVALCODE EVAL_MARMARA +const char *MarmaraCCaddr = "RGLSRDnUqTB43bYtRtNVgmwSSd1sun2te8"; +const char *MarmaraNormaladdr = "RMN25Tn8NNzcyQDiQNuMp8UmwLMFd9thYc"; +char MarmaraCChexstr[67] = { "03afc5be570d0ff419425cfcc580cc762ab82baad88c148f5b028d7db7bfeee61d" }; +uint8_t MarmaraCCpriv[32] = { 0x7c, 0x0b, 0x54, 0x9b, 0x65, 0xd4, 0x89, 0x57, 0xdf, 0x05, 0xfe, 0xa2, 0x62, 0x41, 0xa9, 0x09, 0x0f, 0x2a, 0x6b, 0x11, 0x2c, 0xbe, 0xbd, 0x06, 0x31, 0x8d, 0xc0, 0xb9, 0x96, 0x76, 0x3f, 0x24 }; #include "CCcustom.inc" #undef FUNCNAME #undef EVALCODE @@ -323,13 +323,13 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) cp->validate = PegsValidate; cp->ismyvin = IsPegsInput; break; - case EVAL_TRIGGERS: - strcpy(cp->unspendableCCaddr,TriggersCCaddr); - strcpy(cp->normaladdr,TriggersNormaladdr); - strcpy(cp->CChexstr,TriggersCChexstr); - memcpy(cp->CCpriv,TriggersCCpriv,32); - cp->validate = TriggersValidate; - cp->ismyvin = IsTriggersInput; + case EVAL_MARMARA: + strcpy(cp->unspendableCCaddr,MarmaraCCaddr); + strcpy(cp->normaladdr,MarmaraNormaladdr); + strcpy(cp->CChexstr,MarmaraCChexstr); + memcpy(cp->CCpriv,MarmaraCCpriv,32); + cp->validate = MarmaraValidate; + cp->ismyvin = IsMarmaraInput; break; case EVAL_PAYMENTS: strcpy(cp->unspendableCCaddr,PaymentsCCaddr); diff --git a/src/cc/eval.h b/src/cc/eval.h index 9c6a050b7..87b98349b 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -53,7 +53,7 @@ EVAL(EVAL_ORACLES, 0xec) \ EVAL(EVAL_PRICES, 0xed) \ EVAL(EVAL_PEGS, 0xee) \ - EVAL(EVAL_TRIGGERS, 0xef) \ + EVAL(EVAL_MARMARA, 0xef) \ EVAL(EVAL_PAYMENTS, 0xf0) \ EVAL(EVAL_GATEWAYS, 0xf1) diff --git a/src/cc/triggers.cpp b/src/cc/marmara.cpp similarity index 73% rename from src/cc/triggers.cpp rename to src/cc/marmara.cpp index a98e4da02..4bbccee4a 100644 --- a/src/cc/triggers.cpp +++ b/src/cc/marmara.cpp @@ -13,16 +13,16 @@ * * ******************************************************************************/ -#include "CCTriggers.h" +#include "CCMarmara.h" /* - Triggers CC is a building block CC that allows creation of event -> action processing, where events are defined during trigger creation and actions to be mostly done via payments, but by making payments to other CC contracts, it can be used to invoke other CC contracts + Marmara CC is for the MARMARA project */ // start of consensus code -int64_t IsTriggersvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsMarmaravout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -33,7 +33,7 @@ int64_t IsTriggersvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t return(0); } -bool TriggersExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool MarmaraExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -51,8 +51,8 @@ bool TriggersExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti { //fprintf(stderr,"vini.%d check hash and vout\n",i); if ( hashBlock == zerohash ) - return eval->Invalid("cant Triggers from mempool"); - if ( (assetoshis= IsTriggersvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) + return eval->Invalid("cant Marmara from mempool"); + if ( (assetoshis= IsMarmaravout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) inputs += assetoshis; } } @@ -60,7 +60,7 @@ bool TriggersExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti for (i=0; i origpubkey; CTransaction vintx; int32_t vout,n = 0; @@ -126,7 +126,7 @@ int64_t AddTriggersInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( (nValue= IsTriggersvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsMarmaravout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -141,28 +141,28 @@ int64_t AddTriggersInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP return(totalinputs); } -std::string TriggersGet(uint64_t txfee,int64_t nValue) +std::string MarmaraGet(uint64_t txfee,int64_t nValue) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Triggerspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; - cp = CCinit(&C,EVAL_TRIGGERS); + CPubKey mypk,Marmarapk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; - Triggerspk = GetUnspendable(cp,0); + Marmarapk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); - if ( (inputs= AddTriggersInputs(cp,mtx,Triggerspk,nValue+txfee,60)) > 0 ) + if ( (inputs= AddMarmaraInputs(cp,mtx,Marmarapk,nValue+txfee,60)) > 0 ) { if ( inputs > nValue ) CCchange = (inputs - nValue - txfee); if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_TRIGGERS,CCchange,Triggerspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,CCchange,Marmarapk)); mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); fprintf(stderr,"start at %u\n",(uint32_t)time(NULL)); j = rand() & 0xfffffff; for (i=0; i<1000000; i++,j++) { tmpmtx = mtx; - rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_TRIGGERS << (uint8_t)'G' << j)); + rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_MARMARA << (uint8_t)'G' << j)); if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 ) { len >>= 1; @@ -178,37 +178,37 @@ std::string TriggersGet(uint64_t txfee,int64_t nValue) } fprintf(stderr,"couldnt generate valid txid %u\n",(uint32_t)time(NULL)); return(""); - } else fprintf(stderr,"cant find Triggers inputs\n"); + } else fprintf(stderr,"cant find Marmara inputs\n"); return(""); } -std::string TriggersFund(uint64_t txfee,int64_t funds) +std::string MarmaraFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey mypk,Triggerspk; CScript opret; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_TRIGGERS); + CPubKey mypk,Marmarapk; CScript opret; struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_MARMARA); if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - Triggerspk = GetUnspendable(cp,0); + Marmarapk = GetUnspendable(cp,0); if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) { - mtx.vout.push_back(MakeCC1vout(EVAL_TRIGGERS,funds,Triggerspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,funds,Marmarapk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); } return(""); } -UniValue TriggersInfo() +UniValue MarmaraInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - CPubKey Triggerspk; struct CCcontract_info *cp,C; int64_t funding; + CPubKey Marmarapk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); - result.push_back(Pair("name","Triggers")); - cp = CCinit(&C,EVAL_TRIGGERS); - Triggerspk = GetUnspendable(cp,0); - funding = AddTriggersInputs(cp,mtx,Triggerspk,0,0); + result.push_back(Pair("name","Marmara")); + cp = CCinit(&C,EVAL_MARMARA); + Marmarapk = GetUnspendable(cp,0); + funding = AddMarmaraInputs(cp,mtx,Marmarapk,0,0); sprintf(numstr,"%.8f",(double)funding/COIN); result.push_back(Pair("funding",numstr)); return(result); diff --git a/src/importcoin.cpp b/src/importcoin.cpp index 010fbeb7d..39ff01d68 100644 --- a/src/importcoin.cpp +++ b/src/importcoin.cpp @@ -68,13 +68,13 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint if (burnTx.vout.size() == 0) return false; GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret); E_UNMARSHAL(burnOpret, ss >> VARINT(ccid)); - if ( ccid != 0xffffffff ) + /*if ( ccid != 0xffffffff ) { return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; ss >> payoutsHash); } - else + else*/ { return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid); ss >> targetSymbol; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 8e08056df..c210e3099 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -695,7 +695,8 @@ UniValue getblockheader(const UniValue& params, bool fHelp) "\nResult (for verbose = true):\n" "{\n" " \"hash\" : \"hash\", (string) the block hash (same as provided)\n" - " \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" + " \"confirmations\" : n, (numeric) The number of notarized DPoW confirmations, or -1 if the block is not on the main chain\n" + " \"rawconfirmations\" : n,(numeric) The number of raw confirmations, or -1 if the block is not on the main chain\n" " \"height\" : n, (numeric) The block height or index\n" " \"version\" : n, (numeric) The block version\n" " \"merkleroot\" : \"xxxx\", (string) The merkle root\n" @@ -755,7 +756,8 @@ UniValue getblock(const UniValue& params, bool fHelp) "\nResult (for verbosity = 1):\n" "{\n" " \"hash\" : \"hash\", (string) the block hash (same as provided hash)\n" - " \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" + " \"confirmations\" : n, (numeric) The number of notarized DPoW confirmations, or -1 if the block is not on the main chain\n" + " \"rawconfirmations\" : n,(numeric) The number of raw confirmations, or -1 if the block is not on the main chain\n" " \"size\" : n, (numeric) The block size\n" " \"height\" : n, (numeric) The block height or index (same as provided height)\n" " \"version\" : n, (numeric) The block version\n" @@ -1198,7 +1200,8 @@ UniValue gettxout(const UniValue& params, bool fHelp) "\nResult:\n" "{\n" " \"bestblock\" : \"hash\", (string) the block hash\n" - " \"confirmations\" : n, (numeric) The number of confirmations\n" + " \"confirmations\" : n, (numeric) The number of notarized DPoW confirmations\n" + " \"rawconfirmations\" : n, (numeric) The number of raw confirmations\n" " \"value\" : x.xxx, (numeric) The transaction value in " + CURRENCY_UNIT + "\n" " \"scriptPubKey\" : { (json object)\n" " \"asm\" : \"code\", (string) \n" @@ -1251,10 +1254,10 @@ UniValue gettxout(const UniValue& params, bool fHelp) BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); CBlockIndex *pindex = it->second; ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex())); - if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT) + if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT) { ret.push_back(Pair("confirmations", 0)); - else - { + ret.push_back(Pair("rawconfirmations", 0)); + } else { ret.push_back(Pair("confirmations", komodo_dpowconfs(coins.nHeight,pindex->GetHeight() - coins.nHeight + 1))); ret.push_back(Pair("rawconfirmations", pindex->GetHeight() - coins.nHeight + 1)); } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 067471c2c..5ab040711 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -297,6 +297,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& } else { entry.push_back(Pair("height", -1)); entry.push_back(Pair("confirmations", 0)); + entry.push_back(Pair("rawconfirmations", 0)); } } @@ -379,9 +380,10 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) entry.push_back(Pair("confirmations", komodo_dpowconfs(pindex->GetHeight(),1 + chainActive.Height() - pindex->GetHeight()))); entry.push_back(Pair("time", pindex->GetBlockTime())); entry.push_back(Pair("blocktime", pindex->GetBlockTime())); - } - else + } else { entry.push_back(Pair("confirmations", 0)); + entry.push_back(Pair("rawconfirmations", 0)); + } } } } @@ -469,7 +471,8 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp) " ,...\n" " ],\n" " \"blockhash\" : \"hash\", (string) the block hash\n" - " \"confirmations\" : n, (numeric) The confirmations\n" + " \"confirmations\" : n, (numeric) The number of notarized DPoW confirmations\n" + " \"rawconfirmations\" : n, (numeric) The number of raw confirmations\n" " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n" " \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" "}\n" diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 7ebd2c5ef..1a932382e 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -441,8 +441,8 @@ static const CRPCCommand vRPCCommands[] = // Pegs { "pegs", "pegsaddress", &pegsaddress, true }, - // Triggers - { "triggers", "triggersaddress", &triggersaddress, true }, + // Marmara + { "marmara", "Marmaraaddress", &marmaraaddress, true }, // Payments { "payments", "paymentsaddress", &paymentsaddress, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index f462f9363..5bdf62799 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -271,7 +271,7 @@ extern UniValue pricesbet(const UniValue& params, bool fHelp); extern UniValue pricesstatus(const UniValue& params, bool fHelp); extern UniValue pricesfinish(const UniValue& params, bool fHelp); extern UniValue pegsaddress(const UniValue& params, bool fHelp); -extern UniValue triggersaddress(const UniValue& params, bool fHelp); +extern UniValue marmaraaddress(const UniValue& params, bool fHelp); extern UniValue paymentsaddress(const UniValue& params, bool fHelp); extern UniValue gatewaysaddress(const UniValue& params, bool fHelp); extern UniValue gatewayslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f9a6a6a5e..6e5bc5b83 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1435,11 +1435,13 @@ struct tallyitem int nConf; vector txids; bool fIsWatchonly; + int nHeight; tallyitem() { nAmount = 0; nConf = std::numeric_limits::max(); fIsWatchonly = false; + nHeight = 0; } }; @@ -1485,6 +1487,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) tallyitem& item = mapTally[address]; item.nAmount += txout.nValue; // komodo_interest? item.nConf = min(item.nConf, nDepth); + item.nHeight = mapBlockIndex[wtx.hashBlock]->GetHeight(); item.txids.push_back(wtx.GetHash()); if (mine & ISMINE_WATCH_ONLY) item.fIsWatchonly = true; @@ -1504,11 +1507,13 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) CAmount nAmount = 0; int nConf = std::numeric_limits::max(); bool fIsWatchonly = false; + int nHeight=0; if (it != mapTally.end()) { nAmount = (*it).second.nAmount; nConf = (*it).second.nConf; fIsWatchonly = (*it).second.fIsWatchonly; + nHeight = (*it).second.nHeight; } if (fByAccounts) @@ -1521,12 +1526,14 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) else { UniValue obj(UniValue::VOBJ); + if(fIsWatchonly) obj.push_back(Pair("involvesWatchonly", true)); obj.push_back(Pair("address", EncodeDestination(dest))); obj.push_back(Pair("account", strAccount)); obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); + obj.push_back(Pair("rawconfirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); + obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : komodo_dpowconfs(nHeight, nConf)))); UniValue transactions(UniValue::VARR); if (it != mapTally.end()) { @@ -1546,12 +1553,14 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) { CAmount nAmount = (*it).second.nAmount; int nConf = (*it).second.nConf; + int nHeight = (*it).second.nHeight; UniValue obj(UniValue::VOBJ); if((*it).second.fIsWatchonly) obj.push_back(Pair("involvesWatchonly", true)); obj.push_back(Pair("account", (*it).first)); obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); + obj.push_back(Pair("rawconfirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); + obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : komodo_dpowconfs(nHeight, nConf)))); ret.push_back(obj); } } @@ -2954,10 +2963,29 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) for (auto & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); + int nHeight = 0; + CTransaction tx; + uint256 hashBlock; + obj.push_back(Pair("txid", entry.jsop.hash.ToString())); obj.push_back(Pair("jsindex", (int)entry.jsop.js )); obj.push_back(Pair("jsoutindex", (int)entry.jsop.n)); - obj.push_back(Pair("confirmations", entry.confirmations)); + + if (!GetTransaction(entry.jsop.hash, tx, hashBlock, true)) { + // TODO: should we throw JSONRPCError ? + fprintf(stderr,"tx hash %s does not exist!\n", entry.jsop.hash.ToString().c_str() ); + } + + BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); + if (it != mapBlockIndex.end()) { + nHeight = it->second->GetHeight(); + fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + } else { + // TODO: should we throw JSONRPCError ? + fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); + } + obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("rawconfirmations", entry.confirmations)); bool hasSproutSpendingKey = pwalletMain->HaveSproutSpendingKey(boost::get(entry.address)); obj.push_back(Pair("spendable", hasSproutSpendingKey)); obj.push_back(Pair("address", EncodePaymentAddress(entry.address))); @@ -2974,7 +3002,24 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", entry.op.hash.ToString())); obj.push_back(Pair("outindex", (int)entry.op.n)); - obj.push_back(Pair("confirmations", entry.confirmations)); + int nHeight = 0; + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(entry.op.hash, tx, hashBlock, true)) { + // TODO: should we throw JSONRPCError ? + fprintf(stderr,"tx hash %s does not exist!\n", entry.op.hash.ToString().c_str() ); + } + + BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); + if (it != mapBlockIndex.end()) { + nHeight = it->second->GetHeight(); + fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + } else { + // TODO: should we throw JSONRPCError ? + fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); + } + obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); + obj.push_back(Pair("rawconfirmations", entry.confirmations)); libzcash::SaplingIncomingViewingKey ivk; libzcash::SaplingFullViewingKey fvk; pwalletMain->GetSaplingIncomingViewingKey(boost::get(entry.address), ivk); @@ -3702,7 +3747,11 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) "{\n" " \"txid\": xxxxx, (string) the transaction id\n" " \"amount\": xxxxx, (numeric) the amount of value in the note\n" - " \"memo\": xxxxx, (string) hexademical string representation of memo field\n" + " \"memo\": xxxxx, (string) hexadecimal string representation of memo field\n" + " \"confirmations\" : n, (numeric) the number of confirmations\n" + " \"jsindex\" (sprout) : n, (numeric) the joinsplit index\n" + " \"jsoutindex\" (sprout) : n, (numeric) the output index of the joinsplit\n" + " \"outindex\" (sapling) : n, (numeric) the output index\n" " \"change\": true|false, (boolean) true if the address that received the note is also one of the sending addresses\n" "}\n" "\nExamples:\n" @@ -3747,12 +3796,30 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) if (boost::get(&zaddr) != nullptr) { for (CSproutNotePlaintextEntry & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); + int nHeight = 0; + CTransaction tx; + uint256 hashBlock; + + if (GetTransaction(entry.jsop.hash, tx, hashBlock, true)) { + BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); + if (it != mapBlockIndex.end()) { + nHeight = it->second->GetHeight(); + fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + } else { + fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); + } + } else { + fprintf(stderr,"tx hash %s does not exist!\n", entry.jsop.hash.ToString().c_str() ); + } + obj.push_back(Pair("txid", entry.jsop.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.plaintext.value())))); std::string data(entry.plaintext.memo().begin(), entry.plaintext.memo().end()); obj.push_back(Pair("memo", HexStr(data))); obj.push_back(Pair("jsindex", entry.jsop.js)); obj.push_back(Pair("jsoutindex", entry.jsop.n)); + obj.push_back(Pair("rawconfirmations", entry.confirmations)); + obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSproutChange(nullifierSet, entry.address, entry.jsop))); } @@ -3761,10 +3828,27 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) } else if (boost::get(&zaddr) != nullptr) { for (SaplingNoteEntry & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); + int nHeight = 0; + CTransaction tx; + uint256 hashBlock; + + if (GetTransaction(entry.op.hash, tx, hashBlock, true)) { + BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); + if (it != mapBlockIndex.end()) { + nHeight = it->second->GetHeight(); + fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + } else { + fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); + } + } else { + fprintf(stderr,"tx hash %s does not exist!\n", entry.op.hash.ToString().c_str() ); + } obj.push_back(Pair("txid", entry.op.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.note.value())))); obj.push_back(Pair("memo", HexStr(entry.memo))); obj.push_back(Pair("outindex", (int)entry.op.n)); + obj.push_back(Pair("rawconfirmations", entry.confirmations)); + obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSaplingChange(nullifierSet, entry.address, entry.op))); } @@ -5111,6 +5195,7 @@ int32_t ensure_CCrequirements() #include "../cc/CCGateways.h" #include "../cc/CCPrices.h" #include "../cc/CCHeir.h" +#include "../cc/CCMarmara.h" UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector &pubkey) { @@ -5291,17 +5376,17 @@ UniValue pegsaddress(const UniValue& params, bool fHelp) return(CCaddress(cp,(char *)"Pegs",pubkey)); } -UniValue triggersaddress(const UniValue& params, bool fHelp) +UniValue marmaraaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; - cp = CCinit(&C,EVAL_TRIGGERS); + cp = CCinit(&C,EVAL_MARMARA); if ( fHelp || params.size() > 1 ) - throw runtime_error("triggersaddress [pubkey]\n"); + throw runtime_error("Marmaraaddress [pubkey]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); - return(CCaddress(cp,(char *)"Triggers",pubkey)); + return(CCaddress(cp,(char *)"Marmara",pubkey)); } UniValue paymentsaddress(const UniValue& params, bool fHelp)