aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api/wallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/api/wallet.cpp')
-rw-r--r--src/wallet/api/wallet.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 9a9638b40..3768a7998 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -545,6 +545,8 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
{
clearStatus();
+ // Pause refresh thread while creating transaction
+ pauseRefresh();
vector<cryptonote::tx_destination_entry> dsts;
cryptonote::tx_destination_entry de;
@@ -678,6 +680,8 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
transaction->m_status = m_status;
transaction->m_errorString = m_errorString;
+ // Resume refresh thread
+ startRefresh();
return transaction;
}
@@ -707,6 +711,46 @@ void WalletImpl::setDefaultMixin(uint32_t arg)
m_wallet->default_mixin(arg);
}
+bool WalletImpl::setUserNote(const std::string &txid, const std::string &note)
+{
+ cryptonote::blobdata txid_data;
+ if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data))
+ return false;
+ const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
+
+ m_wallet->set_tx_note(htxid, note);
+ return true;
+}
+
+std::string WalletImpl::getUserNote(const std::string &txid) const
+{
+ cryptonote::blobdata txid_data;
+ if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data))
+ return "";
+ const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
+
+ return m_wallet->get_tx_note(htxid);
+}
+
+std::string WalletImpl::getTxKey(const std::string &txid) const
+{
+ cryptonote::blobdata txid_data;
+ if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data))
+ {
+ return "";
+ }
+ const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
+
+ crypto::secret_key tx_key;
+ if (m_wallet->get_tx_key(htxid, tx_key))
+ {
+ return epee::string_tools::pod_to_hex(tx_key);
+ }
+ else
+ {
+ return "";
+ }
+}
bool WalletImpl::connectToDaemon()
{
@@ -720,9 +764,15 @@ bool WalletImpl::connectToDaemon()
return result;
}
-bool WalletImpl::connected() const
+Wallet::ConnectionStatus WalletImpl::connected() const
{
- return m_wallet->check_connection();
+ bool same_version = false;
+ bool is_connected = m_wallet->check_connection(&same_version);
+ if (!is_connected)
+ return Wallet::ConnectionStatus_Disconnected;
+ if (!same_version)
+ return Wallet::ConnectionStatus_WrongVersion;
+ return Wallet::ConnectionStatus_Connected;
}
void WalletImpl::setTrustedDaemon(bool arg)
@@ -798,6 +848,7 @@ void WalletImpl::doRefresh()
void WalletImpl::startRefresh()
{
+ LOG_PRINT_L2(__FUNCTION__ << ": refresh started/resumed...");
if (!m_refreshEnabled) {
m_refreshEnabled = true;
m_refreshCV.notify_one();
@@ -818,6 +869,7 @@ void WalletImpl::stopRefresh()
void WalletImpl::pauseRefresh()
{
+ LOG_PRINT_L2(__FUNCTION__ << ": refresh paused...");
// TODO synchronize access
if (!m_refreshThreadDone) {
m_refreshEnabled = false;