pull/95/head
Ilya Kitaev 8 years ago
commit ab61ba0c9b

@ -36,7 +36,6 @@
#include "mnemonics/electrum-words.h"
#include <boost/format.hpp>
#include <boost/regex.hpp>
#include <sstream>
using namespace std;
@ -146,7 +145,6 @@ std::string Wallet::genPaymentId()
}
///////////////////////// WalletImpl implementation ////////////////////////
WalletImpl::WalletImpl(bool testnet)
:m_wallet(nullptr), m_status(Wallet::Status_Ok), m_trustedDaemon(false),
@ -397,11 +395,13 @@ bool WalletImpl::refresh()
// - payment_details;
// - unconfirmed_transfer_details;
// - confirmed_transfer_details)
PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const string &payment_id, uint64_t amount, uint32_t mixin_count)
{
clearStatus();
vector<cryptonote::tx_destination_entry> dsts;
cryptonote::tx_destination_entry de;
// indicates if dst_addr is integrated address (address + payment_id)
bool has_payment_id;
crypto::hash8 payment_id_short;
@ -420,6 +420,7 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
break;
}
std::vector<uint8_t> extra;
// if dst_addr is not an integrated address, parse payment_id
if (!has_payment_id && !payment_id.empty()) {
@ -446,7 +447,6 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
}
}
de.amount = amount;
if (de.amount <= 0) {
m_status = Status_Error;
@ -457,8 +457,6 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
dsts.push_back(de);
//std::vector<tools::wallet2::pending_tx> ptx_vector;
try {
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */,
0 /* unused fee arg*/, extra, m_trustedDaemon);

@ -3064,6 +3064,11 @@ std::string wallet2::get_keys_file() const
return m_keys_file;
}
std::string wallet2::get_daemon_address() const
{
return m_daemon_address;
}
void wallet2::set_tx_note(const crypto::hash &txid, const std::string &note)
{
m_tx_notes[txid] = note;
@ -3076,12 +3081,6 @@ std::string wallet2::get_tx_note(const crypto::hash &txid) const
return std::string();
return i->second;
}
std::string wallet2::get_daemon_address() const
{
return m_daemon_address;
}
//----------------------------------------------------------------------------------------------------
void wallet2::generate_genesis(cryptonote::block& b) {
if (m_testnet)

@ -374,6 +374,7 @@ namespace tools
std::string get_wallet_file() const;
std::string get_keys_file() const;
std::string get_daemon_address() const;
std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool trusted_daemon);
std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f);
@ -383,7 +384,6 @@ namespace tools
void set_tx_note(const crypto::hash &txid, const std::string &note);
std::string get_tx_note(const crypto::hash &txid) const;
std::string get_daemon_address() const;
private:
/*!
* \brief Stores wallet information to wallet file.

@ -134,6 +134,7 @@ struct Wallet
virtual std::string errorString() const = 0;
virtual bool setPassword(const std::string &password) = 0;
virtual std::string address() const = 0;
/*!
* \brief integratedAddress - returns integrated address for current wallet address and given payment_id.
* if passed "payment_id" param is an empty string or not-valid payment id string
@ -144,6 +145,7 @@ struct Wallet
* \return - 106 characters string representing integrated address
*/
virtual std::string integratedAddress(const std::string &payment_id) const = 0;
/*!
* \brief store - stores wallet to file.
* \param path - main filename to store wallet to. additionally stores address file and keys file.
@ -186,8 +188,10 @@ struct Wallet
* \return PendingTransaction object. caller is responsible to check PendingTransaction::status()
* after object returned
*/
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id,
uint64_t amount, uint32_t mixin_count) = 0;
virtual void disposeTransaction(PendingTransaction * t) = 0;
virtual TransactionHistory * history() const = 0;
virtual void setListener(WalletListener *) = 0;

@ -62,12 +62,6 @@ const char * WALLET_LANG = "English";
const std::string WALLETS_ROOT_DIR = "/home/mbg033/dev/monero/testnet/";
//const char * TESTNET_WALLET1_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin";
//const char * TESTNET_WALLET2_NAME = "/home/mbg033/dev/monero/testnet/wallet_02.bin";
//const char * TESTNET_WALLET3_NAME = "/home/mbg033/dev/monero/testnet/wallet_03.bin";
//const char * TESTNET_WALLET4_NAME = "/home/mbg033/dev/monero/testnet/wallet_04.bin";
//const char * TESTNET_WALLET5_NAME = "/home/mbg033/dev/monero/testnet/wallet_05.bin";
const std::string TESTNET_WALLET1_NAME = WALLETS_ROOT_DIR + "wallet_01.bin";
const std::string TESTNET_WALLET2_NAME = WALLETS_ROOT_DIR + "wallet_02.bin";
const std::string TESTNET_WALLET3_NAME = WALLETS_ROOT_DIR + "wallet_03.bin";
@ -75,7 +69,6 @@ const std::string TESTNET_WALLET4_NAME = WALLETS_ROOT_DIR + "wallet_04.bin";
const std::string TESTNET_WALLET5_NAME = WALLETS_ROOT_DIR + "wallet_05.bin";
const std::string TESTNET_WALLET6_NAME = WALLETS_ROOT_DIR + "wallet_06.bin";
const char * TESTNET_WALLET_PASS = "";
const std::string CURRENT_SRC_WALLET = TESTNET_WALLET1_NAME;
@ -250,7 +243,7 @@ TEST_F(WalletManagerTest, WalletManagerChangesPassword)
ASSERT_TRUE(wallet1->setPassword(WALLET_PASS2));
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS2);
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);quint64
ASSERT_TRUE(wallet2->seed() == seed1);
ASSERT_TRUE(wmgr->closeWallet(wallet2));
Bitmonero::Wallet * wallet3 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
@ -362,6 +355,7 @@ TEST_F(WalletManagerTest, WalletManagerFindsWallet)
}
}
TEST_F(WalletManagerTest, WalletGeneratesPaymentId)
{
std::string payment_id = Bitmonero::Wallet::genPaymentId();
@ -379,8 +373,6 @@ TEST_F(WalletManagerTest, WalletGeneratesIntegratedAddress)
}
TEST_F(WalletTest1, WalletShowsBalance)
{
// TODO: temporary disabled;
@ -459,8 +451,8 @@ TEST_F(WalletTest1, WalletTransactionWithMixin)
mixins.push_back(7); mixins.push_back(8); mixins.push_back(9); mixins.push_back(10); mixins.push_back(15);
mixins.push_back(20); mixins.push_back(25);
std::string payment_id = "";
std::string payment_id = "";
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
@ -527,9 +519,11 @@ TEST_F(WalletTest1, WalletTransactionAndHistory)
std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
PAYMENT_ID_EMPTY,
AMOUNT_10XMR * 5, 0);
ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
history = wallet_src->history();
@ -543,6 +537,7 @@ TEST_F(WalletTest1, WalletTransactionAndHistory)
}
}
TEST_F(WalletTest1, WalletTransactionWithPaymentId)
{

Loading…
Cancel
Save