diff --git a/lite-client/lite-client.cpp b/lite-client/lite-client.cpp index 1ccfec86..f472af21 100644 --- a/lite-client/lite-client.cpp +++ b/lite-client/lite-client.cpp @@ -4261,6 +4261,8 @@ int main(int argc, char* argv[]) { }); p.add_option('p', "pub", "remote public key", [&](td::Slice arg) { td::actor::send_closure(x, &TestNode::set_public_key, td::BufferSlice{arg}); }); + p.add_option('b', "b64", "remote public key as base64", + [&](td::Slice arg) { td::actor::send_closure(x, &TestNode::decode_public_key, td::BufferSlice{arg}); }); p.add_option('d', "daemonize", "set SIGHUP", [&]() { td::set_signal_handler(td::SignalType::HangUp, [](int sig) { #if TD_DARWIN || TD_LINUX diff --git a/lite-client/lite-client.h b/lite-client/lite-client.h index 7184652a..00d8bd07 100644 --- a/lite-client/lite-client.h +++ b/lite-client/lite-client.h @@ -394,6 +394,18 @@ class TestNode : public td::actor::Actor { } remote_public_key_ = R.move_as_ok(); } + void decode_public_key(td::BufferSlice b64_key) { + auto R = [&]() -> td::Result { + std::string key_bytes = {(char)0xc6, (char)0xb4, (char)0x13, (char)0x48}; + key_bytes = key_bytes + td::base64_decode(b64_key.as_slice().str()).move_as_ok(); + return ton::PublicKey::import(key_bytes); + }(); + + if (R.is_error()) { + LOG(FATAL) << "bad b64 server public key: " << R.move_as_error(); + } + remote_public_key_ = R.move_as_ok(); + } void set_fail_timeout(td::Timestamp ts) { fail_timeout_ = ts; alarm_timestamp().relax(fail_timeout_);