Print wallet cache

This commit is contained in:
thotbot 2021-07-03 23:45:03 +02:00 committed by wowario
parent 60ff2f668e
commit d2a170f6e4
No known key found for this signature in database
GPG Key ID: 24DCBE762DE9C111
5 changed files with 435 additions and 0 deletions

View File

@ -1383,6 +1383,75 @@ bool WalletImpl::scanTransactions(const std::vector<std::string> &txids)
return true; return true;
} }
std::string WalletImpl::printBlockchain()
{
return m_wallet->printBlockchain();
}
std::string WalletImpl::printTransfers()
{
return m_wallet->printTransfers();
}
std::string WalletImpl::printPayments()
{
return m_wallet->printPayments();
}
std::string WalletImpl::printUnconfirmedPayments()
{
return m_wallet->printUnconfirmedPayments();
}
std::string WalletImpl::printConfirmedTransferDetails()
{
return m_wallet->printConfirmedTransferDetails();
}
std::string WalletImpl::printUnconfirmedTransferDetails()
{
return m_wallet->printUnconfirmedTransferDetails();
}
std::string WalletImpl::printPubKeys()
{
return m_wallet->printPubKeys();
}
std::string WalletImpl::printTxNotes()
{
return m_wallet->printTxNotes();
}
std::string WalletImpl::printSubaddresses()
{
return m_wallet->printSubaddresses();
}
std::string WalletImpl::printSubaddressLabels()
{
return m_wallet->printSubaddressLabels();
}
std::string WalletImpl::printAdditionalTxKeys()
{
return m_wallet->printAdditionalTxKeys();
}
std::string WalletImpl::printAttributes()
{
return m_wallet->printAttributes();
}
std::string WalletImpl::printKeyImages()
{
return m_wallet->printKeyImages();
}
std::string WalletImpl::printAccountTags()
{
return m_wallet->printAccountTags();
}
std::string WalletImpl::printTxKeys()
{
return m_wallet->printTxKeys();
}
std::string WalletImpl::printAddressBook()
{
return m_wallet->printAddressBook();
}
std::string WalletImpl::printScannedPoolTxs()
{
return m_wallet->printScannedPoolTxs();
}
void WalletImpl::addSubaddressAccount(const std::string& label) void WalletImpl::addSubaddressAccount(const std::string& label)
{ {
m_wallet->add_subaddress_account(label); m_wallet->add_subaddress_account(label);

View File

@ -185,6 +185,24 @@ public:
bool importOutputs(const std::string &filename) override; bool importOutputs(const std::string &filename) override;
bool scanTransactions(const std::vector<std::string> &txids) override; bool scanTransactions(const std::vector<std::string> &txids) override;
virtual std::string printBlockchain() override;
virtual std::string printTransfers() override;
virtual std::string printPayments() override;
virtual std::string printUnconfirmedPayments() override;
virtual std::string printConfirmedTransferDetails() override;
virtual std::string printUnconfirmedTransferDetails() override;
virtual std::string printPubKeys() override;
virtual std::string printTxNotes() override;
virtual std::string printSubaddresses() override;
virtual std::string printSubaddressLabels() override;
virtual std::string printAdditionalTxKeys() override;
virtual std::string printAttributes() override;
virtual std::string printKeyImages() override;
virtual std::string printAccountTags() override;
virtual std::string printTxKeys() override;
virtual std::string printAddressBook() override;
virtual std::string printScannedPoolTxs() override;
virtual void disposeTransaction(PendingTransaction * t) override; virtual void disposeTransaction(PendingTransaction * t) override;
virtual uint64_t estimateTransactionFee(const std::vector<std::pair<std::string, uint64_t>> &destinations, virtual uint64_t estimateTransactionFee(const std::vector<std::pair<std::string, uint64_t>> &destinations,
PendingTransaction::Priority priority) const override; PendingTransaction::Priority priority) const override;

View File

@ -1063,6 +1063,24 @@ struct Wallet
*/ */
virtual bool scanTransactions(const std::vector<std::string> &txids) = 0; virtual bool scanTransactions(const std::vector<std::string> &txids) = 0;
virtual std::string printBlockchain() = 0;
virtual std::string printTransfers() = 0;
virtual std::string printPayments() = 0;
virtual std::string printUnconfirmedPayments() = 0;
virtual std::string printConfirmedTransferDetails() = 0;
virtual std::string printUnconfirmedTransferDetails() = 0;
virtual std::string printPubKeys() = 0;
virtual std::string printTxNotes() = 0;
virtual std::string printSubaddresses() = 0;
virtual std::string printSubaddressLabels() = 0;
virtual std::string printAdditionalTxKeys() = 0;
virtual std::string printAttributes() = 0;
virtual std::string printKeyImages() = 0;
virtual std::string printAccountTags() = 0;
virtual std::string printTxKeys() = 0;
virtual std::string printAddressBook() = 0;
virtual std::string printScannedPoolTxs() = 0;
virtual TransactionHistory * history() = 0; virtual TransactionHistory * history() = 0;
virtual AddressBook * addressBook() = 0; virtual AddressBook * addressBook() = 0;
virtual Coins * coins() = 0; virtual Coins * coins() = 0;

View File

@ -5336,6 +5336,315 @@ void wallet2::write_watch_only_wallet(const std::string& wallet_name, const epee
bool r = store_keys(new_keys_filename, password, true); bool r = store_keys(new_keys_filename, password, true);
THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, new_keys_filename); THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, new_keys_filename);
} }
std::string wallet2::printBlockchain()
{
std::string blstr;
blstr += "offset: " + std::to_string(m_blockchain.offset()) + "\n";
blstr += "genesis: " + string_tools::pod_to_hex(m_blockchain.genesis()) + "\n";
for (size_t i = m_blockchain.offset(); i < m_blockchain.size(); i++) {
blstr += std::to_string(i) + " : " + string_tools::pod_to_hex(m_blockchain[i]) + "\n";
}
return blstr;
}
std::string wallet2::printTransfers()
{
std::string str;
for (const auto &td : m_transfers) {
str += "block_height: " + std::to_string(td.m_block_height) + "\n";
str += printTxPrefix(td.m_tx);
str += "txid: " + string_tools::pod_to_hex(td.m_txid) + "\n";
str += "internal_output_index: " + std::to_string(td.m_internal_output_index) + "\n";
str += "global_output_index: " + std::to_string(td.m_global_output_index) + "\n";
str += "spent: " + std::to_string(td.m_spent) + "\n";
str += "frozen: " + std::to_string(td.m_frozen) + "\n";
str += "spent_height: " + std::to_string(td.m_spent_height) + "\n";
str += "key_image: " + string_tools::pod_to_hex(td.m_key_image) + "\n";
str += "mask: " + string_tools::pod_to_hex(td.m_mask) + "\n";
str += "amount: " + std::to_string(td.m_amount) + "\n";
str += "rct: " + std::to_string(td.m_rct) + "\n";
str += "key_image_known: " + std::to_string(td.m_key_image_known) + "\n";
str += "key_image_request: " + std::to_string(td.m_key_image_request) + "\n";
str += "pk_index: " + std::to_string(td.m_pk_index) + "\n";
str += "subaddr_index: " + std::to_string(td.m_subaddr_index.major) + "," + std::to_string(td.m_subaddr_index.minor) + "\n";
str += "key_image_partial: " + std::to_string(td.m_key_image_partial) + "\n";
str += "multisig_k:\n";
for (const auto &el : td.m_multisig_k) {
str += " " + string_tools::pod_to_hex(el) + "\n";
}
str += "multisig_info:\n";
for (const auto &el : td.m_multisig_info) {
str += " signer: " + string_tools::pod_to_hex(el.m_signer) + "\n";
str += " LR:\n";
for (const auto &em : el.m_LR) {
str += " L: " + string_tools::pod_to_hex(em.m_L) + "\n";
str += " R: " + string_tools::pod_to_hex(em.m_R) + "\n";
}
str += "\n";
str += " partial_key_images:\n";
for (const auto &em : el.m_partial_key_images) {
str += " " + string_tools::pod_to_hex(em) + "\n";
}
str += "\n";
}
str += "uses:\n";
for (const auto &el : td.m_uses) {
str += " " + std::to_string(el.first) + " : " + string_tools::pod_to_hex(el.second) + "\n";
}
str += "\n";
}
return str;
}
std::string wallet2::printUnconfirmedPayments()
{
std::string str;
for (const auto &el : m_unconfirmed_payments) {
auto ppd = el.second;
str += "double_spend_seen: " + std::to_string(ppd.m_double_spend_seen) + "\n";
str += printPaymentDetails(ppd.m_pd);
str += "\n";
}
return str;
}
std::string wallet2::printConfirmedTransferDetails()
{
std::string str;
for (const auto &el : m_confirmed_txs) {
auto ctd = el.second;
str += "amount_in: " + std::to_string(ctd.m_amount_in) + "\n";
str += "amount_out: " + std::to_string(ctd.m_amount_out) + "\n";
str += "change: " + std::to_string(ctd.m_change) + "\n";
str += "block_height: " + std::to_string(ctd.m_block_height) + "\n";
str += "dests:\n";
for (const auto &em : ctd.m_dests) {
str += printTxDestinationEntry(em);
}
str += "payment_id: " + string_tools::pod_to_hex(ctd.m_payment_id) + "\n";
str += "timestamp: " + std::to_string(ctd.m_timestamp) + "\n";
str += "unlock_time: " + std::to_string(ctd.m_unlock_time) + "\n";
str += "subaddr_account: " + std::to_string(ctd.m_subaddr_account) + "\n";
str += "subaddr_indices: ";
for (auto em : ctd.m_subaddr_indices) {
str += std::to_string(em);
}
str += "\n\n";
}
return str;
}
std::string wallet2::printUnconfirmedTransferDetails()
{
std::string str;
for (const auto &el : m_unconfirmed_txs) {
auto utd = el.second;
str += printTxPrefix(utd.m_tx);
str += "amount_in: " + std::to_string(utd.m_amount_in) + "\n";
str += "amount_out: " + std::to_string(utd.m_amount_out) + "\n";
str += "change: " + std::to_string(utd.m_change) + "\n";
str += "sent_time: " + std::to_string(utd.m_sent_time) + "\n";
str += "dests:\n";
for (const auto &em : utd.m_dests) {
str += printTxDestinationEntry(em);
}
str += "payment_id: " + string_tools::pod_to_hex(utd.m_payment_id) + "\n";
str += "timestamp: " + std::to_string(utd.m_timestamp) + "\n";
str += "subaddr_account: " + std::to_string(utd.m_subaddr_account) + "\n";
str += "subaddr_indices: ";
for (auto em : utd.m_subaddr_indices) {
str += std::to_string(em);
}
str += "\n\n";
}
return str;
}
std::string wallet2::printPayments()
{
std::string str;
for (const auto &el : m_payments) {
str += printPaymentDetails(el.second) + "\n";
}
return str;
}
std::string wallet2::printPubKeys()
{
std::string str;
vector<std::pair<crypto::public_key, size_t>> v;
for (const auto &el : m_pub_keys) {
v.push_back(el);
}
std::sort(v.begin(), v.end(),
[](std::pair<crypto::public_key, size_t> a, std::pair<crypto::public_key, size_t> b){return a.second < b.second;});
for (const auto &el : v){
str += string_tools::pod_to_hex(el.first) + " : " + boost::to_string(el.second) + "\n";
}
return str;
}
std::string wallet2::printTxNotes()
{
std::string str;
for (std::pair<crypto::hash, std::string> el : m_tx_notes) {
str += string_tools::pod_to_hex(el.first) + " : " + el.second + "\n";
}
return str;
}
std::string wallet2::printSubaddresses()
{
std::string str;
vector<std::pair<crypto::public_key, cryptonote::subaddress_index>> v;
for (const auto &el : m_subaddresses) {
v.push_back(el);
}
std::sort(v.begin(), v.end(), [](std::pair<crypto::public_key, cryptonote::subaddress_index> a, std::pair<crypto::public_key, cryptonote::subaddress_index> b) {
if (a.second.major == b.second.major) {
return a.second.minor < b.second.minor;
}
return a.second.major < b.second.major;
});
for (const auto &el : v) {
str += string_tools::pod_to_hex(el.first) + " : " + std::to_string(el.second.major) + "," + std::to_string(el.second.minor) + "\n";
}
return str;
}
std::string wallet2::printSubaddressLabels()
{
std::string str;
for (size_t i = 0; i < m_subaddress_labels.size(); i++) {
for (size_t j = 0; j < m_subaddress_labels[i].size(); j++) {
str += std::to_string(i) + "," + std::to_string(j) + " : " + m_subaddress_labels[i][j] + "\n";
}
}
return str;
}
std::string wallet2::printAdditionalTxKeys()
{
std::string str;
for (std::pair<crypto::hash, std::vector<crypto::secret_key>> el : m_additional_tx_keys) {
str += "Txid: " + string_tools::pod_to_hex(el.first) + " (" + std::to_string(el.second.size()) + ")\n";
for (auto em : el.second) {
str += " " + string_tools::pod_to_hex(em) + "\n";
}
}
return str;
}
std::string wallet2::printAttributes()
{
std::string str;
for (auto el : m_attributes) {
str += el.first + " : " + el.second + "\n";
}
return str;
}
std::string wallet2::printKeyImages()
{
std::string str;
vector<std::pair<crypto::key_image, size_t>> v;
for (const auto &el : m_key_images) {
v.push_back(el);
}
std::sort(v.begin(), v.end(), [](std::pair<crypto::key_image, size_t> a, std::pair<crypto::key_image, size_t> b){return a.second < b.second;});
for (const auto &el: v) {
str += string_tools::pod_to_hex(el.first) + " : " + boost::to_string(el.second) + "\n";
}
return str;
}
std::string wallet2::printAccountTags()
{
std::string str;
for (size_t i = 0; i < m_account_tags.second.size(); i++) {
str += std::to_string(i) + " : " + m_account_tags.second[i] + "\n";
}
return str;
}
std::string wallet2::printTxKeys()
{
std::string str;
for (std::pair<crypto::hash, crypto::secret_key> el : m_tx_keys) {
str += string_tools::pod_to_hex(el.first) + " : " + string_tools::pod_to_hex(el.second) + "\n";
}
return str;
}
std::string wallet2::printAddressBook()
{
std::string str;
for (auto el : m_address_book) {
str += "address: " + string_tools::pod_to_hex(el.m_address) + "\n";
str += "payment_id: " + string_tools::pod_to_hex(el.m_payment_id) + "\n";
str += "description: " + el.m_description + "\n";
str += "is_subaddress: " + std::to_string(el.m_is_subaddress) + "\n";
str += "has_payment_id: " + std::to_string(el.m_has_payment_id) + "\n";
str += "\n";
}
return str;
}
std::string wallet2::printScannedPoolTxs()
{
std::string str;
for (size_t i = 0; i < 2; i++) {
str += "scanned_pool_txs[" + std::to_string(i) + "]\n";
for (auto el : m_scanned_pool_txs[i]) {
str += string_tools::pod_to_hex(el) + "\n";
}
str += "\n";
}
return str;
}
std::string wallet2::printTxPrefix(const cryptonote::transaction_prefix &tx)
{
std::string str;
str += "tx.version: " + std::to_string(tx.version) + "\n";
str += "tx.unlock_time: " + std::to_string(tx.unlock_time) + "\n";
return str;
}
std::string wallet2::printPaymentDetails(const payment_details &pd)
{
std::string str;
str += "tx_hash: " + string_tools::pod_to_hex(pd.m_tx_hash) + "\n";
str += "amount: " + std::to_string(pd.m_amount) + "\n";
str += "amounts: ";
for (auto em : pd.m_amounts) {
str += std::to_string(em);
}
str += "\n";
str += "fee: " + std::to_string(pd.m_fee) + "\n";
str += "block_height: " + std::to_string(pd.m_block_height) + "\n";
str += "unlock_time: " + std::to_string(pd.m_unlock_time) + "\n";
str += "timestamp: " + std::to_string(pd.m_timestamp) + "\n";
str += "coinbase: " + std::to_string(pd.m_coinbase) + "\n";
str += "subaddr_index: " + std::to_string(pd.m_subaddr_index.major) + "," + std::to_string(pd.m_subaddr_index.minor) + "\n";
return str;
}
std::string wallet2::printTxDestinationEntry(const cryptonote::tx_destination_entry &tx)
{
std::string str;
str += " original: " + tx.original + "\n";
str += " amount: " + std::to_string(tx.amount) + "\n";
str += " addr: " + string_tools::pod_to_hex(tx.addr) + "\n";
str += " is_subaddress: " + std::to_string(tx.is_subaddress) + "\n";
str += " is_integrated: " + std::to_string(tx.is_integrated) + "\n";
return str;
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
void wallet2::wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists) void wallet2::wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists)
{ {

View File

@ -1652,6 +1652,27 @@ private:
uint64_t get_bytes_sent() const; uint64_t get_bytes_sent() const;
uint64_t get_bytes_received() const; uint64_t get_bytes_received() const;
std::string printBlockchain();
std::string printTransfers();
std::string printKeyImages();
std::string printUnconfirmedTransferDetails();
std::string printPayments();
std::string printUnconfirmedPayments();
std::string printConfirmedTransferDetails();
std::string printPubKeys();
std::string printTxNotes();
std::string printSubaddresses();
std::string printSubaddressLabels();
std::string printAdditionalTxKeys();
std::string printAttributes();
std::string printAccountTags();
std::string printTxKeys();
std::string printAddressBook();
std::string printScannedPoolTxs();
std::string printTxPrefix(const cryptonote::transaction_prefix &tx);
std::string printPaymentDetails(const payment_details &pd);
std::string printTxDestinationEntry(const cryptonote::tx_destination_entry &tx);
// MMS ------------------------------------------------------------------------------------------------- // MMS -------------------------------------------------------------------------------------------------
mms::message_store& get_message_store() { return m_message_store; }; mms::message_store& get_message_store() { return m_message_store; };
const mms::message_store& get_message_store() const { return m_message_store; }; const mms::message_store& get_message_store() const { return m_message_store; };