mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-06 04:17:42 +00:00
41 lines
1.3 KiB
Dart
41 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 = "YOUR-SCRIPT-PUBKEY-AS-HEX-STRING-FOR-TESTING-GOES-HERE";
|
||
|
// 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.");
|
||
|
}
|
||
|
});
|
||
|
}
|