All pubkey in monospace everywhere; Fix delete all derivations; Fix delete all pubkey refresh

This commit is contained in:
poka 2021-02-15 03:59:07 +01:00
parent 6891df981e
commit c4d774e256
6 changed files with 56 additions and 18 deletions

View File

@ -46,7 +46,14 @@ class GenerateWalletsProvider with ChangeNotifier {
if (isHD) { if (isHD) {
final int _derivationNbr = 3; final int _derivationNbr = 3;
await configFile.writeAsString('$nbrWallet:$_name:$_derivationNbr'); List _pubkeysTmp = await DubpRust.getBip32DewifAccountsPublicKeys(
dewif: wallet.dewif,
secretCode: wallet.pin,
accountsIndex: [_derivationNbr]);
String _pubkey = _pubkeysTmp[0];
await configFile
.writeAsString('$nbrWallet:$_name:$_derivationNbr:$_pubkey');
} else { } else {
await configFile.writeAsString('$nbrWallet:$_name'); await configFile.writeAsString('$nbrWallet:$_name');
} }

View File

@ -26,6 +26,11 @@ class MyWalletsProvider with ChangeNotifier {
Future importWallet() async {} Future importWallet() async {}
String getAllWalletsNames() { String getAllWalletsNames() {
final bool _isWalletsExists = checkIfWalletExist();
if (!_isWalletsExists) {
return '';
}
if (listWallets != null && listWallets.isNotEmpty) { if (listWallets != null && listWallets.isNotEmpty) {
listWallets = ''; listWallets = '';
} }
@ -42,8 +47,8 @@ class MyWalletsProvider with ChangeNotifier {
if (listWallets != '') { if (listWallets != '') {
listWallets += '\n'; listWallets += '\n';
} }
listWallets += listWallets += element;
"${element.split(':')[0]}:${element.split(':')[1]}:${element.split(':')[2]}"; // listWallets += "${element.split(':')[0]}:${element.split(':')[1]}:${element.split(':')[2]}"
}); });
}); });
@ -59,6 +64,7 @@ class MyWalletsProvider with ChangeNotifier {
if (_answer) { if (_answer) {
await walletsDirectory.delete(recursive: true); await walletsDirectory.delete(recursive: true);
await walletsDirectory.create(); await walletsDirectory.create();
notifyListeners();
Navigator.pop(context); Navigator.pop(context);
} }
return 0; return 0;
@ -104,14 +110,18 @@ class MyWalletsProvider with ChangeNotifier {
Future<void> generateNewDerivation( Future<void> generateNewDerivation(
context, String _name, int _walletNbr) async { context, String _name, int _walletNbr) async {
int _newDerivationNbr;
final _walletConfig = final _walletConfig =
File('${walletsDirectory.path}/$_walletNbr/config.txt'); File('${walletsDirectory.path}/$_walletNbr/config.txt');
String _lastWallet = if (await _walletConfig.readAsString() == '') {
await _walletConfig.readAsLines().then((value) => value.last); _newDerivationNbr = 3;
int _lastDerivation = int.parse(_lastWallet.split(':')[2]); } else {
// print(_lastDerivation); String _lastWallet =
int _newDerivationNbr = _lastDerivation + 3; await _walletConfig.readAsLines().then((value) => value.last);
int _lastDerivation = int.parse(_lastWallet.split(':')[2]);
_newDerivationNbr = _lastDerivation + 3;
}
await _walletConfig.writeAsString('\n$_walletNbr:$_name:$_newDerivationNbr', await _walletConfig.writeAsString('\n$_walletNbr:$_name:$_newDerivationNbr',
mode: FileMode.append); mode: FileMode.append);

View File

@ -161,7 +161,7 @@ class WalletOptionsProvider with ChangeNotifier {
String newConfig = String newConfig =
await _walletConfig.readAsLines().then((List<String> lines) { await _walletConfig.readAsLines().then((List<String> lines) {
lines.removeWhere( lines.removeWhere(
(element) => element == '$_walletNbr:$_name:$_derivation'); (element) => element.contains('$_walletNbr:$_name:$_derivation'));
return lines.join('\n'); return lines.join('\n');
}); });

View File

@ -78,7 +78,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
errorBorder: InputBorder.none, errorBorder: InputBorder.none,
disabledBorder: InputBorder.none, disabledBorder: InputBorder.none,
), ),
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)), style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.bold,
fontFamily: 'Monospace')),
if (_historyProvider.pubkey != '') if (_historyProvider.pubkey != '')
historyQuery(context, _historyProvider), historyQuery(context, _historyProvider),
])); ]));
@ -273,7 +276,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
subtitle: Text( subtitle: Text(
truncate(repository[2], 20, truncate(repository[2], 20,
omission: "...", position: TruncatePosition.end), omission: "...", position: TruncatePosition.end),
style: TextStyle(fontSize: 11.0), style: TextStyle(fontSize: 11.0, fontFamily: 'Monospace'),
textAlign: TextAlign.center), textAlign: TextAlign.center),
trailing: Text("${repository[3]} Ğ1", trailing: Text("${repository[3]} Ğ1",
style: TextStyle(fontSize: 14.0), style: TextStyle(fontSize: 14.0),

View File

@ -8,7 +8,6 @@ import 'package:provider/provider.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class WalletsHome extends StatelessWidget { class WalletsHome extends StatelessWidget {
final _derivationKey = GlobalKey<FormState>(); final _derivationKey = GlobalKey<FormState>();
final TextEditingController _newDerivationName = TextEditingController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -88,20 +87,37 @@ class WalletsHome extends StatelessWidget {
} }
Widget myWalletsList(BuildContext context) { Widget myWalletsList(BuildContext context) {
MyWalletsProvider myWalletProvider = MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context); Provider.of<MyWalletsProvider>(context);
List _listWallets = myWalletProvider.listWallets.split('\n'); final bool isWalletsExists = _myWalletProvider.checkIfWalletExist();
if (!isWalletsExists) {
return Text('');
}
if (_myWalletProvider.listWallets == '') {
return Expanded(
child: Center(
child: Text(
'Veuillez générer votre premier portefeuille',
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
)));
}
List _listWallets = _myWalletProvider.listWallets.split('\n');
return Expanded( return Expanded(
child: ListView(children: <Widget>[ child: ListView(children: <Widget>[
SizedBox(height: 8), SizedBox(height: 8),
for (String _repository in _listWallets) for (String _repository in _listWallets)
ListTile( ListTile(
contentPadding: const EdgeInsets.all(5.0), contentPadding: const EdgeInsets.only(left: 7.0),
leading: Padding( leading: Padding(
padding: const EdgeInsets.all(15.0), padding: const EdgeInsets.all(6.0),
child: Text("0 Ğ1", style: TextStyle(fontSize: 14.0))), child: Text("0 Ğ1", style: TextStyle(fontSize: 14.0))),
// subtitle: Text(_repository.split(':')[3],
// style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
title: title:
Text(_repository.split(':')[1], style: TextStyle(fontSize: 16.0)), Text(_repository.split(':')[1], style: TextStyle(fontSize: 16.0)),
dense: true, dense: true,
@ -118,8 +134,10 @@ class WalletsHome extends StatelessWidget {
} }
Widget addNewDerivation(context, int _walletNbr) { Widget addNewDerivation(context, int _walletNbr) {
final TextEditingController _newDerivationName = TextEditingController();
MyWalletsProvider _myWalletProvider = MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context); Provider.of<MyWalletsProvider>(context);
return AlertDialog( return AlertDialog(
content: Stack( content: Stack(
overflow: Overflow.visible, overflow: Overflow.visible,

View File

@ -42,9 +42,9 @@ class SettingsScreen extends StatelessWidget {
.redAccent, //Color(0xffFFD68E), // background .redAccent, //Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground onPrimary: Colors.black, // foreground
), ),
onPressed: () => { onPressed: () async => {
print('Suppression de tous les wallets'), print('Suppression de tous les wallets'),
_myWallets.deleteAllWallet(context) await _myWallets.deleteAllWallet(context)
}, },
child: Text( child: Text(
"EFFACER TOUS MES PORTEFEUILLES, LE TEMPS DE L'ALPHA", "EFFACER TOUS MES PORTEFEUILLES, LE TEMPS DE L'ALPHA",