notification tx record type storage fix and a couple other little fixes

This commit is contained in:
julian 2023-01-09 15:42:37 -06:00
parent 12477e8fb5
commit cba33a1d69

View file

@ -492,7 +492,7 @@ extension PayNym on DogecoinWallet {
await updatePaynymNotificationInfo( await updatePaynymNotificationInfo(
txid: txHash, txid: txHash,
confirmed: false, confirmed: false,
paymentCodeString: preparedTx["paymentCodeString"] as String, paymentCodeString: preparedTx["address"] as String,
); );
return txHash; return txHash;
} catch (e, s) { } catch (e, s) {
@ -520,12 +520,14 @@ extension PayNym on DogecoinWallet {
bool hasConnected(String paymentCodeString) { bool hasConnected(String paymentCodeString) {
return getPaynymNotificationTxInfo() return getPaynymNotificationTxInfo()
.values
.where((e) => e["paymentCodeString"] == paymentCodeString) .where((e) => e["paymentCodeString"] == paymentCodeString)
.isNotEmpty; .isNotEmpty;
} }
bool hasConnectedConfirmed(String paymentCodeString) { bool hasConnectedConfirmed(String paymentCodeString) {
return getPaynymNotificationTxInfo() return getPaynymNotificationTxInfo()
.values
.where((e) => .where((e) =>
e["paymentCodeString"] == paymentCodeString && e["paymentCodeString"] == paymentCodeString &&
e["confirmed"] == true) e["confirmed"] == true)
@ -533,12 +535,12 @@ extension PayNym on DogecoinWallet {
} }
// fetch paynym notification tx meta data // fetch paynym notification tx meta data
Set<Map<String, dynamic>> getPaynymNotificationTxInfo() { Map<String, dynamic> getPaynymNotificationTxInfo() {
final set = DB.instance.get<dynamic>( final map = DB.instance.get<dynamic>(
boxName: walletId, key: "paynymNotificationTxInfo") as Set? ?? boxName: walletId, key: "paynymNotificationTxInfo") as Map? ??
{}; {};
return Set<Map<String, dynamic>>.from(set); return Map<String, dynamic>.from(map);
} }
// add/update paynym notification tx meta data entry // add/update paynym notification tx meta data entry
@ -548,11 +550,11 @@ extension PayNym on DogecoinWallet {
required String paymentCodeString, required String paymentCodeString,
}) async { }) async {
final data = getPaynymNotificationTxInfo(); final data = getPaynymNotificationTxInfo();
data.add({ data[txid] = {
"txid": txid, "txid": txid,
"confirmed": confirmed, "confirmed": confirmed,
"paymentCodeString": paymentCodeString, "paymentCodeString": paymentCodeString,
}); };
await DB.instance.put<dynamic>( await DB.instance.put<dynamic>(
boxName: walletId, boxName: walletId,
key: "paynymNotificationTxInfo", key: "paynymNotificationTxInfo",
@ -605,6 +607,7 @@ Future<Map<String, dynamic>> parseTransaction(
// get input(prevOut) address // get input(prevOut) address
final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? final address = output["scriptPubKey"]?["addresses"]?[0] as String? ??
output["scriptPubKey"]?["address"] as String?; output["scriptPubKey"]?["address"] as String?;
if (address != null) { if (address != null) {
inputAddresses.add(address); inputAddresses.add(address);
@ -629,8 +632,8 @@ Future<Map<String, dynamic>> parseTransaction(
totalOutputValue += value; totalOutputValue += value;
// get output address // get output address
final address = output["scriptPubKey"]["addresses"][0] as String? ?? final address = output["scriptPubKey"]?["addresses"]?[0] as String? ??
output["scriptPubKey"]["address"] as String?; output["scriptPubKey"]?["address"] as String?;
if (address != null) { if (address != null) {
outputAddresses.add(address); outputAddresses.add(address);