mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
Fixes for backups for Android. Fixes for send almost all amount.
This commit is contained in:
parent
5631961e47
commit
2ce34919bf
10 changed files with 60 additions and 21 deletions
|
@ -31,7 +31,7 @@ if (keystorePropertiesFile.exists()) {
|
|||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
compileSdkVersion 29
|
||||
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:label="Cake Wallet"
|
||||
android:allowBackup="false"
|
||||
android:fullBackupContent="false"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:requestLegacyExternalStorage="true">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleTop"
|
||||
|
|
|
@ -72,6 +72,8 @@ PODS:
|
|||
- Flutter
|
||||
- path_provider (0.0.1):
|
||||
- Flutter
|
||||
- "permission_handler (5.0.1+1)":
|
||||
- Flutter
|
||||
- Reachability (3.2)
|
||||
- SDWebImage (5.9.1):
|
||||
- SDWebImage/Core (= 5.9.1)
|
||||
|
@ -98,6 +100,7 @@ DEPENDENCIES:
|
|||
- local_auth (from `.symlinks/plugins/local_auth/ios`)
|
||||
- package_info (from `.symlinks/plugins/package_info/ios`)
|
||||
- path_provider (from `.symlinks/plugins/path_provider/ios`)
|
||||
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
|
||||
- share (from `.symlinks/plugins/share/ios`)
|
||||
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
||||
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
|
||||
|
@ -136,6 +139,8 @@ EXTERNAL SOURCES:
|
|||
:path: ".symlinks/plugins/package_info/ios"
|
||||
path_provider:
|
||||
:path: ".symlinks/plugins/path_provider/ios"
|
||||
permission_handler:
|
||||
:path: ".symlinks/plugins/permission_handler/ios"
|
||||
share:
|
||||
:path: ".symlinks/plugins/share/ios"
|
||||
shared_preferences:
|
||||
|
@ -159,6 +164,7 @@ SPEC CHECKSUMS:
|
|||
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
|
||||
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
|
||||
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
|
||||
permission_handler: eac8e15b4a1a3fba55b761d19f3f4e6b005d15b6
|
||||
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
|
||||
SDWebImage: a990c053fff71e388a10f3357edb0be17929c9c5
|
||||
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
|
||||
|
|
|
@ -261,14 +261,20 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
@override
|
||||
Future<PendingBitcoinTransaction> createTransaction(
|
||||
Object credentials) async {
|
||||
const minAmount = 546;
|
||||
final transactionCredentials = credentials as BitcoinTransactionCredentials;
|
||||
final inputs = <BitcoinUnspent>[];
|
||||
final allAmountFee =
|
||||
calculateEstimatedFee(transactionCredentials.priority, null);
|
||||
final allAmount = balance.confirmed - allAmountFee;
|
||||
var fee = 0;
|
||||
final amount = transactionCredentials.amount != null
|
||||
final credentialsAmount = transactionCredentials.amount != null
|
||||
? stringDoubleToBitcoinAmount(transactionCredentials.amount)
|
||||
: balance.confirmed - allAmountFee;
|
||||
: 0;
|
||||
final amount = transactionCredentials.amount == null ||
|
||||
allAmount - credentialsAmount < minAmount
|
||||
? allAmount
|
||||
: credentialsAmount;
|
||||
final txb = bitcoin.TransactionBuilder(network: bitcoin.bitcoin);
|
||||
final changeAddress = address;
|
||||
var leftAmount = amount;
|
||||
|
@ -294,8 +300,8 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
|
||||
final totalAmount = amount + fee;
|
||||
fee = transactionCredentials.amount != null
|
||||
? feeAmountForPriority(
|
||||
transactionCredentials.priority, inputs.length, 2)
|
||||
? feeAmountForPriority(transactionCredentials.priority, inputs.length,
|
||||
amount == allAmount ? 1 : 2)
|
||||
: allAmountFee;
|
||||
|
||||
if (totalAmount > balance.confirmed) {
|
||||
|
@ -329,7 +335,7 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
final feeAmount = transactionCredentials.priority.rate * estimatedSize;
|
||||
final changeValue = totalInputAmount - amount - feeAmount;
|
||||
|
||||
if (changeValue > 0) {
|
||||
if (changeValue > minAmount) {
|
||||
txb.addOutput(changeAddress, changeValue);
|
||||
}
|
||||
|
||||
|
@ -375,8 +381,9 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
} else {
|
||||
inputsCount = _unspent.length;
|
||||
}
|
||||
|
||||
return feeAmountForPriority(priority, inputsCount, 2);
|
||||
// If send all, then we have no change value
|
||||
return feeAmountForPriority(
|
||||
priority, inputsCount, amount != null ? 2 : 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -14,6 +14,7 @@ import 'package:cake_wallet/utils/show_pop_up.dart';
|
|||
import 'package:cake_wallet/view_model/backup_view_model.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class BackupPage extends BasePage {
|
||||
BackupPage(this.backupViewModelBase);
|
||||
|
@ -99,8 +100,6 @@ class BackupPage extends BasePage {
|
|||
actionRightButton: () async {
|
||||
Navigator.of(dialogContext).pop();
|
||||
final backup = await backupViewModelBase.exportBackup();
|
||||
await backupViewModelBase.saveToDownload(
|
||||
backup.name, backup.content);
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
onExportAndroid(context, backup);
|
||||
|
@ -123,9 +122,16 @@ class BackupPage extends BasePage {
|
|||
rightButtonText: 'Save to Downloads',
|
||||
leftButtonText: 'Share',
|
||||
actionRightButton: () async {
|
||||
Navigator.of(dialogContext).pop();
|
||||
final permission = await Permission.storage.request();
|
||||
|
||||
if (permission.isDenied) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
return;
|
||||
}
|
||||
|
||||
await backupViewModelBase.saveToDownload(
|
||||
backup.name, backup.content);
|
||||
Navigator.of(dialogContext).pop();
|
||||
},
|
||||
actionLeftButton: () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
|
|
|
@ -255,11 +255,11 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
.pendingTransaction.feeFormatted,
|
||||
rightButtonText: S.of(context).ok,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
actionRightButton: () async {
|
||||
Navigator.of(context).pop();
|
||||
widget.exchangeTradeViewModel.sendViewModel
|
||||
await widget.exchangeTradeViewModel.sendViewModel
|
||||
.commitTransaction();
|
||||
showPopUp<void>(
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Observer(builder: (_) {
|
||||
|
@ -359,10 +359,10 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
});
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(context).pop(),
|
||||
feeFiatAmount: widget.exchangeTradeViewModel.sendViewModel
|
||||
.pendingTransaction.feeFormatted,
|
||||
feeFiatAmount: widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount
|
||||
+ ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title,
|
||||
fiatAmountValue: widget.exchangeTradeViewModel.sendViewModel
|
||||
.pendingTransactionFeeFiatAmount +
|
||||
.pendingTransactionFiatAmount +
|
||||
' ' +
|
||||
widget.exchangeTradeViewModel.sendViewModel.fiat.title,
|
||||
recipientTitle: S.of(context).recipient_address,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:cake_wallet/core/backup_service.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/entities/secret_store_key.dart';
|
||||
|
@ -7,6 +6,7 @@ import 'package:cake_wallet/store/secret_store.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
part 'backup_view_model.g.dart';
|
||||
|
||||
|
@ -56,9 +56,11 @@ abstract class BackupViewModelBase with Store {
|
|||
state = IsExecutingState();
|
||||
final backupContent = await backupService.exportBackup(backupPassword);
|
||||
state = ExecutedSuccessfullyState();
|
||||
final now = DateTime.now();
|
||||
final formatter = DateFormat('yyyy-MM-dd_Hm');
|
||||
|
||||
return BackupExportFile(backupContent.toList(),
|
||||
name: 'backup_${DateTime.now().toString()}.zip');
|
||||
name: 'cake_wallet_backup_${formatter.format(now)}');
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
state = FailureState(e.toString());
|
||||
|
|
|
@ -167,6 +167,7 @@ abstract class SendViewModelBase with Store {
|
|||
|
||||
Validator get templateValidator => TemplateValidator();
|
||||
|
||||
@observable
|
||||
PendingTransaction pendingTransaction;
|
||||
|
||||
@computed
|
||||
|
|
14
pubspec.lock
14
pubspec.lock
|
@ -695,6 +695,20 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.2"
|
||||
permission_handler:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: permission_handler
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.0.1+1"
|
||||
permission_handler_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -11,7 +11,7 @@ description: Cake Wallet.
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 4.1.0+37
|
||||
version: 4.1.0+38
|
||||
|
||||
environment:
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
|
@ -72,6 +72,7 @@ dependencies:
|
|||
cryptography: ^1.4.0
|
||||
file_picker: ^2.1.4
|
||||
unorm_dart: ^0.1.2
|
||||
permission_handler: ^5.0.1+1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
Loading…
Reference in a new issue