Skip to content

Commit d1738bc

Browse files
rename sign_hex->sign_trx; remove chainid from command sign_trx
1 parent b93ed95 commit d1738bc

16 files changed

+39
-50
lines changed

keychain_cmd_app/sec_mod.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ std::string keychain_app::sec_mod_dummy::exec_cmd(const std::string& json_cmd) c
3030
case secmod_commands::events_te::export_keys:
3131
case secmod_commands::events_te::import_keys:
3232
break;
33-
case secmod_commands::events_te::sign_hex:
34-
no_password = parser.params<secmod_commands::events_te::sign_hex>().no_password;
33+
case secmod_commands::events_te::sign_trx:
34+
no_password = parser.params<secmod_commands::events_te::sign_trx>().no_password;
3535
break;
3636
case secmod_commands::events_te::sign_hash:
3737
no_password = parser.params<secmod_commands::events_te::sign_hash>().no_password;

keychain_lib/include/keychain_lib/keychain_commands.hpp

+7-16
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ enum struct command_te {
236236
null = 0,
237237
about,
238238
version,
239-
sign_hex,
239+
sign_trx,
240240
sign_hash,
241241
// create,
242242
select_key,
@@ -328,14 +328,13 @@ struct keychain_command<command_te::select_key>: keychain_command_base
328328
};
329329

330330
template<>
331-
struct keychain_command<command_te::sign_hex> : keychain_command_base
331+
struct keychain_command<command_te::sign_trx> : keychain_command_base
332332
{
333-
keychain_command():keychain_command_base(command_te::sign_hex) {}
333+
keychain_command():keychain_command_base(command_te::sign_trx) {}
334334
virtual ~keychain_command(){}
335335
struct params
336336
{
337337
params():unlock_time(0){};
338-
std::string chainid;
339338
std::string transaction;
340339
blockchain_te blockchain_type;
341340
dev::Public public_key;
@@ -354,15 +353,11 @@ struct keychain_command<command_te::sign_hex> : keychain_command_base
354353

355354
unit_list_t unit_list;
356355
dev::Signature signature;
357-
std::vector<unsigned char> chain(32);
358356
std::vector<unsigned char> raw(params.transaction.length());
359357
fc_light::variant json;
360358
dev::Secret private_key;
361359
auto& keyfiles = keyfile_singleton::instance();
362360

363-
if (!params.chainid.empty())
364-
auto chain_len = keychain_app::from_hex(params.chainid, chain.data(), chain.size());
365-
366361
//NOTE: using vector instead array because move semantic is implemented in the vector
367362
auto trans_len = keychain_app::from_hex(params.transaction, raw.data(), raw.size());
368363
raw.resize(trans_len);
@@ -410,7 +405,7 @@ struct keychain_command<command_te::sign_hex> : keychain_command_base
410405

411406
auto reply = [&keyfiles, &params, &id](auto& message, const dev::bytes& transaction){
412407
keyfiles.add_log_record(params.public_key,
413-
keyfile_format::log_record(transaction, fc_light::time_point::now(), params.blockchain_type, params.chainid ));
408+
keyfile_format::log_record(transaction, fc_light::time_point::now(), params.blockchain_type ));
414409
json_response response(fc_light::variant(message), id);
415410
fc_light::variant res(response);
416411
return fc_light::json::to_string(res);
@@ -420,8 +415,6 @@ struct keychain_command<command_te::sign_hex> : keychain_command_base
420415
{
421416
case blockchain_te::bitshares:
422417
{
423-
if (chain.size())
424-
unit_list.push_back(chain);
425418
unit_list.push_back(raw);
426419

427420
std::array<unsigned char, 65> signature_;
@@ -432,8 +425,6 @@ struct keychain_command<command_te::sign_hex> : keychain_command_base
432425
}
433426
case blockchain_te::array:
434427
{
435-
if (chain.size())
436-
unit_list.push_back(chain);
437428
unit_list.push_back(raw);
438429

439430
signature = dev::sign(private_key,dev::FixedHash<32>(((byte const*) get_hash(unit_list, dev::openssl::sha3_256_encoder()).data()),
@@ -659,7 +650,7 @@ struct keychain_command<command_te::sign_hash> : keychain_command_base
659650
dev::bytes hash_vec;
660651
std::copy(params.hash.begin(), params.hash.end(), std::back_inserter(hash_vec));
661652
keyfiles.add_log_record(params.public_key,
662-
keyfile_format::log_record(hash_vec, fc_light::time_point::now(), blockchain_te::rawhash, ""));
653+
keyfile_format::log_record(hash_vec, fc_light::time_point::now(), blockchain_te::rawhash));
663654
json_response response(fc_light::variant(signature), id);
664655
fc_light::variant res(response);
665656
return fc_light::json::to_string(res);
@@ -899,7 +890,7 @@ FC_LIGHT_REFLECT_ENUM(
899890
(null)
900891
(about)
901892
(version)
902-
(sign_hex)
893+
(sign_trx)
903894
(sign_hash)
904895
// (create)
905896
(select_key)
@@ -915,7 +906,7 @@ FC_LIGHT_REFLECT_ENUM(
915906
(last)
916907
)
917908

918-
FC_LIGHT_REFLECT(keychain_app::keychain_command<keychain_app::command_te::sign_hex>::params_t, (chainid)(transaction)(blockchain_type)(public_key)(unlock_time))
909+
FC_LIGHT_REFLECT(keychain_app::keychain_command<keychain_app::command_te::sign_trx>::params_t, (transaction)(blockchain_type)(public_key)(unlock_time))
919910
FC_LIGHT_REFLECT(keychain_app::keychain_command<keychain_app::command_te::sign_hash>::params_t, (hash)(sign_type)(public_key))
920911
//FC_LIGHT_REFLECT(keychain_app::keychain_command<keychain_app::command_te::create>::params_t, (keyname)(description)(encrypted)(cipher)(curve))
921912
FC_LIGHT_REFLECT(keychain_app::keychain_command<keychain_app::command_te::public_key>::params_t, (keyname))

keychain_lib/include/keychain_lib/keyfile_parser.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ struct keyfile_t {
6767
struct log_record
6868
{
6969
log_record(): blockchain_type(blockchain_te::unknown){}
70-
log_record(const dev::bytes& transaction_, const fc_light::time_point& sign_time_, blockchain_te blockchain_type_, const std::string& chainid_)
70+
log_record(const dev::bytes& transaction_, const fc_light::time_point& sign_time_, blockchain_te blockchain_type_)
7171
: transaction(transaction_)
7272
, sign_time(sign_time_)
73-
, blockchain_type(blockchain_type_)
74-
, chainid(chainid_) {}
73+
, blockchain_type(blockchain_type_) {}
7574
dev::bytes transaction;
7675
fc_light::time_point sign_time;
7776
blockchain_te blockchain_type;
78-
std::string chainid;
7977
};
8078

8179
struct signlog_file_t
@@ -92,7 +90,7 @@ struct signlog_file_t
9290
FC_LIGHT_REFLECT_ENUM(keychain_app::keyfile_format::cipher_etype, (unknown)(aes128)(aes192)(aes256))
9391
FC_LIGHT_REFLECT_ENUM(keychain_app::keyfile_format::file_type, (TYPE_UNKNOWN)(TYPE_KEY)(TYPE_LOG))
9492
FC_LIGHT_REFLECT_ENUM(keychain_app::keyfile_format::curve_etype, (unknown)(secp256k1))
95-
FC_LIGHT_REFLECT(keychain_app::keyfile_format::log_record, (transaction)(sign_time)(blockchain_type)(chainid))
93+
FC_LIGHT_REFLECT(keychain_app::keyfile_format::log_record, (transaction)(sign_time)(blockchain_type))
9694
FC_LIGHT_REFLECT(keychain_app::keyfile_format::signlog_file_t, (filetype)(public_key)(sign_events))
9795
FC_LIGHT_REFLECT(keychain_app::keyfile_format::encrypted_data, (cipher_type)(iv)(enc_data))
9896
FC_LIGHT_REFLECT(keychain_app::keyfile_format::keyfile_t::keyinfo_t, (encrypted)(curve_type)(priv_key_data)(public_key))

keychain_lib/include/keychain_lib/secmod_parser_cmd.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace keychain_app
1515
namespace secmod_commands
1616
{
1717

18-
using signhex_event = secmod_event<events_te::sign_hex>::params_t;
18+
using signhex_event = secmod_event<events_te::sign_trx>::params_t;
1919

2020
std::string to_expert_mode_string(const signhex_event& signhex_event);
2121

keychain_lib/include/keychain_lib/secmod_protocol.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct transaction_view<blockchain_secmod_te::bitcoin> {
100100
enum struct events_te {
101101
unknown = 0,
102102
create_key,
103-
sign_hex,
103+
sign_trx,
104104
sign_hash,
105105
unlock,
106106
edit_key,
@@ -129,7 +129,7 @@ struct secmod_event<events_te::create_key>
129129
};
130130

131131
template<>
132-
struct secmod_event<events_te::sign_hex>
132+
struct secmod_event<events_te::sign_trx>
133133
{
134134
struct params {
135135
params() : is_parsed(false), no_password(false), unlock_time(0) {}
@@ -271,12 +271,12 @@ struct secmod_response_common
271271

272272
FC_LIGHT_REFLECT_ENUM(keychain_app::secmod_commands::blockchain_secmod_te, (unknown)(ethereum)(bitcoin)(ethereum_swap))
273273
FC_LIGHT_REFLECT_ENUM(keychain_app::secmod_commands::events_te,
274-
(unknown)(create_key)(sign_hex)(sign_hash)(unlock)(edit_key)(remove_key)(export_keys)(import_keys)(print_mnemonic))
274+
(unknown)(create_key)(sign_trx)(sign_hash)(unlock)(edit_key)(remove_key)(export_keys)(import_keys)(print_mnemonic))
275275
FC_LIGHT_REFLECT_ENUM(keychain_app::secmod_commands::response_te, (null)(password)(boolean)(canceled))
276276

277277

278278
FC_LIGHT_REFLECT(keychain_app::secmod_commands::secmod_event<keychain_app::secmod_commands::events_te::create_key>::params_t, (keyname))
279-
FC_LIGHT_REFLECT(keychain_app::secmod_commands::secmod_event<keychain_app::secmod_commands::events_te::sign_hex>::params_t, (is_parsed)(no_password)(keyname)(blockchain)(unlock_time)(trx_view))
279+
FC_LIGHT_REFLECT(keychain_app::secmod_commands::secmod_event<keychain_app::secmod_commands::events_te::sign_trx>::params_t, (is_parsed)(no_password)(keyname)(blockchain)(unlock_time)(trx_view))
280280
FC_LIGHT_REFLECT(keychain_app::secmod_commands::secmod_event<keychain_app::secmod_commands::events_te::sign_hash>::params_t, (no_password)(keyname)(from)(hash))
281281
FC_LIGHT_REFLECT(keychain_app::secmod_commands::secmod_event<keychain_app::secmod_commands::events_te::unlock>::params_t, (no_password)(keyname)(unlock_time))
282282
FC_LIGHT_REFLECT(keychain_app::secmod_commands::secmod_event<keychain_app::secmod_commands::events_te::edit_key>::params_t, (keyname)(unlock_time))

keychain_lib/src/keychain_commands.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fc_light::variant create_secmod_signhex_cmd(const std::vector<unsigned char>& ra
5858
std::string json;
5959
auto& log = logger_singleton::instance();
6060
secmod_commands::secmod_command cmd;
61-
using params_t = secmod_commands::secmod_event<secmod_commands::events_te::sign_hex>::params_t;
61+
using params_t = secmod_commands::secmod_event<secmod_commands::events_te::sign_trx>::params_t;
6262
params_t params;
6363
params.is_parsed = true;
6464
params.keyname = keyname;
@@ -138,7 +138,7 @@ fc_light::variant create_secmod_signhex_cmd(const std::vector<unsigned char>& ra
138138
}
139139
}
140140
params.unlock_time = unlock_time;
141-
cmd.etype = secmod_commands::events_te::sign_hex;
141+
cmd.etype = secmod_commands::events_te::sign_trx;
142142
cmd.params = params;
143143
return fc_light::variant(cmd);
144144
}

keychain_linux/passentry_gui/src/BitcoinWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ BitcoinWidget::BitcoinWidget( QWidget * parent)
3232

3333
//}
3434
namespace sm_cmd = keychain_app::secmod_commands;
35-
auto event = shared_event::ptr<sm_cmd::events_te::sign_hex>();
35+
auto event = shared_event::ptr<sm_cmd::events_te::sign_trx>();
3636
auto trx = event.get()->get_trx_view<sm_cmd::blockchain_secmod_te::bitcoin>();
3737

3838
bool overflow = false;

keychain_linux/passentry_gui/src/EthereumSwapWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ EthereumSwapWidget::EthereumSwapWidget(QWidget * parent)
1515

1616
//QList<QString> fieldList({ "From","To","Amount" });
1717
namespace sm_cmd = keychain_app::secmod_commands;
18-
auto event = shared_event::ptr<sm_cmd::events_te::sign_hex>();
18+
auto event = shared_event::ptr<sm_cmd::events_te::sign_trx>();
1919
auto trx = event.get()->get_trx_view<sm_cmd::blockchain_secmod_te::ethereum_swap>();
2020

2121
action = new SecureWindowElement(this);

keychain_linux/passentry_gui/src/EthereumWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ EthereumWidget::EthereumWidget(QWidget * parent)
1616

1717
//QList<QString> fieldList({ "From","To","Amount" });
1818
namespace sm_cmd = keychain_app::secmod_commands;
19-
auto event = shared_event::ptr<sm_cmd::events_te::sign_hex>();
19+
auto event = shared_event::ptr<sm_cmd::events_te::sign_trx>();
2020
auto trx = event.get()->get_trx_view<sm_cmd::blockchain_secmod_te::ethereum>();
2121

2222
from = new SecureWindowElement(this);

keychain_linux/passentry_gui/src/UnlockKeyWidget.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ UnlockKeyWidget::UnlockKeyWidget(QWidget * parent)
1414
auto event_num = shared_event::event_num();
1515
int time;
1616
switch(event_num) {
17-
case (sm_cmd::events_te::sign_hex): {
18-
auto event = shared_event::ptr<sm_cmd::events_te::sign_hex>();
17+
case (sm_cmd::events_te::sign_trx): {
18+
auto event = shared_event::ptr<sm_cmd::events_te::sign_trx>();
1919
time = event.get()->unlock_time;
2020
break;
2121
}

keychain_linux/passentry_gui/src/UnparsedTransactionWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ UnparsedTransactionWidget::UnparsedTransactionWidget(QWidget * parent)
1111
QString labelStyle("font:16px \"Segoe UI\";background:transparent;");
1212

1313
namespace sm_cmd = keychain_app::secmod_commands;
14-
auto event = shared_event::ptr<sm_cmd::events_te::sign_hex>();
14+
auto event = shared_event::ptr<sm_cmd::events_te::sign_trx>();
1515

1616
expertModeElement = new ExpertModeElement(this);
1717
expertModeElement->SetExpertModeText(QString::fromStdString(

keychain_linux/passentry_gui/src/cmd.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ namespace slave
4747
event_num = sm_cmd::events_te::create_key;
4848
break;
4949
}
50-
case sm_cmd::events_te::sign_hex:
50+
case sm_cmd::events_te::sign_trx:
5151
{
52-
auto& event = shared_event::ptr<sm_cmd::events_te::sign_hex>();
53-
event.reset(new sm_cmd::secmod_event<sm_cmd::events_te::sign_hex>::params_t (
54-
std::move(event_parser.params<sm_cmd::events_te::sign_hex>())
52+
auto& event = shared_event::ptr<sm_cmd::events_te::sign_trx>();
53+
event.reset(new sm_cmd::secmod_event<sm_cmd::events_te::sign_trx>::params_t (
54+
std::move(event_parser.params<sm_cmd::events_te::sign_trx>())
5555
));
5656
auto& event_num = shared_event::event_num();
57-
event_num = sm_cmd::events_te::sign_hex;
57+
event_num = sm_cmd::events_te::sign_trx;
5858
break;
5959
}
6060
case sm_cmd::events_te::sign_hash:

keychain_linux/passentry_gui/src/keychain_gui_win.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ void keychain_gui_win::refresh()
7171
OKButton = new QPushButton("CREATE", this);
7272
break;
7373
}
74-
case(sm_cmd::events_te::sign_hex):
74+
case(sm_cmd::events_te::sign_trx):
7575
{
76-
auto event = shared_event::ptr<sm_cmd::events_te::sign_hex>();
76+
auto event = shared_event::ptr<sm_cmd::events_te::sign_trx>();
7777
if (event.get()->unlock_time)
7878
{
7979
OKButton = new QPushButton("UNLOCK", this);

keychain_win/keychain_gui/include/EventsHandlers.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ struct EventHandler< sm_cmd::events_te::create_key> : EventHandlerBase
3535
};
3636

3737
template <>
38-
struct EventHandler < sm_cmd::events_te::sign_hex > : EventHandlerBase
38+
struct EventHandler < sm_cmd::events_te::sign_trx > : EventHandlerBase
3939
{
40-
EventHandler() :EventHandlerBase(static_cast<sm_cmd::events_te>(sm_cmd::events_te::sign_hex)) {}
40+
EventHandler() :EventHandlerBase(static_cast<sm_cmd::events_te>(sm_cmd::events_te::sign_trx)) {}
4141
virtual ~EventHandler() {}
4242
virtual void operator()(const sm_cmd::secmod_parser_f& parser) const override
4343
{
4444
try
4545
{
46-
auto cmd = parser.params< sm_cmd::events_te::sign_hex >();
46+
auto cmd = parser.params< sm_cmd::events_te::sign_trx >();
4747
FC_LIGHT_THROW_EXCEPTION(fc_light::internal_error_exception, "Secmod command is not implemented, etype = %{ETYPE}", ("ETYPE", e_type));
4848
//TODO: need to implement
4949
}
@@ -53,7 +53,7 @@ struct EventHandler < sm_cmd::events_te::sign_hex > : EventHandlerBase
5353

5454
template <>
5555
struct EventHandler < sm_cmd::events_te::sign_hash> : EventHandlerBase
56-
{
56+
{
5757
EventHandler() :EventHandlerBase(static_cast<sm_cmd::events_te>(sm_cmd::events_te::sign_hash)) {}
5858
virtual ~EventHandler() {}
5959
virtual void operator()(const sm_cmd::secmod_parser_f& parser) const override

keychain_win/keychain_gui/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
6565
#endif
6666
BOOST_LOG_SEV(log.lg, info) << "Got from pipe: " << buffer;
6767

68-
// std::string input = "{\"etype\":\"sign_hex\",\"params\":{\"keyname\":\"test1\",\"is_parsed\":false,\"blockchain\":\"unknown\",\"unlock_time\":45,\"trx_view\":\"871689d060721b5cec5a010080841e00000000000011130065cd1d0000000000000000\"}}";
68+
// std::string input = "{\"etype\":\"sign_trx\",\"params\":{\"keyname\":\"test1\",\"is_parsed\":false,\"blockchain\":\"unknown\",\"unlock_time\":45,\"trx_view\":\"871689d060721b5cec5a010080841e00000000000011130065cd1d0000000000000000\"}}";
6969

7070
QApplication a(argc, argv);
7171
parseSecmodEvents(std::string(buffer));

keychain_win/secmodlib/src/SecureModuleWrapper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ std::string SecureModuleWrapper::exec_cmd(const std::string& json_cmd) const
2323
int unlock_time = 0;
2424
switch (etype)
2525
{
26-
case sm_cmd::events_te::sign_hex:
26+
case sm_cmd::events_te::sign_trx:
2727
{
28-
auto cmd = parser.params<sm_cmd::events_te::sign_hex>();
28+
auto cmd = parser.params<sm_cmd::events_te::sign_trx>();
2929
unlock_time = cmd.unlock_time;
3030
}
3131
break;

0 commit comments

Comments
 (0)