diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 737e003dd..7709f9d7f 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -62,12 +62,12 @@ public: return ret; } - /// Create a new message call. - bool call(Address _receiveAddress, u256 _txValue, bytesConstRef _txData, u256* _gas, bytesRef _out, OnOpFunc const& _onOp = OnOpFunc()) + /// Create a new message call. Leave _myAddressOverride at he default to use the present address as caller. + bool call(Address _receiveAddress, u256 _txValue, bytesConstRef _txData, u256* _gas, bytesRef _out, OnOpFunc const& _onOp = OnOpFunc(), Address _myAddressOverride = Address()) { if (m_ms) m_ms->internal.resize(m_ms->internal.size() + 1); - auto ret = m_s.call(_receiveAddress, myAddress, _txValue, gasPrice, _txData, _gas, _out, origin, &suicides, &posts, m_ms ? &(m_ms->internal.back()) : nullptr, _onOp, level + 1); + auto ret = m_s.call(_receiveAddress, _myAddressOverride ? _myAddressOverride : myAddress, _txValue, gasPrice, _txData, _gas, _out, origin, &suicides, &posts, m_ms ? &(m_ms->internal.back()) : nullptr, _onOp, level + 1); if (m_ms && !m_ms->internal.back().from) m_ms->internal.pop_back(); return ret; @@ -100,7 +100,7 @@ public: while (posts.size()) { Post& p = posts.front(); - call(p.to, p.value, &p.data, &p.gas, bytesRef(), _onOp); + call(p.to, p.value, &p.data, &p.gas, bytesRef(), _onOp, p.from); ret += p.gas; posts.pop_front(); } diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 3fe7bea5a..7aa8df8e5 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -31,6 +31,7 @@ namespace eth struct Post { + Address from; Address to; u256 value; bytes data; @@ -79,7 +80,7 @@ public: bool call(Address, u256, bytesConstRef, u256*, bytesRef) { return false; } /// Post a new message call. - void post(Address _to, u256 _value, bytesConstRef _data, u256 _gas) { posts.push_back(Post({_to, _value, _data.toBytes(), _gas})); } + void post(Address _to, u256 _value, bytesConstRef _data, u256 _gas) { posts.push_back(Post({myAddress, _to, _value, _data.toBytes(), _gas})); } /// Revert any changes made (by any of the other calls). void revert() {}