@@ -182,7 +182,7 @@
|
||||
"190.114.254.104"
|
||||
]
|
||||
},
|
||||
{
|
||||
{
|
||||
"ac_name": "DION",
|
||||
"ac_supply": "3900000000",
|
||||
"ac_reward": "22260000000",
|
||||
|
||||
@@ -1213,6 +1213,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit
|
||||
} else {
|
||||
return(0);
|
||||
}
|
||||
fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN);
|
||||
entropytxs = n;
|
||||
return(totalinputs);
|
||||
}
|
||||
|
||||
bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks)
|
||||
|
||||
@@ -551,6 +551,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "wallet", "getaccountaddress", &getaccountaddress, true },
|
||||
{ "wallet", "getaccount", &getaccount, true },
|
||||
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
|
||||
{ "wallet", "cleanwallettransactions", &cleanwallettransactions, false },
|
||||
{ "wallet", "getbalance", &getbalance, false },
|
||||
{ "wallet", "getbalance64", &getbalance64, false },
|
||||
{ "wallet", "getnewaddress", &getnewaddress, true },
|
||||
|
||||
@@ -350,6 +350,7 @@ extern UniValue signmessage(const UniValue& params, bool fHelp);
|
||||
extern UniValue verifymessage(const UniValue& params, bool fHelp);
|
||||
extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp);
|
||||
extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp);
|
||||
extern UniValue cleanwallettransactions(const UniValue& params, bool fHelp);
|
||||
extern UniValue getbalance(const UniValue& params, bool fHelp);
|
||||
extern UniValue getbalance64(const UniValue& params, bool fHelp);
|
||||
extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp);
|
||||
|
||||
@@ -1029,6 +1029,108 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef
|
||||
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
|
||||
}
|
||||
|
||||
UniValue cleanwallettransactions(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (fHelp || params.size() > 1 )
|
||||
throw runtime_error(
|
||||
"cleanwallettransactions \"txid\"\n"
|
||||
"\nRemove all txs that are spent. You can clear all txs bar one, by specifiying a txid.\n"
|
||||
"\nPlease backup your wallet.dat before running this command.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"txid\" (string, optional) The transaction id to keep.\n"
|
||||
"\nResult:\n"
|
||||
"{\n"
|
||||
" \"total_transactons\" : n, (numeric) Transactions in wallet of " + strprintf("%s",komodo_chainname()) + "\n"
|
||||
" \"remaining_transactons\" : n, (numeric) Transactions in wallet after clean.\n"
|
||||
" \"removed_transactons\" : n, (numeric) The number of transactions removed.\n"
|
||||
"}\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("cleanwallettransactions", "")
|
||||
+ HelpExampleCli("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
|
||||
+ HelpExampleRpc("cleanwallettransactions", "")
|
||||
+ HelpExampleRpc("cleanwallettransactions","\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
|
||||
);
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
uint256 exception; int32_t txs = pwalletMain->mapWallet.size();
|
||||
std::vector<uint256> TxToRemove;
|
||||
if (params.size() == 1)
|
||||
{
|
||||
exception.SetHex(params[0].get_str());
|
||||
uint256 tmp_hash; CTransaction tmp_tx;
|
||||
if (GetTransaction(exception,tmp_tx,tmp_hash,false))
|
||||
{
|
||||
if ( !pwalletMain->IsMine(tmp_tx) )
|
||||
{
|
||||
throw runtime_error("\nThe transaction is not yours!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
if ( wtx.GetHash() != exception )
|
||||
{
|
||||
TxToRemove.push_back(wtx.GetHash());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw runtime_error("\nThe transaction could not be found!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// get all locked utxos to relock them later.
|
||||
vector<COutPoint> 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<COutput> vecOutputs;
|
||||
assert(pwalletMain != NULL);
|
||||
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
|
||||
int32_t oldestTxDepth = 0;
|
||||
BOOST_FOREACH(const COutput& out, vecOutputs)
|
||||
{
|
||||
if ( out.nDepth > oldestTxDepth )
|
||||
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<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
if (wtx.GetDepthInMainChain() > oldestTxDepth)
|
||||
TxToRemove.push_back(wtx.GetHash());
|
||||
}
|
||||
}
|
||||
|
||||
// erase txs
|
||||
BOOST_FOREACH (uint256& hash, TxToRemove)
|
||||
{
|
||||
pwalletMain->EraseFromWallet(hash);
|
||||
LogPrintf("Erased %s from wallet.\n",hash.ToString().c_str());
|
||||
}
|
||||
|
||||
// build return JSON for stats.
|
||||
int remaining = pwalletMain->mapWallet.size();
|
||||
ret.push_back(Pair("total_transactons", (int)txs));
|
||||
ret.push_back(Pair("remaining_transactons", (int)remaining));
|
||||
ret.push_back(Pair("removed_transactions", (int)(txs-remaining)));
|
||||
return (ret);
|
||||
}
|
||||
|
||||
UniValue getbalance(const UniValue& params, bool fHelp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user