diff options
| author | Gavin Andresen <[email protected]> | 2013-09-23 14:23:14 -0700 |
|---|---|---|
| committer | Gavin Andresen <[email protected]> | 2013-09-23 14:23:14 -0700 |
| commit | fb8724ee6caa0e55bba9849d9a672b5467bcbc0f (patch) | |
| tree | 54a8eccef31de48f8d715bc8729b86d5888f2dce /src | |
| parent | Merge pull request #3016 from sipa/lows (diff) | |
| parent | Prune provably-unspendable outputs (diff) | |
| download | discoin-fb8724ee6caa0e55bba9849d9a672b5467bcbc0f.tar.xz discoin-fb8724ee6caa0e55bba9849d9a672b5467bcbc0f.zip | |
Merge pull request #2791 from sipa/proveprune
Prune provably-unspendable outputs
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.h | 8 | ||||
| -rw-r--r-- | src/script.h | 7 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/core.h b/src/core.h index 1b9d4dd76..a8828324f 100644 --- a/src/core.h +++ b/src/core.h @@ -389,7 +389,13 @@ public: 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) { } diff --git a/src/script.h b/src/script.h index f5ed61154..842b8512e 100644 --- a/src/script.h +++ b/src/script.h @@ -553,6 +553,13 @@ public: 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); |