src/wallet/wallet.cpp
/**
 * Finds all output notes in the given transaction that have been sent to
 * SaplingPaymentAddresses in this wallet.
 *
 * It should never be necessary to call this method with a CWalletTx, because
 * the result of FindMySaplingNotes (for the addresses available at the time) will
 * already have been cached in CWalletTx.mapSaplingNoteData.
 */
Finds all output notes in the given transaction that have been sent to
SaplingPaymentAddresses in this wallet.

It should never be necessary to call this method with a CWalletTx, because
the result of FindMySaplingNotes (for the addresses available at the time) will
already have been cached in CWalletTx.mapSaplingNoteData.
Finds all output notes in the given transaction that have been sent to SaplingPaymentAddresses in this wallet . It should never be necessary to call this method with a CWalletTx because the result of FindMySaplingNotes ( for the addresses available at the time ) will already have been cached in CWalletTx . mapSaplingNoteData .
std::pair<mapSaplingNoteData_t, SaplingIncomingViewingKeyMap> CWallet::FindMySaplingNotes(const CTransaction &tx) const
{
    LOCK(cs_SpendingKeyStore);
    uint256 hash = tx.GetHash();
    mapSaplingNoteData_t noteData;
    SaplingIncomingViewingKeyMap viewingKeysToAdd;
    for (uint32_t i = 0; i < tx.vShieldedOutput.size(); ++i) {
        const OutputDescription output = tx.vShieldedOutput[i];
        for (auto it = mapSaplingFullViewingKeys.begin(); it != mapSaplingFullViewingKeys.end(); ++it) {
            SaplingIncomingViewingKey ivk = it->first;
            auto result = SaplingNotePlaintext::decrypt(output.encCiphertext, ivk, output.ephemeralKey, output.cm);
            if (!result) {
                continue;
            }
            auto address = ivk.address(result.get().d);
            if (address && mapSaplingIncomingViewingKeys.count(address.get()) == 0) {
                viewingKeysToAdd[address.get()] = ivk;
            }
            SaplingOutPoint op {hash, i};
            SaplingNoteData nd;
            nd.ivk = ivk;
            noteData.insert(std::make_pair(op, nd));
            break;
        }
    }
    return std::make_pair(noteData, viewingKeysToAdd);
}
std :: pair < mapSaplingNoteData_t , SaplingIncomingViewingKeyMap > CWallet :: FindMySaplingNotes ( const CTransaction & tx ) const { LOCK ( cs_SpendingKeyStore ) ; uint256 hash = tx . GetHash ( ) ; mapSaplingNoteData_t noteData ; SaplingIncomingViewingKeyMap viewingKeysToAdd ; for ( uint32_t i = 0 ; i < tx . vShieldedOutput . size ( ) ; ++ i ) { const OutputDescription output = tx . vShieldedOutput [ i ] ; for ( auto it = mapSaplingFullViewingKeys . begin ( ) ; it != mapSaplingFullViewingKeys . end ( ) ; ++ it ) { SaplingIncomingViewingKey ivk = it -> first ; auto result = SaplingNotePlaintext :: decrypt ( output . encCiphertext , ivk , output . ephemeralKey , output . cm ) ; if ( ! result ) { continue ; } auto address = ivk . address ( result . get ( ) . d ) ; if ( address && mapSaplingIncomingViewingKeys . count ( address . get ( ) ) == 0 ) { viewingKeysToAdd [ address . get ( ) ] = ivk ; } SaplingOutPoint op { hash , i } ; SaplingNoteData nd ; nd . ivk = ivk ; noteData . insert ( std :: make_pair ( op , nd ) ) ; break ; } } return std :: make_pair ( noteData , viewingKeysToAdd ) ; }
Finds all output notes in the given transaction that have been sent to
 SaplingPaymentAddresses in this wallet.
Finds all output notes in the given transaction that have been sent to SaplingPaymentAddresses in this wallet .
// Protocol Spec: 4.19 Block Chain Scanning (Sapling) // We don't cache the nullifier here as computing it requires knowledge of the note position // in the commitment tree, which can only be determined when the transaction has been mined.