diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-03-13 17:22:07 -0400 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-03-20 15:34:43 -0400 |
commit | 2f2ac3fece6c7f576c5957f05f342f2830301b54 (patch) | |
tree | 1c6fd5b8c24d00483e5863b1c191560663384101 /src/main.h | |
parent | 11c34e0f6cf9cb2715c28b85a1ec8f47bf5ca8dd (diff) | |
download | bitcoin-2f2ac3fece6c7f576c5957f05f342f2830301b54.tar.xz |
Minimal support for validating BIP16 pay-to-script-hash transactions
Note this does NOT include accepting them in blocks (making them standard)
Diffstat (limited to 'src/main.h')
-rw-r--r-- | src/main.h | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/main.h b/src/main.h index 3e381b060b..f29ccde080 100644 --- a/src/main.h +++ b/src/main.h @@ -386,6 +386,7 @@ public: }; +typedef std::map<uint256, std::pair<CTxIndex, CTransaction> > MapPrevTx; // @@ -494,6 +495,15 @@ public: return n; } + /** Count ECDSA signature operations in pay-to-script-hash inputs. + This is a better measure of how expensive it is to process this transaction. + + @param[in] mapInputsMap of previous transactions that have outputs we're spending + @return maximum number of sigops required to validate this transaction's inputs + @see CTransaction::FetchInputs + */ + int GetP2SHSigOpCount(const MapPrevTx& mapInputs) const; + bool IsStandard() const { BOOST_FOREACH(const CTxIn& txin, vin) @@ -517,6 +527,16 @@ public: return nValueOut; } + /** Amount of bitcoins coming in to this transaction + Note that lightweight clients may not know anything besides the hash of previous transactions, + so may not be able to calculate this. + + @param[in] mapInputsMap of previous transactions that have outputs we're spending + @returnSum of value of all inputs (scriptSigs) + @see CTransaction::FetchInputs + */ + int64 GetValueIn(const MapPrevTx& mapInputs) const; + static bool AllowFree(double dPriority) { // Large (in bytes) low-priority (new, small-coin) transactions @@ -631,14 +651,41 @@ public: bool ReadFromDisk(CTxDB& txdb, COutPoint prevout); bool ReadFromDisk(COutPoint prevout); bool DisconnectInputs(CTxDB& txdb); - bool ConnectInputs(CTxDB& txdb, std::map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx, - CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee, - bool& fInvalid); + + /** Fetch from memory and/or disk. inputsRet keys are transaction hashes. + + @param[in] txdb Transaction database + @param[in] mapTestPool List of pending changes to the transaction index database + @param[in] fBlock True if being called to add a new best-block to the chain + @param[in] fMiner True if being called by CreateNewBlock + @param[out] inputsRet Pointers to this transaction's inputs + @param[out] fInvalid returns true if transaction is invalid + @return Returns true if all inputs are in txdb or mapTestPool + */ + bool FetchInputs(CTxDB& txdb, const std::map<uint256, CTxIndex>& mapTestPool, + bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid); + + /** Sanity check previous transactions, then, if all checks succeed, + mark them as spent by this transaction. + + @param[in] inputsPrevious transactions (from FetchInputs) + @param[out] mapTestPoolKeeps track of inputs that need to be updated on disk + @param[in] posThisTxPosition of this transaction on disk + @param[in] pindexBlock + @param[in] fBlock true if called from ConnectBlock + @param[in] fMiner true if called from CreateNewBlock + @param[in] fStrictPayToScriptHash true if fully validating p2sh transactions + @return Returns true if all checks succeed + */ + bool ConnectInputs(MapPrevTx inputs, + std::map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx, + const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, bool fStrictPayToScriptHash=true); bool ClientConnectInputs(); bool CheckTransaction() const; bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL); bool AcceptToMemoryPool(bool fCheckInputs=true, bool* pfMissingInputs=NULL); protected: + const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const; bool AddToMemoryPoolUnchecked(); public: bool RemoveFromMemoryPool(); |