bool CCoins::Spend(const COutPoint &out, CTxInUndo &undo) { if (out.n >= vout.size()) return false; if (vout[out.n].IsNull()) return false; undo = CTxInUndo(vout[out.n]); vout[out.n].SetNull(); Cleanup(); if (vout.size() == 0) { undo.nHeight = nHeight; undo.fCoinBase = fCoinBase; undo.nVersion = this->nVersion; } return true; }
bool CCoins::Spend(uint32_t nPos, CTxInUndo* undo) { if (nPos >= vout.size() || vout[nPos].IsNull()) return false; if (undo) *undo = CTxInUndo(vout[nPos]); vout[nPos].SetNull(); Cleanup(); if (undo && vout.empty()) { undo->nHeight = nHeight; undo->fCoinBase = fCoinBase; undo->nVersion = nVersion; } return true; }