From 85e3bd49397bfbba564148796704f938f6af87c2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 18 Nov 2014 13:40:32 +0100 Subject: [PATCH] Allow data to be passed in old way. --- libweb3jsonrpc/WebThreeStubServer.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 6a91080e3..8ee9ee722 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -310,9 +310,16 @@ static TransactionSkeleton toTransaction(Json::Value const& _json) else if (_json["gasPrice"].isInt()) ret.gas = u256(_json["gas"].asInt()); } - if (_json["data"].isString()) - ret.data = jsToBytes(_json["data"].asString()); - else if (_json["code"].isString()) + if (!_json["data"].empty()) + { + if (_json["data"].isString()) // ethereum.js has preconstructed the data array + ret.data = jsToBytes(_json["data"].asString()); + else if (_json["data"].isArray()) // old style: array of 32-byte-padded values. TODO: remove PoC-8 + for (auto i: _json["data"]) + dev::operator +=(ret.data, padded(jsToBytes(i.asString()), 32)); + } + + if (_json["code"].isString()) ret.data = jsToBytes(_json["code"].asString()); return ret; }