mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Merge branch 'master' of https://github.com/mbg033/bitmonero
This commit is contained in:
commit
ab61ba0c9b
5 changed files with 19 additions and 23 deletions
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
#include "mnemonics/electrum-words.h"
|
#include "mnemonics/electrum-words.h"
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/regex.hpp>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -146,7 +145,6 @@ std::string Wallet::genPaymentId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////// WalletImpl implementation ////////////////////////
|
///////////////////////// WalletImpl implementation ////////////////////////
|
||||||
WalletImpl::WalletImpl(bool testnet)
|
WalletImpl::WalletImpl(bool testnet)
|
||||||
:m_wallet(nullptr), m_status(Wallet::Status_Ok), m_trustedDaemon(false),
|
:m_wallet(nullptr), m_status(Wallet::Status_Ok), m_trustedDaemon(false),
|
||||||
|
@ -397,11 +395,13 @@ bool WalletImpl::refresh()
|
||||||
// - payment_details;
|
// - payment_details;
|
||||||
// - unconfirmed_transfer_details;
|
// - unconfirmed_transfer_details;
|
||||||
// - confirmed_transfer_details)
|
// - confirmed_transfer_details)
|
||||||
|
|
||||||
PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const string &payment_id, uint64_t amount, uint32_t mixin_count)
|
PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const string &payment_id, uint64_t amount, uint32_t mixin_count)
|
||||||
{
|
{
|
||||||
clearStatus();
|
clearStatus();
|
||||||
vector<cryptonote::tx_destination_entry> dsts;
|
vector<cryptonote::tx_destination_entry> dsts;
|
||||||
cryptonote::tx_destination_entry de;
|
cryptonote::tx_destination_entry de;
|
||||||
|
|
||||||
// indicates if dst_addr is integrated address (address + payment_id)
|
// indicates if dst_addr is integrated address (address + payment_id)
|
||||||
bool has_payment_id;
|
bool has_payment_id;
|
||||||
crypto::hash8 payment_id_short;
|
crypto::hash8 payment_id_short;
|
||||||
|
@ -420,6 +420,7 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<uint8_t> extra;
|
std::vector<uint8_t> extra;
|
||||||
// if dst_addr is not an integrated address, parse payment_id
|
// if dst_addr is not an integrated address, parse payment_id
|
||||||
if (!has_payment_id && !payment_id.empty()) {
|
if (!has_payment_id && !payment_id.empty()) {
|
||||||
|
@ -446,7 +447,6 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
de.amount = amount;
|
de.amount = amount;
|
||||||
if (de.amount <= 0) {
|
if (de.amount <= 0) {
|
||||||
m_status = Status_Error;
|
m_status = Status_Error;
|
||||||
|
@ -457,8 +457,6 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
|
||||||
dsts.push_back(de);
|
dsts.push_back(de);
|
||||||
//std::vector<tools::wallet2::pending_tx> ptx_vector;
|
//std::vector<tools::wallet2::pending_tx> ptx_vector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */,
|
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */,
|
||||||
0 /* unused fee arg*/, extra, m_trustedDaemon);
|
0 /* unused fee arg*/, extra, m_trustedDaemon);
|
||||||
|
|
|
@ -3064,6 +3064,11 @@ std::string wallet2::get_keys_file() const
|
||||||
return m_keys_file;
|
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 ¬e)
|
void wallet2::set_tx_note(const crypto::hash &txid, const std::string ¬e)
|
||||||
{
|
{
|
||||||
m_tx_notes[txid] = 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 std::string();
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string wallet2::get_daemon_address() const
|
|
||||||
{
|
|
||||||
return m_daemon_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
void wallet2::generate_genesis(cryptonote::block& b) {
|
void wallet2::generate_genesis(cryptonote::block& b) {
|
||||||
if (m_testnet)
|
if (m_testnet)
|
||||||
|
|
|
@ -374,6 +374,7 @@ namespace tools
|
||||||
|
|
||||||
std::string get_wallet_file() const;
|
std::string get_wallet_file() const;
|
||||||
std::string get_keys_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_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);
|
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 ¬e);
|
void set_tx_note(const crypto::hash &txid, const std::string ¬e);
|
||||||
std::string get_tx_note(const crypto::hash &txid) const;
|
std::string get_tx_note(const crypto::hash &txid) const;
|
||||||
|
|
||||||
std::string get_daemon_address() const;
|
|
||||||
private:
|
private:
|
||||||
/*!
|
/*!
|
||||||
* \brief Stores wallet information to wallet file.
|
* \brief Stores wallet information to wallet file.
|
||||||
|
|
|
@ -134,6 +134,7 @@ struct Wallet
|
||||||
virtual std::string errorString() const = 0;
|
virtual std::string errorString() const = 0;
|
||||||
virtual bool setPassword(const std::string &password) = 0;
|
virtual bool setPassword(const std::string &password) = 0;
|
||||||
virtual std::string address() const = 0;
|
virtual std::string address() const = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief integratedAddress - returns integrated address for current wallet address and given payment_id.
|
* \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
|
* 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
|
* \return - 106 characters string representing integrated address
|
||||||
*/
|
*/
|
||||||
virtual std::string integratedAddress(const std::string &payment_id) const = 0;
|
virtual std::string integratedAddress(const std::string &payment_id) const = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief store - stores wallet to file.
|
* \brief store - stores wallet to file.
|
||||||
* \param path - main filename to store wallet to. additionally stores address file and keys 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()
|
* \return PendingTransaction object. caller is responsible to check PendingTransaction::status()
|
||||||
* after object returned
|
* after object returned
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id,
|
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id,
|
||||||
uint64_t amount, uint32_t mixin_count) = 0;
|
uint64_t amount, uint32_t mixin_count) = 0;
|
||||||
|
|
||||||
virtual void disposeTransaction(PendingTransaction * t) = 0;
|
virtual void disposeTransaction(PendingTransaction * t) = 0;
|
||||||
virtual TransactionHistory * history() const = 0;
|
virtual TransactionHistory * history() const = 0;
|
||||||
virtual void setListener(WalletListener *) = 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 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_WALLET1_NAME = WALLETS_ROOT_DIR + "wallet_01.bin";
|
||||||
const std::string TESTNET_WALLET2_NAME = WALLETS_ROOT_DIR + "wallet_02.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";
|
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_WALLET5_NAME = WALLETS_ROOT_DIR + "wallet_05.bin";
|
||||||
const std::string TESTNET_WALLET6_NAME = WALLETS_ROOT_DIR + "wallet_06.bin";
|
const std::string TESTNET_WALLET6_NAME = WALLETS_ROOT_DIR + "wallet_06.bin";
|
||||||
|
|
||||||
|
|
||||||
const char * TESTNET_WALLET_PASS = "";
|
const char * TESTNET_WALLET_PASS = "";
|
||||||
|
|
||||||
const std::string CURRENT_SRC_WALLET = TESTNET_WALLET1_NAME;
|
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(wallet1->setPassword(WALLET_PASS2));
|
||||||
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
||||||
Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS2);
|
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(wallet2->seed() == seed1);
|
||||||
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
||||||
Bitmonero::Wallet * wallet3 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
|
Bitmonero::Wallet * wallet3 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
|
||||||
|
@ -362,6 +355,7 @@ TEST_F(WalletManagerTest, WalletManagerFindsWallet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(WalletManagerTest, WalletGeneratesPaymentId)
|
TEST_F(WalletManagerTest, WalletGeneratesPaymentId)
|
||||||
{
|
{
|
||||||
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
||||||
|
@ -379,8 +373,6 @@ TEST_F(WalletManagerTest, WalletGeneratesIntegratedAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_F(WalletTest1, WalletShowsBalance)
|
TEST_F(WalletTest1, WalletShowsBalance)
|
||||||
{
|
{
|
||||||
// TODO: temporary disabled;
|
// 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(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);
|
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);
|
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);
|
std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
|
||||||
|
|
||||||
|
|
||||||
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
|
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
|
||||||
PAYMENT_ID_EMPTY,
|
PAYMENT_ID_EMPTY,
|
||||||
AMOUNT_10XMR * 5, 0);
|
AMOUNT_10XMR * 5, 0);
|
||||||
|
|
||||||
ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok);
|
ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok);
|
||||||
ASSERT_TRUE(tx->commit());
|
ASSERT_TRUE(tx->commit());
|
||||||
history = wallet_src->history();
|
history = wallet_src->history();
|
||||||
|
@ -543,6 +537,7 @@ TEST_F(WalletTest1, WalletTransactionAndHistory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(WalletTest1, WalletTransactionWithPaymentId)
|
TEST_F(WalletTest1, WalletTransactionWithPaymentId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue