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.cpp65
1 files changed, 53 insertions, 12 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index db3049f9e..8da99eb0c 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();
@@ -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