mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 21:03:28 +01:00
wallet2_api: add blackball api
This commit is contained in:
parent
2ab66ff1d4
commit
a7da8208f5
@ -69,6 +69,7 @@ target_link_libraries(wallet_api
|
|||||||
common
|
common
|
||||||
cryptonote_core
|
cryptonote_core
|
||||||
mnemonics
|
mnemonics
|
||||||
|
${LMDB_LIBRARY}
|
||||||
${Boost_CHRONO_LIBRARY}
|
${Boost_CHRONO_LIBRARY}
|
||||||
${Boost_SERIALIZATION_LIBRARY}
|
${Boost_SERIALIZATION_LIBRARY}
|
||||||
${Boost_FILESYSTEM_LIBRARY}
|
${Boost_FILESYSTEM_LIBRARY}
|
||||||
|
@ -68,6 +68,15 @@ namespace {
|
|||||||
static const int DEFAULT_REMOTE_NODE_REFRESH_INTERVAL_MILLIS = 1000 * 10;
|
static const int DEFAULT_REMOTE_NODE_REFRESH_INTERVAL_MILLIS = 1000 * 10;
|
||||||
// Connection timeout 30 sec
|
// Connection timeout 30 sec
|
||||||
static const int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 1000 * 30;
|
static const int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 1000 * 30;
|
||||||
|
|
||||||
|
std::string get_default_ringdb_path()
|
||||||
|
{
|
||||||
|
boost::filesystem::path dir = tools::get_default_data_dir();
|
||||||
|
// remove .bitmonero, replace with .shared-ringdb
|
||||||
|
dir = dir.remove_filename();
|
||||||
|
dir /= ".shared-ringdb";
|
||||||
|
return dir.string();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Wallet2CallbackImpl : public tools::i_wallet2_callback
|
struct Wallet2CallbackImpl : public tools::i_wallet2_callback
|
||||||
@ -590,6 +599,7 @@ bool WalletImpl::open(const std::string &path, const std::string &password)
|
|||||||
// Rebuilding wallet cache, using refresh height from .keys file
|
// Rebuilding wallet cache, using refresh height from .keys file
|
||||||
m_rebuildWalletCache = true;
|
m_rebuildWalletCache = true;
|
||||||
}
|
}
|
||||||
|
m_wallet->set_ring_database(get_default_ringdb_path());
|
||||||
m_wallet->load(path, password);
|
m_wallet->load(path, password);
|
||||||
|
|
||||||
m_password = password;
|
m_password = password;
|
||||||
@ -1777,6 +1787,7 @@ void WalletImpl::doRefresh()
|
|||||||
if (m_history->count() == 0) {
|
if (m_history->count() == 0) {
|
||||||
m_history->refresh();
|
m_history->refresh();
|
||||||
}
|
}
|
||||||
|
m_wallet->find_and_save_rings(false);
|
||||||
} else {
|
} else {
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": skipping refresh - daemon is not synced");
|
LOG_PRINT_L3(__FUNCTION__ << ": skipping refresh - daemon is not synced");
|
||||||
}
|
}
|
||||||
@ -1897,6 +1908,50 @@ bool WalletImpl::useForkRules(uint8_t version, int64_t early_blocks) const
|
|||||||
return m_wallet->use_fork_rules(version,early_blocks);
|
return m_wallet->use_fork_rules(version,early_blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WalletImpl::blackballOutputs(const std::vector<std::string> &pubkeys, bool add)
|
||||||
|
{
|
||||||
|
std::vector<crypto::public_key> raw_pubkeys;
|
||||||
|
raw_pubkeys.reserve(pubkeys.size());
|
||||||
|
for (const std::string &str: pubkeys)
|
||||||
|
{
|
||||||
|
crypto::public_key pkey;
|
||||||
|
if (!epee::string_tools::hex_to_pod(str, pkey))
|
||||||
|
{
|
||||||
|
m_status = Status_Error;
|
||||||
|
m_errorString = tr("Failed to parse output public key");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
raw_pubkeys.push_back(pkey);
|
||||||
|
}
|
||||||
|
bool ret = m_wallet->set_blackballed_outputs(raw_pubkeys, add);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
m_status = Status_Error;
|
||||||
|
m_errorString = tr("Failed to set blackballed outputs");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WalletImpl::unblackballOutput(const std::string &pubkey)
|
||||||
|
{
|
||||||
|
crypto::public_key raw_pubkey;
|
||||||
|
if (!epee::string_tools::hex_to_pod(pubkey, raw_pubkey))
|
||||||
|
{
|
||||||
|
m_status = Status_Error;
|
||||||
|
m_errorString = tr("Failed to parse output public key");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool ret = m_wallet->unblackball_output(raw_pubkey);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
m_status = Status_Error;
|
||||||
|
m_errorString = tr("Failed to unblackball output");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace Bitmonero = Monero;
|
namespace Bitmonero = Monero;
|
||||||
|
@ -163,6 +163,8 @@ public:
|
|||||||
virtual std::string getDefaultDataDir() const;
|
virtual std::string getDefaultDataDir() const;
|
||||||
virtual bool lightWalletLogin(bool &isNewWallet) const;
|
virtual bool lightWalletLogin(bool &isNewWallet) const;
|
||||||
virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status);
|
virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status);
|
||||||
|
virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add);
|
||||||
|
virtual bool unblackballOutput(const std::string &pubkey);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearStatus() const;
|
void clearStatus() const;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -756,6 +757,12 @@ struct Wallet
|
|||||||
*/
|
*/
|
||||||
virtual bool rescanSpent() = 0;
|
virtual bool rescanSpent() = 0;
|
||||||
|
|
||||||
|
//! blackballs a set of outputs
|
||||||
|
virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add) = 0;
|
||||||
|
|
||||||
|
//! unblackballs an output
|
||||||
|
virtual bool unblackballOutput(const std::string &pubkey) = 0;
|
||||||
|
|
||||||
//! Light wallet authenticate and login
|
//! Light wallet authenticate and login
|
||||||
virtual bool lightWalletLogin(bool &isNewWallet) const = 0;
|
virtual bool lightWalletLogin(bool &isNewWallet) const = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user