diff --git a/tonlib/tonlib/tonlib-cli.cpp b/tonlib/tonlib/tonlib-cli.cpp index 8669dda32..5582377db 100644 --- a/tonlib/tonlib/tonlib-cli.cpp +++ b/tonlib/tonlib/tonlib-cli.cpp @@ -385,6 +385,7 @@ class TonlibCli : public td::actor::Actor { " with specified parameters\n"; td::TerminalIO::out() << "getstate \tget state of wallet with requested key\n"; td::TerminalIO::out() << "getstatebytransaction \tget state of wallet with requested key after transaction with local time and hash (base64url)\n"; + td::TerminalIO::out() << "getconfig \tshow specified configuration parameter from the latest masterchain state\n"; td::TerminalIO::out() << "guessrevision \tsearch of existing accounts corresponding to the given key\n"; td::TerminalIO::out() << "guessaccount \tsearch of existing accounts corresponding to the given key\n"; td::TerminalIO::out() << "getaddress \tget address of wallet with requested key\n"; @@ -487,6 +488,8 @@ class TonlibCli : public td::actor::Actor { get_state(parser.read_word(), std::move(cmd_promise)); } else if (cmd == "getstatebytransaction") { get_state_by_transaction(parser, std::move(cmd_promise)); + } else if (cmd == "getconfig") { + get_config_param(parser, std::move(cmd_promise)); } else if (cmd == "getaddress") { get_address(parser.read_word(), std::move(cmd_promise)); } else if (cmd == "importkeypem") { @@ -2089,6 +2092,26 @@ class TonlibCli : public td::actor::Actor { })); } + void get_config_param(td::ConstParser& parser, td::Promise promise) { + TRY_RESULT_PROMISE(promise, param, td::to_integer_safe(parser.read_word())); + send_query(make_object(0, param), + promise.wrap([param](auto&& result) -> td::Result { + TRY_RESULT(cell, vm::std_boc_deserialize(result->config_->bytes_, true)); + if (cell.is_null()) { + td::TerminalIO::out() << "ConfigParam(" << param << ") = (null)\n"; + return td::Unit(); + } + std::ostringstream os; + if (param >= 0) { + block::gen::ConfigParam{param}.print_ref(4096, os, cell); + os << "\n"; + } + vm::load_cell_slice(cell).print_rec(4096, os); + td::TerminalIO::out() << "ConfigParam(" << param << ") = " << os.str() << "\n"; + return td::Unit(); + })); + } + void get_address(td::Slice key, td::Promise promise) { TRY_RESULT_PROMISE(promise, address, to_account_address(key, false)); promise.set_value(td::Unit());