1
0
Fork 0
forked from lthn/blockchain

wallet: handling incoming txs in auditablility mode (WIP)

This commit is contained in:
sowle 2020-05-11 21:23:00 +03:00
parent b30a3b8f66
commit 9397816f53
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
2 changed files with 11 additions and 2 deletions

View file

@ -263,10 +263,15 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
{
if (in.type() == typeid(currency::txin_to_key))
{
auto it = m_key_images.find(boost::get<currency::txin_to_key>(in).k_image);
const currency::txin_to_key& intk = boost::get<currency::txin_to_key>(in);
// TODO: check for references to our UTXO (auditability)
// intk.key_offsets;
auto it = m_key_images.find(intk.k_image);
if (it != m_key_images.end())
{
tx_money_spent_in_ins += boost::get<currency::txin_to_key>(in).amount;
tx_money_spent_in_ins += intk.amount;
transfer_details& td = m_transfers[it->second];
uint32_t flags_before = td.m_flags;
td.m_flags |= WALLET_TRANSFER_DETAIL_FLAG_SPENT;
@ -340,6 +345,8 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
// obtain key image for this output
crypto::key_image ki = currency::null_ki;
if (m_watch_only)
{
if (!is_auditable())
{
// don't have spend secret key, so we unable to calculate key image for an output
// look it up in special container instead
@ -355,6 +362,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
WLT_LOG_L1("can't find pending key image by out pub key: " << otk.key << ", key image temporarily set to null");
}
}
}
else
{
// normal wallet, calculate and store key images for own outs

View file

@ -631,6 +631,7 @@ namespace tools
void enumerate_unconfirmed_transfers(callback_t cb) const;
bool is_watch_only() const { return m_watch_only; }
bool is_auditable() const { return m_account.get_public_address().is_auditable(); }
void sign_transfer(const std::string& tx_sources_blob, std::string& signed_tx_blob, currency::transaction& tx);
void sign_transfer_files(const std::string& tx_sources_file, const std::string& signed_tx_file, currency::transaction& tx);
void submit_transfer(const std::string& signed_tx_blob, currency::transaction& tx);