WIP mempool electrumx cals

This commit is contained in:
julian 2024-06-05 10:51:18 -06:00
parent debcb71d89
commit 3dac77b8d6

View file

@ -930,6 +930,7 @@ class ElectrumXClient {
}
}
// TODO: update when we get new call to include tx hashes in response
/// Takes [startNumber], if it is 0, we get the full set,
/// otherwise the used tags after that number
Future<List<String>> getSparkUnhashedUsedCoinsTags({
@ -1024,6 +1025,64 @@ class ElectrumXClient {
}
}
/// Returns the txids of the current transactions found in the mempool
Future<Set<String>> getMempoolTxids({
String? requestID,
}) async {
try {
final start = DateTime.now();
final response = await request(
requestID: requestID,
command: "spark.getmempooltxids",
);
// TODO verify once server is live
final txids = List<String>.from(response as List).toSet();
// final map = Map<String, dynamic>.from(response as Map);
// final txids = List<String>.from(map["tags"] as List).toSet();
Logging.instance.log(
"Finished ElectrumXClient.getMempoolTxids(). "
"Duration=${DateTime.now().difference(start)}",
level: LogLevel.Info,
);
return txids;
} catch (e) {
Logging.instance.log(e, level: LogLevel.Error);
rethrow;
}
}
/// Returns the txids of the current transactions found in the mempool
Future<Map<String, dynamic>> getMempoolSparkData({
String? requestID,
required List<String> txids,
}) async {
try {
final start = DateTime.now();
final response = await request(
requestID: requestID,
command: "spark.getmempooltxs",
args: txids,
);
// TODO verify once server is live
final map = Map<String, dynamic>.from(response as Map);
Logging.instance.log(
"Finished ElectrumXClient.getMempoolSparkData(txids: $txids). "
"Duration=${DateTime.now().difference(start)}",
level: LogLevel.Info,
);
return map;
} catch (e) {
Logging.instance.log(e, level: LogLevel.Error);
rethrow;
}
}
// ===========================================================================
/// Get the current fee rate.