/** * Filters a transaction list, removing any that aren't found in the * watcher database. * @param aTransactions The array to filter. This will be modified in-place. * @param pCount The array length. This will be updated upon return. */ tABC_CC ABC_BridgeFilterTransactions(Wallet &self, tABC_TxInfo **aTransactions, unsigned int *pCount, tABC_Error *pError) { tABC_CC cc = ABC_CC_Ok; tABC_TxInfo *const *end = aTransactions + *pCount; tABC_TxInfo *const *si = aTransactions; tABC_TxInfo **di = aTransactions; Watcher *watcher = nullptr; ABC_CHECK_NEW(watcherFind(watcher, self)); while (si < end) { tABC_TxInfo *pTx = *si++; int height; bc::hash_digest txid; if (!bc::decode_hash(txid, pTx->szMalleableTxId)) ABC_RET_ERROR(ABC_CC_ParseError, "Bad txid"); if (watcher->get_tx_height(txid, height)) { *di++ = pTx; } else { ABC_TxFreeTransaction(pTx); } } *pCount = di - aTransactions; exit: return cc; }
tABC_CC ABC_BridgeTxHeight(Wallet &self, const char *szTxId, unsigned int *height, tABC_Error *pError) { tABC_CC cc = ABC_CC_Ok; int height_; bc::hash_digest txid; Watcher *watcher = nullptr; ABC_CHECK_NEW(watcherFind(watcher, self)); if (!bc::decode_hash(txid, szTxId)) ABC_RET_ERROR(ABC_CC_ParseError, "Bad txid"); if (!watcher->get_tx_height(txid, height_)) { cc = ABC_CC_Synchronizing; } *height = height_; exit: return cc; }