Merge remote-tracking branch 'janko33bd/Blackcoin-Lore' into build-fixes-0.13
This commit is contained in:
@@ -391,7 +391,7 @@ bool CWallet::SetMaxVersion(int nVersion)
|
||||
return true;
|
||||
}
|
||||
|
||||
set<uint256> CWallet::GetConflicts(const uint256& txid) const
|
||||
set<uint256> CWallet::GetConflicts(const uint256& txid, bool includeEquivalent) const
|
||||
{
|
||||
set<uint256> result;
|
||||
AssertLockHeld(cs_wallet);
|
||||
@@ -409,7 +409,8 @@ set<uint256> CWallet::GetConflicts(const uint256& txid) const
|
||||
continue; // No conflict if zero or one spends
|
||||
range = mapTxSpends.equal_range(txin.prevout);
|
||||
for (TxSpends::const_iterator it = range.first; it != range.second; ++it)
|
||||
result.insert(it->second);
|
||||
if (includeEquivalent || !wtx.IsEquivalentTo(mapWallet.at(it->second)))
|
||||
result.insert(it->second);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1196,6 +1197,20 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD
|
||||
// Notify UI of new or updated transaction
|
||||
NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
|
||||
|
||||
// Notifications for existing transactions that now have conflicts with this one
|
||||
if (fInsertedNew)
|
||||
{
|
||||
BOOST_FOREACH(const uint256& conflictHash, wtxIn.GetConflicts())
|
||||
{
|
||||
CWalletTx& txConflict = mapWallet[conflictHash];
|
||||
NotifyTransactionChanged(this, conflictHash, CT_UPDATED); //Updates UI table
|
||||
if (IsFromMe(txConflict) || IsMine(txConflict))
|
||||
{
|
||||
NotifyTransactionChanged(this, conflictHash, CT_GOT_CONFLICT); //Throws dialog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// notify an external script when a wallet transaction comes in or is updated
|
||||
std::string strCmd = GetArg("-walletnotify", "");
|
||||
|
||||
@@ -1205,6 +1220,15 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD
|
||||
boost::thread t(runCommand, strCmd); // thread runs free
|
||||
}
|
||||
|
||||
// external respend notify
|
||||
std::string strCmdRespend = GetArg("-respendnotify", "");
|
||||
if (!strCmdRespend.empty())
|
||||
{
|
||||
boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex());
|
||||
boost::replace_all(strCmd, "%t", hash.GetHex());
|
||||
boost::thread t(runCommand, strCmd); // thread runs free
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1214,7 +1238,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD
|
||||
* pblock is optional, but should be provided if the transaction is known to be in a block.
|
||||
* If fUpdate is true, existing transactions will be updated.
|
||||
*/
|
||||
bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate)
|
||||
bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate, bool fRespend)
|
||||
{
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
@@ -1234,7 +1258,15 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
||||
|
||||
bool fExisted = mapWallet.count(tx.GetHash()) != 0;
|
||||
if (fExisted && !fUpdate) return false;
|
||||
if (fExisted || IsMine(tx) || IsFromMe(tx))
|
||||
|
||||
bool fIsConflicting = IsConflicting(tx);
|
||||
// Don't add respends that pay us, unless they conflict with us. Prevents resource exhaustion.
|
||||
if (!fIsConflicting && fRespend) return false;
|
||||
|
||||
if (fIsConflicting)
|
||||
nConflictsReceived++;
|
||||
|
||||
if (fExisted || IsMine(tx) || IsFromMe(tx) || fIsConflicting)
|
||||
{
|
||||
CWalletTx wtx(this,tx);
|
||||
|
||||
@@ -1369,24 +1401,21 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
|
||||
void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock, bool fRespend)
|
||||
{
|
||||
LOCK2(cs_main, cs_wallet);
|
||||
|
||||
if (!pblock) {
|
||||
// wallets need to refund inputs when disconnecting coinstake
|
||||
if (tx.IsCoinStake()) {
|
||||
if (IsFromMe(tx)) {
|
||||
DisableTransaction(tx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCK2(cs_main, cs_wallet);
|
||||
|
||||
if (!pblock) {
|
||||
// wallets need to refund inputs when disconnecting coinstake
|
||||
if (tx.IsCoinStake()) {
|
||||
if (IsFromMe(tx)) {
|
||||
DisableTransaction(tx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!AddToWalletIfInvolvingMe(tx, pblock, true))
|
||||
if (!AddToWalletIfInvolvingMe(tx, pblock, true, fRespend))
|
||||
return; // Not one of ours
|
||||
|
||||
// If a transaction changes 'conflicted' state, that changes the balance
|
||||
@@ -1415,6 +1444,14 @@ isminetype CWallet::IsMine(const CTxIn &txin) const
|
||||
return ISMINE_NO;
|
||||
}
|
||||
|
||||
bool CWallet::IsConflicting(const CTransaction& tx) const
|
||||
{
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
if (mapTxSpends.count(txin.prevout))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
|
||||
{
|
||||
{
|
||||
@@ -1751,7 +1788,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
||||
ReadBlockFromDisk(block, pindex, Params().GetConsensus());
|
||||
BOOST_FOREACH(CTransaction& tx, block.vtx)
|
||||
{
|
||||
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate))
|
||||
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate, false))
|
||||
ret++;
|
||||
}
|
||||
pindex = chainActive.Next(pindex);
|
||||
@@ -1782,7 +1819,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
|
||||
int nDepth = wtx.GetDepthInMainChain();
|
||||
|
||||
if (!wtx.IsCoinBase() && !wtx.IsCoinStake() && (nDepth == 0 && !wtx.isAbandoned())) {
|
||||
if (!wtx.IsCoinBase() && !wtx.IsCoinStake() && (nDepth == 0 && !wtx.isAbandoned() && (IsMine(wtx) || IsFromMe(wtx)))) {
|
||||
mapSorted.insert(std::make_pair(wtx.nOrderPos, &wtx));
|
||||
}
|
||||
}
|
||||
@@ -1811,13 +1848,13 @@ bool CWalletTx::RelayWalletTransaction()
|
||||
return false;
|
||||
}
|
||||
|
||||
set<uint256> CWalletTx::GetConflicts() const
|
||||
set<uint256> CWalletTx::GetConflicts(bool includeEquivalent) const
|
||||
{
|
||||
set<uint256> result;
|
||||
if (pwallet != NULL)
|
||||
{
|
||||
uint256 myHash = GetHash();
|
||||
result = pwallet->GetConflicts(myHash);
|
||||
result = pwallet->GetConflicts(myHash, includeEquivalent);
|
||||
result.erase(myHash);
|
||||
}
|
||||
return result;
|
||||
@@ -3436,9 +3473,9 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx)
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::GetScriptForMining(boost::shared_ptr<CReserveScript> &script)
|
||||
void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script)
|
||||
{
|
||||
boost::shared_ptr<CReserveKey> rKey(new CReserveKey(this));
|
||||
std::shared_ptr<CReserveKey> rKey = std::make_shared<CReserveKey>(this);
|
||||
CPubKey pubkey;
|
||||
if (!rKey->GetReservedKey(pubkey))
|
||||
return;
|
||||
@@ -3667,6 +3704,7 @@ std::string CWallet::GetWalletHelpString(bool showDebug)
|
||||
strUsage += HelpMessageOpt("-wallet=<file>", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT));
|
||||
strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), DEFAULT_WALLETBROADCAST));
|
||||
strUsage += HelpMessageOpt("-walletnotify=<cmd>", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)"));
|
||||
strUsage += HelpMessageOpt("-respendnotify=<cmd>", _("Execute command when a network tx respends wallet tx input (%s=respend TxID, %t=wallet TxID)"));
|
||||
strUsage += HelpMessageOpt("-zapwallettxes=<mode>", _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") +
|
||||
" " + _("(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user