tombstone for import

This commit is contained in:
Scott Sadler
2018-04-17 08:40:02 -05:00
parent 0cb91a8d20
commit 3c7604133e
6 changed files with 109 additions and 29 deletions

View File

@@ -1332,15 +1332,19 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
view.SetBackend(viewMemPool);
// do we already have it?
// This is what stops coin import transactions from being double spent; they
// grow the UTXO set size slightly
if (view.HaveCoins(hash))
{
fprintf(stderr,"view.HaveCoins(hash) error\n");
return state.Invalid(false, REJECT_DUPLICATE, "already have coins");
}
if (!tx.IsCoinImport())
if (tx.IsCoinImport())
{
// Inverse of normal case; if input exists, it's been spent
if (ExistsImportTombstone(tx, view))
return state.Invalid(false, REJECT_DUPLICATE, "import tombstone exists");
}
else
{
// do all inputs exist?
// Note that this does not check for the presence of actual outputs (see the next check for that),
@@ -2007,6 +2011,13 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund
}
}
inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight); // add outputs
// Unorthodox state
if (tx.IsCoinImport()) {
// add a tombstone for the burnTx
AddImportTombstone(tx, inputs, nHeight);
}
}
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight)
@@ -2465,6 +2476,10 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
}
}
}
else if (tx.IsCoinImport())
{
RemoveImportTombstone(tx, view);
}
}
// set the old best anchor back