add lelantus electrum_adapter methods

This commit is contained in:
sneurlax 2024-02-13 15:34:45 -06:00
parent cd951f10cc
commit ceec698a44
3 changed files with 57 additions and 3 deletions

View file

@ -799,6 +799,19 @@ class ElectrumXClient {
String blockhash = "",
String? requestID,
}) async {
// Use electrum_adapter package's getSparkAnonymitySet method.
Logging.instance.log("attempting to fetch lelantus.getanonymityset...",
level: LogLevel.Info);
var channel = await electrum_adapter.connect('firo.stackwallet.com');
var client = electrum_adapter.FiroElectrumClient(channel);
Map<String, dynamic> anonymitySet = await client.getLelantusAnonymitySet(
groupId: groupId, blockHash: blockhash);
Logging.instance.log("Fetching lelantus.getanonymityset finished",
level: LogLevel.Info);
return anonymitySet;
/*
// Original ElectrumXClient:
try {
Logging.instance.log("attempting to fetch lelantus.getanonymityset...",
level: LogLevel.Info);
@ -816,6 +829,7 @@ class ElectrumXClient {
} catch (e) {
rethrow;
}
*/
}
//TODO add example to docs
@ -826,6 +840,18 @@ class ElectrumXClient {
dynamic mints,
String? requestID,
}) async {
// Use electrum_adapter package's getLelantusMintData method.
Logging.instance.log("attempting to fetch lelantus.getmintmetadata...",
level: LogLevel.Info);
var channel = await electrum_adapter.connect('firo.stackwallet.com');
var client = electrum_adapter.FiroElectrumClient(channel);
dynamic mintData = await client.getLelantusMintData(mints: mints);
Logging.instance.log("Fetching lelantus.getmintmetadata finished",
level: LogLevel.Info);
return mintData;
/*
// Original ElectrumXClient:
try {
final response = await request(
requestID: requestID,
@ -838,6 +864,7 @@ class ElectrumXClient {
} catch (e) {
rethrow;
}
*/
}
//TODO add example to docs
@ -846,6 +873,19 @@ class ElectrumXClient {
String? requestID,
required int startNumber,
}) async {
// Use electrum_adapter package's getLelantusUsedCoinSerials method.
Logging.instance.log("attempting to fetch lelantus.getusedcoinserials...",
level: LogLevel.Info);
var channel = await electrum_adapter.connect('firo.stackwallet.com');
var client = electrum_adapter.FiroElectrumClient(channel);
Map<String, dynamic> usedCoinSerials =
await client.getLelantusUsedCoinSerials(startNumber: startNumber);
Logging.instance.log("Fetching lelantus.getusedcoinserials finished",
level: LogLevel.Info);
return usedCoinSerials;
/*
// Original ElectrumXClient:
try {
int retryCount = 3;
dynamic result;
@ -869,12 +909,25 @@ class ElectrumXClient {
Logging.instance.log(e, level: LogLevel.Error);
rethrow;
}
*/
}
/// Returns the latest Lelantus set id
///
/// ex: 1
Future<int> getLelantusLatestCoinId({String? requestID}) async {
// Use electrum_adapter package's getLelantusLatestCoinId method.
Logging.instance.log("attempting to fetch lelantus.getlatestcoinid...",
level: LogLevel.Info);
var channel = await electrum_adapter.connect('firo.stackwallet.com');
var client = electrum_adapter.FiroElectrumClient(channel);
int latestCoinId = await client.getLatestCoinId();
Logging.instance.log("Fetching lelantus.getlatestcoinid finished",
level: LogLevel.Info);
return latestCoinId;
/*
// Original ElectrumXClient:
try {
final response = await request(
requestID: requestID,
@ -885,6 +938,7 @@ class ElectrumXClient {
Logging.instance.log(e, level: LogLevel.Error);
rethrow;
}
*/
}
// ============== Spark ======================================================

View file

@ -528,8 +528,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "9efe2af7fb39a40a17261f8050a65737b7a1618b"
resolved-ref: "9efe2af7fb39a40a17261f8050a65737b7a1618b"
ref: "1c4962bf6fa8fe639be8540f8c61e89e625c7034"
resolved-ref: "1c4962bf6fa8fe639be8540f8c61e89e625c7034"
url: "https://github.com/cypherstack/electrum_adapter.git"
source: git
version: "3.0.0"

View file

@ -176,7 +176,7 @@ dependencies:
electrum_adapter:
git:
url: https://github.com/cypherstack/electrum_adapter.git
ref: 9efe2af7fb39a40a17261f8050a65737b7a1618b
ref: 1c4962bf6fa8fe639be8540f8c61e89e625c7034
dev_dependencies:
flutter_test: