From 1a5ad871098277b9ebadd3e152af9da65e559580 Mon Sep 17 00:00:00 2001 From: Willy <11148913+willyfromtheblock@users.noreply.github.com> Date: Mon, 5 Dec 2022 13:42:28 +0100 Subject: [PATCH] 1.10.0 1 (#206) * fix for new transaction format * send tab: switch into new address, when adding one * pre 0.12 backwards compatability --- lib/providers/active_wallets.dart | 71 ++++++++++++++++--------------- lib/widgets/wallet/send_tab.dart | 10 +++-- pubspec.yaml | 2 +- 3 files changed, 44 insertions(+), 39 deletions(-) diff --git a/lib/providers/active_wallets.dart b/lib/providers/active_wallets.dart index 4f373c59..a87b2b18 100644 --- a/lib/providers/active_wallets.dart +++ b/lib/providers/active_wallets.dart @@ -355,40 +355,43 @@ class ActiveWallets with ChangeNotifier { for (var vOut in voutList) { final asMap = vOut as Map; if (asMap['scriptPubKey']['type'] != 'nulldata') { - asMap['scriptPubKey']['addresses'].forEach( - (addr) { - if (openWallet.addresses.firstWhereOrNull( - (element) => element.address == addr) != - null) { - //address is ours, add new tx - final int txValue = (vOut['value'] * decimalProduct).toInt(); - - //increase notification value for addr - final addrInWallet = openWallet.addresses - .firstWhere((element) => element.address == addr); - addrInWallet.newNotificationBackendCount = - addrInWallet.notificationBackendCount + 1; - openWallet.save(); - - //write tx - openWallet.putTransaction( - WalletTransaction( - txid: tx['txid'], - timestamp: tx['blocktime'] ?? 0, - value: txValue, - fee: 0, - address: addr, - recipients: {addr: txValue}, - direction: direction, - broadCasted: true, - confirmations: tx['confirmations'] ?? 0, - broadcastHex: '', - opReturn: '', - ), - ); - } - }, - ); + //pre 0.12 backwards compatability TODO remove after 0.12 HF + String addr; + if (asMap['scriptPubKey']['addresses'].runtimeType == List) { + addr = asMap['scriptPubKey']['addresses'][0]; + } + addr = asMap['scriptPubKey']['address']; + + if (openWallet.addresses + .firstWhereOrNull((element) => element.address == addr) != + null) { + //address is ours, add new tx + final int txValue = (vOut['value'] * decimalProduct).toInt(); + + //increase notification value for addr + final addrInWallet = openWallet.addresses + .firstWhere((element) => element.address == addr); + addrInWallet.newNotificationBackendCount = + addrInWallet.notificationBackendCount + 1; + openWallet.save(); + + //write tx + openWallet.putTransaction( + WalletTransaction( + txid: tx['txid'], + timestamp: tx['blocktime'] ?? 0, + value: txValue, + fee: 0, + address: addr, + recipients: {addr: txValue}, + direction: direction, + broadCasted: true, + confirmations: tx['confirmations'] ?? 0, + broadcastHex: '', + opReturn: '', + ), + ); + } } } diff --git a/lib/widgets/wallet/send_tab.dart b/lib/widgets/wallet/send_tab.dart index 2cbb56d6..519012f2 100644 --- a/lib/widgets/wallet/send_tab.dart +++ b/lib/widgets/wallet/send_tab.dart @@ -524,9 +524,6 @@ class _SendTabState extends State { bool fromImport = false, }) { if (triggerFormValidation() || fromImport == true) { - if (fromImport == false) { - _formKey.currentState!.save(); - } _labelControllerList.add(TextEditingController(text: label)); _addressControllerList.add(TextEditingController(text: address)); _amountControllerList.add(TextEditingController(text: amount.toString())); @@ -535,7 +532,12 @@ class _SendTabState extends State { _amountKeyList.add(GlobalKey()); _amountInputHelperTextList[_numberOfRecipients] = ''; _requestedAmountInCoinsList[_numberOfRecipients] = amount; - + if (fromImport == false) { + _formKey.currentState!.save(); + setState(() { + _currentAddressIndex = _numberOfRecipients; + }); + } return true; } return false; diff --git a/pubspec.yaml b/pubspec.yaml index cc6e454d..7ac09607 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: peercoin description: A new Peercoin wallet. -version: 1.1.0+119 +version: 1.1.0+120 environment: sdk: '>=2.12.0 <3.0.0'