mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-26 05:19:22 +00:00
40 lines
1.3 KiB
Dart
40 lines
1.3 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:convert/convert.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hex/hex.dart';
|
|
import 'package:stackwallet/services/coins/bitcoincash/cashtokens.dart';
|
|
|
|
void main() {
|
|
// Just a testing function which can be called in standalone fashion.
|
|
// Replace "var1" with a hex string containing an output (script pub key)
|
|
test("testUnwrapSPK", () {
|
|
// Example Hex format string
|
|
String var1 = "76a91463456150b05a67084d795fbce22c8fbbca37697288ac";
|
|
// Convert the Hex string to Uint8List
|
|
Uint8List wrapped_spk = Uint8List.fromList(HEX.decode(var1));
|
|
|
|
// Call unwrap_spk
|
|
ParsedOutput parsedOutput = unwrap_spk(wrapped_spk);
|
|
|
|
print("Parsed Output: $parsedOutput");
|
|
|
|
// Access token_data inside parsedOutput
|
|
TokenOutputData? tokenData = parsedOutput.token_data;
|
|
|
|
// Check if tokenData is null
|
|
if (tokenData != null) {
|
|
// Print specific fields
|
|
if (tokenData.id != null) {
|
|
print("ID: ${hex.encode(tokenData.id!)}"); // hex is imported
|
|
} else {
|
|
print("ID: null");
|
|
}
|
|
print("amount of tokens");
|
|
print(tokenData.amount);
|
|
print("Is it an NFT?: ${tokenData.hasNFT()}");
|
|
} else {
|
|
print("Token data is null.");
|
|
}
|
|
});
|
|
}
|