aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto.cpp14
-rw-r--r--state.cpp7
-rw-r--r--vm.cpp38
3 files changed, 16 insertions, 43 deletions
diff --git a/crypto.cpp b/crypto.cpp
index b0785aca..3d818b41 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -450,16 +450,11 @@ BOOST_AUTO_TEST_CASE(eth_keypairs)
BOOST_REQUIRE(p.pub() == Public(fromHex("97466f2b32bc3bb76d4741ae51cd1d8578b48d3f1e68da206d47321aec267ce78549b514e4453d74ef11b0cd5e4e4c364effddac8b51bcfc8de80682f952896f")));
BOOST_REQUIRE(p.address() == Address(fromHex("8a40bfaa73256b60764c1bf40675a99083efb075")));
{
- eth::Transaction t;
- t.nonce = 0;
- t.type = eth::Transaction::MessageCall;
- t.receiveAddress = h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b"));
- t.value = 1000;
+ eth::Transaction t(1000, 0, 0, h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b")), bytes(), 0, p.secret());
auto rlp = t.rlp(false);
cnote << RLP(rlp);
cnote << toHex(rlp);
cnote << t.sha3(false);
- t.sign(p.secret());
rlp = t.rlp(true);
cnote << RLP(rlp);
cnote << toHex(rlp);
@@ -479,16 +474,11 @@ int cryptoTest()
BOOST_REQUIRE(p.pub() == Public(fromHex("97466f2b32bc3bb76d4741ae51cd1d8578b48d3f1e68da206d47321aec267ce78549b514e4453d74ef11b0cd5e4e4c364effddac8b51bcfc8de80682f952896f")));
BOOST_REQUIRE(p.address() == Address(fromHex("8a40bfaa73256b60764c1bf40675a99083efb075")));
{
- eth::Transaction t;
- t.nonce = 0;
- t.type = eth::Transaction::MessageCall;
- t.receiveAddress = h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b"));
- t.value = 1000;
+ eth::Transaction t(1000, 0, 0, h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b")), bytes(), 0, p.secret());
auto rlp = t.rlp(false);
cnote << RLP(rlp);
cnote << toHex(rlp);
cnote << t.sha3(false);
- t.sign(p.secret());
rlp = t.rlp(true);
cnote << RLP(rlp);
cnote << toHex(rlp);
diff --git a/state.cpp b/state.cpp
index b0f279ba..921be5f9 100644
--- a/state.cpp
+++ b/state.cpp
@@ -65,12 +65,7 @@ int stateTest()
// Inject a transaction to transfer funds from miner to me.
bytes tx;
{
- Transaction t;
- t.nonce = s.transactionsFrom(myMiner.address());
- t.value = 1000; // 1e3 wei.
- t.type = eth::Transaction::MessageCall;
- t.receiveAddress = me.address();
- t.sign(myMiner.secret());
+ Transaction t(1000, 0, 0, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret());
assert(t.sender() == myMiner.address());
tx = t.rlp();
}
diff --git a/vm.cpp b/vm.cpp
index 617cb95c..8344c0c5 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -36,11 +36,7 @@ FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const&
h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc const&)
{
- Transaction t;
- t.value = _endowment;
- t.gasPrice = gasPrice;
- t.gas = *_gas;
- t.data = _init.toBytes();
+ Transaction t(_endowment, gasPrice, *_gas, _init.toBytes());
m_s.noteSending(myAddress);
m_ms.internal.resize(m_ms.internal.size() + 1);
@@ -55,7 +51,6 @@ h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFun
get<3>(addresses[ret]) = m_s.code(ret);
}
- t.type = eth::Transaction::ContractCreation;
callcreates.push_back(t);
return ret;
}
@@ -64,13 +59,7 @@ bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data,
{
u256 contractgas = 0xffff;
- Transaction t;
- t.value = _value;
- t.gasPrice = gasPrice;
- t.gas = *_gas;
- t.data = _data.toVector();
- t.type = eth::Transaction::MessageCall;
- t.receiveAddress = _receiveAddress;
+ Transaction t(_value, gasPrice, *_gas, _receiveAddress, _data.toVector());
callcreates.push_back(t);
string codeOf_CodeAddress = _codeAddressOverride ? toHex(get<3>(addresses[_codeAddressOverride])) : toHex(get<3>(addresses[_receiveAddress]) );
@@ -386,10 +375,10 @@ mArray FakeExtVM::exportCallCreates()
for (Transaction const& tx: callcreates)
{
mObject o;
- o["destination"] = tx.type == Transaction::ContractCreation ? "" : toString(tx.receiveAddress);
- push(o, "gasLimit", tx.gas);
- push(o, "value", tx.value);
- o["data"] = "0x" + toHex(tx.data);
+ o["destination"] = tx.type() == Transaction::ContractCreation ? "" : toString(tx.receiveAddress());
+ push(o, "gasLimit", tx.gas());
+ push(o, "value", tx.value());
+ o["data"] = "0x" + toHex(tx.data());
ret.push_back(o);
}
return ret;
@@ -404,19 +393,18 @@ void FakeExtVM::importCallCreates(mArray& _callcreates)
BOOST_REQUIRE(tx.count("value") > 0);
BOOST_REQUIRE(tx.count("destination") > 0);
BOOST_REQUIRE(tx.count("gasLimit") > 0);
- Transaction t;
- t.type = tx["destination"].get_str().empty() ? Transaction::ContractCreation : Transaction::MessageCall;
- t.receiveAddress = Address(tx["destination"].get_str());
- t.value = toInt(tx["value"]);
- t.gas = toInt(tx["gasLimit"]);
+ bytes data;
if (tx["data"].type() == str_type)
if (tx["data"].get_str().find_first_of("0x") == 0)
- t.data = fromHex(tx["data"].get_str().substr(2));
+ data = fromHex(tx["data"].get_str().substr(2));
else
- t.data = fromHex(tx["data"].get_str());
+ data = fromHex(tx["data"].get_str());
else
for (auto const& j: tx["data"].get_array())
- t.data.push_back(toByte(j));
+ data.push_back(toByte(j));
+ Transaction t = tx["destination"].get_str().empty() ?
+ Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), data) :
+ Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), Address(tx["destination"].get_str()), data);
callcreates.push_back(t);
}
}