Sync with latest Komodo changes
This commit is contained in:
@@ -152,9 +152,9 @@ void AsyncRPCOperation_mergetoaddress::main()
|
||||
|
||||
#ifdef ENABLE_MINING
|
||||
#ifdef ENABLE_WALLET
|
||||
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
|
||||
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 0));
|
||||
#else
|
||||
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 1));
|
||||
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 0));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -158,9 +158,9 @@ void AsyncRPCOperation_sendmany::main() {
|
||||
|
||||
#ifdef ENABLE_MINING
|
||||
#ifdef ENABLE_WALLET
|
||||
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 1));
|
||||
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 0));
|
||||
#else
|
||||
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 1));
|
||||
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 0));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -138,9 +138,9 @@ void AsyncRPCOperation_shieldcoinbase::main() {
|
||||
|
||||
#ifdef ENABLE_MINING
|
||||
#ifdef ENABLE_WALLET
|
||||
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 1));
|
||||
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 0));
|
||||
#else
|
||||
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 1));
|
||||
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 0));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ std::string DecodeDumpString(const std::string &str) {
|
||||
for (unsigned int pos = 0; pos < str.length(); pos++) {
|
||||
unsigned char c = str[pos];
|
||||
if (c == '%' && pos+2 < str.length()) {
|
||||
c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) |
|
||||
c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) |
|
||||
((str[pos+2]>>6)*9+((str[pos+2]-'0')&15));
|
||||
pos += 2;
|
||||
}
|
||||
@@ -77,13 +77,13 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() < 1 || params.size() > 3)
|
||||
throw runtime_error(
|
||||
"importprivkey \"zcashprivkey\" ( \"label\" rescan )\n"
|
||||
"importprivkey \"komodoprivkey\" ( \"label\" rescan )\n"
|
||||
"\nAdds a private key (as returned by dumpprivkey) to your wallet.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"zcashprivkey\" (string, required) The private key (see dumpprivkey)\n"
|
||||
"1. \"komodoprivkey\" (string, required) The private key (see dumpprivkey)\n"
|
||||
"2. \"label\" (string, optional, default=\"\") An optional label\n"
|
||||
"3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n"
|
||||
"\nNote: This call can take minutes to complete if rescan is true.\n"
|
||||
@@ -152,7 +152,7 @@ UniValue importaddress(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() < 1 || params.size() > 3)
|
||||
throw runtime_error(
|
||||
"importaddress \"address\" ( \"label\" rescan )\n"
|
||||
@@ -248,7 +248,7 @@ UniValue importwallet(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"importwallet \"filename\"\n"
|
||||
@@ -278,7 +278,7 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
|
||||
if (!file.is_open())
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
||||
|
||||
int64_t nTimeBegin = chainActive.Tip()->GetBlockTime();
|
||||
int64_t nTimeBegin = chainActive.LastTip()->GetBlockTime();
|
||||
|
||||
bool fGood = true;
|
||||
|
||||
@@ -364,7 +364,7 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
|
||||
file.close();
|
||||
pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI
|
||||
|
||||
CBlockIndex *pindex = chainActive.Tip();
|
||||
CBlockIndex *pindex = chainActive.LastTip();
|
||||
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
|
||||
pindex = pindex->pprev;
|
||||
|
||||
@@ -385,14 +385,14 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"dumpprivkey \"zcashaddress\"\n"
|
||||
"\nReveals the private key corresponding to 'zcashaddress'.\n"
|
||||
"dumpprivkey \"komodoaddress\"\n"
|
||||
"\nReveals the private key corresponding to 'komodoaddress'.\n"
|
||||
"Then the importprivkey can be used with this output\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"zcashaddress\" (string, required) The zcash address for the private key\n"
|
||||
"1. \"komodoaddress\" (string, required) The komodo address for the private key\n"
|
||||
"\nResult:\n"
|
||||
"\"key\" (string) The private key\n"
|
||||
"\nExamples:\n"
|
||||
@@ -424,13 +424,13 @@ UniValue z_exportwallet(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"z_exportwallet \"filename\"\n"
|
||||
"\nExports all wallet keys, for taddr and zaddr, in a human-readable format. Overwriting an existing file is not permitted.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"filename\" (string, required) The filename, saved in folder set by zcashd -exportdir option\n"
|
||||
"1. \"filename\" (string, required) The filename, saved in folder set by komodod -exportdir option\n"
|
||||
"\nResult:\n"
|
||||
"\"path\" (string) The full path of the destination file\n"
|
||||
"\nExamples:\n"
|
||||
@@ -451,7 +451,7 @@ UniValue dumpwallet(const UniValue& params, bool fHelp)
|
||||
"dumpwallet \"filename\"\n"
|
||||
"\nDumps taddr wallet keys in a human-readable format. Overwriting an existing file is not permitted.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"filename\" (string, required) The filename, saved in folder set by zcashd -exportdir option\n"
|
||||
"1. \"filename\" (string, required) The filename, saved in folder set by komodod -exportdir option\n"
|
||||
"\nResult:\n"
|
||||
"\"path\" (string) The full path of the destination file\n"
|
||||
"\nExamples:\n"
|
||||
@@ -475,7 +475,7 @@ UniValue dumpwallet_impl(const UniValue& params, bool fHelp, bool fDumpZKeys)
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, e.what());
|
||||
}
|
||||
if (exportdir.empty()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot export wallet until the zcashd -exportdir option has been set");
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot export wallet until the komodod -exportdir option has been set");
|
||||
}
|
||||
std::string unclean = params[0].get_str();
|
||||
std::string clean = SanitizeFilename(unclean);
|
||||
@@ -509,8 +509,8 @@ UniValue dumpwallet_impl(const UniValue& params, bool fHelp, bool fDumpZKeys)
|
||||
// produce output
|
||||
file << strprintf("# Wallet dump created by Komodo %s (%s)\n", CLIENT_BUILD, CLIENT_DATE);
|
||||
file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime()));
|
||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
|
||||
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime()));
|
||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.LastTip()->GetBlockHash().ToString());
|
||||
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.LastTip()->GetBlockTime()));
|
||||
file << "\n";
|
||||
for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
|
||||
const CKeyID &keyid = it->second;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,6 +46,7 @@ extern int32_t KOMODO_EXCHANGEWALLET;
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern int32_t VERUS_MIN_STAKEAGE;
|
||||
CBlockIndex *komodo_chainactive(int32_t height);
|
||||
extern std::string DONATION_PUBKEY;
|
||||
|
||||
/**
|
||||
* Fees smaller than this (in satoshi) are considered zero fee (for transaction creation)
|
||||
@@ -2044,7 +2045,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
||||
|
||||
ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
|
||||
double dProgressStart = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false);
|
||||
double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip(), false);
|
||||
double dProgressTip = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.LastTip(), false);
|
||||
while (pindex)
|
||||
{
|
||||
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0)
|
||||
@@ -2110,10 +2111,17 @@ void CWallet::ReacceptWalletTransactions()
|
||||
|
||||
bool CWalletTx::RelayWalletTransaction()
|
||||
{
|
||||
if ( pwallet == 0 )
|
||||
{
|
||||
fprintf(stderr,"unexpected null pwallet in RelayWalletTransaction\n");
|
||||
return(false);
|
||||
}
|
||||
assert(pwallet->GetBroadcastTransactions());
|
||||
if (!IsCoinBase())
|
||||
{
|
||||
if (GetDepthInMainChain() == 0) {
|
||||
if (GetDepthInMainChain() == 0)
|
||||
{
|
||||
// if tx is expired, dont relay
|
||||
LogPrintf("Relaying wtx %s\n", GetHash().ToString());
|
||||
RelayTransaction((CTransaction)*this);
|
||||
return true;
|
||||
@@ -2326,19 +2334,31 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
||||
LOCK(cs_wallet);
|
||||
// Sort them in chronological order
|
||||
multimap<unsigned int, CWalletTx*> mapSorted;
|
||||
uint32_t now = (uint32_t)time(NULL);
|
||||
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
||||
{
|
||||
CWalletTx& wtx = item.second;
|
||||
// Don't rebroadcast if newer than nTime:
|
||||
if (wtx.nTimeReceived > nTime)
|
||||
continue;
|
||||
//if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
if ( wtx.nLockTime >= LOCKTIME_THRESHOLD && wtx.nLockTime < now-KOMODO_MAXMEMPOOLTIME )
|
||||
{
|
||||
LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", wtx.GetHash().ToString(),(uint32_t)wtx.nLockTime,now);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
|
||||
}
|
||||
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
|
||||
{
|
||||
CWalletTx& wtx = *item.second;
|
||||
if (wtx.RelayWalletTransaction())
|
||||
result.push_back(wtx.GetHash());
|
||||
if ( item.second != 0 )
|
||||
{
|
||||
CWalletTx &wtx = *item.second;
|
||||
if (wtx.RelayWalletTransaction())
|
||||
result.push_back(wtx.GetHash());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -2511,20 +2531,20 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
|
||||
if ( KOMODO_EXCHANGEWALLET == 0 )
|
||||
{
|
||||
uint32_t locktime; int32_t txheight; CBlockIndex *tipindex;
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight >= 60000 )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.LastTip() != 0 && chainActive.LastTip()->nHeight >= 60000 )
|
||||
{
|
||||
if ( pcoin->vout[i].nValue >= 10*COIN )
|
||||
{
|
||||
if ( (tipindex= chainActive.Tip()) != 0 )
|
||||
if ( (tipindex= chainActive.LastTip()) != 0 )
|
||||
{
|
||||
komodo_accrued_interest(&txheight,&locktime,wtxid,i,0,pcoin->vout[i].nValue,(int32_t)tipindex->nHeight);
|
||||
interest = komodo_interestnew(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime);
|
||||
} else interest = 0;
|
||||
//interest = komodo_interestnew(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime);
|
||||
//interest = komodo_interestnew(chainActive.LastTip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.LastTip()->nTime);
|
||||
if ( interest != 0 )
|
||||
{
|
||||
//printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime);
|
||||
//fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,pcoin->nLockTime,chainActive.Tip()->nTime);
|
||||
//fprintf(stderr,"wallet nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,chainActive.LastTip()->nHeight+1,pcoin->nLockTime,chainActive.LastTip()->nTime);
|
||||
//ptr = (uint64_t *)&pcoin->vout[i].nValue;
|
||||
//(*ptr) += interest;
|
||||
ptr = (uint64_t *)&pcoin->vout[i].interest;
|
||||
@@ -2899,7 +2919,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
||||
int nextBlockHeight = chainActive.Height() + 1;
|
||||
CMutableTransaction txNew = CreateNewContextualCMutableTransaction(
|
||||
Params().GetConsensus(), nextBlockHeight);
|
||||
txNew.nLockTime = (uint32_t)chainActive.Tip()->nTime + 1; // set to a time close to now
|
||||
txNew.nLockTime = (uint32_t)chainActive.LastTip()->nTime + 1; // set to a time close to now
|
||||
|
||||
// Activates after Overwinter network upgrade
|
||||
// Set nExpiryHeight to expiryDelta (default 20) blocks past current block height
|
||||
@@ -3002,6 +3022,15 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
||||
//fprintf(stderr,"KOMODO_EXCHANGEWALLET disable interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN);
|
||||
//interest = 0; // interest2 also
|
||||
//}
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && DONATION_PUBKEY.size() == 66 && interest2 > 5000 )
|
||||
{
|
||||
CScript scriptDonation = CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG;
|
||||
CTxOut newTxOut(interest2,scriptDonation);
|
||||
int32_t nDonationPosRet = txNew.vout.size() - 1; // dont change first or last
|
||||
vector<CTxOut>::iterator position = txNew.vout.begin()+nDonationPosRet;
|
||||
txNew.vout.insert(position, newTxOut);
|
||||
interest2 = 0;
|
||||
}
|
||||
CAmount nChange = (nValueIn - nValue + interest2);
|
||||
//fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest2 %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest2/COIN,(double)nTotalValue/COIN);
|
||||
if (nSubtractFeeFromAmount == 0)
|
||||
|
||||
@@ -992,9 +992,9 @@ public:
|
||||
bool UpdateNullifierNoteMap();
|
||||
void UpdateNullifierNoteMapWithTx(const CWalletTx& wtx);
|
||||
bool AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb);
|
||||
void EraseFromWallet(const uint256 &hash);
|
||||
void SyncTransaction(const CTransaction& tx, const CBlock* pblock);
|
||||
bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate);
|
||||
void EraseFromWallet(const uint256 &hash);
|
||||
void WitnessNoteCommitment(
|
||||
std::vector<uint256> commitments,
|
||||
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
|
||||
|
||||
Reference in New Issue
Block a user