Fabcoin Core  0.16.2
P2P Digital Currency
Transaction.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
22 #pragma once
23 
24 #include <libdevcore/RLP.h>
25 #include <libdevcore/SHA3.h>
26 #include <libethcore/Common.h>
27 #include <libethcore/Transaction.h>
29 
30 namespace dev
31 {
32 namespace eth
33 {
34 
36 {
37  None = 0,
38  Unknown,
39  BadRLP,
45  OutOfGasBase,
49  OutOfGas,
50  OutOfStack,
54 };
55 
56 enum class CodeDeposit
57 {
58  None = 0,
59  Failed,
60  Success
61 };
62 
63 struct VMException;
64 
66 std::ostream& operator<<(std::ostream& _out, TransactionException const& _er);
67 
70 {
71  u256 gasUsed = 0;
76  u256 gasRefunded = 0;
77  unsigned depositSize = 0;
79 };
80 
81 std::ostream& operator<<(std::ostream& _out, ExecutionResult const& _er);
82 
85 {
86 public:
89 
91  Transaction(TransactionSkeleton const& _ts, Secret const& _s = Secret()): TransactionBase(_ts, _s) {}
92 
94  Transaction(u256 const& _value, u256 const& _gasPrice, u256 const& _gas, Address const& _dest, bytes const& _data, u256 const& _nonce, Secret const& _secret):
95  TransactionBase(_value, _gasPrice, _gas, _dest, _data, _nonce, _secret)
96  {}
97 
99  Transaction(u256 const& _value, u256 const& _gasPrice, u256 const& _gas, bytes const& _data, u256 const& _nonce, Secret const& _secret):
100  TransactionBase(_value, _gasPrice, _gas, _data, _nonce, _secret)
101  {}
102 
104  Transaction(u256 const& _value, u256 const& _gasPrice, u256 const& _gas, Address const& _dest, bytes const& _data, u256 const& _nonce = Invalid256):
105  TransactionBase(_value, _gasPrice, _gas, _dest, _data, _nonce)
106  {}
107 
109  Transaction(u256 const& _value, u256 const& _gasPrice, u256 const& _gas, bytes const& _data, u256 const& _nonce = Invalid256):
110  TransactionBase(_value, _gasPrice, _gas, _data, _nonce)
111  {}
112 
114  explicit Transaction(bytesConstRef _rlp, CheckTransaction _checkSig);
115 
117  explicit Transaction(bytes const& _rlp, CheckTransaction _checkSig): Transaction(&_rlp, _checkSig) {}
118 };
119 
121 using Transactions = std::vector<Transaction>;
122 
124 {
125 public:
127  Transaction const& _t,
128  h256 const& _blockHash,
129  unsigned _transactionIndex,
130  BlockNumber _blockNumber = 0
131  ):
132  Transaction(_t),
133  m_blockHash(_blockHash),
134  m_transactionIndex(_transactionIndex),
135  m_blockNumber(_blockNumber)
136  {}
137 
138  h256 const& blockHash() const { return m_blockHash; }
139  unsigned transactionIndex() const { return m_transactionIndex; }
140  BlockNumber blockNumber() const { return m_blockNumber; }
141 
142 private:
146 };
147 
148 }
149 }
Transaction(u256 const &_value, u256 const &_gasPrice, u256 const &_gas, Address const &_dest, bytes const &_data, u256 const &_nonce, Secret const &_secret)
Constructs a signed message-call transaction.
Definition: Transaction.h:94
unsigned transactionIndex() const
Definition: Transaction.h:139
Too little gas to pay for the base transaction cost.
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
BlockNumber blockNumber() const
Definition: Transaction.h:140
std::ostream & operator<<(std::ostream &_out, BlockHeader const &_bi)
Definition: BlockHeader.h:194
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
Definition: Transaction.h:121
SecureFixedHash< 32 > Secret
Definition: Common.h:35
Transaction(u256 const &_value, u256 const &_gasPrice, u256 const &_gas, bytes const &_data, u256 const &_nonce=Invalid256)
Constructs an unsigned contract-creation transaction.
Definition: Transaction.h:109
Transaction(u256 const &_value, u256 const &_gasPrice, u256 const &_gas, Address const &_dest, bytes const &_data, u256 const &_nonce=Invalid256)
Constructs an unsigned message-call transaction.
Definition: Transaction.h:104
Ran out of stack executing code of the transaction.
Transaction(bytes const &_rlp, CheckTransaction _checkSig)
Constructs a transaction from the given RLP.
Definition: Transaction.h:117
Description of the result of executing a transaction.
Definition: Transaction.h:69
unsigned BlockNumber
Definition: Common.h:72
Ran out of gas executing code of the transaction.
Base class for all exceptions.
Definition: Exceptions.h:39
std::vector< byte > bytes
Definition: Common.h:75
const u256 Invalid256
Definition: Common.cpp:38
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Definition: FixedHash.h:47
CheckTransaction
Definition: Transaction.h:42
LocalisedTransaction(Transaction const &_t, h256 const &_blockHash, unsigned _transactionIndex, BlockNumber _blockNumber=0)
Definition: Transaction.h:126
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
Encodes a transaction, ready to be exported to or freshly imported from RLP.
Definition: Transaction.h:84
u256 gasForDeposit
Amount of gas remaining for the code deposit phase.
Definition: Transaction.h:78
h256 const & blockHash() const
Definition: Transaction.h:138
Transaction(TransactionSkeleton const &_ts, Secret const &_s=Secret())
Constructs from a transaction skeleton & optional secret.
Definition: Transaction.h:91
Transaction()
Constructs a null transaction.
Definition: Transaction.h:88
Too little gas to pay for the base transaction cost.
TransactionException
Definition: Transaction.h:35
Encodes a transaction, ready to be exported to or freshly imported from RLP.
Definition: Transaction.h:50
Transaction(u256 const &_value, u256 const &_gasPrice, u256 const &_gas, bytes const &_data, u256 const &_nonce, Secret const &_secret)
Constructs a signed contract-creation transaction.
Definition: Transaction.h:99
TransactionException toTransactionException(Exception const &_e)
Definition: Transaction.cpp:42