mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-22 19:39:22 +00:00
use electrum_adapter package methods for all spark calls
add spark methods and tests, remove some Ravencoin references and use cypherstack remote. much trust, veryfy
This commit is contained in:
parent
831d1951c1
commit
4147e357a8
3 changed files with 78 additions and 1 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 978404cedadeb5f5670c2b2e1dfea595598614cc
|
||||
Subproject commit 89dae750e1c9457c13db6a0103a48615154579e8
|
|
@ -14,6 +14,11 @@ import 'dart:io';
|
|||
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:decimal/decimal.dart';
|
||||
import 'package:electrum_adapter/electrum_adapter.dart' as electrum_adapter;
|
||||
import 'package:electrum_adapter/methods/spark/get_spark_anonymity_set.dart';
|
||||
import 'package:electrum_adapter/methods/spark/get_spark_latest_coin_id.dart';
|
||||
import 'package:electrum_adapter/methods/spark/get_spark_mint_meta_data.dart';
|
||||
import 'package:electrum_adapter/methods/spark/get_used_coins_tags.dart';
|
||||
import 'package:event_bus/event_bus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_libsparkmobile/flutter_libsparkmobile.dart';
|
||||
|
@ -906,6 +911,19 @@ class ElectrumXClient {
|
|||
String? requestID,
|
||||
}) async {
|
||||
try {
|
||||
// Use electrum_adapter package's getSparkAnonymitySet method.
|
||||
Logging.instance.log("attempting to fetch spark.getsparkanonymityset...",
|
||||
level: LogLevel.Info);
|
||||
var channel = await electrum_adapter.connect('firo.stackwallet.com');
|
||||
var client = electrum_adapter.FiroElectrumClient(channel);
|
||||
Map<String, dynamic> anonymitySet = await client.getSparkAnonymitySet(
|
||||
coinGroupId: coinGroupId, startBlockHash: startBlockHash);
|
||||
Logging.instance.log("Fetching spark.getsparkanonymityset finished",
|
||||
level: LogLevel.Info);
|
||||
return anonymitySet;
|
||||
|
||||
/*
|
||||
// Original ElectrumXClient:
|
||||
Logging.instance.log("attempting to fetch spark.getsparkanonymityset...",
|
||||
level: LogLevel.Info);
|
||||
final response = await request(
|
||||
|
@ -919,6 +937,7 @@ class ElectrumXClient {
|
|||
Logging.instance.log("Fetching spark.getsparkanonymityset finished",
|
||||
level: LogLevel.Info);
|
||||
return Map<String, dynamic>.from(response["result"] as Map);
|
||||
*/
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
|
@ -931,6 +950,21 @@ class ElectrumXClient {
|
|||
required int startNumber,
|
||||
}) async {
|
||||
try {
|
||||
// Use electrum_adapter package's getSparkUsedCoinsTags method.
|
||||
Logging.instance.log("attempting to fetch spark.getusedcoinstags...",
|
||||
level: LogLevel.Info);
|
||||
var channel = await electrum_adapter.connect('firo.stackwallet.com');
|
||||
var client = electrum_adapter.FiroElectrumClient(channel);
|
||||
Map<String, dynamic> usedCoinsTags =
|
||||
await client.getUsedCoinsTags(startNumber: startNumber);
|
||||
Logging.instance.log("Fetching spark.getusedcoinstags finished",
|
||||
level: LogLevel.Info);
|
||||
final map = Map<String, dynamic>.from(usedCoinsTags);
|
||||
final set = Set<String>.from(map["tags"] as List);
|
||||
return await compute(_ffiHashTagsComputeWrapper, set);
|
||||
|
||||
/*
|
||||
// Original ElectrumXClient:
|
||||
final response = await request(
|
||||
requestID: requestID,
|
||||
command: 'spark.getusedcoinstags',
|
||||
|
@ -942,6 +976,7 @@ class ElectrumXClient {
|
|||
final map = Map<String, dynamic>.from(response["result"] as Map);
|
||||
final set = Set<String>.from(map["tags"] as List);
|
||||
return await compute(_ffiHashTagsComputeWrapper, set);
|
||||
*/
|
||||
} catch (e) {
|
||||
Logging.instance.log(e, level: LogLevel.Error);
|
||||
rethrow;
|
||||
|
@ -963,6 +998,19 @@ class ElectrumXClient {
|
|||
required List<String> sparkCoinHashes,
|
||||
}) async {
|
||||
try {
|
||||
// Use electrum_adapter package's getSparkMintMetaData method.
|
||||
Logging.instance.log("attempting to fetch spark.getsparkmintmetadata...",
|
||||
level: LogLevel.Info);
|
||||
var channel = await electrum_adapter.connect('firo.stackwallet.com');
|
||||
var client = electrum_adapter.FiroElectrumClient(channel);
|
||||
List<dynamic> mintMetaData =
|
||||
await client.getSparkMintMetaData(sparkCoinHashes: sparkCoinHashes);
|
||||
Logging.instance.log("Fetching spark.getsparkmintmetadata finished",
|
||||
level: LogLevel.Info);
|
||||
return List<Map<String, dynamic>>.from(mintMetaData);
|
||||
|
||||
/*
|
||||
// Original ElectrumXClient:
|
||||
final response = await request(
|
||||
requestID: requestID,
|
||||
command: 'spark.getsparkmintmetadata',
|
||||
|
@ -973,6 +1021,7 @@ class ElectrumXClient {
|
|||
],
|
||||
);
|
||||
return List<Map<String, dynamic>>.from(response["result"] as List);
|
||||
*/
|
||||
} catch (e) {
|
||||
Logging.instance.log(e, level: LogLevel.Error);
|
||||
rethrow;
|
||||
|
@ -986,11 +1035,24 @@ class ElectrumXClient {
|
|||
String? requestID,
|
||||
}) async {
|
||||
try {
|
||||
// Use electrum_adapter package's getSparkLatestCoinId method.
|
||||
Logging.instance.log("attempting to fetch spark.getsparklatestcoinid...",
|
||||
level: LogLevel.Info);
|
||||
var channel = await electrum_adapter.connect('firo.stackwallet.com');
|
||||
var client = electrum_adapter.FiroElectrumClient(channel);
|
||||
int latestCoinId = await client.getSparkLatestCoinId();
|
||||
Logging.instance.log("Fetching spark.getsparklatestcoinid finished",
|
||||
level: LogLevel.Info);
|
||||
return latestCoinId;
|
||||
|
||||
/*
|
||||
// Original ElectrumXClient:
|
||||
final response = await request(
|
||||
requestID: requestID,
|
||||
command: 'spark.getsparklatestcoinid',
|
||||
);
|
||||
return response["result"] as int;
|
||||
*/
|
||||
} catch (e) {
|
||||
Logging.instance.log(e, level: LogLevel.Error);
|
||||
rethrow;
|
||||
|
|
15
pubspec.lock
15
pubspec.lock
|
@ -524,6 +524,13 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
electrum_adapter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: electrum_adapter
|
||||
relative: true
|
||||
source: path
|
||||
version: "3.0.0"
|
||||
emojis:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -1258,6 +1265,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
permission_handler:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
Loading…
Reference in a new issue