getInvoicesByStatus method
Get all invoices with a specific status.
Parameters:
status: Invoice status to filter bywalletId: Optional wallet ID to filter further
Returns: List of invoices matching the status
Implementation
@override
Future<List<dynamic>> getInvoicesByStatus(
dynamic status, {
String? walletId,
}) async {
_ensureInitialized();
var sql = '''
SELECT invoice_id, wallet_id, addresses_json, amount, description,
status, created_at, expires_at, paid_at, payment_txid,
amount_received, metadata_json
FROM invoices
WHERE status = @status
''';
final params = <String, dynamic>{
'status': (status as InvoiceStatus).name,
};
if (walletId != null) {
sql += ' AND wallet_id = @walletId';
params['walletId'] = walletId;
}
sql += ' ORDER BY created_at DESC';
final result = await _pool!.execute(Sql.named(sql), parameters: params);
return result.map(_rowToInvoice).toList();
}