bitcoin/BRWalletManager.c
/**
 * Find the tracked transaction that corresponds to the confirmed send with the highest
 * block height. Deleted transactions are not checked (i.e. they are skipped).
 */
Find the tracked transaction that corresponds to the confirmed send with the highest
block height. Deleted transactions are not checked .
Find the tracked transaction that corresponds to the confirmed send with the highest block height . Deleted transactions are not checked .
static BRTransactionWithState
BRWalletManagerFindTransactionWithLastConfirmedSend(BRWalletManager manager,
                                                    uint64_t lastBlockHeight,
                                                    uint64_t confirmationsUntilFinal) {
    BRTransactionWithState txnWithState = NULL;
    if (lastBlockHeight >= confirmationsUntilFinal) {
        for (size_t index = 0; index < array_count (manager->transactions); index++) {
            if (!manager->transactions[index]->isDeleted &&
                BRTransactionIsSigned (manager->transactions[index]->ownedTransaction) &&
                BRWalletTransactionIsValid (manager->wallet, manager->transactions[index]->ownedTransaction) &&
                0 != BRWalletAmountSentByTx (manager->wallet, manager->transactions[index]->ownedTransaction) &&
                TX_UNCONFIRMED != manager->transactions[index]->ownedTransaction->blockHeight &&
                manager->transactions[index]->ownedTransaction->blockHeight < (lastBlockHeight - confirmationsUntilFinal)) {
                if (NULL == txnWithState ||
                    txnWithState->ownedTransaction->blockHeight < manager->transactions[index]->ownedTransaction->blockHeight) {
                    txnWithState =  manager->transactions[index];
                }
            }
        }
    }
    return txnWithState;
}
static BRTransactionWithState BRWalletManagerFindTransactionWithLastConfirmedSend ( BRWalletManager manager , uint64_t lastBlockHeight , uint64_t confirmationsUntilFinal ) { BRTransactionWithState txnWithState = NULL ; if ( lastBlockHeight >= confirmationsUntilFinal ) { for ( size_t index = 0 ; index < array_count ( manager -> transactions ) ; index ++ ) { if ( ! manager -> transactions [ index ] -> isDeleted && BRTransactionIsSigned ( manager -> transactions [ index ] -> ownedTransaction ) && BRWalletTransactionIsValid ( manager -> wallet , manager -> transactions [ index ] -> ownedTransaction ) && 0 != BRWalletAmountSentByTx ( manager -> wallet , manager -> transactions [ index ] -> ownedTransaction ) && TX_UNCONFIRMED != manager -> transactions [ index ] -> ownedTransaction -> blockHeight && manager -> transactions [ index ] -> ownedTransaction -> blockHeight < ( lastBlockHeight - confirmationsUntilFinal ) ) { if ( NULL == txnWithState || txnWithState -> ownedTransaction -> blockHeight < manager -> transactions [ index ] -> ownedTransaction -> blockHeight ) { txnWithState = manager -> transactions [ index ] ; } } } } return txnWithState ; }
Find the tracked transaction that corresponds to the confirmed send with the highest
 block height.
Find the tracked transaction that corresponds to the confirmed send with the highest block height .
// ensure: // - tx is not deleted // - tx is valid (i.e. no previous transaction spend any of utxos, and no inputs are invalid) // - AND the transaction was a SEND // - AND the transaction has been confirmed