mirror of
https://github.com/wownero/lwcli-wow.git
synced 2026-10-17 15:01:26 +02:00
Add dump keys to file command to TUI
This commit is contained in:
+31
-2
@@ -29,6 +29,8 @@
|
|||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
|
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
#include <ftxui/component/component.hpp>
|
#include <ftxui/component/component.hpp>
|
||||||
#include <ftxui/component/event.hpp>
|
#include <ftxui/component/event.hpp>
|
||||||
#include <lws_frontend.h>
|
#include <lws_frontend.h>
|
||||||
@@ -178,6 +180,7 @@ namespace lwcli { namespace view
|
|||||||
const ftxui::Element title_;
|
const ftxui::Element title_;
|
||||||
const ftxui::Component buttons_;
|
const ftxui::Component buttons_;
|
||||||
const ftxui::Element display_;
|
const ftxui::Element display_;
|
||||||
|
const std::shared_ptr<Monero::Wallet> wal_;
|
||||||
|
|
||||||
bool Focusable() const override final { return true; }
|
bool Focusable() const override final { return true; }
|
||||||
ftxui::Component ActiveChild() override final { return buttons_; }
|
ftxui::Component ActiveChild() override final { return buttons_; }
|
||||||
@@ -196,12 +199,38 @@ namespace lwcli { namespace view
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DumpKeys()
|
||||||
|
{
|
||||||
|
std::string filename = "lwcli_keys_dump.txt";
|
||||||
|
std::string wallet_path = wal_->path();
|
||||||
|
if (!wallet_path.empty())
|
||||||
|
{
|
||||||
|
std::filesystem::path p(wallet_path);
|
||||||
|
filename = (p.parent_path() / filename).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ofstream out(filename);
|
||||||
|
if (out)
|
||||||
|
{
|
||||||
|
out << "Address: " << wal_->mainAddress() << "\n"
|
||||||
|
<< "Spend Pub: " << wal_->publicSpendKey() << "\n"
|
||||||
|
<< "View Pub: " << wal_->publicViewKey() << "\n"
|
||||||
|
<< "Spend Key: " << wal_->secretSpendKey() << "\n"
|
||||||
|
<< "View Key: " << wal_->secretViewKey() << "\n"
|
||||||
|
<< "Seed: " << wal_->seed({}) << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit show_keys_(const std::shared_ptr<Monero::Wallet>& wal)
|
explicit show_keys_(const std::shared_ptr<Monero::Wallet>& wal)
|
||||||
: ftxui::ComponentBase(),
|
: ftxui::ComponentBase(),
|
||||||
title_(ftxui::text(_("Wallet (Secret) Keys"))),
|
title_(ftxui::text(_("Wallet (Secret) Keys"))),
|
||||||
buttons_(ftxui::Button(_("Close"), [] () { throw event::close{}; }, ascii())),
|
buttons_(ftxui::Container::Horizontal({
|
||||||
display_(get_keys(wal))
|
ftxui::Button(_("Close"), [] () { throw event::close{}; }, ascii()),
|
||||||
|
ftxui::Button(_("Dump to File"), [this] { DumpKeys(); }, ascii())
|
||||||
|
})),
|
||||||
|
display_(get_keys(wal)),
|
||||||
|
wal_(wal)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool OnEvent(ftxui::Event event) override final
|
bool OnEvent(ftxui::Event event) override final
|
||||||
|
|||||||
Reference in New Issue
Block a user