bool init_output_indices(map_output_idx_t& outs, std::map<uint64_t, std::vector<size_t> >& outs_mine, const std::vector<cryptonote::Block>& blockchain, const map_hash2tx_t& mtx, const cryptonote::account_base& from) { BOOST_FOREACH (const Block& blk, blockchain) { vector<const Transaction*> vtx; vtx.push_back(&blk.minerTx); for (const crypto::hash& h : blk.txHashes) { const map_hash2tx_t::const_iterator cit = mtx.find(h); if (mtx.end() == cit) throw std::runtime_error("block contains an unknown tx hash"); vtx.push_back(cit->second); } //vtx.insert(vtx.end(), blk.); // TODO: add all other txes for (size_t i = 0; i < vtx.size(); i++) { const Transaction &tx = *vtx[i]; size_t keyIndex = 0; for (size_t j = 0; j < tx.vout.size(); ++j) { const TransactionOutput &out = tx.vout[j]; if (out.target.type() == typeid(TransactionOutputToKey)) { output_index oi(out.target, out.amount, boost::get<TransactionInputGenerate>(*blk.minerTx.vin.begin()).height, i, j, &blk, vtx[i]); outs[out.amount].push_back(oi); size_t tx_global_idx = outs[out.amount].size() - 1; outs[out.amount][tx_global_idx].idx = tx_global_idx; // Is out to me? if (is_out_to_acc(from.get_keys(), boost::get<TransactionOutputToKey>(out.target), get_tx_pub_key_from_extra(tx), keyIndex)) { outs_mine[out.amount].push_back(tx_global_idx); } ++keyIndex; } else if (out.target.type() == typeid(TransactionOutputMultisignature)) { keyIndex += boost::get<TransactionOutputMultisignature>(out.target).keys.size(); } } } }
bool init_output_indices(map_output_idx_t& outs, std::map<uint64_t, std::vector<size_t> >& outs_mine, const std::vector<CryptoNote::Block>& blockchain, const map_hash2tx_t& mtx, const CryptoNote::AccountBase& from) { BOOST_FOREACH (const Block& blk, blockchain) { vector<const Transaction*> vtx; vtx.push_back(&blk.baseTransaction); for (const Crypto::Hash& h : blk.transactionHashes) { const map_hash2tx_t::const_iterator cit = mtx.find(h); if (mtx.end() == cit) throw std::runtime_error("block contains an unknown tx hash"); vtx.push_back(cit->second); } //vtx.insert(vtx.end(), blk.); // TODO: add all other txes for (size_t i = 0; i < vtx.size(); i++) { const Transaction &tx = *vtx[i]; size_t keyIndex = 0; for (size_t j = 0; j < tx.outputs.size(); ++j) { const TransactionOutput &out = tx.outputs[j]; if (out.target.type() == typeid(KeyOutput)) { output_index oi(out.target, out.amount, boost::get<BaseInput>(*blk.baseTransaction.inputs.begin()).blockIndex, i, j, &blk, vtx[i]); outs[out.amount].push_back(oi); uint32_t tx_global_idx = static_cast<uint32_t>(outs[out.amount].size() - 1); outs[out.amount][tx_global_idx].idx = tx_global_idx; // Is out to me? if (is_out_to_acc(from.getAccountKeys(), boost::get<KeyOutput>(out.target), getTransactionPublicKeyFromExtra(tx.extra), keyIndex)) { outs_mine[out.amount].push_back(tx_global_idx); } ++keyIndex; } else if (out.target.type() == typeid(MultisignatureOutput)) { keyIndex += boost::get<MultisignatureOutput>(out.target).keys.size(); } } } }