forked from lthn/blockchain
added api fo exporting tx history from UI
This commit is contained in:
parent
a7b6c04eb1
commit
52440749ed
6 changed files with 44 additions and 42 deletions
|
|
@ -834,7 +834,16 @@ bool MainWindow::set_is_disabled_notifications(const bool& param)
|
|||
m_config.disable_notifications = param;
|
||||
return m_config.disable_notifications;
|
||||
}
|
||||
|
||||
QString MainWindow::export_wallet_history(const QString& param)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
LOG_API_TIMING();
|
||||
PREPARE_ARG_FROM_JSON(view::export_wallet_info, ewi);
|
||||
PREPARE_RESPONSE(view::api_response, ar);
|
||||
ar.error_code = m_backend.export_wallet_history(ewi);
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY2(false);
|
||||
}
|
||||
bool MainWindow::update_wallets_info(const view::wallets_summary_info& wsi)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ public:
|
|||
|
||||
bool get_is_disabled_notifications();
|
||||
bool set_is_disabled_notifications(const bool& param);
|
||||
QString export_wallet_history(const QString& param);
|
||||
QString get_log_file();
|
||||
QString check_available_sources(const QString& param);
|
||||
QString open_url_in_browser(const QString& param);
|
||||
|
|
|
|||
|
|
@ -838,47 +838,6 @@ bool simple_wallet::export_recent_transfers(const std::vector<std::string>& args
|
|||
success_msg_writer() << "Failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// std::vector<tools::wallet_public::wallet_transfer_info> unconfirmed;
|
||||
// std::vector<tools::wallet_public::wallet_transfer_info> recent;
|
||||
// uint64_t total = 0;
|
||||
// uint64_t last_index = 0;
|
||||
// m_wallet->get_recent_transfers_history(recent, 0, 0, total, last_index, false);
|
||||
// m_wallet->get_unconfirmed_transfers(unconfirmed, false);
|
||||
// //workaround for missed fee
|
||||
// stringstream ss;
|
||||
// LOG_PRINT_GREEN("Generating text....", LOG_LEVEL_0);
|
||||
// ss << "Unconfirmed transfers: " << ENDL;
|
||||
// for (auto & wti : unconfirmed)
|
||||
// {
|
||||
// if(ignore_pos && wti.is_mining)
|
||||
// continue;
|
||||
// if (!wti.fee)
|
||||
// wti.fee = currency::get_tx_fee(wti.tx);
|
||||
// if(export_to_json)
|
||||
// ss << epee::serialization::store_t_to_json(wti) << ENDL;
|
||||
// else
|
||||
// ss << wti_to_text_line(wti) << ENDL;
|
||||
//
|
||||
// }
|
||||
// ss << "Recent transfers: " << ENDL;
|
||||
// for (auto & wti : recent)
|
||||
// {
|
||||
// if (ignore_pos && wti.is_mining)
|
||||
// continue;
|
||||
// if (!wti.fee)
|
||||
// wti.fee = currency::get_tx_fee(wti.tx);
|
||||
//
|
||||
// if (export_to_json)
|
||||
// ss << epee::serialization::store_t_to_json(wti) << ENDL;
|
||||
// else
|
||||
// ss << wti_to_text_line(wti) << ENDL;
|
||||
// }
|
||||
// LOG_PRINT_GREEN("Storing text to wallet_recent_transfers.txt....", LOG_LEVEL_0);
|
||||
// file_io_utils::save_string_to_file(log_space::log_singletone::get_default_log_folder() + "/wallet_recent_transfers.txt", ss.str());
|
||||
// LOG_PRINT_GREEN("Done", LOG_LEVEL_0);
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -284,6 +284,20 @@ public:
|
|||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct export_wallet_info
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
bool include_pos_transactions;
|
||||
std::string path;
|
||||
std::string format;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(include_pos_transactions)
|
||||
KV_SERIALIZE(path)
|
||||
KV_SERIALIZE(format)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct response_mining_estimate
|
||||
{
|
||||
|
|
|
|||
|
|
@ -803,6 +803,24 @@ std::string wallets_manager::get_tx_pool_info(currency::COMMAND_RPC_GET_POOL_INF
|
|||
}
|
||||
|
||||
|
||||
std::string wallets_manager::export_wallet_history(const view::export_wallet_info& ewi)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(ewi.wallet_id, wo);
|
||||
try {
|
||||
|
||||
boost::filesystem::ofstream fstream;
|
||||
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
fstream.open(ewi.path, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
|
||||
wo.w->get()->export_transaction_history(fstream, ewi.format, ewi.include_pos_transactions);
|
||||
fstream.close();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return API_RETURN_CODE_FAIL;
|
||||
}
|
||||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
|
||||
uint64_t wallets_manager::get_default_fee()
|
||||
{
|
||||
return TX_DEFAULT_FEE;
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ public:
|
|||
std::string get_my_offers(const bc_services::core_offers_filter& filter, std::list<bc_services::offer_details_ex>& offers);
|
||||
std::string get_fav_offers(const std::list<bc_services::offer_id>& hashes, const bc_services::core_offers_filter& filter, std::list<bc_services::offer_details_ex>& offers);
|
||||
std::string get_tx_pool_info(currency::COMMAND_RPC_GET_POOL_INFO::response& res);
|
||||
std::string export_wallet_history(const view::export_wallet_info& ewi);
|
||||
uint64_t get_default_fee();
|
||||
std::string get_mining_estimate(uint64_t amuont_coins,
|
||||
uint64_t time,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue