|
|
@ -24,7 +24,7 @@ |
|
|
|
#include <libdevcore/RLP.h> |
|
|
|
#include <libdevcrypto/SHA3.h> |
|
|
|
#include <libethcore/Common.h> |
|
|
|
|
|
|
|
#include <libethcore/Params.h> |
|
|
|
namespace dev |
|
|
|
{ |
|
|
|
namespace eth |
|
|
@ -37,11 +37,11 @@ enum IncludeSignature |
|
|
|
WithSignature = 1, ///< Do include a signature.
|
|
|
|
}; |
|
|
|
|
|
|
|
enum class CheckSignature |
|
|
|
enum class CheckTransaction |
|
|
|
{ |
|
|
|
None, |
|
|
|
Range, |
|
|
|
Sender |
|
|
|
Cheap, |
|
|
|
Everything |
|
|
|
}; |
|
|
|
|
|
|
|
enum class TransactionException |
|
|
@ -119,10 +119,10 @@ public: |
|
|
|
Transaction(u256 const& _value, u256 const& _gasPrice, u256 const& _gas, bytes const& _data): m_type(ContractCreation), m_value(_value), m_gasPrice(_gasPrice), m_gas(_gas), m_data(_data) {} |
|
|
|
|
|
|
|
/// Constructs a transaction from the given RLP.
|
|
|
|
explicit Transaction(bytesConstRef _rlp, CheckSignature _checkSig); |
|
|
|
explicit Transaction(bytesConstRef _rlp, CheckTransaction _checkSig); |
|
|
|
|
|
|
|
/// Constructs a transaction from the given RLP.
|
|
|
|
explicit Transaction(bytes const& _rlp, CheckSignature _checkSig): Transaction(&_rlp, _checkSig) {} |
|
|
|
explicit Transaction(bytes const& _rlp, CheckTransaction _checkSig): Transaction(&_rlp, _checkSig) {} |
|
|
|
|
|
|
|
|
|
|
|
/// Checks equality of transactions.
|
|
|
@ -178,6 +178,15 @@ public: |
|
|
|
/// @returns the signature of the transaction. Encodes the sender.
|
|
|
|
SignatureStruct const& signature() const { return m_vrs; } |
|
|
|
|
|
|
|
/// @returns true if the transaction contains enough gas for the basic payment.
|
|
|
|
bool checkPayment() const { return m_gas >= gasRequired(); } |
|
|
|
|
|
|
|
/// @returns the gas required to run this transaction.
|
|
|
|
bigint gasRequired() const; |
|
|
|
|
|
|
|
/// Get the fee associated for a transaction with the given data.
|
|
|
|
template <class T> static bigint gasRequired(T const& _data, u256 _gas = 0) { bigint ret = c_txGas + _gas; for (auto i: _data) ret += i ? c_txDataNonZeroGas : c_txDataZeroGas; return ret; } |
|
|
|
|
|
|
|
private: |
|
|
|
/// Type of transaction.
|
|
|
|
enum Type |
|
|
@ -199,6 +208,7 @@ private: |
|
|
|
SignatureStruct m_vrs; ///< The signature of the transaction. Encodes the sender.
|
|
|
|
|
|
|
|
mutable Address m_sender; ///< Cached sender, determined from signature.
|
|
|
|
mutable bigint m_gasRequired = 0; ///< Memoised amount required for the transaction to run.
|
|
|
|
}; |
|
|
|
|
|
|
|
/// Nice name for vector of Transaction.
|
|
|
|