blockchain: return error when requesting non existent output

avoids RPC thread dying, causing the wallet to timeout
This commit is contained in:
moneromooo-monero 2018-06-01 21:52:04 +01:00
parent 1d3874dabf
commit 8e64b61663
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 13 additions and 6 deletions

View File

@ -1941,14 +1941,21 @@ bool Blockchain::get_outs(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMA
res.outs.clear();
res.outs.reserve(req.outputs.size());
for (const auto &i: req.outputs)
try
{
// get tx_hash, tx_out_index from DB
const output_data_t od = m_db->get_output_key(i.amount, i.index);
tx_out_index toi = m_db->get_output_tx_and_index(i.amount, i.index);
bool unlocked = is_tx_spendtime_unlocked(m_db->get_tx_unlock_time(toi.first));
for (const auto &i: req.outputs)
{
// get tx_hash, tx_out_index from DB
const output_data_t od = m_db->get_output_key(i.amount, i.index);
tx_out_index toi = m_db->get_output_tx_and_index(i.amount, i.index);
bool unlocked = is_tx_spendtime_unlocked(m_db->get_tx_unlock_time(toi.first));
res.outs.push_back({od.pubkey, od.commitment, unlocked, od.height, toi.first});
res.outs.push_back({od.pubkey, od.commitment, unlocked, od.height, toi.first});
}
}
catch (const std::exception &e)
{
return false;
}
return true;
}