From cba33a1d69ff7d91323f4dd748e332c8d18f0b72 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 15:42:37 -0600 Subject: [PATCH] notification tx record type storage fix and a couple other little fixes --- lib/services/coins/coin_paynym_extension.dart | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index fe31a4945..b64c7dbfa 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -492,7 +492,7 @@ extension PayNym on DogecoinWallet { await updatePaynymNotificationInfo( txid: txHash, confirmed: false, - paymentCodeString: preparedTx["paymentCodeString"] as String, + paymentCodeString: preparedTx["address"] as String, ); return txHash; } catch (e, s) { @@ -520,12 +520,14 @@ extension PayNym on DogecoinWallet { bool hasConnected(String paymentCodeString) { return getPaynymNotificationTxInfo() + .values .where((e) => e["paymentCodeString"] == paymentCodeString) .isNotEmpty; } bool hasConnectedConfirmed(String paymentCodeString) { return getPaynymNotificationTxInfo() + .values .where((e) => e["paymentCodeString"] == paymentCodeString && e["confirmed"] == true) @@ -533,12 +535,12 @@ extension PayNym on DogecoinWallet { } // fetch paynym notification tx meta data - Set> getPaynymNotificationTxInfo() { - final set = DB.instance.get( - boxName: walletId, key: "paynymNotificationTxInfo") as Set? ?? + Map getPaynymNotificationTxInfo() { + final map = DB.instance.get( + boxName: walletId, key: "paynymNotificationTxInfo") as Map? ?? {}; - return Set>.from(set); + return Map.from(map); } // add/update paynym notification tx meta data entry @@ -548,11 +550,11 @@ extension PayNym on DogecoinWallet { required String paymentCodeString, }) async { final data = getPaynymNotificationTxInfo(); - data.add({ + data[txid] = { "txid": txid, "confirmed": confirmed, "paymentCodeString": paymentCodeString, - }); + }; await DB.instance.put( boxName: walletId, key: "paynymNotificationTxInfo", @@ -605,6 +607,7 @@ Future> parseTransaction( // get input(prevOut) address final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? output["scriptPubKey"]?["address"] as String?; + if (address != null) { inputAddresses.add(address); @@ -629,8 +632,8 @@ Future> parseTransaction( totalOutputValue += value; // get output address - final address = output["scriptPubKey"]["addresses"][0] as String? ?? - output["scriptPubKey"]["address"] as String?; + final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? + output["scriptPubKey"]?["address"] as String?; if (address != null) { outputAddresses.add(address);