mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 21:33:27 +01:00
wallet2_api: add API for tx notes
This commit is contained in:
parent
d51f1af75f
commit
97288a5ce2
@ -69,6 +69,14 @@ string PendingTransactionImpl::errorString() const
|
||||
return m_errorString;
|
||||
}
|
||||
|
||||
std::vector<std::string> PendingTransactionImpl::txid() const
|
||||
{
|
||||
std::vector<std::string> txid;
|
||||
for (const auto &pt: m_pending_tx)
|
||||
txid.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(pt.tx)));
|
||||
return txid;
|
||||
}
|
||||
|
||||
bool PendingTransactionImpl::commit()
|
||||
{
|
||||
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
uint64_t amount() const;
|
||||
uint64_t dust() const;
|
||||
uint64_t fee() const;
|
||||
std::vector<std::string> txid() const;
|
||||
// TODO: continue with interface;
|
||||
|
||||
private:
|
||||
|
@ -707,6 +707,26 @@ void WalletImpl::setDefaultMixin(uint32_t arg)
|
||||
m_wallet->default_mixin(arg);
|
||||
}
|
||||
|
||||
bool WalletImpl::setUserNote(const std::string &txid, const std::string ¬e)
|
||||
{
|
||||
cryptonote::blobdata txid_data;
|
||||
if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data))
|
||||
return false;
|
||||
const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
|
||||
|
||||
m_wallet->set_tx_note(htxid, note);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string WalletImpl::getUserNote(const std::string &txid) const
|
||||
{
|
||||
cryptonote::blobdata txid_data;
|
||||
if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data))
|
||||
return "";
|
||||
const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
|
||||
|
||||
return m_wallet->get_tx_note(htxid);
|
||||
}
|
||||
|
||||
bool WalletImpl::connectToDaemon()
|
||||
{
|
||||
|
@ -97,6 +97,8 @@ public:
|
||||
virtual void setListener(WalletListener * l);
|
||||
virtual uint32_t defaultMixin() const;
|
||||
virtual void setDefaultMixin(uint32_t arg);
|
||||
virtual bool setUserNote(const std::string &txid, const std::string ¬e);
|
||||
virtual std::string getUserNote(const std::string &txid) const;
|
||||
|
||||
private:
|
||||
void clearStatus();
|
||||
|
@ -65,6 +65,7 @@ struct PendingTransaction
|
||||
virtual uint64_t amount() const = 0;
|
||||
virtual uint64_t dust() const = 0;
|
||||
virtual uint64_t fee() const = 0;
|
||||
virtual std::vector<std::string> txid() const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -340,6 +341,20 @@ struct Wallet
|
||||
* \param arg
|
||||
*/
|
||||
virtual void setDefaultMixin(uint32_t arg) = 0;
|
||||
|
||||
/*!
|
||||
* \brief setUserNote - attach an arbitrary string note to a txid
|
||||
* \param txid - the transaction id to attach the note to
|
||||
* \param note - the note
|
||||
* \return true if succesful, false otherwise
|
||||
*/
|
||||
virtual bool setUserNote(const std::string &txid, const std::string ¬e) = 0;
|
||||
/*!
|
||||
* \brief getUserNote - return an arbitrary string note attached to a txid
|
||||
* \param txid - the transaction id to attach the note to
|
||||
* \return the attached note, or empty string if there is none
|
||||
*/
|
||||
virtual std::string getUserNote(const std::string &txid) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user