Skip to content

Commit

Permalink
Merge pull request #159 from peercoin/0.9.2
Browse files Browse the repository at this point in the history
0.9.2
  • Loading branch information
willyfromtheblock authored May 13, 2022
2 parents 845832f + 53888a0 commit edea42c
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 112 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
### **0.9.1** (2022-05-12)
### **0.9.2** (2022-05-13)
* Improved wallet performance:
From now on the wallet will only watch addresses that it knows to have coins and the unusued address (the one displayed in the "Receive" tab).
From now on the wallet will only watch addresses that it knows to have coins and the unused address (the one displayed in the "Receive" tab).
You can manually enable watching other addresses in the address book (slide left).
Background notifications only work for watched addresses.
Rescans are not affected.

### **0.9.1** (2022-05-12)
* Price ticker: show latest price update
* Minor localization improvements

Expand Down
3 changes: 2 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@
"wallet_pop_menu_rescan": "Rescan",
"wallet_pop_menu_servers": "Adjust Servers",
"wallet_receive": "Receive",
"wallet_receive_label_hint": "Hint: Pressing this button will save the address label",
"wallet_receive_label_hint": "Pressing the Share button will save the address label.",
"wallet_receive_label_hint_privacy": "Reusing your address is discouraged for privacy reasons.\nIf you want to reuse this address, you have to set it to \"watched\" in the address book after having used it.",
"wallet_rescan_title": "Rescan wallet",
"wallet_rescan_content": "Scans the wallet again. If you're having trouble with transactions or amounts, this might be helpful.\nThis might take a moment.",
"wallet__send_label_hint": "Hint: Scanning the QR-Code will save you some time",
Expand Down
4 changes: 3 additions & 1 deletion lib/providers/active_wallets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,9 @@ class ActiveWallets with ChangeNotifier {
var utxoRes = utxos
.firstWhereOrNull((element) => element.address == addr.address);

if (addr.isWatched || utxoRes != null && utxoRes.value > 0) {
if (addr.isWatched ||
utxoRes != null && utxoRes.value > 0 ||
addr.address == _unusedAddress) {
answerMap[addr.address] = getScriptHash(identifier, addr.address);
}
}
Expand Down
180 changes: 93 additions & 87 deletions lib/screens/wallet/import_wif.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,22 @@ class _ImportWifScreenState extends State<ImportWifScreen> {
},
);

//set to watched
await _activeWallets.updateAddressWatched(_walletName, address, true);

//sync background notification
await BackgroundSync.executeSync(fromScan: true);

//send snack notification for success
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
AppLocalizations.instance.translate('import_wif_success_snack'),
textAlign: TextAlign.center,
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
AppLocalizations.instance.translate('import_wif_success_snack'),
textAlign: TextAlign.center,
),
duration: Duration(seconds: 3),
),
duration: Duration(seconds: 3),
));
);

//pop import wif
Navigator.of(context).pop();
Expand Down Expand Up @@ -161,98 +166,99 @@ class _ImportWifScreenState extends State<ImportWifScreen> {
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
AppLocalizations.instance.translate('import_wif_intro'),
),
TextFormField(
textInputAction: TextInputAction.done,
key: _wifGlobalKey,
controller: _wifController,
autocorrect: false,
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.instance
.translate('import_wif_error_empty');
}
if (validatePrivKey(value)) {
return AppLocalizations.instance
.translate('import_wif_error_failed_parse');
}
child: SingleChildScrollView(
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
AppLocalizations.instance.translate('import_wif_intro'),
),
TextFormField(
textInputAction: TextInputAction.done,
key: _wifGlobalKey,
controller: _wifController,
autocorrect: false,
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.instance
.translate('import_wif_error_empty');
}
if (validatePrivKey(value)) {
return AppLocalizations.instance
.translate('import_wif_error_failed_parse');
}

triggerConfirmMessage(context, value);
return null;
},
decoration: InputDecoration(
icon: Icon(
Icons.vpn_key,
color: Theme.of(context).primaryColor,
),
labelText: AppLocalizations.instance
.translate('import_wif_textfield_label'),
suffixIcon: IconButton(
onPressed: () async {
var data = await Clipboard.getData('text/plain');
_wifController.text = data!.text!.trim();
},
triggerConfirmMessage(context, value);
return null;
},
decoration: InputDecoration(
icon: Icon(
Icons.paste_rounded,
Icons.vpn_key,
color: Theme.of(context).primaryColor,
),
labelText: AppLocalizations.instance
.translate('import_wif_textfield_label'),
suffixIcon: IconButton(
onPressed: () async {
var data = await Clipboard.getData('text/plain');
_wifController.text = data!.text!.trim();
},
icon: Icon(
Icons.paste_rounded,
color: Theme.of(context).primaryColor,
),
),
),
minLines: 4,
maxLines: 4,
),
minLines: 4,
maxLines: 4,
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PeerButton(
action: () => createQrScanner('priv'),
text: AppLocalizations.instance
.translate('paperwallet_step_2_text'),
small: true,
),
],
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PeerButton(
action: () {
_formKey.currentState!.save();
_formKey.currentState!.validate();
},
text: AppLocalizations.instance
.translate('import_button'),
small: true,
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PeerButton(
action: () => createQrScanner('priv'),
text: AppLocalizations.instance
.translate('paperwallet_step_2_text'),
small: true,
),
],
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PeerButton(
action: () {
_formKey.currentState!.save();
_formKey.currentState!.validate();
},
text: AppLocalizations.instance
.translate('import_button'),
small: true,
),
],
),
SizedBox(height: 10),
Text(
AppLocalizations.instance.translate('import_wif_hint'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.secondary,
),
],
),
SizedBox(height: 10),
Text(
AppLocalizations.instance.translate('import_wif_hint'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.secondary,
),
),
],
],
),
),
),
),
))
)
],
),
);
Expand Down
46 changes: 26 additions & 20 deletions lib/widgets/wallet/addresses_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class _AddressTabState extends State<AddressTab> {
bool _showEmpty = true;
bool _showUnwatched = true;
final Map _addressBalanceMap = {};
String _currentChangeAddress = '';
final Map _isWatchedMap = {};
late ActiveWallets _activeWallets;
late ElectrumConnection _connection;
var _listenedAddresses;
Expand All @@ -56,12 +56,12 @@ class _AddressTabState extends State<AddressTab> {
_availableCoin = AvailableCoins().getSpecificCoin(widget.name);
_activeWallets = Provider.of<ActiveWallets>(context);
_connection = Provider.of<ElectrumConnection>(context);
_currentChangeAddress = _activeWallets.getUnusedAddress;
_listenedAddresses = _connection.listenedAddresses.keys;
await fillAddressBalanceMap();
setState(() {
_initial = false;
});
applyFilter();
}
super.didChangeDependencies();
}
Expand All @@ -77,6 +77,8 @@ class _AddressTabState extends State<AddressTab> {
}

void applyFilter([String? searchedKey]) {
if (_initial) return;

var _filteredListReceive = <WalletAddress>[];
var _filteredListSend = <WalletAddress>[];

Expand All @@ -86,8 +88,11 @@ class _AddressTabState extends State<AddressTab> {
_filteredListReceive.add(e);
//fake watch change address and addresses with balance
if (_addressBalanceMap[e.address] != null ||
e.address == _currentChangeAddress) {
e.isWatched = true;
e.address == _activeWallets.getUnusedAddress ||
e.isWatched == true) {
_isWatchedMap[e.address] = true;
} else {
_isWatchedMap[e.address] = false;
}
} else {
_filteredListSend.add(e);
Expand All @@ -109,7 +114,7 @@ class _AddressTabState extends State<AddressTab> {
}
}
if (_showUnwatched == false) {
if (address.isWatched == false) {
if (_isWatchedMap[address.address] == false) {
_toRemove.add(address);
}
}
Expand Down Expand Up @@ -256,10 +261,10 @@ class _AddressTabState extends State<AddressTab> {
var snackText;
//addresses with balance or currentChangeAddress can not be unwatched
if (_addressBalanceMap[addr.address] != null ||
addr.address == _currentChangeAddress) {
addr.address == _activeWallets.getUnusedAddress) {
snackText = 'addressbook_dialog_addr_unwatch_unable';
} else {
snackText = addr.isWatched
snackText = _isWatchedMap[addr.address] == true
? 'addressbook_dialog_addr_unwatched'
: 'addressbook_dialog_addr_watched';

Expand Down Expand Up @@ -549,19 +554,20 @@ class _AddressTabState extends State<AddressTab> {
),
),
IconSlideAction(
caption: AppLocalizations.instance.translate(
addr.isWatched
? 'addressbook_swipe_unwatch'
: 'addressbook_swipe_watch',
),
color: Theme.of(context).colorScheme.secondary,
iconWidget: Icon(
addr.isWatched
? Icons.visibility_off
: Icons.visibility,
color: Theme.of(context).backgroundColor,
),
onTap: () => _toggleWatched(addr)),
caption: AppLocalizations.instance.translate(
_isWatchedMap[addr.address] == true
? 'addressbook_swipe_unwatch'
: 'addressbook_swipe_watch',
),
color: Theme.of(context).colorScheme.secondary,
iconWidget: Icon(
_isWatchedMap[addr.address] == true
? Icons.visibility_off
: Icons.visibility,
color: Theme.of(context).backgroundColor,
),
onTap: () => _toggleWatched(addr),
),
IconSlideAction(
caption: AppLocalizations.instance
.translate('addressbook_swipe_export'),
Expand Down
9 changes: 9 additions & 0 deletions lib/widgets/wallet/receive_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ class _ReceiveTabState extends State<ReceiveTab> {
color: Theme.of(context).colorScheme.secondary,
),
),
Text(
AppLocalizations.instance
.translate('wallet_receive_label_hint_privacy'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: peercoin
description: A new Peercoin wallet.

version: 0.9.1+88
version: 0.9.2+89

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down

0 comments on commit edea42c

Please sign in to comment.