bitcoin/BRWallet.c
// returns the amount sent from the wallet by the trasaction (total wallet outputs consumed, change and fee included)
returns the amount sent from the wallet by the trasaction (total wallet outputs consumed, change and fee included)
returns the amount sent from the wallet by the trasaction ( total wallet outputs consumed change and fee included )
uint64_t BRWalletAmountSentByTx(BRWallet *wallet, const BRTransaction *tx)
{
    uint64_t amount = 0;
    assert(wallet != NULL);
    assert(tx != NULL);
    pthread_mutex_lock(&wallet->lock);
    for (size_t i = 0; tx && i < tx->inCount; i++) {
        BRTransaction *t = BRSetGet(wallet->allTx, &tx->inputs[i].txHash);
        uint32_t n = tx->inputs[i].index;
        const uint8_t *pkh;
        if (t && n < t->outCount) {
            pkh = BRScriptPKH(t->outputs[n].script, t->outputs[n].scriptLen);
            if (pkh && BRSetContains(wallet->allPKH, pkh)) amount += t->outputs[n].amount;
        }
    }
    pthread_mutex_unlock(&wallet->lock);
    return amount;
}
uint64_t BRWalletAmountSentByTx ( BRWallet * wallet , const BRTransaction * tx ) { uint64_t amount = 0 ; assert ( wallet != NULL ) ; assert ( tx != NULL ) ; pthread_mutex_lock ( & wallet -> lock ) ; for ( size_t i = 0 ; tx && i < tx -> inCount ; i ++ ) { BRTransaction * t = BRSetGet ( wallet -> allTx , & tx -> inputs [ i ] . txHash ) ; uint32_t n = tx -> inputs [ i ] . index ; const uint8_t * pkh ; if ( t && n < t -> outCount ) { pkh = BRScriptPKH ( t -> outputs [ n ] . script , t -> outputs [ n ] . scriptLen ) ; if ( pkh && BRSetContains ( wallet -> allPKH , pkh ) ) amount += t -> outputs [ n ] . amount ; } } pthread_mutex_unlock ( & wallet -> lock ) ; return amount ; }
returns the amount sent from the wallet by the trasaction (total wallet outputs consumed, change and fee included)
returns the amount sent from the wallet by the trasaction ( total wallet outputs consumed change and fee included )