Merge pull request #2791 from sipa/proveprune
Prune provably-unspendable outputs
This commit is contained in:
commit
fb8724ee6c
2 changed files with 14 additions and 1 deletions
|
@ -389,7 +389,13 @@ public:
|
||||||
int nVersion;
|
int nVersion;
|
||||||
|
|
||||||
// construct a CCoins from a CTransaction, at a given height
|
// 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
|
// empty constructor
|
||||||
CCoins() : fCoinBase(false), vout(0), nHeight(0), nVersion(0) { }
|
CCoins() : fCoinBase(false), vout(0), nHeight(0), nVersion(0) { }
|
||||||
|
|
|
@ -553,6 +553,13 @@ public:
|
||||||
return true;
|
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 SetDestination(const CTxDestination& address);
|
||||||
void SetMultisig(int nRequired, const std::vector<CPubKey>& keys);
|
void SetMultisig(int nRequired, const std::vector<CPubKey>& keys);
|
||||||
|
|
Loading…
Reference in a new issue