mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-23 19:05:51 +00:00
WIP bch transaction parsing
This commit is contained in:
parent
85e248f2e1
commit
a21eb37b26
3 changed files with 101 additions and 3 deletions
|
@ -15,12 +15,15 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:stackwallet/db/hive/db.dart';
|
import 'package:stackwallet/db/hive/db.dart';
|
||||||
|
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/providers/global/debug_service_provider.dart';
|
import 'package:stackwallet/providers/global/debug_service_provider.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
|
import 'package:stackwallet/services/mixins/electrum_x_parsing.dart';
|
||||||
import 'package:stackwallet/themes/stack_colors.dart';
|
import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
|
@ -343,6 +346,80 @@ class HiddenSettings extends StatelessWidget {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
Consumer(
|
||||||
|
builder: (_, ref, __) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
try {
|
||||||
|
final p = TT();
|
||||||
|
|
||||||
|
final n = ref
|
||||||
|
.read(nodeServiceChangeNotifierProvider)
|
||||||
|
.getPrimaryNodeFor(
|
||||||
|
coin: Coin.bitcoincash)!;
|
||||||
|
|
||||||
|
final e = ElectrumX.from(
|
||||||
|
node: ElectrumXNode(
|
||||||
|
address: n.host,
|
||||||
|
port: n.port,
|
||||||
|
name: n.name,
|
||||||
|
id: n.id,
|
||||||
|
useSSL: n.useSSL,
|
||||||
|
),
|
||||||
|
prefs:
|
||||||
|
ref.read(prefsChangeNotifierProvider),
|
||||||
|
failovers: [],
|
||||||
|
);
|
||||||
|
|
||||||
|
final txids = [
|
||||||
|
"", // cashTokenTxid
|
||||||
|
"6a0444358bc41913c5b04a8dc06896053184b3641bc62502d18f954865b6ce1e", // normalTxid
|
||||||
|
"67f13c375f9be897036cac77b7900dc74312c4ba6fe22f419f5cb21d4151678c", // fusionTxid
|
||||||
|
"c0ac3f88b238a023d2a87226dc90c3b0f9abc3eeb227e2730087b0b95ee5b3f9", // slpTokenSendTxid
|
||||||
|
"7a427a156fe70f83d3ccdd17e75804cc0df8c95c64ce04d256b3851385002a0b", // slpTokenGenesisTxid
|
||||||
|
];
|
||||||
|
|
||||||
|
// final json =
|
||||||
|
// await e.getTransaction(txHash: txids[1]);
|
||||||
|
// await p.parseBchTx(json, "NORMAL TXID:");
|
||||||
|
//
|
||||||
|
// final json2 =
|
||||||
|
// await e.getTransaction(txHash: txids[2]);
|
||||||
|
// await p.parseBchTx(json2, "FUSION TXID:");
|
||||||
|
//
|
||||||
|
// // print("CASH TOKEN TXID:");
|
||||||
|
// // final json3 =
|
||||||
|
// // await e.getTransaction(txHash: txids[2]);
|
||||||
|
// // await p.parseBchTx(json3);
|
||||||
|
//
|
||||||
|
final json4 =
|
||||||
|
await e.getTransaction(txHash: txids[3]);
|
||||||
|
await p.parseBchTx(
|
||||||
|
json4, "SLP TOKEN SEND TXID:");
|
||||||
|
|
||||||
|
final json5 =
|
||||||
|
await e.getTransaction(txHash: txids[4]);
|
||||||
|
await p.parseBchTx(
|
||||||
|
json5, "SLP TOKEN GENESIS TXID:");
|
||||||
|
} catch (e, s) {
|
||||||
|
print("$e\n$s");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: RoundedWhiteContainer(
|
||||||
|
child: Text(
|
||||||
|
"Parse BCH tx test",
|
||||||
|
style: STextStyles.button(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.accentColorDark),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
// const SizedBox(
|
// const SizedBox(
|
||||||
// height: 12,
|
// height: 12,
|
||||||
// ),
|
// ),
|
||||||
|
|
|
@ -16,9 +16,23 @@ import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||||
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
||||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
import 'package:stackwallet/utilities/util.dart' as util;
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
|
class TT with ElectrumXParsing {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
mixin ElectrumXParsing {
|
mixin ElectrumXParsing {
|
||||||
|
Future<dynamic> parseBchTx(
|
||||||
|
Map<String, dynamic> json, [
|
||||||
|
String? debugTitle,
|
||||||
|
]) async {
|
||||||
|
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||||
|
util.Util.printJson(json, debugTitle);
|
||||||
|
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||||
|
}
|
||||||
|
|
||||||
Future<Tuple2<Transaction, Address>> parseTransaction(
|
Future<Tuple2<Transaction, Address>> parseTransaction(
|
||||||
Map<String, dynamic> txData,
|
Map<String, dynamic> txData,
|
||||||
dynamic electrumxClient,
|
dynamic electrumxClient,
|
||||||
|
|
|
@ -73,14 +73,21 @@ abstract class Util {
|
||||||
return MaterialColor(color.value, swatch);
|
return MaterialColor(color.value, swatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printJson(dynamic json) {
|
static void printJson(dynamic json, [String? debugTitle]) {
|
||||||
|
final String result;
|
||||||
if (json is Map || json is List) {
|
if (json is Map || json is List) {
|
||||||
final spaces = ' ' * 4;
|
final spaces = ' ' * 4;
|
||||||
final encoder = JsonEncoder.withIndent(spaces);
|
final encoder = JsonEncoder.withIndent(spaces);
|
||||||
final pretty = encoder.convert(json);
|
final pretty = encoder.convert(json);
|
||||||
log(pretty);
|
result = pretty;
|
||||||
} else {
|
} else {
|
||||||
log(dynamic.toString());
|
result = dynamic.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debugTitle != null) {
|
||||||
|
log("$debugTitle\n$result");
|
||||||
|
} else {
|
||||||
|
log(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue