src/MicroCore.cpp
/**
     * Find output with given public key in a given transaction
     */
Find output with given public key in a given transaction
Find output with given public key in a given transaction
bool
    MicroCore::find_output_in_tx(const transaction& tx,
                                 const public_key& output_pubkey,
                                 tx_out& out,
                                 size_t& output_index)
    {
        size_t idx {0};
        auto it = std::find_if(tx.vout.begin(), tx.vout.end(),
                               [&](const tx_out& o)
                               {
                                   const txout_to_key& tx_in_to_key
                                           = boost::get<txout_to_key>(o.target);
                                   ++idx;
                                   return tx_in_to_key.key == output_pubkey;
                               });
        if (it != tx.vout.end())
        {
            out = *it;
            output_index = idx > 0 ? idx - 1 : idx;
            return true;
        }
        return false;
    }
bool MicroCore :: find_output_in_tx ( const transaction & tx , const public_key & output_pubkey , tx_out & out , size_t & output_index ) { size_t idx { 0 } ; auto it = std :: find_if ( tx . vout . begin ( ) , tx . vout . end ( ) , [ & ] ( const tx_out & o ) { const txout_to_key & tx_in_to_key = boost :: get < txout_to_key > ( o . target ) ; ++ idx ; return tx_in_to_key . key == output_pubkey ; } ) ; if ( it != tx . vout . end ( ) ) { out = * it ; output_index = idx > 0 ? idx - 1 : idx ; return true ; } return false ; }
Find output with given public key in a given transaction
Find output with given public key in a given transaction
// search in the ouputs for an output which // public key matches to what we want // we found the desired public key //cout << idx << " " << output_index << endl;