Skip to content

Commit

Permalink
Merge pull request #2791 from sipa/proveprune
Browse files Browse the repository at this point in the history
Prune provably-unspendable outputs
  • Loading branch information
gavinandresen committed Sep 23, 2013
2 parents a28fb70 + ec84e81 commit fb8724e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core.h
Expand Up @@ -389,7 +389,13 @@ class CCoins
int nVersion;

// construct a CCoins from a CTransaction, at a given height
CCoins(const CTransaction &tx, int nHeightIn) : fCoinBase(tx.IsCoinBase()), vout(tx.vout), nHeight(nHeightIn), nVersion(tx.nVersion) { }
CCoins(const CTransaction &tx, int nHeightIn) : fCoinBase(tx.IsCoinBase()), vout(tx.vout), nHeight(nHeightIn), nVersion(tx.nVersion) {
BOOST_FOREACH(CTxOut &txout, vout) {
if (txout.scriptPubKey.IsUnspendable())
txout.SetNull();
}
Cleanup();
}

// empty constructor
CCoins() : fCoinBase(false), vout(0), nHeight(0), nVersion(0) { }
Expand Down
7 changes: 7 additions & 0 deletions src/script.h
Expand Up @@ -553,6 +553,13 @@ class CScript : public std::vector<unsigned char>
return true;
}

// Returns whether the script is guaranteed to fail at execution,
// regardless of the initial stack. This allows outputs to be pruned
// instantly when entering the UTXO set.
bool IsUnspendable() const
{
return (size() > 0 && *begin() == OP_RETURN);
}

void SetDestination(const CTxDestination& address);
void SetMultisig(int nRequired, const std::vector<CPubKey>& keys);
Expand Down

0 comments on commit fb8724e

Please sign in to comment.