From 0dbfccadf6db8594865338f7dc4c0743de3b9e4e Mon Sep 17 00:00:00 2001 From: bananenwilly Date: Thu, 6 Jan 2022 12:02:19 +0100 Subject: [PATCH 1/8] version bump --- CHANGELOG.md | 5 ++++- pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0f58f79..07f85073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ +### **0.7.9** (2022-01-xx) +* Translation fixes + ### **0.7.8** (2022-01-06) * Translation fixes * Fix issue where wallet balance was not updated after TX confirmed -* Fix issue with authentification +* Fix issue with authentication ### **0.7.7** (2021-12-30) * allow import of WIF-format private keys diff --git a/pubspec.yaml b/pubspec.yaml index db5e3b67..334a2376 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: peercoin description: A new Peercoin wallet. -version: 0.7.8+75 +version: 0.7.9+76 environment: sdk: '>=2.12.0 <3.0.0' From 7748d464281fe603932f2e1f9378436511a3c200 Mon Sep 17 00:00:00 2001 From: bananenwilly Date: Thu, 6 Jan 2022 16:26:50 +0100 Subject: [PATCH 2/8] don't pass null result to reply handler --- lib/providers/electrumconnection.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/providers/electrumconnection.dart b/lib/providers/electrumconnection.dart index c2dce16f..449073f2 100644 --- a/lib/providers/electrumconnection.dart +++ b/lib/providers/electrumconnection.dart @@ -208,7 +208,7 @@ class ElectrumConnection with ChangeNotifier { var idString = id.toString(); var result = decoded['result']; - if (decoded['id'] != null) { + if (decoded['id'] != null && result != null) { log('replyhandler $idString'); if (idString == 'version') { handleVersion(result); From aac7aea4044db1a65f32a715080927426a747195 Mon Sep 17 00:00:00 2001 From: bananenwilly Date: Thu, 6 Jan 2022 17:26:55 +0100 Subject: [PATCH 3/8] allow export of private keys --- assets/translations/en.json | 5 ++ lib/widgets/wallet/addresses_tab.dart | 80 +++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/assets/translations/en.json b/assets/translations/en.json index f9fe7d30..1af4d721 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -24,11 +24,16 @@ "addressbook_dialog_remove_snack": "Address successfully removed", "addressbook_edit_dialog_title": "Edit label", "addressbook_edit_dialog_input": "New label", + "addressbook_export_dialog_title": "Export Private Key", + "addressbook_export_dialog_description": "This key gives full access to the coins stored with this address.\nDon't share this key with anyone!\nOnly proceed if you are absolutely sure what you are doing.", + "addressbook_export_dialog_button": "Show me the key", + "addressbook_export_dialog_hint": "This key is WIF-format.", "addressbook_no_label": "no label", "addressbook_no_sending": "No addresses", "addressbook_search": "Insert addresses, labels", "addressbook_swipe_delete": "Delete", "addressbook_swipe_edit": "Edit", + "addressbook_swipe_export": "Export", "addressbook_swipe_share": "Share", "addressbook_swipe_send": "Send to", "addressbook_title": "$coin Addresses", diff --git a/lib/widgets/wallet/addresses_tab.dart b/lib/widgets/wallet/addresses_tab.dart index 9372974f..8ec71721 100644 --- a/lib/widgets/wallet/addresses_tab.dart +++ b/lib/widgets/wallet/addresses_tab.dart @@ -5,8 +5,10 @@ import 'package:peercoin/models/availablecoins.dart'; import 'package:peercoin/models/coin.dart'; import 'package:peercoin/models/walletaddress.dart'; import 'package:peercoin/providers/activewallets.dart'; +import 'package:peercoin/providers/appsettings.dart'; import 'package:peercoin/screens/wallet/wallet_home.dart'; import 'package:peercoin/tools/app_localizations.dart'; +import 'package:peercoin/tools/auth.dart'; import 'package:peercoin/widgets/wallet/wallet_home_qr.dart'; import 'package:provider/provider.dart'; @@ -120,6 +122,69 @@ class _AddressTabState extends State { ); } + Future _showAddressExportDialog( + BuildContext context, WalletAddress address) async { + return showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + AppLocalizations.instance + .translate('addressbook_export_dialog_title'), + textAlign: TextAlign.center, + ), + content: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + AppLocalizations.instance + .translate('addressbook_export_dialog_description'), + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, + letterSpacing: 1.2, + fontWeight: FontWeight.bold, + color: Theme.of(context).errorColor, + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: Text( + AppLocalizations.instance + .translate('server_settings_alert_cancel'), + ), + ), + TextButton( + onPressed: () async { + var _wif; + if (address.wif!.isEmpty || address.wif == null) { + _wif = await context.read().getWif( + _availableCoin.name, + address.address, + ); + } else { + _wif = address.wif; + } + Navigator.of(context).pop(); + WalletHomeQr.showQrDialog(context, _wif); + }, + child: Text( + AppLocalizations.instance + .translate('addressbook_export_dialog_button'), + ), + ) + ], + ); + }, + ); + } + Future _addressAddDialog(BuildContext context) async { var _labelController = TextEditingController(); var _addressController = TextEditingController(); @@ -353,6 +418,21 @@ class _AddressTabState extends State { addr.address, ), ), + IconSlideAction( + caption: AppLocalizations.instance + .translate('addressbook_swipe_export'), + color: Theme.of(context).backgroundColor, + iconWidget: Icon( + Icons.vpn_key, + color: Theme.of(context).colorScheme.secondary, + ), + onTap: () => Auth.requireAuth( + context: context, + biometricsAllowed: + context.read().biometricsAllowed, + callback: () => _showAddressExportDialog(context, addr), + ), + ), ], actionExtentRatio: 0.25, child: ListTile( From 55576e868da268e68e2690c62bb952279e814725 Mon Sep 17 00:00:00 2001 From: bananenwilly Date: Thu, 6 Jan 2022 18:55:25 +0100 Subject: [PATCH 4/8] check wif on update --- lib/providers/activewallets.dart | 45 +++++++++++++++++------------ lib/screens/wallet/wallet_home.dart | 6 ++-- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/lib/providers/activewallets.dart b/lib/providers/activewallets.dart index 598ae81f..9135f93c 100644 --- a/lib/providers/activewallets.dart +++ b/lib/providers/activewallets.dart @@ -282,18 +282,20 @@ class ActiveWallets with ChangeNotifier { if (scanMode == true) { //write phantom tx that are not displayed in tx list but known to the wallet //so they won't be parsed again and cause weird display behaviour - openWallet.putTransaction(WalletTransaction( - txid: tx['txid'], - timestamp: -1, //flags phantom tx - value: 0, - fee: 0, - address: address, - direction: 'in', - broadCasted: true, - confirmations: 0, - broadcastHex: '', - opReturn: '', - )); + openWallet.putTransaction( + WalletTransaction( + txid: tx['txid'], + timestamp: -1, //flags phantom tx + value: 0, + fee: 0, + address: address, + direction: 'in', + broadCasted: true, + confirmations: 0, + broadcastHex: '', + opReturn: '', + ), + ); } else { //check if that tx is already in the db var txInWallet = openWallet.transactions; @@ -458,13 +460,19 @@ class ActiveWallets with ChangeNotifier { //set address to used //update status for address var openWallet = getSpecificCoinWallet(identifier); - openWallet.addresses.forEach((walletAddr) async { - if (walletAddr.address == address) { - walletAddr.newUsed = status == null ? false : true; - walletAddr.newStatus = status; + var addrInWallet = openWallet.addresses + .firstWhereOrNull((element) => element.address == _unusedAddress); + if (addrInWallet != null) { + addrInWallet.newUsed = status == null ? false : true; + addrInWallet.newStatus = status; + + print(addrInWallet.wif); + + if (addrInWallet.wif!.isEmpty || addrInWallet.wif == null) { + await getWif(identifier, address); } - await openWallet.save(); - }); + } + await openWallet.save(); await generateUnusedAddress(identifier); } @@ -482,6 +490,7 @@ class ActiveWallets with ChangeNotifier { String identifier, String address, ) async { + print('getWif called for $address'); var network = AvailableCoins().getSpecificCoin(identifier).networkType; var openWallet = getSpecificCoinWallet(identifier); var walletAddress = openWallet.addresses diff --git a/lib/screens/wallet/wallet_home.dart b/lib/screens/wallet/wallet_home.dart index 0aa89a83..db59da40 100644 --- a/lib/screens/wallet/wallet_home.dart +++ b/lib/screens/wallet/wallet_home.dart @@ -263,8 +263,10 @@ class _WalletHomeState extends State _rescanInProgress = true; //init rescan await Navigator.of(context).pushNamedAndRemoveUntil( - Routes.WalletImportScan, (_) => false, - arguments: _wallet.name); + Routes.WalletImportScan, + (_) => false, + arguments: _wallet.name, + ); }, ), ], From 3d1fb19d9e8699c930a3427501c1fabc677d0386 Mon Sep 17 00:00:00 2001 From: bananenwilly Date: Thu, 6 Jan 2022 18:58:32 +0100 Subject: [PATCH 5/8] fix --- lib/providers/activewallets.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/providers/activewallets.dart b/lib/providers/activewallets.dart index 9135f93c..6e3063f8 100644 --- a/lib/providers/activewallets.dart +++ b/lib/providers/activewallets.dart @@ -461,13 +461,11 @@ class ActiveWallets with ChangeNotifier { //update status for address var openWallet = getSpecificCoinWallet(identifier); var addrInWallet = openWallet.addresses - .firstWhereOrNull((element) => element.address == _unusedAddress); + .firstWhereOrNull((element) => element.address == address); if (addrInWallet != null) { addrInWallet.newUsed = status == null ? false : true; addrInWallet.newStatus = status; - print(addrInWallet.wif); - if (addrInWallet.wif!.isEmpty || addrInWallet.wif == null) { await getWif(identifier, address); } @@ -490,7 +488,6 @@ class ActiveWallets with ChangeNotifier { String identifier, String address, ) async { - print('getWif called for $address'); var network = AvailableCoins().getSpecificCoin(identifier).networkType; var openWallet = getSpecificCoinWallet(identifier); var walletAddress = openWallet.addresses From 5154ccf47045d25fd3755b4320d7596526a1dd6c Mon Sep 17 00:00:00 2001 From: bananenwilly Date: Fri, 7 Jan 2022 17:36:39 +0100 Subject: [PATCH 6/8] fix scan issue --- lib/providers/electrumconnection.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/providers/electrumconnection.dart b/lib/providers/electrumconnection.dart index 449073f2..c2dce16f 100644 --- a/lib/providers/electrumconnection.dart +++ b/lib/providers/electrumconnection.dart @@ -208,7 +208,7 @@ class ElectrumConnection with ChangeNotifier { var idString = id.toString(); var result = decoded['result']; - if (decoded['id'] != null && result != null) { + if (decoded['id'] != null) { log('replyhandler $idString'); if (idString == 'version') { handleVersion(result); From 2dc2aad1508abfad10ed31bd41ab12109ed6fb12 Mon Sep 17 00:00:00 2001 From: bananenwilly Date: Fri, 7 Jan 2022 17:52:42 +0100 Subject: [PATCH 7/8] changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07f85073..1f0b5185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### **0.7.9** (2022-01-xx) -* Translation fixes +* Allow keys to be exported in address book +* Performance improvements for transaction building for imported keys ### **0.7.8** (2022-01-06) * Translation fixes From ee7359398923e31fe4573cd99652e462e03abbce Mon Sep 17 00:00:00 2001 From: Willy Date: Tue, 11 Jan 2022 13:52:59 +0100 Subject: [PATCH 8/8] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f0b5185..99d8e1f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### **0.7.9** (2022-01-xx) +### **0.7.9** (2022-01-11) * Allow keys to be exported in address book * Performance improvements for transaction building for imported keys