comment update

This commit is contained in:
sneurlax 2023-01-06 11:15:32 -06:00
parent 2495673f79
commit 3794b18ba6

View file

@ -310,6 +310,8 @@ abstract class CoinServiceAPI {
// Certain outputs return address as an array/list of strings like List<String> ["addresses"][0], some return it as a string like String ["address"]
String? getAddress(dynamic output) {
// Julian's code from https://github.com/cypherstack/stack_wallet/blob/35a8172d35f1b5cdbd22f0d56c4db02f795fd032/lib/services/coins/coin_paynym_extension.dart#L170 wins codegolf for this, I'd love to commit it now but need to retest this section ... should make unit tests for this case
// final String? address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? output["scriptPubKey"]?["address"] as String?;
String? address;
if (output.containsKey('scriptPubKey') as bool) {
// Make sure the key exists before using it
@ -330,6 +332,8 @@ abstract class CoinServiceAPI {
// Firo wants an array/list of address strings like List<String>
List? getAddresses(dynamic output) {
// Inspired by Julian's code as referenced above, need to test before committing
// final List? addresses = output["scriptPubKey"]?["addresses"] as List? ?? [output["scriptPubKey"]?["address"]] as List?;
List? addresses;
if (output.containsKey('scriptPubKey') as bool) {
if (output["scriptPubKey"].containsKey('addresses') as bool) {