How can i get *TxOut by *KeyImage?

I want to GenerateTx with some InputList []*UnspentTxOut, which the InputList is from different SubaddressIndex and MonitorId, how can I get TxOut of the KeyImage in the UnspentTxOut.

When you are using the mobilecoind API to create a transaction, you can see the fn GenerateTx requires the request object:

message GenerateTxRequest {
    // Monitor id sending the funds.
    bytes sender_monitor_id = 1;

    // Subaddress to return change to.
    uint64 change_subaddress = 2;

    // List of UnspentTxOuts to be spent by the transaction.
    // All UnspentTxOuts must belong to the same sender_monitor_id.
    // mobilecoind would choose a subset of these inputs to construct the transaction.
    // Total input amount must be >= sum of outlays + fees.
    repeated UnspentTxOut input_list = 3;

    // Outputs to be generated by the transaction. This excludes change and fee.
    repeated Outlay outlay_list = 4;

    // Fee in picoMOB (setting to 0 causes mobilecoind to choose a value).
    // The value used can be checked (but not changed) in tx_proposal.tx.prefix.fee
    uint64 fee = 5;

    // Tombstone block (setting to 0 causes mobilecoind to choose a value).
    // The value used can be checked (but not changed) in tx_proposal.tx.prefix.tombstone_block
    uint64 tombstone = 6;
}

The input_list field contains a list of UnspentTxOuts. The easiest way to get these is to collect them with a monitor and to use the function GetUnspentTxOutList. This will give you a list of all available utxos that you can use as the input_list.

It will be difficult to build an UnspectTxOut directly:

// Structure used to refer to a TxOut in the ledger that is presumed to be spendable.
// The structure is annotated with extra information needed to spend the TxOut in a payment, calculated using the private keys that control the TxOut.
message UnspentTxOut {
    // The actual TxOut object found in the ledger.
    external.TxOut tx_out = 1;

    // The subaddress the TxOut was sent to.
    uint64 subaddress_index = 2;

    // The key image of the TxOut.
    external.KeyImage key_image = 3;

    // The value of the TxOut.
    uint64 value = 4;

    // The block height at which this UnspentTxOut was last attempted to be spent.
    uint64 attempted_spend_height = 5;

    // The tombstone block used when we attempted to spend the UTXO.
    uint64 attempted_spend_tombstone = 6;

    // The monitor id this UnspentTxOut belongs to.
    // Note that this field is not included in the Rust `utxo_store::UnspentTxOut` struct.
    bytes monitor_id = 10;
}

For example, to calculate the key_image you must perform calculations with the private keys that own the utxo. The MobileCoin Daemon (mobilecoind) does not currently expose a function that can construct a UnspentTxOut from user supplied inputs (perhaps tx_out and account_key could work…)

Our suggestion is to process the ledger using a monitor and collect the UnspentTxOut objects with the API. If this won’t work for your application, please let us know and we can discuss how to make changes to accommodate your needs!