getConfirmedTransactionsFromHeight method
Confirmed rows of every wallet whose blockHeight is at least
minHeight; with includeWithoutHeight, also confirmed rows that have
no block height (bead libspiffy-ctkm). Rows come newest first
(createdAt descending).
Serves header-chain reorganizations: the confirmations that may rest on a changed block are found without reading the confirmed history. Backends read only those rows (a (status, block height) index).
The default implementation filters getTransactionsByStatus; the libspiffy backends override it.
Implementation
@override
Future<List<BitcoinTransaction>> getConfirmedTransactionsFromHeight(
int minHeight, {
bool includeWithoutHeight = false,
}) async {
_ensureInitialized();
// idx_transactions_confirmed_height (v014, partial on status =
// 'confirmed'): the literal status lets the planner match the index
// predicate (ctkm).
final params = <String, dynamic>{'minHeight': minHeight};
final sql = '''
SELECT $_transactionColumns
FROM bitcoin_transactions
WHERE status = 'confirmed'
AND (block_height >= @minHeight${includeWithoutHeight ? ' OR block_height IS NULL' : ''})
ORDER BY created_at DESC, id
''';
onTransactionLookupQuery?.call(sql, params);
final result = await _pool!.execute(Sql.named(sql), parameters: params);
return result.map(_rowToTransaction).toList();
}