ppcoin: disable transaction (only for coinstake)
This commit is contained in:
@@ -486,6 +486,23 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid)
|
||||
}
|
||||
|
||||
|
||||
void CWallet::RemoveFromSpends(const COutPoint& outpoint, const uint256& wtxid)
|
||||
{
|
||||
pair<TxSpends::iterator, TxSpends::iterator> range;
|
||||
range = mapTxSpends.equal_range(outpoint);
|
||||
TxSpends::iterator it = range.first;
|
||||
for(; it != range.second; ++ it)
|
||||
{
|
||||
if(it->second == wtxid)
|
||||
{
|
||||
mapTxSpends.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
range = mapTxSpends.equal_range(outpoint);
|
||||
SyncMetaData(range);
|
||||
}
|
||||
|
||||
void CWallet::AddToSpends(const uint256& wtxid)
|
||||
{
|
||||
assert(mapWallet.count(wtxid));
|
||||
@@ -497,6 +514,17 @@ void CWallet::AddToSpends(const uint256& wtxid)
|
||||
AddToSpends(txin.prevout, wtxid);
|
||||
}
|
||||
|
||||
void CWallet::RemoveFromSpends(const uint256& wtxid)
|
||||
{
|
||||
assert(mapWallet.count(wtxid));
|
||||
CWalletTx& thisTx = mapWallet[wtxid];
|
||||
if (thisTx.IsCoinBase()) // Coinbases don't spend anything!
|
||||
return;
|
||||
|
||||
BOOST_FOREACH(const CTxIn& txin, thisTx.vin)
|
||||
RemoveFromSpends(txin.prevout, wtxid);
|
||||
}
|
||||
|
||||
void CWallet::AvailableCoinsForStaking(std::vector<COutput>& vCoins) const
|
||||
{
|
||||
vCoins.clear();
|
||||
@@ -1204,7 +1232,20 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
|
||||
|
||||
void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
|
||||
{
|
||||
LOCK2(cs_main, cs_wallet);
|
||||
|
||||
|
||||
|
||||
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))
|
||||
return; // Not one of ours
|
||||
@@ -3054,6 +3095,30 @@ std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAcco
|
||||
return result;
|
||||
}
|
||||
|
||||
// ppcoin: disable transaction (only for coinstake)
|
||||
void CWallet::DisableTransaction(const CTransaction &tx)
|
||||
{
|
||||
if (!tx.IsCoinStake() || !IsFromMe(tx))
|
||||
return; // only disconnecting coinstake requires marking input unspent
|
||||
|
||||
LOCK(cs_wallet);
|
||||
uint256 hash = tx.GetHash();
|
||||
if(AbandonTransaction(hash))
|
||||
{
|
||||
RemoveFromSpends(hash);
|
||||
set<CWalletTx*> setCoins;
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
{
|
||||
CWalletTx &coin = mapWallet[txin.prevout.hash];
|
||||
coin.BindWallet(this);
|
||||
NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED);
|
||||
}
|
||||
CWalletTx& wtx = mapWallet[hash];
|
||||
wtx.BindWallet(this);
|
||||
NotifyTransactionChanged(this, hash, CT_DELETED);
|
||||
}
|
||||
}
|
||||
|
||||
bool CReserveKey::GetReservedKey(CPubKey& pubkey)
|
||||
{
|
||||
if (nIndex == -1)
|
||||
|
||||
Reference in New Issue
Block a user