From f72c3ba1d27e3e8d4dc7e0f19ed0138c4965ba5c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 22 Nov 2018 16:51:34 +0800 Subject: [PATCH] fix --- src/komodo.h | 6 ++++-- src/rpcmisc.cpp | 8 ++++++++ src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 9 +++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e6c9a8c54..5b1bfe1ac 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -811,9 +811,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) return; } //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); - if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY != -1 ) { + if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 ) + { staked_era = STAKED_era(pindex->GetBlockTime()); - if ( staked_era != lastStakedEra ) { + if ( staked_era != lastStakedEra ) + { uint8_t tmp_pubkeys[64][33]; int8_t numSN = numStakedNotaries(tmp_pubkeys,staked_era); UpdateNotaryAddrs(tmp_pubkeys,numSN); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index e51a50a97..f85705a90 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -64,6 +64,14 @@ extern uint32_t ASSETCHAINS_MAGIC; extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY; extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[]; +UniValue getiguanajson(const UniValue& params, bool fHelp) +{ + if ( params.size() != 1 ) + throw runtime_error("please supply old staked.json!\n"); + UniValue json = params[0].get_obj(); + return json; +} + UniValue getinfo(const UniValue& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 65f12a346..dc0ebd465 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -263,6 +263,7 @@ static const CRPCCommand vRPCCommands[] = /* Overall control/query calls */ { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */ { "control", "help", &help, true }, + { "control", "getiguanajson", &getiguanajson, true }, { "control", "stop", &stop, true }, /* P2P networking */ diff --git a/src/rpcserver.h b/src/rpcserver.h index f7fa65942..2ae1e8de1 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -324,6 +324,7 @@ extern UniValue walletlock(const UniValue& params, bool fHelp); extern UniValue encryptwallet(const UniValue& params, bool fHelp); extern UniValue validateaddress(const UniValue& params, bool fHelp); extern UniValue getinfo(const UniValue& params, bool fHelp); +extern UniValue getiguanajson(const UniValue& params, bool fHelp); extern UniValue setpubkey(const UniValue& params, bool fHelp); extern UniValue getwalletinfo(const UniValue& params, bool fHelp); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a5c8bdaff..d6a06525d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1061,6 +1061,11 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) } else { + // get all locked utxos to relock them later. + vector vLockedUTXO; + pwalletMain->ListLockedCoins(vLockedUTXO); + // unlock all coins so that the following call containes all utxos. + pwalletMain->UnlockAllCoins(); // listunspent call... this gets us all the txids that are unspent, we search this list for the oldest tx, vector vecOutputs; assert(pwalletMain != NULL); @@ -1072,6 +1077,10 @@ UniValue cleanwallettransactions(const UniValue& params, bool fHelp) oldestTxDepth = out.nDepth; } oldestTxDepth = oldestTxDepth + 1; // add extra block just for safety. + // lock all the previouly locked coins. + BOOST_FOREACH(COutPoint &outpt, vLockedUTXO) { + pwalletMain->LockCoin(outpt); + } // then add all txs in the wallet before this block to the list to remove. for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)