mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Add base64 key input parameter to LiteClient
This commit is contained in:
parent
59fcd7cbd5
commit
112bed0478
2 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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<ton::PublicKey> {
|
||||
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_);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue