mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-18 23:58:59 +02:00
start monero_wallet_keys and default impls in monero_wallet.h
This commit is contained in:
@@ -301,7 +301,7 @@ namespace monero {
|
||||
* @return the wallet's primary address
|
||||
*/
|
||||
virtual string get_primary_address() const {
|
||||
throw runtime_error("get_primary_address() not implemented");
|
||||
return get_address(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -568,7 +568,7 @@ namespace monero {
|
||||
* @return List<monero_account> are all accounts within the wallet
|
||||
*/
|
||||
virtual vector<monero_account> get_accounts() const {
|
||||
throw runtime_error("get_accounts() not implemented");
|
||||
return get_accounts(false, string(""));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,7 +578,7 @@ namespace monero {
|
||||
* @return List<monero_account> are all accounts
|
||||
*/
|
||||
virtual vector<monero_account> get_accounts(bool include_subaddresses) const {
|
||||
throw runtime_error("get_accounts() not implemented");
|
||||
return get_accounts(include_subaddresses, "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -588,7 +588,7 @@ namespace monero {
|
||||
* @return List<monero_account> are all accounts for the wallet with the given tag
|
||||
*/
|
||||
virtual vector<monero_account> get_accounts(const string& tag) const {
|
||||
throw runtime_error("get_accounts() not implemented");
|
||||
return get_accounts(false, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -609,7 +609,7 @@ namespace monero {
|
||||
* @return the retrieved account
|
||||
*/
|
||||
virtual monero_account get_account(uint32_t account_idx) const {
|
||||
throw runtime_error("get_account() not implemented");
|
||||
return get_account(account_idx, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -640,7 +640,7 @@ namespace monero {
|
||||
* @return List<monero_subaddress> are the retrieved subaddresses
|
||||
*/
|
||||
virtual vector<monero_subaddress> get_subaddresses(const uint32_t account_idx) const {
|
||||
throw runtime_error("get_subaddresses() not implemented");
|
||||
return get_subaddresses(account_idx, vector<uint32_t>());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,7 +661,7 @@ namespace monero {
|
||||
* @param subaddress_idx specifies index of the subaddress within the account
|
||||
* @return the retrieved subaddress
|
||||
*/
|
||||
virtual monero_subaddress getSubaddress(const uint32_t account_idx, const uint32_t subaddress_idx) const {
|
||||
virtual monero_subaddress get_subaddress(const uint32_t account_idx, const uint32_t subaddress_idx) const {
|
||||
throw runtime_error("getSubaddress() not implemented");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
/**
|
||||
* Copyright (c) 2017-2019 woodser
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Parts of this file are originally copyright (c) 2014-2019, The Monero Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
*/
|
||||
|
||||
#include "monero_wallet_keys.h"
|
||||
|
||||
#include "utils/monero_utils.h"
|
||||
#include <chrono>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include "mnemonics/electrum-words.h"
|
||||
#include "mnemonics/english.h"
|
||||
#include "wallet/wallet_rpc_server_commands_defs.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace epee;
|
||||
using namespace tools;
|
||||
|
||||
/**
|
||||
* Public library interface.
|
||||
*/
|
||||
namespace monero {
|
||||
|
||||
// ---------------------------- WALLET MANAGEMENT ---------------------------
|
||||
|
||||
monero_wallet_key* monero_wallet_key::create_wallet_random(const string& path, const string& password) {
|
||||
MTRACE("create_wallet_random(path, password)");
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
// TODO: ensure that wallet does not already exist
|
||||
monero_wallet_key* monero_wallet_key::create_wallet_random(const string& path, const string& password, const monero_network_type network_type, const monero_rpc_connection& daemon_connection, const string& language) {
|
||||
MTRACE("create_wallet_random(path, password, network_type, daemon_connection, language)");
|
||||
monero_wallet_key* wallet = new monero_wallet_key();
|
||||
wallet->m_w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
|
||||
wallet->set_daemon_connection(daemon_connection);
|
||||
wallet->m_w2->set_seed_language(language);
|
||||
crypto::secret_key secret_key;
|
||||
wallet->m_w2->generate(path, password, secret_key, false, false);
|
||||
wallet->init_common();
|
||||
if (wallet->is_connected()) wallet->m_w2->set_refresh_from_block_height(wallet->get_daemon_height());
|
||||
return wallet;
|
||||
}
|
||||
|
||||
monero_wallet_key* monero_wallet_key::create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic) {
|
||||
MTRACE("create_wallet_from_mnemonic(path, password, network_type, mnemonic)");
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
monero_wallet_key* monero_wallet_key::create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic, const monero_rpc_connection& daemon_connection, uint64_t restore_height) {
|
||||
MTRACE("create_wallet_from_mnemonic(path, password, mnemonic, network_type, daemon_connection, restore_height)");
|
||||
monero_wallet_key* wallet = new monero_wallet_key();
|
||||
|
||||
// validate mnemonic and get recovery key and language
|
||||
crypto::secret_key recoveryKey;
|
||||
std::string language;
|
||||
bool is_valid = crypto::ElectrumWords::words_to_bytes(mnemonic, recoveryKey, language);
|
||||
if (!is_valid) throw runtime_error("Invalid mnemonic");
|
||||
if (language == crypto::ElectrumWords::old_language_name) language = Language::English().get_language_name();
|
||||
|
||||
// initialize wallet
|
||||
wallet->m_w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
|
||||
wallet->set_daemon_connection(daemon_connection);
|
||||
wallet->m_w2->set_seed_language(language);
|
||||
wallet->m_w2->generate(path, password, recoveryKey, true, false);
|
||||
wallet->m_w2->set_refresh_from_block_height(restore_height);
|
||||
wallet->init_common();
|
||||
return wallet;
|
||||
}
|
||||
|
||||
monero_wallet_key* monero_wallet_key::create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key) {
|
||||
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, network_type)");
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
monero_wallet_key* monero_wallet_key::create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height) {
|
||||
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, network_type, daemon_connection, restore_height)");
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
monero_wallet_key* monero_wallet_key::create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& language) {
|
||||
MTRACE("create_wallet_from_keys(path, password, address, view_key, spend_key, network_type, daemon_connection, restore_height, language)");
|
||||
monero_wallet_key* wallet = new monero_wallet_key();
|
||||
|
||||
// validate and parse address
|
||||
cryptonote::address_parse_info info;
|
||||
if (!get_account_address_from_str(info, static_cast<cryptonote::network_type>(network_type), address)) throw runtime_error("failed to parse address");
|
||||
|
||||
// validate and parse optional private spend key
|
||||
crypto::secret_key spend_key_sk;
|
||||
bool has_spend_key = false;
|
||||
if (!spend_key.empty()) {
|
||||
cryptonote::blobdata spend_key_data;
|
||||
if (!epee::string_tools::parse_hexstr_to_binbuff(spend_key, spend_key_data) || spend_key_data.size() != sizeof(crypto::secret_key)) {
|
||||
throw runtime_error("failed to parse secret spend key");
|
||||
}
|
||||
has_spend_key = true;
|
||||
spend_key_sk = *reinterpret_cast<const crypto::secret_key*>(spend_key_data.data());
|
||||
}
|
||||
|
||||
// validate and parse private view key
|
||||
bool has_view_key = true;
|
||||
crypto::secret_key view_key_sk;
|
||||
if (view_key.empty()) {
|
||||
if (has_spend_key) has_view_key = false;
|
||||
else throw runtime_error("Neither view key nor spend key supplied, cancelled");
|
||||
}
|
||||
if (has_view_key) {
|
||||
cryptonote::blobdata view_key_data;
|
||||
if (!epee::string_tools::parse_hexstr_to_binbuff(view_key, view_key_data) || view_key_data.size() != sizeof(crypto::secret_key)) {
|
||||
throw runtime_error("failed to parse secret view key");
|
||||
}
|
||||
view_key_sk = *reinterpret_cast<const crypto::secret_key*>(view_key_data.data());
|
||||
}
|
||||
|
||||
// check the spend and view keys match the given address
|
||||
crypto::public_key pkey;
|
||||
if (has_spend_key) {
|
||||
if (!crypto::secret_key_to_public_key(spend_key_sk, pkey)) throw runtime_error("failed to verify secret spend key");
|
||||
if (info.address.m_spend_public_key != pkey) throw runtime_error("spend key does not match address");
|
||||
}
|
||||
if (has_view_key) {
|
||||
if (!crypto::secret_key_to_public_key(view_key_sk, pkey)) throw runtime_error("failed to verify secret view key");
|
||||
if (info.address.m_view_public_key != pkey) throw runtime_error("view key does not match address");
|
||||
}
|
||||
|
||||
// initialize wallet
|
||||
wallet->m_w2 = unique_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(network_type), 1, true));
|
||||
if (has_spend_key && has_view_key) wallet->m_w2->generate(path, password, info.address, spend_key_sk, view_key_sk);
|
||||
if (!has_spend_key && has_view_key) wallet->m_w2->generate(path, password, info.address, view_key_sk);
|
||||
if (has_spend_key && !has_view_key) wallet->m_w2->generate(path, password, spend_key_sk, true, false);
|
||||
wallet->set_daemon_connection(daemon_connection);
|
||||
wallet->m_w2->set_refresh_from_block_height(restore_height);
|
||||
wallet->m_w2->set_seed_language(language);
|
||||
wallet->init_common();
|
||||
return wallet;
|
||||
}
|
||||
|
||||
monero_wallet_key::~monero_wallet_key() {
|
||||
MTRACE("~monero_wallet_key()");
|
||||
close(false);
|
||||
}
|
||||
|
||||
// ----------------------------- WALLET METHODS -----------------------------
|
||||
|
||||
monero_version monero_wallet_key::get_version() const {
|
||||
monero_version version;
|
||||
version.m_number = 65552; // same as monero-wallet-rpc v0.15.0.1 release
|
||||
version.m_is_release = false; // TODO: could pull from MONERO_VERSION_IS_RELEASE in version.cpp
|
||||
return version;
|
||||
}
|
||||
|
||||
monero_network_type monero_wallet_key::get_network_type() const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
string monero_wallet_key::get_language() const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
vector<string> monero_wallet_key::get_languages() const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
string monero_wallet_key::get_mnemonic() const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
string monero_wallet_key::get_public_view_key() const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
string monero_wallet_key::get_private_view_key() const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
string monero_wallet_key::get_public_spend_key() const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
string monero_wallet_key::get_private_spend_key() const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
string monero_wallet_key::get_address(uint32_t account_idx, uint32_t subaddress_idx) const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
monero_subaddress monero_wallet_key::get_address_index(const string& address) const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
monero_integrated_address monero_wallet_key::get_integrated_address(const string& standard_address, const string& payment_id) const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
monero_integrated_address monero_wallet_key::decode_integrated_address(const string& integrated_address) const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
vector<monero_account> monero_wallet_key::get_accounts(bool include_subaddresses, const string& tag) const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
monero_account monero_wallet_key::get_account(uint32_t account_idx, bool include_subaddresses) const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
monero_account monero_wallet_key::create_account(const string& label) {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
vector<monero_subaddress> monero_wallet_key::get_subaddresses(const uint32_t account_idx) const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
vector<monero_subaddress> monero_wallet_key::get_subaddresses(const uint32_t account_idx, const vector<uint32_t>& subaddress_indices) const {
|
||||
throw runtime_error("monero_wallet_key::get_subaddresses() not implemented");
|
||||
}
|
||||
|
||||
monero_subaddress monero_wallet_key::get_subaddress(const uint32_t account_idx, const uint32_t subaddress_idx) const {
|
||||
throw runtime_error("monero_wallet_key::getSubaddress() not implemented");
|
||||
}
|
||||
|
||||
// get_subaddresses
|
||||
|
||||
monero_subaddress monero_wallet_key::create_subaddress(const uint32_t account_idx, const string& label) {
|
||||
throw runtime_error("monero_wallet_key::getSubaddress() not implemented");
|
||||
}
|
||||
void monero_wallet_key::close() {
|
||||
throw runtime_error("monero_wallet_key::getSubaddress() not implemented");
|
||||
}
|
||||
|
||||
// ------------------------------- PRIVATE HELPERS ----------------------------
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* Copyright (c) 2017-2019 woodser
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Parts of this file are originally copyright (c) 2014-2019, The Monero Project
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "monero_wallet.h"
|
||||
#include "wallet/wallet2.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace crypto;
|
||||
using namespace monero;
|
||||
|
||||
/**
|
||||
* Public library interface.
|
||||
*/
|
||||
namespace monero {
|
||||
|
||||
/**
|
||||
* Monero wallet implementation to provide basic offline key management.
|
||||
*/
|
||||
class monero_wallet_keys : public monero_wallet {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create a new wallet with a randomly generated seed.
|
||||
*
|
||||
* @param path is the path to create the wallet
|
||||
* @param password is the password encrypt the wallet
|
||||
* @param network_type is the wallet's network type (default = monero_network_type.MAINNET)
|
||||
* @param daemon_connection is connection information to a daemon (default = an unconnected wallet)
|
||||
* @param language is the wallet and mnemonic's language (default = "English")
|
||||
*/
|
||||
static monero_wallet_w2* create_wallet_random(const string& path, const string& password);
|
||||
static monero_wallet_w2* create_wallet_random(const string& path, const string& password, const monero_network_type network_type, const monero_rpc_connection& daemon_connection, const string& language);
|
||||
|
||||
/**
|
||||
* Create a wallet from an existing mnemonic phrase.
|
||||
*
|
||||
* @param path is the path to create the wallet
|
||||
* @param password is the password encrypt the wallet
|
||||
* @param network_type is the wallet's network type
|
||||
* @param mnemonic is the mnemonic of the wallet to construct
|
||||
* @param daemon_connection is connection information to a daemon (default = an unconnected wallet)
|
||||
* @param restore_height is the block height to restore (i.e. scan the chain) from (default = 0)
|
||||
*/
|
||||
static monero_wallet_w2* create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic);
|
||||
static monero_wallet_w2* create_wallet_from_mnemonic(const string& path, const string& password, const monero_network_type network_type, const string& mnemonic, const monero_rpc_connection& daemon_connection, uint64_t restore_height);
|
||||
|
||||
/**
|
||||
* Create a wallet from an address, view key, and spend key.
|
||||
*
|
||||
* @param path is the path to create the wallet
|
||||
* @param password is the password encrypt the wallet
|
||||
* @param network_type is the wallet's network type
|
||||
* @param address is the address of the wallet to construct
|
||||
* @param view_key is the view key of the wallet to construct
|
||||
* @param spend_key is the spend key of the wallet to construct
|
||||
* @param daemon_connection is connection information to a daemon (default = an unconnected wallet)
|
||||
* @param restore_height is the block height to restore (i.e. scan the chain) from (default = 0)
|
||||
* @param language is the wallet and mnemonic's language (default = "English")
|
||||
*/
|
||||
static monero_wallet_w2* create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key);
|
||||
static monero_wallet_w2* create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height);
|
||||
static monero_wallet_w2* create_wallet_from_keys(const string& path, const string& password, const monero_network_type network_type, const string& address, const string& view_key, const string& spend_key, const monero_rpc_connection& daemon_connection, uint64_t restore_height, const string& language);
|
||||
|
||||
/**
|
||||
* Destruct the wallet.
|
||||
*/
|
||||
~monero_wallet_keys();
|
||||
|
||||
/**
|
||||
* Supported wallet methods.
|
||||
*/
|
||||
monero_version get_version() const;
|
||||
monero_network_type get_network_type() const;
|
||||
string get_mnemonic() const;
|
||||
string get_language() const;
|
||||
vector<string> get_languages() const;
|
||||
string get_public_view_key() const;
|
||||
string get_private_view_key() const;
|
||||
string get_public_spend_key() const;
|
||||
string get_private_spend_key() const;
|
||||
string get_address(const uint32_t account_idx, const uint32_t subaddress_idx) const;
|
||||
monero_subaddress get_address_index(const string& address) const;
|
||||
monero_integrated_address get_integrated_address(const string& standard_address = "", const string& payment_id = "") const;
|
||||
monero_integrated_address decode_integrated_address(const string& integrated_address) const;
|
||||
vector<monero_account> get_accounts(bool include_subaddresses, const string& tag) const;
|
||||
monero_account get_account(const uint32_t account_idx, bool include_subaddresses) const;
|
||||
monero_account create_account(const string& label = "");
|
||||
vector<monero_subaddress> get_subaddresses(const uint32_t account_idx, const vector<uint32_t>& subaddress_indices) const;
|
||||
monero_subaddress getSubaddress(const uint32_t account_idx, const uint32_t subaddress_idx) const;
|
||||
monero_subaddress create_subaddress(uint32_t account_idx, const string& label = "");
|
||||
string sign(const string& msg) const;
|
||||
bool verify(const string& msg, const string& address, const string& signature) const;
|
||||
void close();
|
||||
|
||||
// --------------------------------- PRIVATE --------------------------------
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1038,11 +1038,6 @@ namespace monero {
|
||||
return spend_key;
|
||||
}
|
||||
|
||||
string monero_wallet_w2::get_primary_address() const {
|
||||
MTRACE("get_primary_address()");
|
||||
return get_address(0, 0);
|
||||
}
|
||||
|
||||
string monero_wallet_w2::get_address(uint32_t account_idx, uint32_t subaddress_idx) const {
|
||||
return m_w2->get_subaddress_as_str({account_idx, subaddress_idx});
|
||||
}
|
||||
@@ -1273,21 +1268,6 @@ namespace monero {
|
||||
return iter == unlocked_balance_per_subaddress.end() ? 0 : iter->second.first;
|
||||
}
|
||||
|
||||
vector<monero_account> monero_wallet_w2::get_accounts() const {
|
||||
MTRACE("get_accounts()");
|
||||
return get_accounts(false, string(""));
|
||||
}
|
||||
|
||||
vector<monero_account> monero_wallet_w2::get_accounts(bool include_subaddresses) const {
|
||||
MTRACE("get_accounts(" << include_subaddresses << ")");
|
||||
return get_accounts(include_subaddresses, "");
|
||||
}
|
||||
|
||||
vector<monero_account> monero_wallet_w2::get_accounts(const string& tag) const {
|
||||
MTRACE("get_accounts(" << tag << ")");
|
||||
return get_accounts(false, tag);
|
||||
}
|
||||
|
||||
vector<monero_account> monero_wallet_w2::get_accounts(bool include_subaddresses, const string& tag) const {
|
||||
MTRACE("get_accounts(" << include_subaddresses << ", " << tag << ")");
|
||||
|
||||
@@ -1310,10 +1290,6 @@ namespace monero {
|
||||
return accounts;
|
||||
}
|
||||
|
||||
monero_account monero_wallet_w2::get_account(const uint32_t account_idx) const {
|
||||
return get_account(account_idx, false);
|
||||
}
|
||||
|
||||
monero_account monero_wallet_w2::get_account(uint32_t account_idx, bool include_subaddresses) const {
|
||||
MTRACE("get_account(" << account_idx << ", " << include_subaddresses << ")");
|
||||
|
||||
@@ -1346,10 +1322,6 @@ namespace monero {
|
||||
return account;
|
||||
}
|
||||
|
||||
vector<monero_subaddress> monero_wallet_w2::get_subaddresses(const uint32_t account_idx) const {
|
||||
return get_subaddresses(account_idx, vector<uint32_t>());
|
||||
}
|
||||
|
||||
vector<monero_subaddress> monero_wallet_w2::get_subaddresses(const uint32_t account_idx, const vector<uint32_t>& subaddress_indices) const {
|
||||
MTRACE("get_subaddresses(" << account_idx << ", ...)");
|
||||
MTRACE("Subaddress indices size: " << subaddress_indices.size());
|
||||
@@ -1359,7 +1331,7 @@ namespace monero {
|
||||
return get_subaddresses_aux(account_idx, subaddress_indices, transfers);
|
||||
}
|
||||
|
||||
monero_subaddress monero_wallet_w2::getSubaddress(const uint32_t account_idx, const uint32_t subaddress_idx) const {
|
||||
monero_subaddress monero_wallet_w2::get_subaddress(const uint32_t account_idx, const uint32_t subaddress_idx) const {
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
@@ -2020,13 +1992,13 @@ namespace monero {
|
||||
indices[request.m_account_index.get()] = request.m_subaddress_indices;
|
||||
} else {
|
||||
vector<uint32_t> subaddress_indices;
|
||||
for (const monero_subaddress& subaddress : get_subaddresses(request.m_account_index.get())) {
|
||||
for (const monero_subaddress& subaddress : monero_wallet::get_subaddresses(request.m_account_index.get())) {
|
||||
if (subaddress.m_unlocked_balance.get() > 0) subaddress_indices.push_back(subaddress.m_index.get());
|
||||
}
|
||||
indices[request.m_account_index.get()] = subaddress_indices;
|
||||
}
|
||||
} else {
|
||||
vector<monero_account> accounts = get_accounts(true);
|
||||
vector<monero_account> accounts = monero_wallet::get_accounts(true);
|
||||
for (const monero_account& account : accounts) {
|
||||
if (account.m_unlocked_balance.get() > 0) {
|
||||
vector<uint32_t> subaddress_indices;
|
||||
|
||||
@@ -166,7 +166,6 @@ namespace monero {
|
||||
string get_private_view_key() const;
|
||||
string get_public_spend_key() const;
|
||||
string get_private_spend_key() const;
|
||||
string get_primary_address() const;
|
||||
string get_address(const uint32_t account_idx, const uint32_t subaddress_idx) const;
|
||||
monero_subaddress get_address_index(const string& address) const;
|
||||
monero_integrated_address get_integrated_address(const string& standard_address = "", const string& payment_id = "") const;
|
||||
@@ -193,16 +192,11 @@ namespace monero {
|
||||
uint64_t get_unlocked_balance() const;
|
||||
uint64_t get_unlocked_balance(uint32_t account_idx) const;
|
||||
uint64_t get_unlocked_balance(uint32_t account_idx, uint32_t subaddress_idx) const;
|
||||
vector<monero_account> get_accounts() const;
|
||||
vector<monero_account> get_accounts(bool include_subaddresses) const;
|
||||
vector<monero_account> get_accounts(const string& tag) const;
|
||||
vector<monero_account> get_accounts(bool include_subaddresses, const string& tag) const;
|
||||
monero_account get_account(uint32_t account_idx) const;
|
||||
monero_account get_account(const uint32_t account_idx, bool include_subaddresses) const;
|
||||
monero_account create_account(const string& label = "");
|
||||
vector<monero_subaddress> get_subaddresses(const uint32_t account_idx) const;
|
||||
vector<monero_subaddress> get_subaddresses(const uint32_t account_idx, const vector<uint32_t>& subaddress_indices) const;
|
||||
monero_subaddress getSubaddress(const uint32_t account_idx, const uint32_t subaddress_idx) const;
|
||||
monero_subaddress get_subaddress(const uint32_t account_idx, const uint32_t subaddress_idx) const;
|
||||
monero_subaddress create_subaddress(uint32_t account_idx, const string& label = "");
|
||||
vector<shared_ptr<monero_tx_wallet>> get_txs() const;
|
||||
vector<shared_ptr<monero_tx_wallet>> get_txs(const monero_tx_query& query) const;
|
||||
|
||||
Reference in New Issue
Block a user