Merge pull request #4387

6e6ffc06 wallet2_api: bring up to latest wallet api (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2018-09-18 17:59:44 +02:00
commit 2371a814cf
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
3 changed files with 38 additions and 18 deletions

View file

@ -629,7 +629,7 @@ bool WalletImpl::recoverFromDevice(const std::string &path, const std::string &p
m_recoveringFromDevice = true; m_recoveringFromDevice = true;
try try
{ {
m_wallet->restore(path, password, device_name); m_wallet->restore(path, password, device_name, false);
LOG_PRINT_L1("Generated new wallet from device: " + device_name); LOG_PRINT_L1("Generated new wallet from device: " + device_name);
} }
catch (const std::exception& e) { catch (const std::exception& e) {
@ -2109,21 +2109,36 @@ 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) bool WalletImpl::blackballOutputs(const std::vector<std::string> &outputs, bool add)
{ {
std::vector<crypto::public_key> raw_pubkeys; std::vector<std::pair<uint64_t, uint64_t>> raw_outputs;
raw_pubkeys.reserve(pubkeys.size()); raw_outputs.reserve(outputs.size());
for (const std::string &str: pubkeys) uint64_t amount = std::numeric_limits<uint64_t>::max(), offset, num_offsets;
for (const std::string &str: outputs)
{ {
crypto::public_key pkey; if (sscanf(str.c_str(), "@%" PRIu64, &amount) == 1)
if (!epee::string_tools::hex_to_pod(str, pkey)) continue;
if (amount == std::numeric_limits<uint64_t>::max())
{ {
setStatusError(tr("Failed to parse output public key")); setStatusError("First line is not an amount");
return true;
}
if (sscanf(str.c_str(), "%" PRIu64 "*%" PRIu64, &offset, &num_offsets) == 2 && num_offsets <= std::numeric_limits<uint64_t>::max() - offset)
{
while (num_offsets--)
raw_outputs.push_back(std::make_pair(amount, offset++));
}
else if (sscanf(str.c_str(), "%" PRIu64, &offset) == 1)
{
raw_outputs.push_back(std::make_pair(amount, offset));
}
else
{
setStatusError(tr("Invalid output: ") + str);
return false; return false;
} }
raw_pubkeys.push_back(pkey);
} }
bool ret = m_wallet->set_blackballed_outputs(raw_pubkeys, add); bool ret = m_wallet->set_blackballed_outputs(raw_outputs, add);
if (!ret) if (!ret)
{ {
setStatusError(tr("Failed to set blackballed outputs")); setStatusError(tr("Failed to set blackballed outputs"));
@ -2132,15 +2147,20 @@ bool WalletImpl::blackballOutputs(const std::vector<std::string> &pubkeys, bool
return true; return true;
} }
bool WalletImpl::unblackballOutput(const std::string &pubkey) bool WalletImpl::unblackballOutput(const std::string &amount, const std::string &offset)
{ {
crypto::public_key raw_pubkey; uint64_t raw_amount, raw_offset;
if (!epee::string_tools::hex_to_pod(pubkey, raw_pubkey)) if (!epee::string_tools::get_xtype_from_string(raw_amount, amount))
{ {
setStatusError(tr("Failed to parse output public key")); setStatusError(tr("Failed to parse output amount"));
return false; return false;
} }
bool ret = m_wallet->unblackball_output(raw_pubkey); if (!epee::string_tools::get_xtype_from_string(raw_offset, offset))
{
setStatusError(tr("Failed to parse output offset"));
return false;
}
bool ret = m_wallet->unblackball_output(std::make_pair(raw_amount, raw_offset));
if (!ret) if (!ret)
{ {
setStatusError(tr("Failed to unblackball output")); setStatusError(tr("Failed to unblackball output"));

View file

@ -182,7 +182,7 @@ public:
virtual bool lightWalletLogin(bool &isNewWallet) const override; virtual bool lightWalletLogin(bool &isNewWallet) const override;
virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) override; virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) override;
virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add) override; virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add) override;
virtual bool unblackballOutput(const std::string &pubkey) override; virtual bool unblackballOutput(const std::string &amount, const std::string &offset) override;
virtual bool getRing(const std::string &key_image, std::vector<uint64_t> &ring) const override; virtual bool getRing(const std::string &key_image, std::vector<uint64_t> &ring) const override;
virtual bool getRings(const std::string &txid, std::vector<std::pair<std::string, std::vector<uint64_t>>> &rings) const override; virtual bool getRings(const std::string &txid, std::vector<std::pair<std::string, std::vector<uint64_t>>> &rings) const override;
virtual bool setRing(const std::string &key_image, const std::vector<uint64_t> &ring, bool relative) override; virtual bool setRing(const std::string &key_image, const std::vector<uint64_t> &ring, bool relative) override;

View file

@ -880,7 +880,7 @@ struct Wallet
virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add) = 0; virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add) = 0;
//! unblackballs an output //! unblackballs an output
virtual bool unblackballOutput(const std::string &pubkey) = 0; virtual bool unblackballOutput(const std::string &amount, const std::string &offset) = 0;
//! gets the ring used for a key image, if any //! gets the ring used for a key image, if any
virtual bool getRing(const std::string &key_image, std::vector<uint64_t> &ring) const = 0; virtual bool getRing(const std::string &key_image, std::vector<uint64_t> &ring) const = 0;