aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wallet/wallet2_api.cpp40
-rw-r--r--src/wallet/wallet2_api.h3
2 files changed, 42 insertions, 1 deletions
diff --git a/src/wallet/wallet2_api.cpp b/src/wallet/wallet2_api.cpp
index e6ed249cc..dcd17d804 100644
--- a/src/wallet/wallet2_api.cpp
+++ b/src/wallet/wallet2_api.cpp
@@ -32,7 +32,11 @@
#include "wallet2.h"
#include "mnemonics/electrum-words.h"
#include "cryptonote_core/cryptonote_format_utils.h"
+#include "cryptonote_core/cryptonote_basic_impl.h"
+
+
#include <memory>
+#include <vector>
namespace epee {
unsigned int g_test_dbg_lock_sleep = 0;
@@ -44,11 +48,16 @@ struct WalletManagerImpl;
namespace {
static WalletManagerImpl * g_walletManager = nullptr;
+ // copy-pasted from
+ static const size_t DEFAULT_MIX = 4;
}
+
+using namespace std;
+
Wallet::~Wallet() {}
///////////////////////// Wallet implementation ////////////////////////////////
@@ -77,6 +86,7 @@ public:
uint64_t unlockedBalance() const;
std::string displayAmount(uint64_t amount) const;
bool refresh();
+ bool transfer(const std::string &dst_addr, uint64_t amount);
private:
@@ -306,6 +316,36 @@ bool WalletImpl::refresh()
return m_status == Status_Ok;
}
+bool WalletImpl::transfer(const std::string &dst_addr, uint64_t amount)
+{
+ clearStatus();
+ vector<cryptonote::tx_destination_entry> dsts;
+ cryptonote::tx_destination_entry de;
+ bool has_payment_id;
+ bool payment_id_seen = false;
+ crypto::hash8 new_payment_id;
+ size_t fake_outs_count = DEFAULT_MIX;
+ if(!cryptonote::get_account_integrated_address_from_str(de.addr, has_payment_id, new_payment_id, m_wallet->testnet(), dst_addr)) {
+ // TODO: copy-paste 'if treating as an address fails, try as url' from simplewallet.cpp:1982
+ m_status = Status_Error;
+ m_errorString = "Invalid destination address";
+ return false;
+ }
+
+ de.amount = amount;
+ if (de.amount <= 0) {
+ m_status = Status_Error;
+ m_errorString = "Invalid amount";
+ return false;
+ }
+ dsts.push_back(de);
+
+
+
+
+ return m_status == Status_Ok;
+}
+
bool WalletImpl::connectToDaemon()
{
bool result = m_wallet->check_connection();
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index c818608ed..1c3cd595a 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -74,9 +74,10 @@ struct Wallet
virtual std::string displayAmount(uint64_t amount) const = 0;
// TODO?
// virtual uint64_t unlockedDustBalance() const = 0;
- // TODO refresh
virtual bool refresh() = 0;
// TODO transfer
+ virtual bool transfer(const std::string &dst_addr, uint64_t amount) = 0;
+
};
/**