bitcoin/BRWallet.c
// returns the amount received by the wallet from the transaction (total outputs to change and/or receive addresses)
returns the amount received by the wallet from the transaction (total outputs to change and/or receive addresses)
returns the amount received by the wallet from the transaction ( total outputs to change and / or receive addresses )
uint64_t BRWalletAmountReceivedFromTx(BRWallet *wallet, const BRTransaction *tx)
{
    uint64_t amount = 0;
    const uint8_t *pkh;
    assert(wallet != NULL);
    assert(tx != NULL);
    pthread_mutex_lock(&wallet->lock);
    for (size_t i = 0; tx && i < tx->outCount; i++) {
        pkh = BRScriptPKH(tx->outputs[i].script, tx->outputs[i].scriptLen);
        if (pkh && BRSetContains(wallet->allPKH, pkh)) amount += tx->outputs[i].amount;
    }
    pthread_mutex_unlock(&wallet->lock);
    return amount;
}
uint64_t BRWalletAmountReceivedFromTx ( BRWallet * wallet , const BRTransaction * tx ) { uint64_t amount = 0 ; const uint8_t * pkh ; assert ( wallet != NULL ) ; assert ( tx != NULL ) ; pthread_mutex_lock ( & wallet -> lock ) ; for ( size_t i = 0 ; tx && i < tx -> outCount ; i ++ ) { pkh = BRScriptPKH ( tx -> outputs [ i ] . script , tx -> outputs [ i ] . scriptLen ) ; if ( pkh && BRSetContains ( wallet -> allPKH , pkh ) ) amount += tx -> outputs [ i ] . amount ; } pthread_mutex_unlock ( & wallet -> lock ) ; return amount ; }
returns the amount received by the wallet from the transaction (total outputs to change and/or receive addresses)
returns the amount received by the wallet from the transaction ( total outputs to change and / or receive addresses )
// TODO: don't include outputs below TX_MIN_OUTPUT_AMOUNT