wtx.MarkSpent(txin.prevout.n);
wtx.WriteToDisk();
NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED);
+ vMintingWalletUpdated.push_back(txin.prevout.hash);
}
}
}
wtx.MarkUnspent(&txout - &tx.vout[0]);
wtx.WriteToDisk();
NotifyTransactionChanged(this, hash, CT_UPDATED);
+ vMintingWalletUpdated.push_back(hash);
}
}
}
// Notify UI of new or updated transaction
NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
-
+ vMintingWalletUpdated.push_back(hash);
// notify an external script when a wallet transaction comes in or is updated
std::string strCmd = GetArg("-walletnotify", "");
}
if (fDebug)
- printf("Get stake weight: %zu meta items loaded for %zu coins\n", mapMeta.size(), setCoins.size());
+ printf("Get stake weight: %d meta items loaded for %d coins\n", mapMeta.size(), setCoins.size());
fCoinsDataActual = true;
}
}
if (fDebug)
- printf("Stake miner: %zu meta items loaded for %zu coins\n", mapMeta.size(), setCoins.size());
+ printf("Stake miner: %d meta items loaded for %d coins\n", mapMeta.size(), setCoins.size());
fCoinsDataActual = true;
}
CTxDB txdb("r");
if (!txNew.GetCoinAge(txdb, nCoinAge))
return error("CreateCoinStake : failed to calculate coin age");
- nCredit += GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
+
+ int64 nReward = GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
+ // Refuse to create mint that has zero or negative reward
+ if(nReward <= 0)
+ return false;
+
+ nCredit += nReward;
}
int64 nMinFee = 0;
coin.MarkSpent(txin.prevout.n);
coin.WriteToDisk();
NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED);
+ vMintingWalletUpdated.push_back(coin.GetHash());
}
if (fFileBacked)
// Only notify UI if this transaction is in this wallet
map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(hashTx);
if (mi != mapWallet.end())
+ {
NotifyTransactionChanged(this, hashTx, CT_UPDATED);
- vMintingWalletUpdated.push_back(hashTx);
+ vMintingWalletUpdated.push_back(hashTx);
+ }
}
}
for (std::map<CKeyID, CBlockIndex*>::const_iterator it = mapKeyFirstBlock.begin(); it != mapKeyFirstBlock.end(); it++)
mapKeyBirth[it->first] = it->second->nTime - 7200; // block times can be 2h off
}
+
+void CWallet::ClearOrphans()
+{
+ list<uint256> orphans;
+
+ LOCK(cs_wallet);
+ for(map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
+ {
+ const CWalletTx *wtx = &(*it).second;
+ if((wtx->IsCoinBase() || wtx->IsCoinStake()) && !wtx->IsInMainChain())
+ {
+ orphans.push_back(wtx->GetHash());
+ }
+ }
+
+ for(list<uint256>::const_iterator it = orphans.begin(); it != orphans.end(); ++it)
+ EraseFromWallet(*it);
+}