From b03c8f3108adf837c682cc0ddcf8f36828fc9e65 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 17 Jun 2023 21:31:05 -0400 Subject: [PATCH] Remove unused code --- src/rpc/blockchain.cpp | 71 ----------------------------------- src/rpc/client.cpp | 3 -- src/rpc/server.cpp | 3 -- src/rpc/server.h | 5 --- src/wallet/rpcwallet.cpp | 81 ---------------------------------------- 5 files changed, 163 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 1c34cd1b0..7bdf840da 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1061,79 +1061,8 @@ UniValue notaries(const UniValue& params, bool fHelp, const CPubKey& mypk) } int32_t hush_pending_withdraws(char *opretstr); -int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); extern char CURRENCIES[][8]; -UniValue paxpending(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR); char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t available,deposited,issued,withdrawn,approved,redeemed; - if ( fHelp || params.size() != 0 ) - throw runtime_error("paxpending needs no args\n"); - LOCK(cs_main); - if ( (opretlen= hush_pending_withdraws(opretbuf)) > 0 ) - ret.push_back(Pair("withdraws", opretbuf)); - else ret.push_back(Pair("withdraws", (char *)"")); - for (baseid=0; baseid<32; baseid++) - { - UniValue item(UniValue::VOBJ); UniValue obj(UniValue::VOBJ); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) - { - if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) - { - item.push_back(Pair("available", ValueFromAmount(available))); - item.push_back(Pair("deposited", ValueFromAmount(deposited))); - item.push_back(Pair("issued", ValueFromAmount(issued))); - item.push_back(Pair("withdrawn", ValueFromAmount(withdrawn))); - item.push_back(Pair("approved", ValueFromAmount(approved))); - item.push_back(Pair("redeemed", ValueFromAmount(redeemed))); - obj.push_back(Pair(CURRENCIES[baseid],item)); - a.push_back(obj); - } - } - } - ret.push_back(Pair("fiatstatus", a)); - return ret; -} - -UniValue paxprice(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - if ( fHelp || params.size() > 4 || params.size() < 2 ) - throw runtime_error("paxprice \"base\" \"rel\" height\n"); - LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t basevolume=0,relvolume,seed; - std::string base = params[0].get_str(); - std::string rel = params[1].get_str(); - int32_t height; - if ( params.size() == 2 ) - height = chainActive.LastTip()->GetHeight(); - else height = atoi(params[2].get_str().c_str()); - //if ( params.size() == 3 || (basevolume= COIN * atof(params[3].get_str().c_str())) == 0 ) - basevolume = 100000; - relvolume = hush_paxprice(&seed,height,(char *)base.c_str(),(char *)rel.c_str(),basevolume); - ret.push_back(Pair("base", base)); - ret.push_back(Pair("rel", rel)); - ret.push_back(Pair("height", height)); - char seedstr[32]; - sprintf(seedstr,"%llu",(long long)seed); - ret.push_back(Pair("seed", seedstr)); - if ( height < 0 || height > chainActive.Height() ) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - else - { - CBlockIndex *pblockindex = chainActive[height]; - if ( pblockindex != 0 ) - ret.push_back(Pair("timestamp", (int64_t)pblockindex->nTime)); - if ( basevolume != 0 && relvolume != 0 ) - { - ret.push_back(Pair("price",((double)relvolume / (double)basevolume))); - ret.push_back(Pair("invprice",((double)basevolume / (double)relvolume))); - ret.push_back(Pair("basevolume",ValueFromAmount(basevolume))); - ret.push_back(Pair("relvolume",ValueFromAmount(relvolume))); - } else ret.push_back(Pair("error", "overflow or error in one or more of parameters")); - } - return ret; -} - UniValue gettxout(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (fHelp || params.size() < 2 || params.size() > 3) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 9e9178f25..563864c12 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -154,9 +154,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "z_shieldcoinbase", 3}, { "z_getoperationstatus", 0}, { "z_getoperationresult", 0}, - { "paxprice", 4 }, - { "paxprices", 3 }, - { "paxpending", 0 }, { "notaries", 2 }, { "minerids", 1 }, { "kvsearch", 1 }, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index e81ad19e6..703cdc7b9 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -332,9 +332,6 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true }, { "blockchain", "verifychain", &verifychain, true }, { "blockchain", "getspentinfo", &getspentinfo, false }, - //{ "blockchain", "paxprice", &paxprice, true }, - //{ "blockchain", "paxpending", &paxpending, true }, - //{ "blockchain", "paxprices", &paxprices, true }, { "blockchain", "notaries", ¬aries, true }, //{ "blockchain", "height_MoM", &height_MoM, true }, //{ "blockchain", "txMoMproof", &txMoMproof, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 87b46610d..3bfc0654e 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -502,10 +502,5 @@ extern UniValue notaries(const UniValue& params, bool fHelp, const CPubKey& mypk extern UniValue minerids(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxprice(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxpending(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxprices(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk); #endif // HUSH_RPCSERVER_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 87d8ed64f..db2250a66 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -612,7 +612,6 @@ extern int32_t HUSH_PAX; int32_t hush_is_issuer(); int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t hush_isrealtime(int32_t *hushheightp); -int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); int32_t hush_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); int32_t hush_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize); uint64_t hush_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen); @@ -763,86 +762,6 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) return ret; } -UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,puposhis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; - bool fSubtractFeeFromAmount = false; - if ( HUSH_PAX == 0 ) - { - throw runtime_error("paxdeposit disabled without -pax"); - } - if ( hush_is_issuer() != 0 ) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "paxdeposit only from KYC"); - if (!EnsureWalletIsAvailable(fHelp)) - throw runtime_error("paxdeposit needs wallet"); //return Value::null; - if (fHelp || params.size() != 3) - throw runtime_error("paxdeposit address fiatoshis base"); - LOCK2(cs_main, pwalletMain->cs_wallet); - CBitcoinAddress address(params[0].get_str()); - if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; - std::string base = params[2].get_str(); - std::string dest; - height = chainActive.LastTip()->GetHeight(); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) - { - fprintf(stderr,"available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); - throw runtime_error("paxdeposit not enough available inventory"); - } - puposhis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); - dest.append(destaddr); - CBitcoinAddress destaddress(CRYPTO555_HUSHADDR); - if (!destaddress.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); - for (i=0; i<33; i++) - fprintf(stderr,"%02x",pubkey37[i]); - fprintf(stderr," ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) puposhis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)puposhis,(long long)seed); - EnsureWalletIsUnlocked(); - CWalletTx wtx; - uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = puposhis / 1000; - if ( fee < 10000 ) - fee = 10000; - dragon_rwnum(1,&pubkey37[33],sizeof(height),&height); - opretlen = hush_opreturnscript(opretbuf,'D',pubkey37,37); - SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,puposhis); - return wtx.GetHash().GetHex(); -} - -UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - CWalletTx wtx; std::string dest; int32_t hushheight; uint64_t seed,puposhis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false; - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - return(0); - if (!EnsureWalletIsAvailable(fHelp)) - return 0; - throw runtime_error("paxwithdraw deprecated"); - if (fHelp || params.size() != 2) - throw runtime_error("paxwithdraw address fiatamount"); - if ( hush_isrealtime(&hushheight) == 0 ) - return(0); - LOCK2(cs_main, pwalletMain->cs_wallet); - CBitcoinAddress address(params[0].get_str()); - if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; - puposhis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),hushheight,SMART_CHAIN_SYMBOL,fiatoshis); - dest.append(destaddr); - CBitcoinAddress destaddress(CRYPTO555_HUSHADDR); - if (!destaddress.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); - for (i=0; i<33; i++) - printf("%02x",pubkey37[i]); - printf(" hushheight.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) puposhis.%llu seed.%llx\n",hushheight,(char *)params[0].get_str().c_str(),SMART_CHAIN_SYMBOL,(long long)fiatoshis,destaddr,(long long)puposhis,(long long)seed); - EnsureWalletIsUnlocked(); - uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = fiatoshis / 1000; - if ( fee < 10000 ) - fee = 10000; - dragon_rwnum(1,&pubkey37[33],sizeof(hushheight),&hushheight); - opretlen = hush_opreturnscript(opretbuf,'W',pubkey37,37); - SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis); - return wtx.GetHash().GetHex(); -} UniValue listaddressgroupings(const UniValue& params, bool fHelp, const CPubKey& mypk) {