diff --git a/crypto_plugins/flutter_libmonero b/crypto_plugins/flutter_libmonero index b9bc2dcc5..2da774385 160000 --- a/crypto_plugins/flutter_libmonero +++ b/crypto_plugins/flutter_libmonero @@ -1 +1 @@ -Subproject commit b9bc2dcc56e13f235a6c5b0fc02c0e543eb87758 +Subproject commit 2da77438527732dfaa5398aa391eab5253dabe19 diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 9e9ffc783..fd8f9a79e 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -1349,10 +1349,8 @@ class MoneroWallet extends CoinServiceAPI { Future> get unspentOutputs => throw UnimplementedError(); @override - // TODO: implement validateAddress bool validateAddress(String address) { - bool valid = RegExp("[a-zA-Z0-9]{95}").hasMatch(address) || - RegExp("[a-zA-Z0-9]{106}").hasMatch(address); + bool valid = walletBase!.validateAddress(address); return valid; } diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 39d3038ee..d03733edb 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1372,10 +1372,8 @@ class WowneroWallet extends CoinServiceAPI { Future> get unspentOutputs => throw UnimplementedError(); @override - // TODO: implement validateAddress bool validateAddress(String address) { - bool valid = RegExp("[a-zA-Z0-9]{95}").hasMatch(address) || - RegExp("[a-zA-Z0-9]{106}").hasMatch(address); + bool valid = walletBase!.validateAddress(address); return valid; } diff --git a/pubspec.yaml b/pubspec.yaml index 8b03cd57e..b7947a58d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Stack 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: 1.5.16+88 +version: 1.5.17+89 environment: sdk: ">=2.17.0 <3.0.0" diff --git a/scripts/linux/build_secure_storage_deps.sh b/scripts/linux/build_secure_storage_deps.sh index 5ed032b1a..378f7a604 100755 --- a/scripts/linux/build_secure_storage_deps.sh +++ b/scripts/linux/build_secure_storage_deps.sh @@ -1,25 +1,37 @@ #!/bin/bash LINUX_DIRECTORY=$(pwd) -mkdir build +mkdir -p build # Build JsonCPP -cd build -git clone https://github.com/open-source-parsers/jsoncpp.git -cd jsoncpp +cd build || exit +if ! [ -x "$(command -v git)" ]; then + echo 'Error: git is not installed.' >&2 + exit 1 +fi +git -C jsoncpp pull || git clone https://github.com/open-source-parsers/jsoncpp.git jsoncpp +cd jsoncpp || exit git checkout 1.7.4 -mkdir build -cd build +mkdir -p build +cd build || exit cmake -DCMAKE_BUILD_TYPE=release -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=ON -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" .. -make -j$(nproc) +make -j"$(nproc)" -cd $LINUX_DIRECTORY +cd "$LINUX_DIRECTORY" || exit # Build libSecret # sudo apt install meson libgirepository1.0-dev valac xsltproc gi-docgen docbook-xsl # sudo apt install python3-pip #pip3 install --user meson --upgrade # pip3 install --user gi-docgen -cd build -git clone https://gitlab.gnome.org/GNOME/libsecret.git -cd libsecret +cd build || exit +git -C libsecret pull || git clone https://gitlab.gnome.org/GNOME/libsecret.git libsecret +cd libsecret || exit +if ! [ -x "$(command -v meson)" ]; then + echo 'Error: meson is not installed.' >&2 + exit 1 +fi meson _build +if ! [ -x "$(command -v ninja)" ]; then + echo 'Error: ninja is not installed.' >&2 + exit 1 +fi ninja -C _build diff --git a/test/services/coins/monero/monero_wallet_test.dart b/test/services/coins/monero/monero_wallet_test.dart index 7bbc88ed9..79bf98a41 100644 --- a/test/services/coins/monero/monero_wallet_test.dart +++ b/test/services/coins/monero/monero_wallet_test.dart @@ -90,12 +90,12 @@ void main() async { final dirPath = await pathForWalletDir(name: name, type: type); path = await pathForWallet(name: name, type: type); credentials = - // // creating a new wallet - // monero.createMoneroNewWalletCredentials( - // name: name, language: "English"); - // restoring a previous wallet - monero.createMoneroRestoreWalletFromSeedCredentials( - name: name, height: 2580000, mnemonic: testMnemonic); + // // creating a new wallet + // monero.createMoneroNewWalletCredentials( + // name: name, language: "English"); + // restoring a previous wallet + monero.createMoneroRestoreWalletFromSeedCredentials( + name: name, height: 2580000, mnemonic: testMnemonic); walletInfo = WalletInfo.external( id: WalletBase.idFor(name, type), @@ -124,8 +124,8 @@ void main() async { test("Test mainnet address generation from seed", () async { final wallet = await - // _walletCreationService.create(credentials); - _walletCreationService.restoreFromSeed(credentials); + // _walletCreationService.create(credentials); + _walletCreationService.restoreFromSeed(credentials); walletInfo.address = wallet.walletAddresses.address; //print(walletInfo.address); @@ -134,6 +134,9 @@ void main() async { walletBase = wallet as MoneroWalletBase; //print("${walletBase?.seed}"); + expect( + await walletBase!.validateAddress(walletInfo.address ?? ''), true); + // print(walletBase); // loggerPrint(walletBase.toString()); // loggerPrint("name: ${walletBase!.name} seed: ${walletBase!.seed} id: " @@ -153,6 +156,21 @@ void main() async { await walletBase!.getTransactionAddress(1, 1), mainnetTestData[1][1]); expect( await walletBase!.getTransactionAddress(1, 2), mainnetTestData[1][2]); + + expect( + await walletBase!.validateAddress(''), false); + expect( + await walletBase!.validateAddress('4AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), true); + expect( + await walletBase!.validateAddress('4asdfkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gpjkl'), false); + expect( + await walletBase!.validateAddress('8AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), false); + expect( + await walletBase!.validateAddress('84kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), true); + expect( + await walletBase!.validateAddress('8asdfuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenjkl'), false); + expect( + await walletBase!.validateAddress('44kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), false); }); }); /* @@ -211,6 +229,6 @@ Future pathForWalletDir( } Future pathForWallet( - {required String name, required WalletType type}) async => + {required String name, required WalletType type}) async => await pathForWalletDir(name: name, type: type) .then((path) => path + '/$name'); diff --git a/test/services/coins/wownero/wownero_wallet_test.dart b/test/services/coins/wownero/wownero_wallet_test.dart index c58654b4b..78a9c56c1 100644 --- a/test/services/coins/wownero/wownero_wallet_test.dart +++ b/test/services/coins/wownero/wownero_wallet_test.dart @@ -126,13 +126,21 @@ void main() async { walletBase?.close(); walletBase = wallet as WowneroWalletBase; - // TODO validate - //expect(walletInfo.address, mainnetTestData14[0][0]); + expect( + await walletBase!.validateAddress(wallet.walletAddresses.address ?? ''), true); } catch (_) { hasThrown = true; } expect(hasThrown, false); + // Address validation + expect( + await walletBase!.validateAddress(''), false); + expect( + await walletBase!.validateAddress('Wo3jmHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmsEi'), true); + expect( + await walletBase!.validateAddress('WasdfHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmjkl'), false); + walletBase?.close(); walletBase = wallet as WowneroWalletBase; }); @@ -359,6 +367,6 @@ Future pathForWalletDir( } Future pathForWallet( - {required String name, required WalletType type}) async => + {required String name, required WalletType type}) async => await pathForWalletDir(name: name, type: type) .then((path) => path + '/$name');