Skip to content

Commit

Permalink
Merge pull request #158 from peercoin/0.9.1
Browse files Browse the repository at this point in the history
0.9.1
  • Loading branch information
willyfromtheblock authored May 12, 2022
2 parents fac9c10 + 3705b9d commit 845832f
Show file tree
Hide file tree
Showing 19 changed files with 577 additions and 300 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/analyze-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1.5.3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '2.10.0'
- run: flutter pub get
# run static analys code
- run: flutter analyze
Expand All @@ -31,9 +31,9 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1.5.3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '2.10.0'
- name: run tests
uses: ReactiveCircus/[email protected]
with:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### **0.9.1** (2022-05-12)
* 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).
You can manually enable watching other addresses in the address book (slide left).
Background notifications only work for watched addresses.
Rescans are not affected.
* Price ticker: show latest price update
* Minor localization improvements

### **0.9.0** (2022-04-26)
* Bug fix: Edge case for importing paper wallets

Expand Down
8 changes: 8 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"addressbook_bottom_bar_sending_addresses": "Sending Addresses",
"addressbook_dialog_remove_title": "Do you really want to remove this address?",
"addressbook_dialog_remove_snack": "Address successfully removed",
"addressbook_dialog_addr_watched": "$address\nis now watched",
"addressbook_dialog_addr_unwatched": "$address\nis no longer watched",
"addressbook_dialog_addr_unwatch_unable": "$address\ncan't be unwatched\n(has balance or is the next change address)",
"addressbook_edit_dialog_title": "Edit label",
"addressbook_edit_dialog_input": "New label",
"addressbook_export_dialog_title": "Export Private Key",
Expand All @@ -31,6 +34,7 @@
"addressbook_hide_change": "Hide change addresses",
"addressbook_hide_empty": "Hide empty",
"addressbook_hide_used": "Hide used",
"addressbook_hide_unwatched": "Hide unwatched",
"addressbook_show_balance": "Show balance",
"addressbook_show_label": "Show label",
"addressbook_no_label": "no label",
Expand All @@ -41,6 +45,8 @@
"addressbook_swipe_export": "Export",
"addressbook_swipe_share": "Share",
"addressbook_swipe_send": "Send to",
"addressbook_swipe_watch": "Watch",
"addressbook_swipe_unwatch": "Unwatch",
"addressbook_title": "$coin Addresses",
"app_navigation": "Navigation",
"app_settings": "Settings",
Expand Down Expand Up @@ -235,6 +241,7 @@
"setup_price_feed_allow": "Allow price feed API",
"setup_price_feed_description": "This will allow for your wallet balance to be displayed at real time exchange value.",
"setup_price_feed_title": "External APIs",
"setup_price_feed_last_update": "Last update: $timestamp",
"setup_bg_sync_description": "This will enable background notifications for your wallets.",
"setup_bg_sync_allow": "Allow background sync API",
"setup_securebox_fail": "We are very sorry.\nYour device does not support a secure enough way of storing keys.",
Expand Down Expand Up @@ -271,6 +278,7 @@
"wallet_offline": "offline",
"wallet_pop_menu_paperwallet": "Import Paper Wallet",
"wallet_pop_menu_wif": "Import Private Key",
"wallet_pop_menu_performance": "Performance",
"wallet_pop_menu_rescan": "Rescan",
"wallet_pop_menu_servers": "Adjust Servers",
"wallet_receive": "Receive",
Expand Down
2 changes: 2 additions & 0 deletions lib/models/wallet_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class WalletAddress extends HiveObject {
bool? _isChangeAddr = false;
@HiveField(7, defaultValue: 0)
int notificationBackendCount = 0;
@HiveField(8, defaultValue: false)
bool isWatched = false;

WalletAddress({
required this.address,
Expand Down
9 changes: 6 additions & 3 deletions lib/models/wallet_address.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 33 additions & 11 deletions lib/providers/active_wallets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -647,22 +647,22 @@ class ActiveWallets with ChangeNotifier {
//change is too small! no change output
_destroyedChange = changeAmount;
if (_txAmount == 0) {
tx.addOutput(address, _txAmount);
tx.addOutput(address, BigInt.from(_txAmount));
} else {
tx.addOutput(address, _txAmount - fee);
tx.addOutput(address, BigInt.from(_txAmount - fee));
_destroyedChange = _destroyedChange + fee;
}
} else {
tx.addOutput(address, _txAmount);
tx.addOutput(_unusedAddress, changeAmount);
tx.addOutput(address, BigInt.from(_txAmount));
tx.addOutput(_unusedAddress, BigInt.from(changeAmount));
}
} else {
LoggerWrapper.logInfo(
'ActiveWallets',
'buildTransaction',
'no change needed, tx amount $_txAmount, fee $fee, output added for $address ${_txAmount - fee}',
);
tx.addOutput(address, _txAmount - fee);
tx.addOutput(address, BigInt.from(_txAmount - fee));
}

//add OP_RETURN if exists
Expand Down Expand Up @@ -760,13 +760,22 @@ class ActiveWallets with ChangeNotifier {
var answerMap = {};
if (address == null) {
//get all
var utxos = await getWalletUtxos(identifier);
addresses = await getWalletAddresses(identifier);
addresses.forEach((addr) {
if (addr.isOurs == true || addr.isOurs == null) {
// == null for backwards compatability
answerMap[addr.address] = getScriptHash(identifier, addr.address);
}
});
addresses.forEach(
(addr) {
if (addr.isOurs == true || addr.isOurs == null) {
// == null for backwards compatability
//does addr have a balance?
var utxoRes = utxos
.firstWhereOrNull((element) => element.address == addr.address);

if (addr.isWatched || utxoRes != null && utxoRes.value > 0) {
answerMap[addr.address] = getScriptHash(identifier, addr.address);
}
}
},
);
} else {
//get just one
answerMap[address] = getScriptHash(identifier, address);
Expand Down Expand Up @@ -852,6 +861,19 @@ class ActiveWallets with ChangeNotifier {
await openWallet.save();
}

Future<void> updateAddressWatched(
String identifier, String address, bool newValue) async {
var openWallet = getSpecificCoinWallet(identifier);
var addr = openWallet.addresses.firstWhereOrNull(
(element) => element.address == address,
);
if (addr != null) {
addr.isWatched = newValue;
}
await openWallet.save();
notifyListeners();
}

void removeAddress(String identifier, WalletAddress addr) {
var openWallet = getSpecificCoinWallet(identifier);
openWallet.removeAddress(addr);
Expand Down
1 change: 1 addition & 0 deletions lib/providers/electrum_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ class ElectrumConnection with ChangeNotifier {
addresses.entries.forEach((hash) {
_addresses[hash.key] = hash.value;
sendMessage('blockchain.scripthash.subscribe', hash.key, [hash.value]);
notifyListeners();
});
}

Expand Down
1 change: 0 additions & 1 deletion lib/screens/app_settings_notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,4 @@ class _AppSettingsNotificationsScreenState
),
);
}
//TODO allow to not listen to change addresses? .. would save data
}
Loading

0 comments on commit 845832f

Please sign in to comment.