aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/api')
-rw-r--r--src/wallet/api/CMakeLists.txt3
-rw-r--r--src/wallet/api/address_book.cpp4
-rw-r--r--src/wallet/api/address_book.h3
-rw-r--r--src/wallet/api/pending_transaction.cpp3
-rw-r--r--src/wallet/api/pending_transaction.h2
-rw-r--r--src/wallet/api/transaction_history.cpp2
-rw-r--r--src/wallet/api/transaction_history.h3
-rw-r--r--src/wallet/api/transaction_info.cpp2
-rw-r--r--src/wallet/api/transaction_info.h2
-rw-r--r--src/wallet/api/unsigned_transaction.cpp3
-rw-r--r--src/wallet/api/unsigned_transaction.h2
-rw-r--r--src/wallet/api/utils.cpp2
-rw-r--r--src/wallet/api/wallet.cpp67
-rw-r--r--src/wallet/api/wallet.h9
-rw-r--r--src/wallet/api/wallet2_api.h15
-rw-r--r--src/wallet/api/wallet_manager.cpp2
-rw-r--r--src/wallet/api/wallet_manager.h2
17 files changed, 74 insertions, 52 deletions
diff --git a/src/wallet/api/CMakeLists.txt b/src/wallet/api/CMakeLists.txt
index 30eb4ce03..655cdfefd 100644
--- a/src/wallet/api/CMakeLists.txt
+++ b/src/wallet/api/CMakeLists.txt
@@ -71,10 +71,13 @@ target_link_libraries(wallet_api
mnemonics
${LMDB_LIBRARY}
${Boost_CHRONO_LIBRARY}
+ ${Boost_LOCALE_LIBRARY}
+ ${ICU_LIBRARIES}
${Boost_SERIALIZATION_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
${Boost_REGEX_LIBRARY}
PRIVATE
${EXTRA_LIBRARIES})
diff --git a/src/wallet/api/address_book.cpp b/src/wallet/api/address_book.cpp
index 96090d9f5..0b0e17464 100644
--- a/src/wallet/api/address_book.cpp
+++ b/src/wallet/api/address_book.cpp
@@ -81,7 +81,7 @@ bool AddressBookImpl::setDescription(std::size_t index, const std::string &descr
tools::wallet2::address_book_row entry = ab[index];
entry.m_description = description;
- bool r = m_wallet->m_wallet->set_address_book_row(index, entry.m_address, NULL, entry.m_description, entry.m_is_subaddress);
+ bool r = m_wallet->m_wallet->set_address_book_row(index, entry.m_address, entry.m_has_payment_id ? &entry.m_payment_id : nullptr, entry.m_description, entry.m_is_subaddress);
if (r)
refresh();
else
@@ -166,5 +166,3 @@ AddressBookImpl::~AddressBookImpl()
}
} // namespace
-
-namespace Bitmonero = Monero;
diff --git a/src/wallet/api/address_book.h b/src/wallet/api/address_book.h
index e22f474fb..40da46853 100644
--- a/src/wallet/api/address_book.h
+++ b/src/wallet/api/address_book.h
@@ -66,6 +66,3 @@ private:
};
}
-
-namespace Bitmonero = Monero;
-
diff --git a/src/wallet/api/pending_transaction.cpp b/src/wallet/api/pending_transaction.cpp
index b28ffd64c..f7e74591f 100644
--- a/src/wallet/api/pending_transaction.cpp
+++ b/src/wallet/api/pending_transaction.cpp
@@ -264,6 +264,3 @@ std::vector<std::string> PendingTransactionImpl::signersKeys() const {
}
}
-
-namespace Bitmonero = Monero;
-
diff --git a/src/wallet/api/pending_transaction.h b/src/wallet/api/pending_transaction.h
index bd0ca80a6..274c60851 100644
--- a/src/wallet/api/pending_transaction.h
+++ b/src/wallet/api/pending_transaction.h
@@ -73,5 +73,3 @@ private:
}
-
-namespace Bitmonero = Monero;
diff --git a/src/wallet/api/transaction_history.cpp b/src/wallet/api/transaction_history.cpp
index d8e4aab65..4649089ea 100644
--- a/src/wallet/api/transaction_history.cpp
+++ b/src/wallet/api/transaction_history.cpp
@@ -266,5 +266,3 @@ void TransactionHistoryImpl::refresh()
}
} // namespace
-
-namespace Bitmonero = Monero;
diff --git a/src/wallet/api/transaction_history.h b/src/wallet/api/transaction_history.h
index 60f12d771..fe77253e6 100644
--- a/src/wallet/api/transaction_history.h
+++ b/src/wallet/api/transaction_history.h
@@ -56,6 +56,3 @@ private:
};
}
-
-namespace Bitmonero = Monero;
-
diff --git a/src/wallet/api/transaction_info.cpp b/src/wallet/api/transaction_info.cpp
index 33e7856db..edbdc469a 100644
--- a/src/wallet/api/transaction_info.cpp
+++ b/src/wallet/api/transaction_info.cpp
@@ -150,5 +150,3 @@ uint64_t TransactionInfoImpl::unlockTime() const
}
} // namespace
-
-namespace Bitmonero = Monero;
diff --git a/src/wallet/api/transaction_info.h b/src/wallet/api/transaction_info.h
index 8bc36a8e9..5eeeb04c2 100644
--- a/src/wallet/api/transaction_info.h
+++ b/src/wallet/api/transaction_info.h
@@ -87,5 +87,3 @@ private:
};
} // namespace
-
-namespace Bitmonero = Monero;
diff --git a/src/wallet/api/unsigned_transaction.cpp b/src/wallet/api/unsigned_transaction.cpp
index fb96674a7..4ccfafebd 100644
--- a/src/wallet/api/unsigned_transaction.cpp
+++ b/src/wallet/api/unsigned_transaction.cpp
@@ -316,6 +316,3 @@ uint64_t UnsignedTransactionImpl::minMixinCount() const
}
} // namespace
-
-namespace Bitmonero = Monero;
-
diff --git a/src/wallet/api/unsigned_transaction.h b/src/wallet/api/unsigned_transaction.h
index 81fc098ff..07649e39e 100644
--- a/src/wallet/api/unsigned_transaction.h
+++ b/src/wallet/api/unsigned_transaction.h
@@ -71,5 +71,3 @@ private:
}
-
-namespace Bitmonero = Monero;
diff --git a/src/wallet/api/utils.cpp b/src/wallet/api/utils.cpp
index 34debee9d..19151b5f6 100644
--- a/src/wallet/api/utils.cpp
+++ b/src/wallet/api/utils.cpp
@@ -60,5 +60,3 @@ void onStartup()
} // namespace
-
-namespace Bitmonero = Monero;
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index db3049f9e..b4fa1ea8c 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -58,7 +58,6 @@ namespace Monero {
namespace {
// copy-pasted from simplewallet
- static const size_t DEFAULT_MIXIN = 6;
static const int DEFAULT_REFRESH_INTERVAL_MILLIS = 1000 * 10;
// limit maximum refresh interval as one minute
static const int MAX_REFRESH_INTERVAL_MILLIS = 1000 * 60 * 1;
@@ -837,6 +836,11 @@ bool WalletImpl::setPassword(const std::string &password)
return status() == Status_Ok;
}
+const std::string& WalletImpl::getPassword() const
+{
+ return m_password;
+}
+
bool WalletImpl::setDevicePin(const std::string &pin)
{
clearStatus();
@@ -1176,7 +1180,7 @@ bool WalletImpl::exportKeyImages(const string &filename, bool all)
try
{
- if (!m_wallet->export_key_images(filename), all)
+ if (!m_wallet->export_key_images(filename, all))
{
setStatusError(tr("failed to save file ") + filename);
return false;
@@ -1491,13 +1495,6 @@ PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<stri
cryptonote::address_parse_info info;
- // indicates if dst_addr is integrated address (address + payment_id)
- // TODO: (https://bitcointalk.org/index.php?topic=753252.msg9985441#msg9985441)
- size_t fake_outs_count = mixin_count > 0 ? mixin_count : m_wallet->default_mixin();
- if (fake_outs_count == 0)
- fake_outs_count = DEFAULT_MIXIN;
- fake_outs_count = m_wallet->adjust_mixin(fake_outs_count);
-
uint32_t adjusted_priority = m_wallet->adjust_priority(static_cast<uint32_t>(priority));
PendingTransactionImpl * transaction = new PendingTransactionImpl(*this);
@@ -1563,6 +1560,9 @@ PendingTransaction *WalletImpl::createTransactionMultDest(const std::vector<stri
break;
}
try {
+ size_t fake_outs_count = mixin_count > 0 ? mixin_count : m_wallet->default_mixin();
+ fake_outs_count = m_wallet->adjust_mixin(mixin_count);
+
if (amount) {
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */,
adjusted_priority,
@@ -2063,9 +2063,24 @@ bool WalletImpl::checkReserveProof(const std::string &address, const std::string
}
}
-std::string WalletImpl::signMessage(const std::string &message)
+std::string WalletImpl::signMessage(const std::string &message, const std::string &address)
{
- return m_wallet->sign(message, tools::wallet2::sign_with_spend_key);
+ if (address.empty()) {
+ return m_wallet->sign(message, tools::wallet2::sign_with_spend_key);
+ }
+
+ cryptonote::address_parse_info info;
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address)) {
+ setStatusError(tr("Failed to parse address"));
+ return "";
+ }
+ auto index = m_wallet->get_subaddress_index(info.address);
+ if (!index) {
+ setStatusError(tr("Address doesn't belong to the wallet"));
+ return "";
+ }
+
+ return m_wallet->sign(message, tools::wallet2::sign_with_spend_key, *index);
}
bool WalletImpl::verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const
@@ -2576,6 +2591,32 @@ void WalletImpl::deviceShowAddress(uint32_t accountIndex, uint32_t addressIndex,
m_wallet->device_show_address(accountIndex, addressIndex, payment_id_param);
}
-} // namespace
-namespace Bitmonero = Monero;
+bool WalletImpl::reconnectDevice()
+{
+ clearStatus();
+
+ bool r;
+ try {
+ r = m_wallet->reconnect_device();
+ }
+ catch (const std::exception &e) {
+ LOG_ERROR(__FUNCTION__ << " error: " << e.what());
+ setStatusError(e.what());
+ return false;
+ }
+
+ return r;
+}
+
+uint64_t WalletImpl::getBytesReceived()
+{
+ return m_wallet->get_bytes_received();
+}
+
+uint64_t WalletImpl::getBytesSent()
+{
+ return m_wallet->get_bytes_sent();
+}
+
+} // namespace
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index ce2d7d7e4..217f16e48 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -89,6 +89,7 @@ public:
std::string errorString() const override;
void statusWithErrorString(int& status, std::string& errorString) const override;
bool setPassword(const std::string &password) override;
+ const std::string& getPassword() const override;
bool setDevicePin(const std::string &password) override;
bool setDevicePassphrase(const std::string &password) override;
std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0) const override;
@@ -196,7 +197,7 @@ public:
virtual bool checkSpendProof(const std::string &txid, const std::string &message, const std::string &signature, bool &good) const override;
virtual std::string getReserveProof(bool all, uint32_t account_index, uint64_t amount, const std::string &message) const override;
virtual bool checkReserveProof(const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &total, uint64_t &spent) const override;
- virtual std::string signMessage(const std::string &message) override;
+ virtual std::string signMessage(const std::string &message, const std::string &address) override;
virtual bool verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const override;
virtual std::string signMultisigParticipant(const std::string &message) const override;
virtual bool verifyMessageWithPublicKey(const std::string &message, const std::string &publicKey, const std::string &signature) const override;
@@ -220,6 +221,9 @@ public:
virtual bool isKeysFileLocked() override;
virtual uint64_t coldKeyImageSync(uint64_t &spent, uint64_t &unspent) override;
virtual void deviceShowAddress(uint32_t accountIndex, uint32_t addressIndex, const std::string &paymentId) override;
+ virtual bool reconnectDevice() override;
+ virtual uint64_t getBytesReceived() override;
+ virtual uint64_t getBytesSent() override;
private:
void clearStatus() const;
@@ -281,7 +285,4 @@ private:
} // namespace
-namespace Bitmonero = Monero;
-
#endif
-
diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h
index e34332734..a08033033 100644
--- a/src/wallet/api/wallet2_api.h
+++ b/src/wallet/api/wallet2_api.h
@@ -456,6 +456,7 @@ struct Wallet
//! returns both error and error string atomically. suggested to use in instead of status() and errorString()
virtual void statusWithErrorString(int& status, std::string& errorString) const = 0;
virtual bool setPassword(const std::string &password) = 0;
+ virtual const std::string& getPassword() const = 0;
virtual bool setDevicePin(const std::string &pin) { (void)pin; return false; };
virtual bool setDevicePassphrase(const std::string &passphrase) { (void)passphrase; return false; };
virtual std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0) const = 0;
@@ -993,7 +994,7 @@ struct Wallet
* \param message - the message to sign (arbitrary byte data)
* \return the signature
*/
- virtual std::string signMessage(const std::string &message) = 0;
+ virtual std::string signMessage(const std::string &message, const std::string &address = "") = 0;
/*!
* \brief verifySignedMessage - verify a signature matches a given message
* \param message - the message (arbitrary byte data)
@@ -1084,6 +1085,15 @@ struct Wallet
//! shows address on device display
virtual void deviceShowAddress(uint32_t accountIndex, uint32_t addressIndex, const std::string &paymentId) = 0;
+
+ //! attempt to reconnect to hardware device
+ virtual bool reconnectDevice() = 0;
+
+ //! get bytes received
+ virtual uint64_t getBytesReceived() = 0;
+
+ //! get bytes sent
+ virtual uint64_t getBytesSent() = 0;
};
/**
@@ -1362,6 +1372,3 @@ struct WalletManagerFactory
}
-
-namespace Bitmonero = Monero;
-
diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp
index 900fe91e5..417a27db5 100644
--- a/src/wallet/api/wallet_manager.cpp
+++ b/src/wallet/api/wallet_manager.cpp
@@ -406,5 +406,3 @@ void WalletManagerFactory::setLogCategories(const std::string &categories)
}
-
-namespace Bitmonero = Monero;
diff --git a/src/wallet/api/wallet_manager.h b/src/wallet/api/wallet_manager.h
index 2f603b0a9..cf3056a17 100644
--- a/src/wallet/api/wallet_manager.h
+++ b/src/wallet/api/wallet_manager.h
@@ -102,5 +102,3 @@ private:
};
} // namespace
-
-namespace Bitmonero = Monero;