diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 29f920f4f..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Launch Program", - "program": "${workspaceFolder}/www/index.html" - } - ] -} \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 7968f2510..8771b85eb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,32 +8,26 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), exec: { + get_nwjs_for_pkg: { + command: 'if [ ! -d ./cache/0.19.4/osx64/nwjs.app ]; then mkdir -p ./cache/0.19.4/osx64; curl https://dl.nwjs.io/v0.19.5-mas-beta/nwjs-mas-v0.19.5-osx-x64.zip --output ./cache/nwjs.zip; unzip ./cache/nwjs.zip -d ./cache; cp -R ./cache/nwjs-mas-v0.19.5-osx-x64/nwjs.app ./cache/0.19.4/osx64/; fi' + }, + create_others_dist: { + command: 'sh webkitbuilds/create-others-dist.sh "<%= pkg.name %>" "<%= pkg.fullVersion %>" "<%= pkg.nameCaseNoSpace %>" "<%= pkg.title %>"' + }, + create_dmg_dist: { + command: 'sh webkitbuilds/create-dmg-dist.sh "<%= pkg.name %>" "<%= pkg.fullVersion %>" "<%= pkg.nameCaseNoSpace %>" "<%= pkg.title %>"' + }, + create_pkg_dist: { + command: 'sh webkitbuilds/create-pkg-dist.sh "<%= pkg.name %>" "<%= pkg.fullVersion %>" "<%= pkg.nameCaseNoSpace %>" "<%= pkg.title %>"' + }, + sign_desktop_dist: { + command: 'sh webkitbuilds/sign-desktop-dist.sh "<%= pkg.name %>" "<%= pkg.fullVersion %>"' + }, appConfig: { command: 'node ./util/buildAppConfig.js' }, - android_studio: { - command: ' open -a open -a /Applications/Android\\ Studio.app platforms/android', - }, - build_android_debug: { - command: 'cordova prepare android && cordova build android --debug', - }, - build_android_release: { - command: 'cordova prepare android && cordova build android --release', - }, - build_ios_debug: { - command: 'cordova prepare ios && cordova build ios --debug', - options: { - maxBuffer: 3200 * 1024 - } - }, - build_ios_release: { - command: 'cordova prepare ios && cordova build ios --release', - options: { - maxBuffer: 1600 * 1024 - } - }, - chrome: { - command: 'make -C chrome-app ' + externalServices: { + command: 'node ./util/buildExternalServices.js' }, clean: { command: 'rm -Rf bower_components node_modules' @@ -44,38 +38,8 @@ module.exports = function(grunt) { coveralls: { command: 'cat coverage/report-lcov/lcov.info |./node_modules/coveralls/bin/coveralls.js' }, - create_dmg_dist: { - command: 'sh webkitbuilds/create-dmg-dist.sh "<%= pkg.name %>" "<%= pkg.fullVersion %>" "<%= pkg.nameCaseNoSpace %>" "<%= pkg.title %>"' - }, - create_others_dist: { - command: 'sh webkitbuilds/create-others-dist.sh "<%= pkg.name %>" "<%= pkg.fullVersion %>" "<%= pkg.nameCaseNoSpace %>" "<%= pkg.title %>"' - }, - create_pkg_dist: { - command: 'sh webkitbuilds/create-pkg-dist.sh "<%= pkg.name %>" "<%= pkg.fullVersion %>" "<%= pkg.nameCaseNoSpace %>" "<%= pkg.title %>"' - }, - externalServices: { - command: 'node ./util/buildExternalServices.js' - }, - get_nwjs_for_pkg: { - command: 'if [ ! -d ./cache/0.19.5-pkg/osx64/nwjs.app ]; then cd ./cache; curl https://dl.nwjs.io/v0.19.5-mas-beta/nwjs-mas-v0.19.5-osx-x64.zip --output nwjs.zip; unzip nwjs.zip; mkdir -p ./0.19.5-pkg/osx64; cp -R ./nwjs-mas-v0.19.5-osx-x64/nwjs.app ./0.19.5-pkg/osx64/; fi' - }, - log_android: { - command: 'adb logcat | grep chromium', - }, - run_android: { - command: 'cordova run android --device', - }, - run_android_emulator: { - command: 'cordova run android --emulator', - }, - sign_android: { - // When the build log outputs "Built the following apk(s):", it seems to need the filename to start with "android-release". - // It looks like it simply lists all apk files starting with "android-release" - command: 'rm -f platforms/android/build/outputs/apk/android-release-signed-*.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../bitcoin-com-release-key.jks -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk bitcoin-com && zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/bitcoin-com-wallet-<%= pkg.fullVersion %>-android-signed-aligned.apk', - stdin: true, - }, - sign_desktop_dist: { - command: 'sh webkitbuilds/sign-desktop-dist.sh "<%= pkg.name %>" "<%= pkg.fullVersion %>"' + chrome: { + command: 'make -C chrome-app ' }, wpinit: { command: 'make -C cordova wp-init', @@ -83,9 +47,40 @@ module.exports = function(grunt) { wpcopy: { command: 'make -C cordova wp-copy', }, + iosdebug: { + command: 'npm run build:ios', + }, + ios: { + command: 'npm run build:ios-release', + }, xcode: { - command: 'open platforms/ios/*.xcodeproj', - } + command: 'npm run open:ios', + }, + androiddebug: { + command: 'npm run build:android', + }, + android: { + command: 'npm run build:android-release', + }, + androidrun: { + command: 'npm run run:android && npm run log:android', + }, + androidbuild: { + command: 'cd cordova/project && cordova build android --release', + }, + androidsign: { + command: 'rm -f cordova/project/platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../bitcoin-com-release-key.jks -signedjar cordova/project/platforms/android/build/outputs/apk/android-release-signed.apk cordova/project/platforms/android/build/outputs/apk/android-release-unsigned.apk bitcoin-com && ../android-sdk-macosx/build-tools/27.0.1/zipalign -v 4 cordova/project/platforms/android/build/outputs/apk/android-release-signed.apk cordova/project/platforms/android/build/outputs/apk/android-release-signed-aligned.apk ', + stdin: true, + }, + desktopsign: { + cmd: 'gpg -u E0AE67E7 --output webkitbuilds/others/<%= pkg.title %>-linux.zip.sig --detach-sig webkitbuilds/others/<%= pkg.title %>-linux.zip ; gpg -u E0AE67E7 --output webkitbuilds/others/<%= pkg.title %>.exe.sig --detach-sig webkitbuilds/others/<%= pkg.title %>.exe' + }, + desktopverify: { + cmd: 'gpg --verify webkitbuilds/<%= pkg.title %>-linux.zip.sig webkitbuilds/<%= pkg.title %>-linux.zip; gpg --verify webkitbuilds/<%= pkg.title %>.exe.sig webkitbuilds/<%= pkg.title %>.exe' + }, + osxsign: { + cmd: 'gpg -u E0AE67E7 --output webkitbuilds/<%= pkg.title %>.dmg.sig --detach-sig webkitbuilds/<%= pkg.title %>.dmg' + }, }, watch: { options: { @@ -353,49 +348,30 @@ module.exports = function(grunt) { grunt.registerTask('wp', ['prod', 'exec:wp']); grunt.registerTask('wp-copy', ['default', 'exec:wpcopy']); grunt.registerTask('wp-init', ['default', 'exec:wpinit']); + grunt.registerTask('ios', ['exec:ios']); + grunt.registerTask('ios-debug', ['exec:iosdebug']); + grunt.registerTask('ios-run', ['exec:xcode']); grunt.registerTask('cordovaclean', ['exec:cordovaclean']); - - // Build all - grunt.registerTask('build-app-release', ['build-mobile-release', 'build-desktop-release']); - - /** - * Mobile app - */ - - // Build mobile app - grunt.registerTask('build-mobile-release', ['build-ios-release', 'build-android-release']); - - // Build ios - grunt.registerTask('start-ios', ['default', 'exec:build_ios_debug', 'exec:xcode']); - grunt.registerTask('build-ios-debug', ['default', 'exec:build_ios_debug']); - grunt.registerTask('build-ios-release', ['prod', 'exec:build_ios_release']); - - // Build android - grunt.registerTask('start-android', ['build-android-debug', 'exec:run_android']); - grunt.registerTask('build-android-debug', ['default', 'exec:build_android_debug']); - grunt.registerTask('start-android-emulator', ['build-android-debug', 'exec:run_android_emulator']); - grunt.registerTask('build-android-release', ['prod', 'exec:build_android_release', 'sign-android']); - grunt.registerTask('sign-android', ['exec:sign_android']); - - /** - * Desktop app - */ + grunt.registerTask('android-debug', ['exec:androiddebug', 'exec:androidrun']); + grunt.registerTask('android', ['exec:android']); + grunt.registerTask('android-release', ['prod', 'exec:android', 'exec:androidsign']); + grunt.registerTask('desktopsign', ['exec:desktopsign', 'exec:desktopverify']); // Build desktop - grunt.registerTask('build-desktop', ['build-desktop-others', 'build-desktop-osx-dmg', 'build-desktop-osx-pkg']); + grunt.registerTask('desktop-build', ['desktop-others', 'desktop-osx-dmg', 'desktop-osx-pkg']); // Build desktop win64 & linux64 - grunt.registerTask('build-desktop-others', ['prod', 'nwjs:others', 'copy:linux', 'exec:create_others_dist']); + grunt.registerTask('desktop-others', ['prod', 'nwjs:others', 'copy:linux', 'exec:create_others_dist']); // Build desktop osx pkg - grunt.registerTask('build-desktop-osx-pkg', ['prod', 'exec:get_nwjs_for_pkg', 'nwjs:pkg', 'exec:create_pkg_dist']); + grunt.registerTask('desktop-osx-pkg', ['prod', 'exec:get_nwjs_for_pkg', 'nwjs:pkg', 'exec:create_pkg_dist']); // Build desktop osx dmg - grunt.registerTask('build-desktop-osx-dmg', ['prod', 'nwjs:dmg', 'exec:create_dmg_dist']); + grunt.registerTask('desktop-osx-dmg', ['prod', 'nwjs:dmg', 'exec:create_dmg_dist']); // Sign desktop - grunt.registerTask('sign-desktop', ['exec:sign_desktop_dist']); + grunt.registerTask('desktop-sign', ['exec:sign_desktop_dist']); // Release desktop - grunt.registerTask('build-desktop-release', ['build-desktop', 'sign-desktop']); + grunt.registerTask('desktop-release', ['desktop-build', 'desktop-sign']); }; diff --git a/README.md b/README.md index ae2788217..56ae84eab 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,3 @@ -This is a fork of the Bitcoin.com wallet to add additional features. -Features included: - - - Zero fee transactions (only works for Bitcoin Cash). You will be asked for, if you want to send a transaction as zero fee on the confirmation page. - - ## Zero fee transactions: - Because most network nodes on the Bitcoin Cash network don't relay zero fee txs, you will experience some strange issues, but don't worry: for me personally the Bitcoin.com pool has included all my zero fee transactions, but please beware that the receiver probably won't see your tx before it has been confirmed and please do also keep in mind, that the transactions coming after it won't confirm or be seen before the zero fee one has been confirmed. - - If you do already have a Bitcoin.com wallet, you need to create a new one to use this feature or change the wallet URL to: https://bws.freepages.dk/bws/api - - ## Disclaimer - - Please beware this is my personal experimental project. You are more than welcome to play with it, but I don't take any responsibility of loss of funds due to errors in the code, so please make sure you made a backup before running this software. - - ## Builds - - You can build the software yourself using the instructions below or use prebuilt binaries which can be found here (currently Windows and Linux only): https://ipfs.io/ipfs/QmR1DaS3QsDS48SzAWKUWFfmtMfJc4tgMtkSk3JFmuzewe - - ## - - The Bitcoin.com wallet is a fork of the Copay Wallet (https://github.com/bitpay/copay). The Bitcoin.com wallet is a secure bitcoin wallet platform for both desktop and mobile devices. It uses [Bitcore Wallet Service](https://github.com/Bitcoin-com/bitcore-wallet-service) (our fork of the [Bitpay Bitcore Wallet Service](https://github.com/bitpay/bitcore-wallet-service)) (BWS) for peer synchronization and network interfacing. @@ -134,14 +113,14 @@ npm run start:desktop Before building the release version for a platform, run the `clean-all` command to delete any untracked files in your current working directory. (Be sure to stash any uncommited changes you've made.) This guarantees consistency across builds for the current state of this repository. -The `build:*-release` commands build the production version of the app, and bundle it with the release version of the platform being built. +The `final` commands build the production version of the app, and bundle it with the release version of the platform being built. ### Android ```sh npm run clean-all npm run apply:bitcoincom -npm run build:android-release +npm run final:android ``` ### iOS @@ -149,7 +128,7 @@ npm run build:android-release ```sh npm run clean-all npm run apply:bitcoincom -npm run build:ios-release +npm run final:ios ``` ### Desktop (Linux, macOS, and Windows) @@ -157,7 +136,7 @@ npm run build:ios-release ```sh npm run clean-all npm run apply:bitcoincom -npm run build:desktop-release +npm run final:desktop ``` ## About The Bitcoin.com Wallet diff --git a/app-template/bitcoincom/appConfig.json b/app-template/bitcoincom/appConfig.json index 2eab6232d..9a155362b 100644 --- a/app-template/bitcoincom/appConfig.json +++ b/app-template/bitcoincom/appConfig.json @@ -24,9 +24,9 @@ "windowsAppId": "804636ee-b017-4cad-8719-e58ac97ffa5c", "pushSenderId": "1036948132229", "description": "A Secure Bitcoin Wallet", - "version": "5.1.3", - "fullVersion": "5.1-rc2", - "androidVersion": "501003", + "version": "5.0.3", + "fullVersion": "5.0-hotfix1", + "androidVersion": "500300", "_extraCSS": "", "_enabledExtensions": { "coinbase": false, diff --git a/app-template/config-template.xml b/app-template/config-template.xml index 8686b7b36..2f8e3db04 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -85,12 +85,6 @@ - - - - - - @@ -108,7 +102,6 @@ - diff --git a/app-template/package-template.json b/app-template/package-template.json index 11b15bfcd..c42ef81b4 100644 --- a/app-template/package-template.json +++ b/app-template/package-template.json @@ -87,53 +87,46 @@ "bitcoincashjs-fork": "^1.0.3" }, "scripts": { - "apply:bitcoincom": "npm i fs-extra && cd app-template && node apply.js bitcoincom && npm i && cordova prepare && cd ../ && ./fix-asn1.sh", - - "build:app-release": "grunt build-app-release", - - "build:mobile-release": "grunt build-mobile-release", - "build:desktop-release": "grunt build-desktop-release", - - "build:android-debug": "grunt build-android-debug", - "build:android-release": "grunt build-android-release", - - "build:ios-debug": "grunt build-ios-debug", - "build:ios-release": "grunt build-ios-release", - - "build:desktop": "grunt build-desktop", - "build:osx-pkg": "grunt build-desktop-osx-pkg", - "build:osx-dmg": "grunt build-desktop-osx-dmg", - "build:others": "grunt build-desktop-others", - - "build:windows": "cordova prepare windows && cordova build windows -- --arch=\"ARM\"", - "build:windows-release": "cordova prepare windows && cordova build windows --release --arch=\"ARM\"", - "build:www": "grunt", - "build:www-release": "grunt prod", - - "clean": "trash platforms && trash plugins && cordova prepare", - "clean-all": "git clean -dfx", - - "log:android": "adb logcat | grep chromium", - - "open:android": "grunt exec:android_studio", - "open:ios": "grunt exec:xcode", - "postinstall": "bower install", - - "sign:android": "grunt sign-android", - "sign:desktop": "grunt sign-desktop", - "start": "npm run build:www && ionic serve --nolivereload --nogulp -s --address 0.0.0.0", "start:chrome": "npm run build:www && ionic serve --nolivereload --nogulp -s --address 0.0.0.0 --browser \"google chrome\"", - "start:android": "grunt start-android", - "start:android-emulator": "grunt start-android", - "start:android-log": "grunt start-android && npm run log:android", - "start:ios": "grunt start-ios", + "start:ios": "npm run build:www && npm run build:ios && npm run open:ios", + "start:android": "npm run build:www && npm run build:android && npm run run:android", "start:windows": "npm run build:www && npm run build:windows", - + "start:desktop": "npm start", + "watch": "grunt watch", + "build:www": "grunt", + "build:www-release": "grunt prod", + "build:ios": "cordova prepare ios && cordova build ios --debug", + "build:android": "cordova prepare android && cordova build android --debug", + "build:windows": "cordova prepare windows && cordova build windows -- --arch=\"ARM\"", + "build:ios-release": "cordova prepare ios && cordova build ios --release", + "build:android-release": "cordova prepare android && cordova build android --release", + "build:windows-release": "cordova prepare windows && cordova build windows --release --arch=\"ARM\"", + "build:desktop-release": "grunt desktop-release", + "build:desktop": "grunt desktop-build", + "build:osx-pkg": "grunt desktop-osx-pkg", + "build:osx-dmg": "grunt desktop-osx-dmg", + "build:others": "grunt desktop-others", + "sign:desktop": "grunt desktop-sign", + "open:ios": "open platforms/ios/*.xcodeproj", + "open:android": "open -a open -a /Applications/Android\\ Studio.app platforms/android", + "final:www": "npm run build:www-release", + "final:ios": "npm run final:www && npm run build:ios-release && npm run open:ios", + "final:android": "npm run final:www && npm run build:android-release && npm run sign:android && npm run run:android-release", + "final:windows": "npm run final:www && npm run build:windows-release", + "final:desktop": "npm run final:www && npm run build:desktop-release", + "run:android": "cordova run android --device", + "run:android-release": "cordova run android --device --release", + "log:android": "adb logcat | grep chromium", + "sign:android": "rm -f platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../bitcoin-com-release-key.jks -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk bitcoin-com && zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-signed-aligned.apk", + "apply:copay": "npm i fs-extra && cd app-template && node apply.js copay && npm i && cordova prepare", + "apply:bitpay": "npm i fs-extra && cd app-template && node apply.js bitpay && npm i && cordova prepare", + "apply:bitcoincom": "npm i fs-extra && cd app-template && node apply.js bitcoincom && npm i && cordova prepare && cd ../ && ./fix-asn1.sh", "test": "karma start test/karma.conf.js --single-run", + "clean": "trash platforms && trash plugins && cordova prepare", "unstage-package": "git reset package.json", - "watch": "grunt watch" + "clean-all": "git clean -dfx" }, "devDependencies": { "cordova": "^6.3.1", diff --git a/i18n/po/ca/template-ca.po b/i18n/po/ca/template-ca.po index 0fa97d8ab..54c5202f2 100644 --- a/i18n/po/ca/template-ca.po +++ b/i18n/po/ca/template-ca.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Catalan\n" "Language: ca\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "No es pot crear la cartera" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "No us podeu unir a la mateixa cartera més d'un cop" #: www/views/includes/bitpayCardsCard.html:2 @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "Escombratge" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Escombra la cartera de paper" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "Escombra la cartera de paper" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "Explora Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Jocs de Bitcoin Cash" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Comparteix l'aplicació de la cartera" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Notícies" @@ -3869,75 +3860,3 @@ msgstr "Menys d'1 cèntim" msgid "This invoice is no longer accepting payments" msgstr "Aquesta factura ja no accepta pagaments" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Envia la quantitat màxima" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Error desconegut." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "No hi ha cap cartera de Bitcoin Cash per transferir els fons trobats." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "No s'ha trobat cap Bitcoin Cash." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "S'ha trobat Bitcoin Core:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "No hi ha cap cartera de Bitcoin Core per transferir els fons trobats." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "No s'ha trobat cap Bitcoin Core." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "L'escaneig ha fallat" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "No s'han reconegut les dades." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "No compatible" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet no és compatible." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Obre a l'explorador web" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Adreça no vàlida" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "No s'ha definit l'import" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "L'import és inferior al mínim" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "L'import supera el límit" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Resposta no vàlida de Shapeshift" - diff --git a/i18n/po/cs/template-cs.po b/i18n/po/cs/template-cs.po index 970b81daf..9627e2119 100644 --- a/i18n/po/cs/template-cs.po +++ b/i18n/po/cs/template-cs.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Czech\n" "Language: cs\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,8 +520,8 @@ msgid "Cannot Create Wallet" msgstr "Není možné vytvořit peněženku" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" -msgstr "Nelze se připojit vícekrát ke stejné peněžence" +msgid "Cannot join the same wallet more that once" +msgstr "Není možné několikrát sloučit stejnou peněženku" #: www/views/includes/bitpayCardsCard.html:2 msgid "Cards" @@ -1297,7 +1297,7 @@ msgstr "Nastavení filtru" #: src/js/services/fingerprintService.js:43 #: src/js/services/fingerprintService.js:48 msgid "Finger Scan Failed" -msgstr "Sken otisku prstu se nezdařil" +msgstr "Scan otisku prstu se nezdařil" #: src/js/controllers/feedback/send.js:34 #: www/views/feedback/complete.html:7 @@ -1667,7 +1667,7 @@ msgstr "Neplatná odvozovací cesta" #: src/js/controllers/copayers.js:90 msgid "Invitation to share a {{appName}} Wallet" -msgstr "Pozvánka ke sdílení {{appName}} peněženky" +msgstr "Pozvání ke sdílení {{appName}} peněženky" #: www/views/mercadoLibreCards.html:20 #: www/views/modals/mercadolibre-card-details.html:48 @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "Sweep" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Sweep papírové peněženky" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "Sweep papírové peněženky" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "Prohlédnout Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Bitcoin Cash hry" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Sdílet aplikaci peněženky" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Novinky" @@ -3869,75 +3860,3 @@ msgstr "Méně než 1 koruna" msgid "This invoice is no longer accepting payments" msgstr "Tato faktura již nepřijímá platby" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Odeslat maximální částku" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Neznámá chyba." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "Žádná Bitcoin Cash peněženka pro transfer nalezených prostředků." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Žádný Bitcoin Cash nenalezen." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Nalezen Bitcoin Core:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "Žádná Bitcoin Core peněženka pro transfer nalezených prostředků." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Žádný Bitcoin Core nenalezen." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Sken selhal" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Data nebyla rozpoznána." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "Nepodporováno" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet není podporován." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Otevřít ve webovém prohlížeči" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Neplatná adresa" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Částka nedefinována" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Nižší než minimální částka" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Nadlimitní částka" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Neplatná odpověď z Shapeshift" - diff --git a/i18n/po/de/template-de.po b/i18n/po/de/template-de.po index d2ea6cc62..e15683a63 100644 --- a/i18n/po/de/template-de.po +++ b/i18n/po/de/template-de.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: German\n" "Language: de\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "Wallet kann nicht erstellt werden" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "An einem Wallet kann nicht mehrfach teilgenommen werden" #: www/views/includes/bitpayCardsCard.html:2 @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "Leeren" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Paperwallet löschen" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "Paperwallet löschen" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "Erkunden Sie Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Bitcoin Cash Spiele" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Die Wallet-App teilen" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Neuigkeiten" @@ -3869,75 +3860,3 @@ msgstr "Weniger als 1 Cent" msgid "This invoice is no longer accepting payments" msgstr "Diese Rechnung akzeptiert keine Zahlungen mehr" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Maximalen Betrag senden" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Unbekannter Fehler." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "Keine Bitcoin Cash Wallet, zu welchem Geld verschickt werden kann, gefunden." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Kein Bitcoin Cash gefunden." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Bitcoin Core gefunden:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "Keine Bitcoin Core Wallet, zu welchem Geld verschickt werden kann, gefunden." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Kein Bitcoin Core gefunden." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Scan ist fehlgeschlagen" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Daten nicht erkannt." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "Nicht unterstützt" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet wird nicht unterstützt." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Im Webbrowser öffnen" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Ungültige Adresse" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Betrag ist nicht definiert" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Menge liegt unter dem Minimum" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Betrag ist über dem Grenzwert" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Ungültige Antwort von Shapeshift" - diff --git a/i18n/po/es-ES/template-es-ES.po b/i18n/po/es-ES/template-es-ES.po index 2a22d3593..76f004f41 100644 --- a/i18n/po/es-ES/template-es-ES.po +++ b/i18n/po/es-ES/template-es-ES.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Spanish\n" "Language: es\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:40\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "No se pudo crear la billetera" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "No puede unirse a la misma billetera más de una vez" #: www/views/includes/bitpayCardsCard.html:2 @@ -2674,7 +2674,7 @@ msgstr "Guardar las direcciones que usas frecuentemente y envía Bitcoin en un c #: www/views/tab-send.html:55 msgid "Add your first contact" -msgstr "Añade tu primer contacto" +msgstr "Añadie tu primer contacto" #: www/views/tab-send.html:65 msgid "Your Bitcoin wallet is empty" @@ -2925,14 +2925,9 @@ msgid "Sweep" msgstr "Importar" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Importar billetera de papel" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" -msgstr "Importar billetera de papel" +msgid "Sweep paper wallet" +msgstr "Importar billetera en papel" #: src/js/services/onGoingProcess.js:33 msgid "Sweeping Wallet..." @@ -3797,10 +3792,6 @@ msgstr "Explora Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Juegos de Bitcoin Cash" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Comparte esta app" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Noticias" @@ -3869,75 +3860,3 @@ msgstr "Menos de 1 centavo" msgid "This invoice is no longer accepting payments" msgstr "Esta factura ya no está aceptando pagos" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Enviar cantidad máxima" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Error desconocido." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "No se encontró billetera BCH para transferir estos fondos." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "No se encontró Bitcoin Cash." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Bitcoin Core encontrado:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "No se encontró billetera BTC para transferir estos fondos." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "No se encontró Bitcoin Core." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Falló el escaneado" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Datos no reconocidos." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "No compatible" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet no es compatible." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Abrir en navegador web" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Dirección inválida" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Cantidad no definida" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Cantidad por debajo del mínimo" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Cantidad por encima del límite" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Respuesta inválida de Shapeshift" - diff --git a/i18n/po/fa/template-fa.po b/i18n/po/fa/template-fa.po index d2b460320..4be7a1e8d 100644 --- a/i18n/po/fa/template-fa.po +++ b/i18n/po/fa/template-fa.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Persian\n" "Language: fa\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "قادر به ایجاد کیف پول نیست" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "امکان بیش از یک بار پیوستن به یک کیف پول نیست" #: www/views/includes/bitpayCardsCard.html:2 @@ -2925,14 +2925,9 @@ msgid "Sweep" msgstr "وارد کردن و تغییر آدرس به جدید(sweep)" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "جاروب کردن کیف پول کاغذی" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" -msgstr "جاروب کردن کیف پول کاغذی" +msgid "Sweep paper wallet" +msgstr "وارد کردن والت کاغذی و تغییر آدرس به جدید(sweep)" #: src/js/services/onGoingProcess.js:33 msgid "Sweeping Wallet..." @@ -3797,10 +3792,6 @@ msgstr "کاوش Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Bitcoin Cash Games" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "اشتراک گذاری نرم افزار کیف پول" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "اخبار" @@ -3869,75 +3860,3 @@ msgstr "کمتر از 1 سنت" msgid "This invoice is no longer accepting payments" msgstr "این صورت حساب دیگر پرداخت ها را نمی پذیرد" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "ارسال حداکثر مقدار" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "خطای ناشناخته." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "هیچ کیف پولی از نوع Bitcoin Cash برای انتقال وجه یافت نشد." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Bitcoin Cash یافت نشد." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Bitcoin Core یافت شده:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "هیچ کیف پولی از نوع Bitcoin Core برای انتقال وجه یافت نشد." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Bitcoin Core یافت نشد." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "اسکن انجام نشد" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "داده ها شناسایی نشد." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "پشتیبانی نشده" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet پشتیبانی نمی شود." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "آدرس" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "باز کردن در مرورگر" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "آدرس نامعتبر" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "مبلغ تعریف نشده است" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "مقدار زیر مقدار حداقل است" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "مقدار بالاتر از حد است" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "پاسخ نامعتبر از Shapeshift" - diff --git a/i18n/po/fr/template-fr.po b/i18n/po/fr/template-fr.po index ba3d98244..aa22631e2 100644 --- a/i18n/po/fr/template-fr.po +++ b/i18n/po/fr/template-fr.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: French\n" "Language: fr\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,8 +520,8 @@ msgid "Cannot Create Wallet" msgstr "Impossible de créer le portefeuille" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" -msgstr "Impossible de joindre le même portefeuille plus d'une fois" +msgid "Cannot join the same wallet more that once" +msgstr "Impossible de rejoindre le même portefeuille plus d'une fois" #: www/views/includes/bitpayCardsCard.html:2 msgid "Cards" @@ -2925,14 +2925,9 @@ msgid "Sweep" msgstr "Balayer" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Balayer un portefeuille papier" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" -msgstr "Balayer un portefeuille papier" +msgid "Sweep paper wallet" +msgstr "Balayer un portefeuille de papier" #: src/js/services/onGoingProcess.js:33 msgid "Sweeping Wallet..." @@ -3797,10 +3792,6 @@ msgstr "Explorez Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Jeux Bitcoin Cash" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Partager l’application Wallet" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Nouvelles" @@ -3869,75 +3860,3 @@ msgstr "Moins de 1 centime" msgid "This invoice is no longer accepting payments" msgstr "Cette facture n’accepte plus les paiements" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Envoi du montant maximal" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Erreur inconnue." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "Aucun portefeuille Bitcoin Cash auquel transférer des fonds trouvé." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Pas de Bitcoin Cash trouvé." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Bitcoin Core trouvé :" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "Aucun portefeuille Bitcoin Core auquel transférer des fonds trouvé." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Pas de Bitcoin Core trouvé." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Échec de l'analyse" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Données non reconnues." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "Non pris en charge" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet n’est pas pris en charge." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Ouvrir dans le navigateur web" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Adresse invalide" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Le montant n’est pas défini" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Le montant est inférieur au minimum" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Le montant est supérieur à la limite" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Réponse de Shapeshift invalide" - diff --git a/i18n/po/it/template-it.po b/i18n/po/it/template-it.po index 0ea7daa0a..d0ac86478 100644 --- a/i18n/po/it/template-it.po +++ b/i18n/po/it/template-it.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Italian\n" "Language: it\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "Impossibile creare portafoglio" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "Non è possibile aggiungere un portafoglio più di una volta" #: www/views/includes/bitpayCardsCard.html:2 @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "Spazzola" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Spazzare il portafoglio di carta" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "Spazzare il portafoglio di carta" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "Esplora Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Giochi Bitcoin Cash" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Condividere l'app Portafoglio" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "News" @@ -3869,75 +3860,3 @@ msgstr "Meno di 1 centesimo" msgid "This invoice is no longer accepting payments" msgstr "Questa fattura non accetta più pagamenti" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Inviare importo massimo" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Errore sconosciuto." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "Nessun portafoglio Bitcoin Cash trovato per il trasferimento di fondi." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Nessun Bitcoin Cash trovato." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Bitcoin Core trovato:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "Nessun portafoglio Bitcoin Core trovato per il trasferimento di fondi." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Nessun Bitcoin Core trovato." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Scansione non riuscita" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Dati non riconosciuti." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "Non supportato" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet non supportato." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Aprire nel browser web" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Indirizzo non valido" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Importo non definito" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Importo inferiore al minimo" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Importo sopra il limite" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Risposta non valida da Shapeshift" - diff --git a/i18n/po/ja/template-ja.po b/i18n/po/ja/template-ja.po index 896e8b06c..7fb88de4f 100644 --- a/i18n/po/ja/template-ja.po +++ b/i18n/po/ja/template-ja.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Japanese\n" "Language: ja\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -522,8 +522,8 @@ msgid "Cannot Create Wallet" msgstr "ウォレットを作成できません。" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" -msgstr "同じ端末で同じウォレットに複数回参加することはできません。" +msgid "Cannot join the same wallet more that once" +msgstr "同じ端末で同じウォレットに複数回参加することができません。" #: www/views/includes/bitpayCardsCard.html:2 msgid "Cards" @@ -2929,13 +2929,8 @@ msgid "Sweep" msgstr "全残高インポート" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "ペーパーウォレットの全残高インポート" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "ペーパーウォレットの全残高インポート" #: src/js/services/onGoingProcess.js:33 @@ -3803,10 +3798,6 @@ msgstr "Bitcoin.com を参照" msgid "Bitcoin Cash Games" msgstr "Bitcoin Cash ゲーム" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "ウォレットアプリを共有" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "ニュース" @@ -3875,75 +3866,3 @@ msgstr "1セント以下" msgid "This invoice is no longer accepting payments" msgstr "この請求書はもう支払を受け付けていません" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "全残高を送金" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "不明なエラーです。" - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "資金を送金できるビットコインキャッシュウォレットが見つかりません。" - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "ビットコインキャッシュが見つかりません。" - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "ビットコインが見つかりました:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "資金を送金できるビットコインウォレットが見つかりません。" - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "ビットコインが見つかりません。" - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "スキャンできませんでした" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "データが認識されていません。" - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "未対応" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet には対応していません。" - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "ウェブブラウザで開く" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "無効なアドレス" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "金額が定義されていません" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "金額が最少額を下回っています" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "金額が上限を超えています" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Shapeshift から無効な応答がありました" - diff --git a/i18n/po/ko/template-ko.po b/i18n/po/ko/template-ko.po index 490acef30..815608a50 100644 --- a/i18n/po/ko/template-ko.po +++ b/i18n/po/ko/template-ko.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Korean\n" "Language: ko\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -233,12 +233,12 @@ msgstr "가격 표시" #: src/js/controllers/tab-settings.js:19 #: www/views/preferencesPriceDisplay.html:12 msgid "Fiat" -msgstr "법정 화폐" +msgstr "고정비" #: src/js/controllers/tab-settings.js:19 #: www/views/preferencesPriceDisplay.html:15 msgid "Cryptocurrency" -msgstr "가상 화폐" +msgstr "가상화폐" #: src/js/controllers/buyAmazon.js:98 msgid "Amazon.com is not available at this moment. Please try back later." @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "지갑을 생성할 수 없습니다" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "같은 지갑에 한 번 이상 접속할 수 없습니다" #: www/views/includes/bitpayCardsCard.html:2 @@ -2658,7 +2658,7 @@ msgstr "주소 붙여넣기" #: www/views/tab-send.html:27 msgid "Transfer between wallets" -msgstr "지갑 간 전송" +msgstr "월릿 간 전송" #: www/views/tab-send.html:35 msgid "Scan QR Code" @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "스윕하기" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "종이 지갑 스윕하기" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "종이 지갑 스윕하기" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "Bitcoin.com 탐색" msgid "Bitcoin Cash Games" msgstr "BCH 게임" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "지갑 응용 프로그램 공유" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "소식" @@ -3869,75 +3860,3 @@ msgstr "1센트 미만" msgid "This invoice is no longer accepting payments" msgstr "이 청구서는 더 이상 결제를 수락하지 않습니다" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "최대 수량 보내는 중" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "알 수 없는 오류가 발생 했습니다." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "자금 찾을 없습니다 Bitcoin Cash 현금 지갑." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "찾을 수 없습니다 Bitcoin Cash 현금." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Bitcoin Core 코어 발견:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "자금 찾을 없습니다 Bitcoin Core 현금 지갑." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "찾을 수 없습니다 Bitcoin Core 현금." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "검색 실패" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "데이터 인식 되지입니다." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "지원 되지 않는" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet는 지원 되지 않습니다." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "웹 브라우저에서 열기" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "주소 오류" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "금액은 정의 되지 않은" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Minimun 아래 금액은" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "제한 위에 금액은" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "변신에서 잘못 된 응답" - diff --git a/i18n/po/nl/template-nl.po b/i18n/po/nl/template-nl.po index a42a1b370..15e0cdde1 100644 --- a/i18n/po/nl/template-nl.po +++ b/i18n/po/nl/template-nl.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Dutch\n" "Language: nl\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,8 +520,8 @@ msgid "Cannot Create Wallet" msgstr "Kan Portemonnee Niet Aanmaken" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" -msgstr "Je kan niet meerdere keren tegelijk aan een portemonnee deelnemen" +msgid "Cannot join the same wallet more that once" +msgstr "Kan niet meerdere keren tegelijk deelnemen aan een portemonnee" #: www/views/includes/bitpayCardsCard.html:2 msgid "Cards" @@ -2925,14 +2925,9 @@ msgid "Sweep" msgstr "Saldo opnemen" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Paper wallet leeghalen" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" -msgstr "Paper wallet leeghalen" +msgid "Sweep paper wallet" +msgstr "Saldo papieren portemonnee opnemen" #: src/js/services/onGoingProcess.js:33 msgid "Sweeping Wallet..." @@ -3797,10 +3792,6 @@ msgstr "Bitcoin.com verkennen" msgid "Bitcoin Cash Games" msgstr "Bitcoin Cash spellen" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Wallet app delen" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Nieuws" @@ -3869,75 +3860,3 @@ msgstr "Minder dan 1 cent" msgid "This invoice is no longer accepting payments" msgstr "Deze factuur accepteert geen betalingen meer" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Alles versturen" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Onbekende fout." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "Geen Bitcoin Cash portemonnee gevonden om bedrag naartoe over te maken." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Geen Bitcoin Cash gevonden." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Bitcoin Core gevonden:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "Geen Bitcoin Core portemonnee gevonden om waarde naartoe te versturen." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Geen Bitcoin Core gevonden." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Scannen mislukt" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Gegevens niet herkend." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "Niet ondersteund" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet wordt niet ondersteund." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Open in webbrowser" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Ongeldig adres" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Bedrag is niet gespecificeerd" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Bedrag lager is dan het minimum" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Bedrag is boven het limiet" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Ongeldig respons van Shapeshift" - diff --git a/i18n/po/pl/template-pl.po b/i18n/po/pl/template-pl.po index 63e8e47ee..584984472 100644 --- a/i18n/po/pl/template-pl.po +++ b/i18n/po/pl/template-pl.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Polish\n" "Language: pl\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:40\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "Nie można utworzyć portfela" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "Nie można dołączyć tego samego portfela więcej niż raz" #: www/views/includes/bitpayCardsCard.html:2 @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "Opróżnij" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Wyczyść papierowy portfel" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "Wyczyść papierowy portfel" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "Poznaj Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Gry Bitcoin Cash" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Udostępnij aplikację Portfel" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Aktualności" @@ -3869,75 +3860,3 @@ msgstr "Mniej niż 1 cent" msgid "This invoice is no longer accepting payments" msgstr "Nie można już opłacić tej faktury" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Wyślij maksymalną kwotę" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Nieznany błąd." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "Nie znaleziono portfela Bitcoin Cash do przekazania środków." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Nie znaleziono Bitcoin Cash." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Znaleziono Bitcoin Core:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "Nie znaleziono portfela Bitcoin Core do przekazania środków." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Nie znaleziono Bitcoin Core." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Skanowanie nie powiodło się" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Nie rozpoznano danych." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "Nieobsługiwane" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Sieć testowa nie jest obsługiwana." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "Adres URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Otwórz w przeglądarce internetowej" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Nieprawidłowy adres" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Kwota nie jest określona" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Kwota niższa od minimalnej" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Kwota przekracza limit" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Nieprawidłowa odpowiedź z Shapeshift" - diff --git a/i18n/po/pt-BR/template-pt-BR.po b/i18n/po/pt-BR/template-pt-BR.po index 7d15602e7..4dec70b33 100644 --- a/i18n/po/pt-BR/template-pt-BR.po +++ b/i18n/po/pt-BR/template-pt-BR.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Portuguese, Brazilian\n" "Language: pt\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:40\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,8 +520,8 @@ msgid "Cannot Create Wallet" msgstr "Não é possível criar a carteira" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" -msgstr "Não pode juntar-se à mesma carteira mais que uma vez" +msgid "Cannot join the same wallet more that once" +msgstr "Não pode juntar-se a mesma carteira mais que uma vez" #: www/views/includes/bitpayCardsCard.html:2 msgid "Cards" @@ -1623,7 +1623,7 @@ msgstr "Endereço de rede incorreto" #: src/js/controllers/confirm.js:306 #: src/js/services/bwcError.js:44 msgid "Insufficient confirmed funds" -msgstr "Insuficiência de fundos confirmada" +msgstr "Insuficiência de fundos confirmados" #: src/js/controllers/topup.js:165 #: src/js/controllers/topup.js:177 @@ -2090,7 +2090,7 @@ msgstr "Abrir Projeto no GitHub" #: src/js/controllers/bitpayCard.js:123 #: src/js/controllers/tx-details.js:192 msgid "Open Explorer" -msgstr "Abrir o Explorer" +msgstr "Abra o Explorer" #: www/views/tab-scan.html:22 msgid "Open Settings" @@ -2222,7 +2222,7 @@ msgstr "Detalhes do pagamento" #: www/views/modals/paypro.html:6 msgid "Payment Request" -msgstr "Solicitação de pagamento" +msgstr "Pedido de pagamento" #: www/views/mercadoLibreCards.html:22 #: www/views/modals/mercadolibre-card-details.html:39 @@ -2696,7 +2696,7 @@ msgstr "Para começar, você precisa criar uma carteira de bitcoins e obter algu #: www/views/tab-send.html:74 msgid "Buy Bitcoin now" -msgstr "Comprar Bitcoin agora" +msgstr "Compre Bitcoin agora" #: www/views/tab-send.html:76 msgid "Show my address" @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "Limpar" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Varrer a carteira de papel" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "Varrer a carteira de papel" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "Explore Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Jogos Bitcoin Cash" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Compartilhar o app de carteira" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Notícias" @@ -3869,75 +3860,3 @@ msgstr "Menos de 1 centavo" msgid "This invoice is no longer accepting payments" msgstr "Essa fatura não aceita mais pagamentos" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Enviar montante máximo" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Erro desconhecido." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "Nenhuma carteira de Bitcoin Cash para transferir fundos encontrada." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Bitcoin Cash não encontrado." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Bitcoin Core encontrado:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "Nenhuma carteira de Bitcoin Core para transferir fundos encontrada." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Nenhum Bitcoin Core encontrado." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Falha de verificação" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Dados não reconhecidos." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "Não suportado" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet não suportado." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Abrir no navegador da Web" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Endereço inválido" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Montante não definido" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Montante abaixo do mínimo" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Montante acima do limite" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Resposta inválida do Shapeshift" - diff --git a/i18n/po/ru/template-ru.po b/i18n/po/ru/template-ru.po index cb4ec3a36..ffdc6c0df 100644 --- a/i18n/po/ru/template-ru.po +++ b/i18n/po/ru/template-ru.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Russian\n" "Language: ru\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:40\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "Не удаётся создать кошелёк" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "Нельзя присоединиться к одному и тому же кошельку более одного раза" #: www/views/includes/bitpayCardsCard.html:2 @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "Считать" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "Пополнить с бумажного кошелька" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "Пополнить с бумажного кошелька" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "Обзор Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Игры Bitcoin Cash" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "Поделиться программой «Кошелёк»" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "Новости" @@ -3869,75 +3860,3 @@ msgstr "менее 1 копейки" msgid "This invoice is no longer accepting payments" msgstr "По этому инвойсу платежи больше не принимаются" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "Отправить максимальную сумму" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "Неизвестная ошибка." - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "Не найден кошелек Bitcoin Cash для перевода средств." - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "Не найден Bitcoin Cash." - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "Найден Bitcoin Core:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "Не найден кошелек Bitcoin Core для перевода средств." - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "Не найден Bitcoin Core." - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "Ошибка сканирования" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "Данные не распознаны." - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "Не поддерживается" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "Testnet не поддерживается." - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "URL-адрес" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "Открыть в веб-браузере" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "Неверный адрес" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "Сумма не задана" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "Сумма ниже минимума" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "Сумма больше ограничения" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Неправильный ответ от Shapeshift" - diff --git a/i18n/po/sv-SE/template-sv-SE.po b/i18n/po/sv-SE/template-sv-SE.po index b80fca04b..a4eeaada7 100644 --- a/i18n/po/sv-SE/template-sv-SE.po +++ b/i18n/po/sv-SE/template-sv-SE.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Swedish\n" "Language: sv\n" -"PO-Revision-Date: 2018-09-06 16:45\n" +"PO-Revision-Date: 2018-08-21 03:40\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "Kan inte skapa plånbok" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "" #: www/views/includes/bitpayCardsCard.html:2 @@ -2925,13 +2925,8 @@ msgid "Sweep" msgstr "" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "" #: src/js/services/onGoingProcess.js:33 @@ -3797,10 +3792,6 @@ msgstr "" msgid "Bitcoin Cash Games" msgstr "" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "" @@ -3869,75 +3860,3 @@ msgstr "" msgid "This invoice is no longer accepting payments" msgstr "" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "" - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "" - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "" - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "" - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "" - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "" - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "" - diff --git a/i18n/po/template.pot b/i18n/po/template.pot index 2b1068ad4..9c0e3bdc6 100644 --- a/i18n/po/template.pot +++ b/i18n/po/template.pot @@ -511,7 +511,7 @@ msgid "Cannot Create Wallet" msgstr "" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "" #: www/views/includes/bitpayCardsCard.html:2 @@ -2916,13 +2916,8 @@ msgid "Sweep" msgstr "" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" +msgid "Sweep paper wallet" msgstr "" #: src/js/services/onGoingProcess.js:33 @@ -3788,10 +3783,6 @@ msgstr "" msgid "Bitcoin Cash Games" msgstr "" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "" @@ -3858,76 +3849,4 @@ msgstr "" #: src/js/services/incomingData.js:129 msgid "This invoice is no longer accepting payments" -msgstr "" - -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "" - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "" - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "" - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "" - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "" - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "" - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" msgstr "" \ No newline at end of file diff --git a/i18n/po/vi/template-vi.po b/i18n/po/vi/template-vi.po index 29e62e498..3bdc71b26 100644 --- a/i18n/po/vi/template-vi.po +++ b/i18n/po/vi/template-vi.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Vietnamese\n" "Language: vi\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:40\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -36,7 +36,7 @@ msgstr "{{tx.feeRateStr}} của giao dịch" #: www/views/feedback/rateApp.html:7 msgid "5-star ratings help us get {{appName}} into more hands, and more users means more resources can be committed to the app!" -msgstr "{{appName}} 5-star ratings help us get {{appName}} into more hands, and more users means more resources can be committed to the app!" +msgstr "5-star ratings help us get {{appName}} into more hands, and more users means more resources can be committed to the app!" #: www/views/mercadoLibre.html:18 #: www/views/mercadoLibre.html:40 @@ -56,8 +56,8 @@ msgstr "A total of {{amountAboveMaxSizeStr}} were excluded. The maximum size all #: src/js/controllers/confirm.js:395 msgid "A total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided." -msgstr "{{amountBelowFeeStr}} Tổng cộng {{amountBelowFeeStr}} đã bị loại trừ. Số tiền này đến từ UTXOs nhỏ hơn chi phí mạng cung cấp.#\n" -"1." +msgstr "Tổng cộng {{amountBelowFeeStr}} đã bị loại trừ. Số tiền này đến từ UTXOs nhỏ hơn chi phí mạng cung cấp.#\n" +"1" #: src/js/controllers/preferencesAbout.js:6 #: www/views/tab-settings.html:156 @@ -67,7 +67,7 @@ msgstr "About" #: src/js/controllers/modals/txpDetails.js:62 #: src/js/controllers/tx-details.js:79 msgid "Accepted" -msgstr "Chấp nhận" +msgstr "Accepted" #: www/views/preferencesInformation.html:72 msgid "Account" @@ -78,7 +78,7 @@ msgstr "Account" #: www/views/tab-create-shared.html:74 #: www/views/tab-import-hardware.html:19 msgid "Account Number" -msgstr "Account Number0941162662" +msgstr "Account Number" #: www/views/tab-home.html:61 msgid "Instant transactions with low fees" @@ -241,7 +241,7 @@ msgstr "Fiat" #: src/js/controllers/tab-settings.js:19 #: www/views/preferencesPriceDisplay.html:15 msgid "Cryptocurrency" -msgstr "Cryptocurrencyg" +msgstr "Cryptocurrency" #: src/js/controllers/buyAmazon.js:98 msgid "Amazon.com is not available at this moment. Please try back later." @@ -523,8 +523,8 @@ msgid "Cannot Create Wallet" msgstr "Cannot Create Wallet" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" -msgstr "" +msgid "Cannot join the same wallet more that once" +msgstr "Cannot join the same wallet more that once" #: www/views/includes/bitpayCardsCard.html:2 msgid "Cards" @@ -2928,14 +2928,9 @@ msgid "Sweep" msgstr "Sweep" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" -msgstr "Sweep Paper Wallet" +msgid "Sweep paper wallet" +msgstr "Sweep paper wallet" #: src/js/services/onGoingProcess.js:33 msgid "Sweeping Wallet..." @@ -3800,10 +3795,6 @@ msgstr "Explore Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Bitcoin Cash Games" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "News" @@ -3872,75 +3863,3 @@ msgstr "Less than 1 cent" msgid "This invoice is no longer accepting payments" msgstr "This invoice is no longer accepting payments" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "" - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "" - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "" - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "" - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "" - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "" - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "" - diff --git a/i18n/po/zh-CN/template-zh-CN.po b/i18n/po/zh-CN/template-zh-CN.po index f648a8cd6..cd2681041 100644 --- a/i18n/po/zh-CN/template-zh-CN.po +++ b/i18n/po/zh-CN/template-zh-CN.po @@ -11,7 +11,7 @@ msgstr "" "Last-Translator: emilold\n" "Language-Team: Chinese Simplified\n" "Language: zh\n" -"PO-Revision-Date: 2018-09-15 05:56\n" +"PO-Revision-Date: 2018-08-21 03:39\n" #: www/views/modals/paypro.html:34 msgid "(Trusted)" @@ -520,7 +520,7 @@ msgid "Cannot Create Wallet" msgstr "不能创建钱包" #: src/js/services/profileService.js:442 -msgid "Cannot join the same wallet more than once" +msgid "Cannot join the same wallet more that once" msgstr "无法重复加入同一个钱包" #: www/views/includes/bitpayCardsCard.html:2 @@ -2925,14 +2925,9 @@ msgid "Sweep" msgstr "扫描" #: www/views/includes/incomingDataMenu.html:89 -msgctxt "List item" -msgid "Sweep paper wallet" -msgstr "清空纸钱包" - #: www/views/paperWallet.html:3 -msgctxt "Page title" -msgid "Sweep Paper Wallet" -msgstr "清空纸钱包" +msgid "Sweep paper wallet" +msgstr "Sweep 纸钱包" #: src/js/services/onGoingProcess.js:33 msgid "Sweeping Wallet..." @@ -3797,10 +3792,6 @@ msgstr "探索 Bitcoin.com" msgid "Bitcoin Cash Games" msgstr "Bitcoin Cash 游戏" -#: www/views/includes/community.html:29 -msgid "Share the Wallet App" -msgstr "分享钱包应用" - #: src/js/services/bitcoincomService.js:28 msgid "News" msgstr "新闻" @@ -3869,75 +3860,3 @@ msgstr "少于 1 美分" msgid "This invoice is no longer accepting payments" msgstr "此发票不再接受付款" -#: www/views/amount.html.js:60 -msgid "Send Maximum Amount" -msgstr "发送最大金额" - -#: src/js/controllers/amount.controller.js:239 -msgid "Unknown error." -msgstr "未知错误。" - -#: www/views/paperWallet.html:48 -msgid "No Bitcoin Cash wallet to transfer funds to found." -msgstr "未找到可以转入资金的 Bitcoin Cash 钱包。" - -#: www/views/paperWallet.html:54 -msgid "No Bitcoin Cash found." -msgstr "未找到 Bitcoin Cash。" - -#: www/views/paperWallet.html:60 -msgid "Bitcoin Core found:" -msgstr "已找到 Bitcoin Core:" - -#: www/views/paperWallet.html:98 -msgid "No Bitcoin Core wallet to transfer funds to found." -msgstr "未找到可以转入资金的 Bitcoin Core 钱包。" - -#: www/views/paperWallet.html:104 -msgid "No Bitcoin Core found." -msgstr "未找到 Bitcoin Core。" - -#: src/js/controllers/tab-scan.js:120 -msgid "Scan Failed" -msgstr "扫描失败" - -#: src/js/controllers/tab-scan.js:121 -msgid "Data not recognised." -msgstr "数据未被识别。" - -#: src/js/controllers/tab-scan.js:121 -msgid "Unsupported" -msgstr "不受支持" - -#: src/js/controllers/tab-scan.js:121 -msgid "Testnet is not supported." -msgstr "不支持测试网。" - -#: www/views/includes/incomingDataMenu.html:81 -msgid "URL" -msgstr "网址" - -#: www/views/includes/incomingDataMenu.html:90 -msgid "Open in web browser" -msgstr "在网络浏览器中打开" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid address" -msgstr "地址无效" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is not defined" -msgstr "未定义金额" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is below the minimun" -msgstr "金额低于最低金额" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Amount is above the limit" -msgstr "金额高于限额" - -#: src/js/services/shapeshift.service.js.html:90 -msgid "Invalid response from Shapeshift" -msgstr "Shapeshift 的响应无效" - diff --git a/resources/bitcoin.com/ios/icon/AppIcon24x24@2x.png b/resources/bitcoin.com/ios/icon/AppIcon24x24@2x.png deleted file mode 100644 index 67dddbb02..000000000 Binary files a/resources/bitcoin.com/ios/icon/AppIcon24x24@2x.png and /dev/null differ diff --git a/resources/bitcoin.com/ios/icon/AppIcon27.5x27.5@2x.png b/resources/bitcoin.com/ios/icon/AppIcon27.5x27.5@2x.png deleted file mode 100644 index 0033e910b..000000000 Binary files a/resources/bitcoin.com/ios/icon/AppIcon27.5x27.5@2x.png and /dev/null differ diff --git a/resources/bitcoin.com/ios/icon/AppIcon44x44@2x.png b/resources/bitcoin.com/ios/icon/AppIcon44x44@2x.png deleted file mode 100644 index ac78920fc..000000000 Binary files a/resources/bitcoin.com/ios/icon/AppIcon44x44@2x.png and /dev/null differ diff --git a/resources/bitcoin.com/ios/icon/AppIcon86x86@2x.png b/resources/bitcoin.com/ios/icon/AppIcon86x86@2x.png deleted file mode 100644 index 5a0e05b71..000000000 Binary files a/resources/bitcoin.com/ios/icon/AppIcon86x86@2x.png and /dev/null differ diff --git a/resources/bitcoin.com/ios/icon/AppIcon98x98@2x.png b/resources/bitcoin.com/ios/icon/AppIcon98x98@2x.png deleted file mode 100644 index a0aaf7bd7..000000000 Binary files a/resources/bitcoin.com/ios/icon/AppIcon98x98@2x.png and /dev/null differ diff --git a/resources/bitcoin.com/ios/icon/icon-1024.png b/resources/bitcoin.com/ios/icon/icon-1024.png deleted file mode 100644 index 2950ff8de..000000000 Binary files a/resources/bitcoin.com/ios/icon/icon-1024.png and /dev/null differ diff --git a/resources/bitcoin.com/ios/icon/icon-20.png b/resources/bitcoin.com/ios/icon/icon-20.png deleted file mode 100644 index 323da6465..000000000 Binary files a/resources/bitcoin.com/ios/icon/icon-20.png and /dev/null differ diff --git a/src/js/app.js b/src/js/app.js index 62ff2e6f4..745ceef50 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -19,9 +19,7 @@ var modules = [ 'copayApp.controllers', 'copayApp.directives', 'copayApp.addons', - 'bitcoincom.controllers', - 'bitcoincom.directives', - 'bitcoincom.services' + 'bitcoincom.directives' ]; var copayApp = window.copayApp = angular.module('copayApp', modules); @@ -31,6 +29,4 @@ angular.module('copayApp.services', []); angular.module('copayApp.controllers', []); angular.module('copayApp.directives', []); angular.module('copayApp.addons', []); -angular.module('bitcoincom.controllers', []); angular.module('bitcoincom.directives', []); -angular.module('bitcoincom.services', []); diff --git a/src/js/controllers/addressbookView.js b/src/js/controllers/addressbookView.js index 16df9e559..89c1cd924 100644 --- a/src/js/controllers/addressbookView.js +++ b/src/js/controllers/addressbookView.js @@ -21,14 +21,28 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f }); $scope.sendTo = function() { - var stateParams = { - data: $scope.addressbookEntry.address, - toName: $scope.addressbookEntry.name, - toEmail: $scope.addressbookEntry.email, - coin: $scope.addressbookEntry.coin - }; + $ionicHistory.removeBackView(); + sendFlowService.clear(); + $state.go('tabs.send'); + $timeout(function() { + var to = ''; + if ($scope.addressbookEntry.coin == 'bch') { + var a = 'bitcoincash:' + $scope.addressbookEntry.address; + to = bitcoinCashJsService.readAddress(a).legacy; + } else { + to = $scope.addressbookEntry.address; + } - sendFlowService.start(stateParams); + var stateParams = { + toAddress: to, + toName: $scope.addressbookEntry.name, + toEmail: $scope.addressbookEntry.email, + coin: $scope.addressbookEntry.coin + }; + + sendFlowService.pushState(stateParams); + $state.transitionTo('tabs.send.origin'); + }, 100); }; $scope.remove = function(addressbookEntry) { diff --git a/src/js/controllers/amount.controller.js b/src/js/controllers/amount.js similarity index 68% rename from src/js/controllers/amount.controller.js rename to src/js/controllers/amount.js index 07f31bb3e..f796f9559 100644 --- a/src/js/controllers/amount.controller.js +++ b/src/js/controllers/amount.js @@ -1,23 +1,16 @@ 'use strict'; -(function(){ +angular.module('copayApp.controllers').controller('amountController', amountController); -angular - .module('bitcoincom.controllers') - .controller('amountController', amountController); - -function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, sendFlowService, shapeshiftService, txFormatService, platformInfo, ongoingProcess, popupService, profileService, walletService, $window) { +function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, sendFlowService, shapeshiftService, txFormatService, platformInfo, profileService, walletService, $window) { var vm = this; - // Variables vm.allowSend = false; vm.altCurrencyList = []; vm.alternativeAmount = ''; vm.alternativeUnit = ''; vm.amount = '0'; vm.availableFunds = ''; - vm.canSendAllAvailableFunds = true; - vm.errorMessage = ''; // Use insufficient for logic, as when the amount is invalid, funds being // either sufficent or insufficient doesn't make sense. vm.fundsAreInsufficient = false; @@ -27,13 +20,9 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, vm.lastUsedPopularList = []; vm.maxAmount = 0; vm.minAmount = 0; - vm.sendableFunds = ''; - vm.showSendMaxButton = false; - vm.showSendLimitMaxButton = false; vm.thirdParty = false; vm.unit = ''; - // Functions vm.changeUnit = changeUnit; vm.close = close; vm.findCurrency = findCurrency; @@ -46,7 +35,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, vm.removeDigit = removeDigit; vm.save = save; vm.sendMax = sendMax; - + vm.errorMessage = ''; $scope.$on('$ionicView.beforeEnter', onBeforeEnter); $scope.$on('$ionicView.leave', onLeave); @@ -57,8 +46,10 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, var altCurrencyModal = null; var altUnitIndex = 0; + var availableFundsInCrypto = ''; + var availableFundsInFiat = ''; + var availableSatoshis = null; var availableUnits = []; - var canSendMax = true; var fiatCode; var isNW = platformInfo.isNW; var isAndroid = platformInfo.isAndroid; @@ -66,18 +57,10 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, var lastUsedAltCurrencyList = []; var passthroughParams = {}; var satToUnit; - var transactionSendableAmount = { - crypto: '', - satoshis: null - }; var unitDecimals; var unitIndex = 0; var unitToSatoshi; var useSendMax = false; - var walletSpendableAmount = { - crypto: '', - satoshis: null - }; function onLeave() { angular.element($window).off('keydown'); @@ -85,26 +68,42 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, function onBeforeEnter(event, data) { if (data.direction == "back") { - sendFlowService.state.pop(); + sendFlowService.popState(); } + console.log('amount onBeforeEnter after back sendflow ', sendFlowService.state); initCurrencies(); - passthroughParams = sendFlowService.state.getClone(); - console.log('amount onBeforeEnter after back sendflow ', passthroughParams); + passthroughParams = sendFlowService.getStateClone(); vm.fromWalletId = passthroughParams.fromWalletId; vm.toWalletId = passthroughParams.toWalletId; vm.minAmount = parseFloat(passthroughParams.minAmount); vm.maxAmount = parseFloat(passthroughParams.maxAmount); + if (passthroughParams.thirdParty) { + vm.thirdParty = passthroughParams.thirdParty; // Parse stringified JSON-object + if (vm.thirdParty) { + if (vm.thirdParty.id === 'shapeshift') { + if (!vm.thirdParty.data) { + vm.thirdParty.data = {}; + } + vm.thirdParty.data['fromWalletId'] = vm.fromWalletId; + + vm.fromWallet = profileService.getWallet(vm.fromWalletId); + vm.toWallet = profileService.getWallet(vm.toWalletId); + + shapeshiftService.getMarketData(vm.fromWallet.coin, vm.toWallet.coin, function(data) { + vm.thirdParty.data['minAmount'] = vm.minAmount = parseFloat(data.minimum); + vm.thirdParty.data['maxAmount'] = vm.maxAmount = parseFloat(data.maxLimit); + }); + } + } + } + vm.isRequestingSpecificAmount = !passthroughParams.fromWalletId; - vm.showSendMaxButton = !vm.isRequestingSpecificAmount; var config = configService.getSync().wallet.settings; - unitToSatoshi = config.unitToSatoshi; - satToUnit = 1 / unitToSatoshi; - unitDecimals = config.unitDecimals; setAvailableUnits(); updateUnitUI(); @@ -113,7 +112,7 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, var reOp = /^[\*\+\-\/]$/; if (!isAndroid && !isIos) { - angular.element($window).on('keydown', function(e) { + var disableKeys = angular.element($window).on('keydown', function(e) { if (!e.key) return; if (e.which === 8) { // you can add others here inside brackets. if (!altCurrencyModal) { @@ -136,7 +135,10 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, }); } - + unitToSatoshi = config.unitToSatoshi; + satToUnit = 1 / unitToSatoshi; + unitDecimals = config.unitDecimals; + resetAmount(); processAmount(); @@ -208,48 +210,13 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, var fromWallet = profileService.getWallet(passthroughParams.fromWalletId); updateAvailableFundsFromWallet(fromWallet); } - - if (passthroughParams.thirdParty) { - vm.thirdParty = passthroughParams.thirdParty; // Parse stringified JSON-object - if (vm.thirdParty) { - initShapeshift(); - } - } } } function goBack() { - sendFlowService.router.goBack(); + $ionicHistory.goBack(); } - function initShapeshift() { - if (vm.thirdParty.id === 'shapeshift') { - vm.thirdParty.data = vm.thirdParty.data || {}; - - vm.fromWallet = profileService.getWallet(vm.fromWalletId); - vm.toWallet = profileService.getWallet(vm.toWalletId); - - vm.showSendMaxButton = false; - vm.showSendLimitMaxButton = false; - vm.canSendAllAvailableFunds = false; - - ongoingProcess.set('connectingShapeshift', true); - shapeshiftService.getMarketData(vm.fromWallet.coin, vm.toWallet.coin, function onMarketData(err, data) { - ongoingProcess.set('connectingShapeshift', false); - if (err) { - // Error stop here - popupService.showAlert(gettextCatalog.getString('Shapeshift Error'), err.message, function () { - goBack(); - }); - } else { - vm.thirdParty.data.minAmount = vm.minAmount = parseFloat(data.minimum); - vm.thirdParty.data.maxAmount = vm.maxAmount = parseFloat(data.maxLimit); - setMaximumButtonFromWallet(vm.fromWallet); - } - }); - } - } - function paste(value) { vm.amount = value; processAmount(); @@ -265,28 +232,8 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, } function sendMax() { - if (canSendMax) { - useSendMax = true; - finish(); - } else { - var transactionSendableAmountInUnits = transactionSendableAmount.satoshis * satToUnit; - if (vm.minAmount && transactionSendableAmountInUnits < vm.minAmount) { - popupService.showAlert( - gettextCatalog.getString('Insufficient funds'), - gettextCatalog.getString('Amount below minimum allowed') - ); - } else { - // Need to be precise, so use crypto directly rather than fiat with exchange rate - if (availableUnits[unitIndex].isFiat) { - var tempIndex = altUnitIndex; - altUnitIndex = unitIndex; - unitIndex = tempIndex; - } - vm.amount = transactionSendableAmountInUnits.toFixed(LENGTH_AFTER_COMMA_EXPRESSION_LIMIT); - useSendMax = true; - finish(); - } - } + useSendMax = true; + finish(); } function updateUnitUI() { @@ -406,8 +353,8 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, amountInCrypto = a; var amountInSatoshis = a * unitToSatoshi; vm.fundsAreInsufficient = !!passthroughParams.fromWalletId - && walletSpendableAmount.satoshis !== null - && walletSpendableAmount.satoshis < amountInSatoshis; + && availableSatoshis !== null + && availableSatoshis < amountInSatoshis; vm.alternativeAmount = txFormatService.formatAmount(amountInSatoshis, true); vm.allowSend = lodash.isNumber(a) @@ -427,8 +374,8 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, } else { amountInCrypto = result; vm.fundsAreInsufficient = passthroughParams.fromWalletId - && walletSpendableAmount.satoshis !== null - && walletSpendableAmount.satoshis < result * unitToSatoshi; + && availableSatoshis !== null + && availableSatoshis < result * unitToSatoshi; vm.alternativeAmount = $filter('formatFiatAmount')(toFiat(result)); vm.allowSend = lodash.isNumber(result) @@ -502,13 +449,13 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, var satoshis = 0; if (unit.isFiat) { - satoshis = Math.floor(fromFiat(uiAmount) * unitToSatoshi); + satoshis = (fromFiat(uiAmount) * unitToSatoshi).toFixed(0); } else { - satoshis = Math.floor(uiAmount * unitToSatoshi); + satoshis = (uiAmount * unitToSatoshi).toFixed(0); } var confirmData = { - amount: (useSendMax && canSendMax) ? undefined : satoshis, + amount: useSendMax ? undefined : satoshis, displayAddress: passthroughParams.displayAddress, fromWalletId: passthroughParams.fromWalletId, sendMax: useSendMax, @@ -520,11 +467,12 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, confirmData.thirdParty = vm.thirdParty; } + sendFlowService.pushState(confirmData); if (!confirmData.fromWalletId) { $state.transitionTo('tabs.paymentRequest.confirm', confirmData); } else { - sendFlowService.goNext(confirmData); - useSendMax = false; + $state.transitionTo('tabs.send.review', confirmData); + $scope.useSendMax = null; } } @@ -642,133 +590,56 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory, } function updateAvailableFundsStringIfNeeded() { - if (passthroughParams.fromWalletId && walletSpendableAmount.satoshis !== null) { - vm.availableFunds = walletSpendableAmount.crypto; + if (passthroughParams.fromWalletId && availableSatoshis !== null) { + availableFundsInFiat = ''; + vm.availableFunds = availableFundsInCrypto; if (availableUnits[unitIndex].isFiat) { var coin = availableUnits[altUnitIndex].id; - txFormatService.formatAlternativeStr(coin, walletSpendableAmount.satoshis, function formatCallback(formatted){ - + txFormatService.formatAlternativeStr(coin, availableSatoshis, function formatCallback(formatted){ if (formatted) { + availableFundsInFiat = formatted; + $scope.$apply(function() { - vm.availableFunds = formatted; + vm.availableFunds = availableFundsInFiat; }); } }); } - updateMaximumButtonIfNeeded(); } } function updateAvailableFundsFromWallet(wallet) { - console.log('amount updateAvailableFundsFromWallet()'); - var availableFundsInFiat = ''; if (wallet.status && wallet.status.isValid) { - walletSpendableAmount.crypto = wallet.status.spendableBalanceStr; - walletSpendableAmount.satoshis = wallet.status.spendableAmount; + availableFundsInCrypto = wallet.status.spendableBalanceStr; + availableSatoshis = wallet.status.spendableAmount; if (wallet.status.alternativeBalanceAvailable) { availableFundsInFiat = wallet.status.spendableBalanceAlternative + ' ' + wallet.status.alternativeIsoCode; } else { availableFundsInFiat = ''; } - } else if (wallet.cachedStatus && wallet.cachedStatus.isValid) { + } else if (wallet.cachedStatus && wallet.status.isValid) { if (wallet.cachedStatus.alternativeBalanceAvailable) { availableFundsInFiat = wallet.cachedStatus.spendableBalanceAlternative + ' ' + wallet.cachedStatus.alternativeIsoCode; } else { availableFundsInFiat = ''; } - walletSpendableAmount.crypto = wallet.cachedStatus.spendableBalanceStr; - walletSpendableAmount.satoshis = wallet.cachedStatus.spendableAmount; + availableFundsInCrypto = wallet.cachedStatus.spendableBalanceStr; + availableSatoshis = wallet.cachedStatus.spendableAmount; } else { - walletSpendableAmount.crypto = ''; - walletSpendableAmount.satoshis = null; + availableFundsInFiat = ''; + availableFundsInCrypto = ''; + availableSatoshis = null; } if (availableUnits[unitIndex].isFiat) { - vm.availableFunds = availableFundsInFiat || walletSpendableAmount.crypto; + vm.availableFunds = availableFundsInFiat || availableFundsInCrypto; } else { - vm.availableFunds = walletSpendableAmount.crypto; + vm.availableFunds = availableFundsInCrypto; } - - setMaximumButtonFromWallet(wallet); - } - - function updateMaximumButtonIfNeeded() { - console.log('sendmax updateMaximumButtonIfNeeded()'); - if (vm.showSendMaxButton || vm.showSendLimitMaxButton) { - transactionSendableAmount.fiat = ''; - vm.sendableFunds = transactionSendableAmount.crypto; - - if (availableUnits[unitIndex].isFiat) { - var coin = availableUnits[altUnitIndex].id; - txFormatService.formatAlternativeStr(coin, transactionSendableAmount.satoshis, function formatCallback(formatted){ - if (formatted) { - $scope.$apply(function onApply() { - vm.sendableFunds = formatted; - }); - } - }); - } - } - } - - function setMaximumButtonFromWallet(wallet) { - console.log('sendmax setMaximumButtonFromWallet()'); - var minSatoshis = vm.minAmount * unitToSatoshi; - var maxSatoshis = vm.maxAmount * unitToSatoshi; - - if (minSatoshis > walletSpendableAmount.satoshis) { - console.log('sendmax Hiding max buttons as minimum is too high.'); - canSendMax = false; - vm.showSendMaxButton = true; - vm.showSendLimitMaxButton = false; - transactionSendableAmount.satoshis = walletSpendableAmount.satoshis; - - } else if (maxSatoshis) { - if (walletSpendableAmount.satoshis > maxSatoshis) { - console.log('sendmax Showing max limit button as available is greater than max limit.'); - canSendMax = false; - vm.showSendMaxButton = false; - vm.showSendLimitMaxButton = true; - transactionSendableAmount.satoshis = maxSatoshis; - } else { - console.log('sendmax Showing sendmax as all available as less than max limit.'); - // Enabling send max here is a little dangerous, if they receive funds between pressing - // this and the calculation in the Review screen. - canSendMax = false; - vm.showSendMaxButton = true; - vm.showSendLimitMaxButton = false; - transactionSendableAmount.satoshis = walletSpendableAmount.satoshis; - } - - } else { - console.log('sendmax Showing sendmax as all available because no limits.'); - canSendMax = true; - vm.showSendMaxButton = true; - vm.showSendLimitMaxButton = false; - transactionSendableAmount.satoshis = walletSpendableAmount.satoshis; - } - - if (vm.showSendMaxButton || vm.showSendLimitMaxButton) { - console.log('sendmax Setting max button text'); - transactionSendableAmount.crypto = txFormatService.formatAmountStr(wallet.coin, transactionSendableAmount.satoshis); - vm.sendableFunds = transactionSendableAmount.crypto; - - if (availableUnits[unitIndex].isFiat) { - txFormatService.formatAlternativeStr(wallet.coin, transactionSendableAmount.satoshis, function onFormat(formatted){ - if (formatted) { - $scope.$apply(function onApply() { - vm.sendableFunds = formatted; - }); - } - }); - } - } - } } -})(); \ No newline at end of file diff --git a/src/js/controllers/amount.spec.js b/src/js/controllers/amount.spec.js index fdef97109..ed64da836 100644 --- a/src/js/controllers/amount.spec.js +++ b/src/js/controllers/amount.spec.js @@ -1,20 +1,12 @@ describe('amountController', function(){ var configCache, - configService, - gettextCatalog, + configService, $controller, $ionicHistory, $rootScope, - ongoingProcess, platformInfo, - popupService, profileService, rateService, - sendFlowService, - shapeshiftService, - txFormatService, - $scope, - $state, $stateParams; @@ -26,7 +18,7 @@ describe('amountController', function(){ configCache = { wallet: { settings: { - unitToSatoshi: 100000000 + } } }; @@ -39,42 +31,18 @@ describe('amountController', function(){ }); configService.getSync.and.returnValue(configCache); - gettextCatalog = jasmine.createSpyObj(['getString']); - gettextCatalog.getString.and.callFake(function(str){ return str; }); $ionicHistory = jasmine.createSpyObj(['backView']); - ongoingProcess = jasmine.createSpyObj(['set']); - platformInfo = { isChromeApp: false, isAndroid: false, isIos: true }; - popupService = jasmine.createSpyObj(['showAlert']); - profileService = jasmine.createSpyObj(['getWallet', 'getWallets']); + + profileService = jasmine.createSpyObj(['getWallets']); - rateService = jasmine.createSpyObj(['fromFiat', 'listAlternatives', 'updateRates', 'whenAvailable']); - sendFlowService = jasmine.createSpyObj(['getStateClone', 'pushState']); - shapeshiftService = jasmine.createSpyObj(['getMarketData']); - txFormatService = jasmine.createSpyObj(['formatAlternativeStr', 'formatAmountStr']); + rateService = jasmine.createSpyObj(['fromFiat', 'whenAvailable']); - txFormatService.formatAlternativeStr.and.callFake(function(coin, satoshis, cb) { - if (typeof satoshis !== "number") { - throw "satoshis in formatAlternativeStr() is not a number." - } - var units = satoshis / 100000000; - var formatted = (units * 10000).toFixed(2) + ' USD'; - cb(formatted); - }); - - txFormatService.formatAmountStr.and.callFake(function(coin, satoshis) { - if (typeof satoshis !== "number") { - throw "satoshis in formatAmountStr() is not a number." - } - return (satoshis * 100000000).toFixed(8) + ' ' + (coin || 'bch').toUpperCase(); - }); - - $state = jasmine.createSpyObj(['transitionTo']); $stateParams = {}; inject(function(_$controller_, _$rootScope_){ @@ -93,14 +61,6 @@ describe('amountController', function(){ stateName: 'ignoreme' }; $ionicHistory.backView.and.returnValue(backView); - - var wallet = { - status: { - isValid: true, - spendableAmount: 123456 - } - }; - profileService.getWallet.and.returnValue(wallet); profileService.getWallets.and.returnValue([{}]); rateService.fromFiat.and.returnValue(12); // satoshis or coins? @@ -109,496 +69,33 @@ describe('amountController', function(){ var amountController = $controller('amountController', { configService: configService, - gettextCatalog: gettextCatalog, + gettextCatalog: {}, $ionicHistory: $ionicHistory, $ionicModal: {}, $ionicScrollDelegate: {}, nodeWebkitService: {}, - ongoingProcess: ongoingProcess, + ongoingProcess: {}, platformInfo: platformInfo, profileService: profileService, - popupService: popupService, + popupService: {}, rateService: rateService, $scope: $scope, - sendFlowService: sendFlowService, - shapeshiftService: shapeshiftService, $state: {}, $stateParams: $stateParams, - txFormatService: txFormatService, + txFormatService: {}, walletService: {} }); - var sendFlowState = { - fromWalletId: 'fd56c1e7-e3ac-4fd9-8afc-27b9c1b3718b', - toAddress: 'qrup46avn8t466xxwlzs4qelht7cnwvesv2e29wf7s' + var data = { + stateParams: { + fromWalletId: 'fd56c1e7-e3ac-4fd9-8afc-27b9c1b3718b', + toAddress: 'qrup46avn8t466xxwlzs4qelht7cnwvesv2e29wf7s' + } }; + $scope.$emit('$ionicView.beforeEnter', data); - sendFlowService.getStateClone.and.returnValue(sendFlowState); - - $scope.$emit('$ionicView.beforeEnter', {}); - - //expect($scope.fromWalletId).toBe('fd56c1e7-e3ac-4fd9-8afc-27b9c1b3718b'); - //expect($scope.toAddress).toBe('qrup46avn8t466xxwlzs4qelht7cnwvesv2e29wf7s'); - }); - - - - describe('Shapeshift', function() { - var walletFrom; - var walletTo; - - beforeEach(function(){ - walletFrom = {}; - walletTo = {}; - - profileService.getWallet.and.callFake(function(walletId){ - if (walletId === '4cd7673e-7320-4dfa-86e5-d4edb51d460a') { - return walletFrom; - } else if (walletId === 'bf00af8f-0788-4b57-b30a-0390747407e9') { - return walletTo; - } else { - return null; - } - }); - - rateService.listAlternatives.and.returnValue([ - {name: "Australian Dollar", isoCode: "AUD"}, - {name: "United States Dollar", isoCode: "USD"} - ]); - - }); - - it ('with available balance below limit, shows sendMax for triggering alert', function() { - - walletFrom.coin = 'btc'; - walletFrom.status = { - isValid: true, - spendableAmount: 789 - }; - walletTo.coin = 'bch'; - - profileService.getWallets.and.returnValue([{}]); - rateService.fromFiat.and.returnValue(12); - - var $scope = $rootScope.$new(); - - var amountController = $controller('amountController', { - configService: configService, - gettextCatalog: gettextCatalog, - $ionicHistory: $ionicHistory, - $ionicModal: {}, - $ionicScrollDelegate: {}, - nodeWebkitService: {}, - ongoingProcess: ongoingProcess, - platformInfo: platformInfo, - profileService: profileService, - popupService: popupService, - rateService: rateService, - $scope: $scope, - sendFlowService: sendFlowService, - shapeshiftService: shapeshiftService, - $state: $state, - $stateParams: $stateParams, - txFormatService: txFormatService, - walletService: {} - }); - - rateService.whenAvailable.and.callFake(function(cb){ - cb(); - }); - - var sendFlowState = { - amount: '', - displayAddress: null, - fromWalletId: '4cd7673e-7320-4dfa-86e5-d4edb51d460a', - sendMax: false, - thirdParty: { - id: 'shapeshift', - data: {}, - }, - toAddress: '', - toWalletId: 'bf00af8f-0788-4b57-b30a-0390747407e9' - }; - - sendFlowService.getStateClone.and.returnValue(sendFlowState); - - var reqCoinIn = ''; - var reqCoinOut = ''; - shapeshiftService.getMarketData.and.callFake(function(coinIn, coinOut, cb){ - reqCoinIn = coinIn; - reqCoinOut = coinOut; - cb({ - maxLimit: '0.6846239', - minimum: '0.00013692' - }); - }); - - $scope.$emit('$ionicView.beforeEnter', {}); - - expect(rateService.updateRates.calls.any()).toEqual(true); - - expect(reqCoinIn).toBe('btc'); - expect(reqCoinOut).toBe('bch'); - - expect(amountController.maxAmount).toBe(0.68462390); - expect(amountController.minAmount).toBe(0.00013692); - - expect(amountController.showSendMaxButton).toEqual(true); - expect(amountController.showSendLimitMaxButton).toEqual(false); - - expect(amountController.sendableFunds).toEqual('0.08 USD'); - - // Now hit the Send Max button - amountController.sendMax(); - - expect(popupService.showAlert.calls.argsFor(0)[0]).toEqual('Insufficient funds'); - expect(popupService.showAlert.calls.argsFor(0)[1]).toEqual('Amount below minimum allowed'); - expect(sendFlowService.pushState.calls.any()).toEqual(false); - expect($state.transitionTo.calls.any()).toEqual(false); - }); - - it ('with available balance between limits, uses sendMax', function() { - - walletFrom.coin = 'btc'; - walletFrom.status = { - isValid: true, - spendableAmount: 456789 - }; - walletTo.coin = 'bch'; - - profileService.getWallets.and.returnValue([{}]); - rateService.fromFiat.and.returnValue(12); - - var $scope = $rootScope.$new(); - - var amountController = $controller('amountController', { - configService: configService, - gettextCatalog: {}, - $ionicHistory: $ionicHistory, - $ionicModal: {}, - $ionicScrollDelegate: {}, - nodeWebkitService: {}, - ongoingProcess: ongoingProcess, - platformInfo: platformInfo, - profileService: profileService, - popupService: {}, - rateService: rateService, - $scope: $scope, - sendFlowService: sendFlowService, - shapeshiftService: shapeshiftService, - $state: $state, - $stateParams: $stateParams, - txFormatService: txFormatService, - walletService: {} - }); - - rateService.whenAvailable.and.callFake(function(cb){ - cb(); - }); - - var sendFlowState = { - amount: '', - displayAddress: null, - fromWalletId: '4cd7673e-7320-4dfa-86e5-d4edb51d460a', - sendMax: false, - thirdParty: { - id: 'shapeshift', - data: {}, - }, - toAddress: '', - toWalletId: 'bf00af8f-0788-4b57-b30a-0390747407e9' - }; - - sendFlowService.getStateClone.and.returnValue(sendFlowState); - - var reqCoinIn = ''; - var reqCoinOut = ''; - shapeshiftService.getMarketData.and.callFake(function(coinIn, coinOut, cb){ - reqCoinIn = coinIn; - reqCoinOut = coinOut; - cb({ - maxLimit: '0.6846239', - minimum: '0.00013692' - }); - }); - - $scope.$emit('$ionicView.beforeEnter', {}); - - expect(rateService.updateRates.calls.any()).toEqual(true); - - expect(reqCoinIn).toBe('btc'); - expect(reqCoinOut).toBe('bch'); - - expect(amountController.maxAmount).toBe(0.68462390); - expect(amountController.minAmount).toBe(0.00013692); - - expect(amountController.showSendMaxButton).toEqual(true); - expect(amountController.showSendLimitMaxButton).toEqual(false); - - // Now hit the Send Max button - var pushedState = null; - sendFlowService.pushState.and.callFake(function (sendFlowState){ - pushedState = sendFlowState; - }); - - amountController.sendMax(); - - expect(pushedState.amount).toBeUndefined(); - expect(pushedState.fromWalletId).toEqual('4cd7673e-7320-4dfa-86e5-d4edb51d460a'); - expect(pushedState.sendMax).toEqual(true); - expect(pushedState.toWalletId).toEqual('bf00af8f-0788-4b57-b30a-0390747407e9'); - - expect(pushedState.thirdParty.id).toEqual('shapeshift'); - expect(pushedState.thirdParty.data.maxAmount).toEqual(0.6846239); - expect(pushedState.thirdParty.data.minAmount).toEqual(0.00013692); - - expect($state.transitionTo.calls.count()).toEqual(1); - expect($state.transitionTo.calls.argsFor(0)[0]).toEqual('tabs.send.review'); - }); - - it ('with available balance higher than max, uses send limit max instead of sendMax', function() { - - walletFrom.coin = 'btc'; - walletFrom.status = { - isValid: true, - spendableAmount: 123456789 - }; - walletTo.coin = 'bch'; - - profileService.getWallets.and.returnValue([{}]); - rateService.fromFiat.and.returnValue(12); // satoshis or coins? - - var $scope = $rootScope.$new(); - - var amountController = $controller('amountController', { - configService: configService, - gettextCatalog: {}, - $ionicHistory: $ionicHistory, - $ionicModal: {}, - $ionicScrollDelegate: {}, - nodeWebkitService: {}, - ongoingProcess: ongoingProcess, - platformInfo: platformInfo, - profileService: profileService, - popupService: {}, - rateService: rateService, - $scope: $scope, - sendFlowService: sendFlowService, - shapeshiftService: shapeshiftService, - $state: $state, - $stateParams: $stateParams, - txFormatService: txFormatService, - walletService: {} - }); - - rateService.whenAvailable.and.callFake(function(cb){ - cb(); - }); - - var sendFlowState = { - amount: '', - displayAddress: null, - fromWalletId: '4cd7673e-7320-4dfa-86e5-d4edb51d460a', - sendMax: false, - thirdParty: { - id: 'shapeshift', - data: {}, - }, - toAddress: '', - toWalletId: 'bf00af8f-0788-4b57-b30a-0390747407e9' - }; - - sendFlowService.getStateClone.and.returnValue(sendFlowState); - - var reqCoinIn = ''; - var reqCoinOut = ''; - shapeshiftService.getMarketData.and.callFake(function(coinIn, coinOut, cb){ - reqCoinIn = coinIn; - reqCoinOut = coinOut; - cb({ - maxLimit: '0.6846239', - minimum: '0.00013692' - }); - }); - - $scope.$emit('$ionicView.beforeEnter', {}); - - expect(rateService.updateRates.calls.any()).toEqual(true); - - expect(reqCoinIn).toBe('btc'); - expect(reqCoinOut).toBe('bch'); - - expect(amountController.maxAmount).toBe(0.6846239); - expect(amountController.minAmount).toBe(0.00013692); - - expect(amountController.showSendMaxButton).toEqual(false); - expect(amountController.showSendLimitMaxButton).toEqual(true); - - // Now hit the Send Max button - var pushedState = null; - sendFlowService.pushState.and.callFake(function (sendFlowState){ - pushedState = sendFlowState; - }); - - amountController.sendMax(); - - expect(pushedState.amount).toEqual(68462390); - expect(pushedState.fromWalletId).toEqual('4cd7673e-7320-4dfa-86e5-d4edb51d460a'); - expect(pushedState.sendMax).toEqual(false); - expect(pushedState.toWalletId).toEqual('bf00af8f-0788-4b57-b30a-0390747407e9'); - - expect(pushedState.thirdParty.id).toEqual('shapeshift'); - expect(pushedState.thirdParty.data.maxAmount).toEqual(0.6846239); - expect(pushedState.thirdParty.data.minAmount).toEqual(0.00013692); - - expect($state.transitionTo.calls.count()).toEqual(1); - expect($state.transitionTo.calls.argsFor(0)[0]).toEqual('tabs.send.review'); - }); - }); - - - describe('Wallet transfer', function() { - var walletFrom; - var walletTo; - - beforeEach(function(){ - walletFrom = {}; - walletTo = {}; - - profileService.getWallet.and.callFake(function(walletId){ - if (walletId === '4cd7673e-7320-4dfa-86e5-d4edb51d460a') { - return walletFrom; - } else if (walletId === 'bf00af8f-0788-4b57-b30a-0390747407e9') { - return walletTo; - } else { - return null; - } - }); - - rateService.listAlternatives.and.returnValue([ - {name: "Australian Dollar", isoCode: "AUD"}, - {name: "United States Dollar", isoCode: "USD"} - ]); - - }); - - it('wallet transfer send max.', function() { - - walletFrom.coin = 'btc'; - walletFrom.status = { - isValid: true, - spendableAmount: 123456789 - }; - - profileService.getWallets.and.returnValue([{}]); - - var $scope = $rootScope.$new(); - - var amountController = $controller('amountController', { - configService: configService, - gettextCatalog: gettextCatalog, - $ionicHistory: $ionicHistory, - $ionicModal: {}, - $ionicScrollDelegate: {}, - nodeWebkitService: {}, - ongoingProcess: ongoingProcess, - platformInfo: platformInfo, - profileService: profileService, - popupService: popupService, - rateService: rateService, - $scope: $scope, - sendFlowService: sendFlowService, - shapeshiftService: shapeshiftService, - $state: $state, - $stateParams: $stateParams, - txFormatService: txFormatService, - walletService: {} - }); - - var sendFlowState = { - fromWalletId: '4cd7673e-7320-4dfa-86e5-d4edb51d460a', - toWalletId: 'bf00af8f-0788-4b57-b30a-0390747407e9' - }; - - sendFlowService.getStateClone.and.returnValue(sendFlowState); - - $scope.$emit('$ionicView.beforeEnter', {}); - - expect(amountController.showSendMaxButton).toEqual(true); - expect(amountController.showSendLimitMaxButton).toEqual(false); - - expect(amountController.sendableFunds).toEqual('12345.68 USD'); - - // Now hit the Send Max button - var pushedState = null; - sendFlowService.pushState.and.callFake(function (sendFlowState){ - pushedState = sendFlowState; - }); - - amountController.sendMax(); - - expect(pushedState.amount).toBeUndefined(); - expect(pushedState.fromWalletId).toEqual('4cd7673e-7320-4dfa-86e5-d4edb51d460a'); - expect(pushedState.sendMax).toEqual(true); - expect(pushedState.toWalletId).toEqual('bf00af8f-0788-4b57-b30a-0390747407e9'); - - expect($state.transitionTo.calls.count()).toEqual(1); - expect($state.transitionTo.calls.argsFor(0)[0]).toEqual('tabs.send.review'); - }); - - - // This situation was seen in real life - it('wallet transfer with valid cached status only.', function() { - - walletFrom.coin = 'btc'; - walletFrom.status = { - isValid: false, - }; - walletFrom.cachedStatus = { - isValid: true, - spendableAmount: 5678 - }; - - profileService.getWallets.and.returnValue([{}]); - - var $scope = $rootScope.$new(); - - var amountController = $controller('amountController', { - configService: configService, - gettextCatalog: gettextCatalog, - $ionicHistory: $ionicHistory, - $ionicModal: {}, - $ionicScrollDelegate: {}, - nodeWebkitService: {}, - ongoingProcess: ongoingProcess, - platformInfo: platformInfo, - profileService: profileService, - popupService: popupService, - rateService: rateService, - $scope: $scope, - sendFlowService: sendFlowService, - shapeshiftService: shapeshiftService, - $state: $state, - $stateParams: $stateParams, - txFormatService: txFormatService, - walletService: {} - }); - - var sendFlowState = { - fromWalletId: '4cd7673e-7320-4dfa-86e5-d4edb51d460a', - toWalletId: 'bf00af8f-0788-4b57-b30a-0390747407e9' - }; - - sendFlowService.getStateClone.and.returnValue(sendFlowState); - - $scope.$emit('$ionicView.beforeEnter', {}); - - expect(amountController.showSendMaxButton).toEqual(true); - expect(amountController.showSendLimitMaxButton).toEqual(false); - - expect(amountController.sendableFunds).toEqual('0.57 USD'); - }); - + expect($scope.fromWalletId).toBe('fd56c1e7-e3ac-4fd9-8afc-27b9c1b3718b'); + expect($scope.toAddress).toBe('qrup46avn8t466xxwlzs4qelht7cnwvesv2e29wf7s'); }); }); \ No newline at end of file diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index ae4bc7153..76950df73 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -517,8 +517,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( if (!lodash.isEmpty(warningMsg)) msg += '\n' + warningMsg; - popupService.showAlert(null, msg, function() {}); - + popupService.showAlert(null, msg, function() {}); }; $scope.onWalletSelect = function(wallet) { diff --git a/src/js/controllers/onboarding/tour.js b/src/js/controllers/onboarding/tour.js index f6cf0afe2..47261006b 100644 --- a/src/js/controllers/onboarding/tour.js +++ b/src/js/controllers/onboarding/tour.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.controllers').controller('tourController', - function ($scope, $state, $log, $timeout, $filter, ongoingProcess, configService, profileService, rateService, popupService, gettextCatalog, lodash, startupService, storageService, uxLanguage, walletService, $q) { + function($scope, $state, $log, $timeout, $filter, ongoingProcess, profileService, rateService, popupService, gettextCatalog, startupService, storageService, walletService, $q) { $scope.data = { index: 0 @@ -46,90 +46,62 @@ angular.module('copayApp.controllers').controller('tourController', creatingWallet = true; ongoingProcess.set('creatingWallet', true); $timeout(function() { - uxLanguage.init(function(lang) { - var rateCode = uxLanguage.getRateCode(lang); - console.log("When Available: rateService"); - rateService.whenAvailable(function() { - var alternatives = rateService.listAlternatives(true); + profileService.createDefaultWallet(function(err, walletClients) { + if (err) { + $log.warn(err); - var newAltCurrency = lodash.find(alternatives, { - 'isoCode': rateCode + return $timeout(function() { + $log.warn('Retrying to create default wallet.....:' + ++retryCount); + if (retryCount > 3) { + ongoingProcess.set('creatingWallet', false); + popupService.showAlert( + gettextCatalog.getString('Cannot Create Wallet'), err, + function() { + retryCount = 0; + return $scope.createDefaultWallet(); + }, gettextCatalog.getString('Retry')); + } else { + return $scope.createDefaultWallet(); + } + }, 2000); + }; + + ongoingProcess.set('creatingWallet', false); + var bchWallet = walletClients[0]; + var btcWallet = walletClients[1]; + var bchWalletId = bchWallet.credentials.walletId; + var btcWalletId = btcWallet.credentials.walletId; + + function createAddressPromise(wallet) { + return $q(function(resolve, reject) { + walletService.getAddress(wallet, true, function(e, addr) { + if (e) reject(e); + resolve(addr); }); - - configService.whenAvailable(function(config) { - var opts = { - wallet: { - settings: { - alternativeName: newAltCurrency.name, - alternativeIsoCode: newAltCurrency.isoCode, - } - } - }; - configService.set(opts, function(err) { - if (err) $log.warn(err); - - profileService.createDefaultWallet(function(err, walletClients) { - if (err) { - $log.warn(err); - - return $timeout(function() { - $log.warn('Retrying to create default wallet.....:' + ++retryCount); - if (retryCount > 3) { - ongoingProcess.set('creatingWallet', false); - popupService.showAlert( - gettextCatalog.getString('Cannot Create Wallet'), err, - function() { - retryCount = 0; - return $scope.createDefaultWallet(); - }, gettextCatalog.getString('Retry')); - } else { - return $scope.createDefaultWallet(); - } - }, 2000); - } - ; - - ongoingProcess.set('creatingWallet', false); - var bchWallet = walletClients[0]; - var btcWallet = walletClients[1]; - var bchWalletId = bchWallet.credentials.walletId; - var btcWalletId = btcWallet.credentials.walletId; - - function createAddressPromise(wallet) { - return $q(function (resolve, reject) { - walletService.getAddress(wallet, true, function (e, addr) { - if (e) reject(e); - resolve(addr); - }); - }); - } - - function goToCollectEmail() { - $state.go('onboarding.collectEmail', { - bchWalletId: bchWalletId, - btcWalletId: btcWalletId - }); - } - - var bchAddressPromise = createAddressPromise(bchWallet); - var btcAddressPromise = createAddressPromise(btcWallet); - ongoingProcess.set('generatingNewAddress', true); - - $q.all([bchAddressPromise, btcAddressPromise]).then(function (addresses) { - ongoingProcess.set('generatingNewAddress', false); - $state.go('tabs.home'); - }, function (e) { - ongoingProcess.set('generatingNewAddress', false); - $log.warn(e); - popupService.showAlert(gettextCatalog.getString('Error'), e); - $state.go('tabs.home'); - }); - }); - }); - }); - $log.debug('Setting default currency : ' + newAltCurrency); }); - }) - }, 300); - }; - }); + } + + function goToCollectEmail() { + $state.go('onboarding.collectEmail', { + bchWalletId: bchWalletId, + btcWalletId: btcWalletId + }); + } + + var bchAddressPromise = createAddressPromise(bchWallet); + var btcAddressPromise = createAddressPromise(btcWallet); + ongoingProcess.set('generatingNewAddress', true); + + $q.all([bchAddressPromise, btcAddressPromise]).then(function(addresses) { + ongoingProcess.set('generatingNewAddress', false); + $state.go('tabs.home'); + }, function(e) { + ongoingProcess.set('generatingNewAddress', false); + $log.warn(e); + popupService.showAlert(gettextCatalog.getString('Error'), e); + $state.go('tabs.home'); + }); + }); + }, 300); + }; + }); diff --git a/src/js/controllers/review.controller.js b/src/js/controllers/review.controller.js index ae30382fb..b377bef58 100644 --- a/src/js/controllers/review.controller.js +++ b/src/js/controllers/review.controller.js @@ -1,496 +1,465 @@ 'use strict'; -(function () { - angular .module('copayApp.controllers') .controller('reviewController', reviewController); - function reviewController(addressbookService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, clipboardService, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, ionicToast, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, sendFlowService, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) { - var vm = this; +function reviewController(addressbookService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, clipboardService, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, ionicToast, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, sendFlowService, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) { + var vm = this; - vm.buttonText = ''; - vm.destination = { - address: '', - balanceAmount: '', - balanceCurrency: '', - coin: '', - color: '', - currency: '', - currencyColor: '', - kind: '', // 'address', 'contact', 'wallet' - name: '' - }; - vm.displayAddress = ''; - vm.feeCrypto = ''; - vm.feeFiat = ''; - vm.fiatCurrency = ''; - vm.feeIsHigh = false; - vm.feeLessThanACent = false; - vm.isCordova = platformInfo.isCordova; - vm.memo = ''; - vm.notReadyMessage = ''; - vm.origin = { - balanceAmount: '', - balanceCurrency: '', - currency: '', - currencyColor: '', - }; - vm.originWallet = null; - vm.paymentExpired = false; - vm.personalNotePlaceholder = gettextCatalog.getString('Enter text here'); - vm.primaryAmount = ''; - vm.primaryCurrency = ''; - vm.usingMerchantFee = false; - vm.readyToSend = false; - vm.remainingTimeStr = ''; - vm.secondaryAmount = ''; - vm.secondaryCurrency = ''; - vm.sendingTitle = gettextCatalog.getString('You are sending'); - vm.sendStatus = ''; - vm.showAddress = true; - vm.thirdParty = false; - vm.wallet = null; - vm.memoExpanded = false; + vm.buttonText = ''; + vm.destination = { + address: '', + balanceAmount: '', + balanceCurrency: '', + coin: '', + color: '', + currency: '', + currencyColor: '', + kind: '', // 'address', 'contact', 'wallet' + name: '' + }; + vm.displayAddress = ''; + vm.feeCrypto = ''; + vm.feeFiat = ''; + vm.fiatCurrency = ''; + vm.feeIsHigh = false; + vm.feeLessThanACent = false; + vm.isCordova = platformInfo.isCordova; + vm.notReadyMessage = ''; + vm.origin = { + balanceAmount: '', + balanceCurrency: '', + currency: '', + currencyColor: '', + }; + vm.originWallet = null; + vm.paymentExpired = false; + vm.personalNotePlaceholder = gettextCatalog.getString('Enter text here'); + vm.primaryAmount = ''; + vm.primaryCurrency = ''; + vm.usingMerchantFee = false; + vm.readyToSend = false; + vm.remainingTimeStr = ''; + vm.secondaryAmount = ''; + vm.secondaryCurrency = ''; + vm.sendingTitle = gettextCatalog.getString('You are sending'); + vm.sendStatus = ''; + vm.showAddress = true; + vm.thirdParty = false; + vm.wallet = null; + vm.memoExpanded = false; - // Functions - vm.goBack = goBack; - vm.onSuccessConfirm = onSuccessConfirm; - vm.onShareTransaction = onShareTransaction; + // Functions + vm.goBack = goBack; + vm.onSuccessConfirm = onSuccessConfirm; + vm.onShareTransaction = onShareTransaction; - var sendFlowData; - var config = null; - var coin = ''; - var countDown = null; - var defaults = {}; - var usingCustomFee = false; - var usingMerchantFee = false; - var destinationWalletId = ''; - var lastTxId = ''; - var originWalletId = ''; - var priceDisplayIsFiat = true; - var satoshis = null; - var toAddress = ''; - var tx = {}; - var txPayproData = null; - var unitFromSat = 0; + var sendFlowData; + var config = null; + var coin = ''; + var countDown = null; + var defaults = {}; + var usingCustomFee = false; + var usingMerchantFee = false; + var destinationWalletId = ''; + var lastTxId = ''; + var originWalletId = ''; + var priceDisplayIsFiat = true; + var satoshis = null; + var toAddress = ''; + var tx = {}; + var txPayproData = null; + var unitFromSat = 0; - var FEE_TOO_HIGH_LIMIT_PERCENTAGE = 15; + var FEE_TOO_HIGH_LIMIT_PERCENTAGE = 15; - $scope.$on("$ionicView.beforeEnter", onBeforeEnter); + $scope.$on("$ionicView.beforeEnter", onBeforeEnter); - function onBeforeEnter(event, data) { - console.log('review onBeforeEnter sendflow ', sendFlowService.state); - // Reset from last time - vm.memo = ''; + function onBeforeEnter(event, data) { + console.log('walletSelector onBeforeEnter sendflow ', sendFlowService.state); + defaults = configService.getDefaults(); + sendFlowData = sendFlowService.getStateClone(); + originWalletId = sendFlowData.fromWalletId; + satoshis = parseInt(sendFlowData.amount, 10); + toAddress = sendFlowData.toAddress; + destinationWalletId = sendFlowData.toWalletId; - defaults = configService.getDefaults(); - sendFlowData = sendFlowService.state.getClone(); - originWalletId = sendFlowData.fromWalletId; - if (typeof sendFlowData.amount === 'string') { - satoshis = parseInt(sendFlowData.amount, 10); - } else { - satoshis = sendFlowData.amount; - } - toAddress = sendFlowData.toAddress; - destinationWalletId = sendFlowData.toWalletId; + vm.displayAddress = sendFlowData.displayAddress; + vm.originWallet = profileService.getWallet(originWalletId); + vm.origin.currency = vm.originWallet.coin.toUpperCase(); + coin = vm.originWallet.coin; - vm.displayAddress = sendFlowData.displayAddress; - vm.originWallet = profileService.getWallet(originWalletId); - vm.origin.currency = vm.originWallet.coin.toUpperCase(); - coin = vm.originWallet.coin; - - if (sendFlowData.thirdParty) { - vm.thirdParty = sendFlowData.thirdParty; - switch (vm.thirdParty.id) { - case 'shapeshift': - initShapeshift(function (err) { - if (err) { - // Error stop here - ongoingProcess.set('connectingShapeshift', false); - popupService.showAlert(gettextCatalog.getString('Shapeshift Error'), err.toString(), function () { - $ionicHistory.goBack(); - }); - } else { - _next(data); - } - }); - break; - case 'bip70': - initBip70(); - default: - _next(data); - break; - } - } else { - _next(data); - } - - function _next() { - configService.get(function onConfig(err, configCache) { - if (err) { - $log.err('Error getting config.', err); - } else { - config = configCache; - priceDisplayIsFiat = config.wallet.settings.priceDisplay === 'fiat'; - vm.origin.currencyColor = (vm.originWallet.coin === 'btc' ? defaults.bitcoinWalletColor : defaults.bitcoinCashWalletColor); - console.log("coin", vm.originWallet.coin, vm.origin.currencyColor, config.bitcoinWalletColor, vm.originWallet.coin === 'btc'); - unitFromSat = 1 / config.wallet.settings.unitToSatoshi; - } - updateSendAmounts(); - getOriginWalletBalance(vm.originWallet); - handleDestinationAsAddress(toAddress, coin); - handleDestinationAsWallet(sendFlowData.toWalletId); - createVanityTransaction(data); - }); - } + if (sendFlowData.thirdParty) { + vm.thirdParty = sendFlowData.thirdParty; + handleThirdPartyInitIfBip70(); + handleThirdPartyInitIfShapeshift(); } - vm.approve = function() { - - if (!tx || !vm.originWallet) return; - - if (vm.paymentExpired) { - popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.', function () { - $ionicHistory.goBack(); - })); - vm.sendStatus = ''; - $timeout(function() { - $scope.$apply(); - }); - return; + configService.get(function onConfig(err, configCache) { + if (err) { + $log.err('Error getting config.', err); + } else { + config = configCache; + priceDisplayIsFiat = config.wallet.settings.priceDisplay === 'fiat'; + vm.origin.currencyColor = (vm.originWallet.coin === 'btc' ? defaults.bitcoinWalletColor : defaults.bitcoinCashWalletColor); + console.log("coin", vm.originWallet.coin, vm.origin.currencyColor, config.bitcoinWalletColor, vm.originWallet.coin === 'btc'); + unitFromSat = 1 / config.wallet.settings.unitToSatoshi; } + updateSendAmounts(); + getOriginWalletBalance(vm.originWallet); + handleDestinationAsAddress(toAddress, coin); + handleDestinationAsWallet(sendFlowData.toWalletId); + createVanityTransaction(data); + }); + } - ongoingProcess.set('creatingTx', true, statusChangeHandler); - getTxp(lodash.clone(tx), vm.originWallet, false, function(err, txp) { - ongoingProcess.set('creatingTx', false, statusChangeHandler); - if (err) return; + vm.approve = function() { + + if (!tx || !vm.originWallet) return; - // confirm txs for more that 20usd, if not spending/touchid is enabled - function confirmTx(cb) { - if (walletService.isEncrypted(vm.originWallet)) - return cb(); + if (vm.paymentExpired) { + popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.', function () { + $ionicHistory.goBack(); + })); + vm.sendStatus = ''; + $timeout(function() { + $scope.$apply(); + }); + return; + } - var amountUsd = parseFloat(txFormatService.formatToUSD(vm.originWallet.coin, txp.amount)); + ongoingProcess.set('creatingTx', true, statusChangeHandler); + getTxp(lodash.clone(tx), vm.originWallet, false, function(err, txp) { + ongoingProcess.set('creatingTx', false, statusChangeHandler); + if (err) return; + + // confirm txs for more that 20usd, if not spending/touchid is enabled + function confirmTx(cb) { + if (walletService.isEncrypted(vm.originWallet)) return cb(); - }; - function publishAndSign() { - if (!vm.originWallet.canSign() && !vm.originWallet.isPrivKeyExternal()) { - $log.info('No signing proposal: No private key'); + var amountUsd = parseFloat(txFormatService.formatToUSD(vm.originWallet.coin, txp.amount)); + return cb(); + }; - return walletService.onlyPublish(vm.originWallet, txp, function(err) { - if (err) setSendError(err); - }, statusChangeHandler); - } + function publishAndSign() { + if (!vm.originWallet.canSign() && !vm.originWallet.isPrivKeyExternal()) { + $log.info('No signing proposal: No private key'); - walletService.publishAndSign(vm.originWallet, txp, function(err, txp) { - if (err) return setSendError(err); - if (config.confirmedTxsNotifications && config.confirmedTxsNotifications.enabled) { - txConfirmNotification.subscribe(vm.originWallet, { - txid: txp.txid - }); - lastTxId = txp.txid; - } + return walletService.onlyPublish(vm.originWallet, txp, function(err) { + if (err) setSendError(err); }, statusChangeHandler); - }; + } - confirmTx(function(nok) { - if (nok) { - vm.sendStatus = ''; - $timeout(function() { - $scope.$apply(); + walletService.publishAndSign(vm.originWallet, txp, function(err, txp) { + if (err) return setSendError(err); + if (config.confirmedTxsNotifications && config.confirmedTxsNotifications.enabled) { + txConfirmNotification.subscribe(vm.originWallet, { + txid: txp.txid }); - return; + lastTxId = txp.txid; } - publishAndSign(); - }); - }); - }; - - vm.chooseFeeLevel = function(tx, wallet) { - - if (wallet.coin == 'bch') return; - if (usingMerchantFee) return; - - var scope = $rootScope.$new(true); - scope.network = tx.network; - scope.feeLevel = tx.feeLevel; - scope.noSave = true; - scope.coin = vm.originWallet.coin; - - if (usingCustomFee) { - scope.customFeePerKB = tx.feeRate; - scope.feePerSatByte = tx.feeRate / 1000; - } - - $ionicModal.fromTemplateUrl('views/modals/chooseFeeLevel.html', { - scope: scope, - backdropClickToClose: false, - hardwareBackButtonClose: false - }).then(function(modal) { - scope.chooseFeeLevelModal = modal; - scope.openModal(); - }); - scope.openModal = function() { - scope.chooseFeeLevelModal.show(); + }, statusChangeHandler); }; - scope.hideModal = function(newFeeLevel, customFeePerKB) { - scope.chooseFeeLevelModal.hide(); - $log.debug('New fee level choosen:' + newFeeLevel + ' was:' + tx.feeLevel); - - usingCustomFee = newFeeLevel == 'custom' ? true : false; - - if (tx.feeLevel == newFeeLevel && !usingCustomFee) return; - - tx.feeLevel = newFeeLevel; - if (usingCustomFee) tx.feeRate = parseInt(customFeePerKB); - - updateTx(tx, vm.originWallet, { - clearCache: true, - dryRun: true - }, function() {}); - }; - }; - - function createVanityTransaction(data) { - console.log('createVanityTransaction()'); - var configFeeLevel = config.wallet.settings.feeLevel ? config.wallet.settings.feeLevel : 'normal'; - - // Grab stateParams - tx = { - amount: parseInt(sendFlowData.amount), - sendMax: sendFlowData.sendMax, - fromWalletId: sendFlowData.fromWalletId, - toAddress: sendFlowData.toAddress, - paypro: txPayproData, - - feeLevel: configFeeLevel, - spendUnconfirmed: config.wallet.spendUnconfirmed, - - // Vanity tx info (not in the real tx) - recipientType: vm.destination.kind || null, - toName: vm.destination.name || null, - toEmail: vm.destination.email || null, - toColor: vm.destination.color || null, - network: false, - coin: vm.originWallet.coin, - txp: {}, - }; - - - if (data.stateParams.requiredFeeRate) { - vm.usingMerchantFee = true; - tx.feeRate = parseInt(data.stateParams.requiredFeeRate); - } - - if (tx.coin && tx.coin === 'bch') { - tx.feeLevel = 'normal'; - } - - var B = tx.coin === 'bch' ? bitcoreCash : bitcore; - var networkName; - try { - if (vm.destination.kind === 'wallet') { // This is a wallet-to-wallet transfer - ongoingProcess.set('generatingNewAddress', true); - var toWallet = profileService.getWallet(destinationWalletId); - - // We need an address to send to, so we ask the walletService to create a new address for the toWallet. - console.log('Getting address for wallet...'); - walletService.getAddress(toWallet, true, function onWalletAddress(err, addr) { - console.log('getAddress cb called', err); - ongoingProcess.set('generatingNewAddress', false); - tx.toAddress = addr; - networkName = (new B.Address(tx.toAddress)).network.name; - tx.network = networkName; - console.log('calling setupTx() for wallet.'); - setupTx(tx); + confirmTx(function(nok) { + if (nok) { + vm.sendStatus = ''; + $timeout(function() { + $scope.$apply(); }); - } else { // This is a Wallet-to-address transfer + return; + } + publishAndSign(); + }); + }); + }; + + vm.chooseFeeLevel = function(tx, wallet) { + + if (wallet.coin == 'bch') return; + if (usingMerchantFee) return; + + var scope = $rootScope.$new(true); + scope.network = tx.network; + scope.feeLevel = tx.feeLevel; + scope.noSave = true; + scope.coin = vm.originWallet.coin; + + if (usingCustomFee) { + scope.customFeePerKB = tx.feeRate; + scope.feePerSatByte = tx.feeRate / 1000; + } + + $ionicModal.fromTemplateUrl('views/modals/chooseFeeLevel.html', { + scope: scope, + backdropClickToClose: false, + hardwareBackButtonClose: false + }).then(function(modal) { + scope.chooseFeeLevelModal = modal; + scope.openModal(); + }); + scope.openModal = function() { + scope.chooseFeeLevelModal.show(); + }; + + scope.hideModal = function(newFeeLevel, customFeePerKB) { + scope.chooseFeeLevelModal.hide(); + $log.debug('New fee level choosen:' + newFeeLevel + ' was:' + tx.feeLevel); + + usingCustomFee = newFeeLevel == 'custom' ? true : false; + + if (tx.feeLevel == newFeeLevel && !usingCustomFee) return; + + tx.feeLevel = newFeeLevel; + if (usingCustomFee) tx.feeRate = parseInt(customFeePerKB); + + updateTx(tx, vm.originWallet, { + clearCache: true, + dryRun: true + }, function() {}); + }; + }; + + function createVanityTransaction(data) { + console.log('createVanityTransaction()'); + var configFeeLevel = config.wallet.settings.feeLevel ? config.wallet.settings.feeLevel : 'normal'; + + // Grab stateParams + tx = { + amount: parseInt(sendFlowData.amount), + sendMax: sendFlowData.sendMax, + fromWalletId: sendFlowData.fromWalletId, + toAddress: sendFlowData.toAddress, + paypro: txPayproData, + + feeLevel: configFeeLevel, + spendUnconfirmed: config.wallet.spendUnconfirmed, + + // Vanity tx info (not in the real tx) + recipientType: vm.destination.kind || null, + toName: vm.destination.name || null, + toEmail: vm.destination.email || null, + toColor: vm.destination.color || null, + network: false, + coin: vm.originWallet.coin, + txp: {}, + }; + + + if (data.stateParams.requiredFeeRate) { + vm.usingMerchantFee = true; + tx.feeRate = parseInt(data.stateParams.requiredFeeRate); + } + + if (tx.coin && tx.coin === 'bch') { + tx.feeLevel = 'normal'; + } + + var B = tx.coin === 'bch' ? bitcoreCash : bitcore; + var networkName; + try { + if (vm.destination.kind === 'wallet') { // This is a wallet-to-wallet transfer + ongoingProcess.set('generatingNewAddress', true); + var toWallet = profileService.getWallet(destinationWalletId); + + // We need an address to send to, so we ask the walletService to create a new address for the toWallet. + console.log('Getting address for wallet...'); + walletService.getAddress(toWallet, true, function onWalletAddress(err, addr) { + console.log('getAddress cb called', err); + ongoingProcess.set('generatingNewAddress', false); + tx.toAddress = addr; networkName = (new B.Address(tx.toAddress)).network.name; tx.network = networkName; - console.log('calling setupTx() for address.'); + console.log('calling setupTx() for wallet.'); setupTx(tx); - } - } catch (e) { - console.error('Error setting up tx', e); - var message = gettextCatalog.getString('Invalid address'); - popupService.showAlert(null, message, function () { - $ionicHistory.nextViewOptions({ - disableAnimate: true, - historyRoot: true - }); - $state.go('tabs.send').then(function () { - $ionicHistory.clearHistory(); - }); }); - return; + } else { // This is a Wallet-to-address transfer + networkName = (new B.Address(tx.toAddress)).network.name; + tx.network = networkName; + console.log('calling setupTx() for address.'); + setupTx(tx); } - } - function getOriginWalletBalance(originWallet) { - var balanceText = getWalletBalanceDisplayText(vm.originWallet); - vm.origin.balanceAmount = balanceText.amount; - vm.origin.balanceCurrency = balanceText.currency; - } - - function getSendMaxInfo(tx, wallet, cb) { - if (!tx.sendMax) return cb(); - - //ongoingProcess.set('retrievingInputs', true); - walletService.getSendMaxInfo(wallet, { - feePerKb: tx.feeRate, - excludeUnconfirmedUtxos: !tx.spendUnconfirmed, - returnInputs: true, - }, cb); - }; - - function getTxp(tx, wallet, dryRun, cb) { - - // ToDo: use a credential's (or fc's) function for this - if (tx.description && !wallet.credentials.sharedEncryptingKey) { - var msg = gettextCatalog.getString('Could not add message to imported wallet without shared encrypting key'); - $log.warn(msg); - return setSendError(msg); - } - - if (tx.amount > Number.MAX_SAFE_INTEGER) { - var msg = gettextCatalog.getString('Amount too big'); - $log.warn(msg); - return setSendError(msg); - } - - var txp = {}; - - txp.outputs = [{ - 'toAddress': tx.toAddress, - 'amount': tx.amount, - 'message': vm.memo - }]; - - if (tx.sendMaxInfo) { - txp.inputs = tx.sendMaxInfo.inputs; - txp.fee = tx.sendMaxInfo.fee; - } else { - if (usingCustomFee || usingMerchantFee) { - txp.feePerKb = tx.feeRate; - } else txp.feeLevel = tx.feeLevel; - } - - txp.message = vm.memo; - - if (tx.paypro) { - txp.payProUrl = tx.paypro.url; - } - txp.excludeUnconfirmedUtxos = !tx.spendUnconfirmed; - txp.dryRun = dryRun; - walletService.createTx(wallet, txp, function(err, ctxp) { - if (err) { - setSendError(err); - return cb(err); - } - return cb(null, ctxp); + } catch (e) { + console.error('Error setting up tx', e); + var message = gettextCatalog.getString('Invalid address'); + popupService.showAlert(null, message, function () { + $ionicHistory.nextViewOptions({ + disableAnimate: true, + historyRoot: true + }); + $state.go('tabs.send').then(function () { + $ionicHistory.clearHistory(); + }); }); + return; + } + } + function getOriginWalletBalance(originWallet) { + var balanceText = getWalletBalanceDisplayText(vm.originWallet); + vm.origin.balanceAmount = balanceText.amount; + vm.origin.balanceCurrency = balanceText.currency; + } + + function getSendMaxInfo(tx, wallet, cb) { + if (!tx.sendMax) return cb(); + + //ongoingProcess.set('retrievingInputs', true); + walletService.getSendMaxInfo(wallet, { + feePerKb: tx.feeRate, + excludeUnconfirmedUtxos: !tx.spendUnconfirmed, + returnInputs: true, + }, cb); + }; + + function getTxp(tx, wallet, dryRun, cb) { + + // ToDo: use a credential's (or fc's) function for this + if (tx.description && !wallet.credentials.sharedEncryptingKey) { + var msg = gettextCatalog.getString('Could not add message to imported wallet without shared encrypting key'); + $log.warn(msg); + return setSendError(msg); + } + + if (tx.amount > Number.MAX_SAFE_INTEGER) { + var msg = gettextCatalog.getString('Amount too big'); + $log.warn(msg); + return setSendError(msg); + } + + var txp = {}; + + txp.outputs = [{ + 'toAddress': tx.toAddress, + 'amount': tx.amount, + 'message': vm.memo + }]; + + if (tx.sendMaxInfo) { + txp.inputs = tx.sendMaxInfo.inputs; + txp.fee = tx.sendMaxInfo.fee; + } else { + if (usingCustomFee || usingMerchantFee) { + txp.feePerKb = tx.feeRate; + } else txp.feeLevel = tx.feeLevel; + } + + txp.message = vm.memo; + + if (tx.paypro) { + txp.payProUrl = tx.paypro.url; + } + txp.excludeUnconfirmedUtxos = !tx.spendUnconfirmed; + txp.dryRun = dryRun; + walletService.createTx(wallet, txp, function(err, ctxp) { + if (err) { + setSendError(err); + return cb(err); + } + return cb(null, ctxp); + }); + }; + + function getWalletBalanceDisplayText(wallet) { + var balanceCryptoAmount = ''; + var balanceCryptoCurrencyCode = ''; + var balanceFiatAmount = ''; + var balanceFiatCurrency = '' + var displayAmount = ''; + var displayCurrency = ''; + + var walletStatus = null; + if (wallet.status.isValid) { + walletStatus = wallet.status; + } else if (wallet.cachedStatus.isValid) { + walletStatus = wallet.cachedStatus; + } + + if (walletStatus) { + var cryptoBalanceParts = walletStatus.spendableBalanceStr.split(' '); + balanceCryptoAmount = cryptoBalanceParts[0]; + balanceCryptoCurrencyCode = cryptoBalanceParts.length > 1 ? cryptoBalanceParts[1] : ''; + + if (walletStatus.alternativeBalanceAvailable) { + balanceFiatAmount = walletStatus.spendableBalanceAlternative; + balanceFiatCurrency = walletStatus.alternativeIsoCode; + } + } + + if (priceDisplayIsFiat) { + displayAmount = balanceFiatAmount ? balanceFiatAmount : balanceCryptoAmount; + displayCurrency = balanceFiatAmount ? balanceFiatCurrency : balanceCryptoCurrencyCode; + } else { + displayAmount = balanceCryptoAmount; + displayCurrency = balanceCryptoCurrencyCode; + } + + return { + amount: displayAmount, + currency: displayCurrency }; + } - function getWalletBalanceDisplayText(wallet) { - var balanceCryptoAmount = ''; - var balanceCryptoCurrencyCode = ''; - var balanceFiatAmount = ''; - var balanceFiatCurrency = ''; - var displayAmount = ''; - var displayCurrency = ''; + function goBack() { + $ionicHistory.goBack(); + } - var walletStatus = null; - if (wallet.status && wallet.status.isValid) { - walletStatus = wallet.status; - } else if (wallet.cachedStatus.isValid) { - walletStatus = wallet.cachedStatus; - } + function handleDestinationAsAddress(address, originCoin) { + if (!address) { + return; + } - if (walletStatus) { - var cryptoBalanceParts = walletStatus.spendableBalanceStr.split(' '); - balanceCryptoAmount = cryptoBalanceParts[0]; - balanceCryptoCurrencyCode = cryptoBalanceParts.length > 1 ? cryptoBalanceParts[1] : ''; - - if (walletStatus.alternativeBalanceAvailable) { - balanceFiatAmount = walletStatus.spendableBalanceAlternative; - balanceFiatCurrency = walletStatus.alternativeIsoCode; - } - } - - if (priceDisplayIsFiat) { - displayAmount = balanceFiatAmount ? balanceFiatAmount : balanceCryptoAmount; - displayCurrency = balanceFiatAmount ? balanceFiatCurrency : balanceCryptoCurrencyCode; + // Check if the recipient is a contact + addressbookService.get(originCoin + address, function(err, contact) { + if (!err && contact) { + handleDestinationAsAddressOfContact(contact); } else { - displayAmount = balanceCryptoAmount; - displayCurrency = balanceCryptoCurrencyCode; - } - - return { - amount: displayAmount, - currency: displayCurrency - }; - } - - function goBack() { - sendFlowService.router.goBack(); - } - - function handleDestinationAsAddress(address, originCoin) { - if (!address) { - return; - } - - // Check if the recipient is a contact - addressbookService.get(originCoin + address, function(err, contact) { - if (!err && contact) { - handleDestinationAsAddressOfContact(contact); + if (originCoin === 'bch') { + vm.destination.address = bitcoinCashJsService.readAddress(address).cashaddr; } else { - if (originCoin === 'bch') { - vm.destination.address = bitcoinCashJsService.readAddress(address).cashaddr; - } else { - vm.destination.address = address; - } - vm.destination.kind = 'address'; + vm.destination.address = address; } - }); - - } - - function handleDestinationAsAddressOfContact(contact) { - vm.destination.kind = 'contact'; - vm.destination.name = contact.name; - vm.destination.email = contact.email; - vm.destination.color = contact.coin === 'btc' ? defaults.bitcoinWalletColor : defaults.bitcoinCashWalletColor; - vm.destination.currency = contact.coin.toUpperCase(); - vm.destination.currencyColor = vm.destination.color; - } - - function handleDestinationAsWallet(walletId) { - destinationWalletId = walletId; - if (!destinationWalletId) { - return; + vm.destination.kind = 'address'; } + }); - var destinationWallet = profileService.getWallet(destinationWalletId); - vm.destination.coin = destinationWallet.coin; - vm.destination.color = destinationWallet.color; - vm.destination.currency = destinationWallet.coin.toUpperCase(); - vm.destination.kind = 'wallet'; - vm.destination.name = destinationWallet.name; + } - if (defaults) { - vm.destination.currencyColor = vm.destination.coin === 'btc' ? defaults.bitcoinWalletColor : defaults.bitcoinCashWalletColor; - } + function handleDestinationAsAddressOfContact(contact) { + vm.destination.kind = 'contact'; + vm.destination.name = contact.name; + vm.destination.email = contact.email; + vm.destination.color = contact.coin === 'btc' ? defaults.bitcoinWalletColor : defaults.bitcoinCashWalletColor; + vm.destination.currency = contact.coin.toUpperCase(); + vm.destination.currencyColor = vm.destination.color; + } - var balanceText = getWalletBalanceDisplayText(destinationWallet); - vm.destination.balanceAmount = balanceText.amount; - vm.destination.balanceCurrency = balanceText.currency; + function handleDestinationAsWallet(walletId) { + destinationWalletId = walletId; + if (!destinationWalletId) { + return; } - function initBip70() { + var destinationWallet = profileService.getWallet(destinationWalletId); + vm.destination.coin = destinationWallet.coin; + vm.destination.color = destinationWallet.color; + vm.destination.currency = destinationWallet.coin.toUpperCase(); + vm.destination.kind = 'wallet'; + vm.destination.name = destinationWallet.name; + + if (defaults) { + vm.destination.currencyColor = vm.destination.coin === 'btc' ? defaults.bitcoinWalletColor : defaults.bitcoinCashWalletColor; + } + + var balanceText = getWalletBalanceDisplayText(destinationWallet); + vm.destination.balanceAmount = balanceText.amount; + vm.destination.balanceCurrency = balanceText.currency; + } + + function handleThirdPartyInitIfBip70() { + if (vm.thirdParty.id === 'bip70') { vm.sendingTitle = gettextCatalog.getString('You are paying'); vm.memo = vm.thirdParty.memo; vm.memoExpanded = !!vm.memo; @@ -505,8 +474,10 @@ angular verified: vm.thirdParty.verified, }; } + } - function initShapeshift(cb) { + function handleThirdPartyInitIfShapeshift() { + if (vm.thirdParty.id === 'shapeshift') { vm.sendingTitle = gettextCatalog.getString('You are shifting'); if (!vm.thirdParty.data) { vm.thirdParty.data = {}; @@ -521,454 +492,441 @@ angular ongoingProcess.set('connectingShapeshift', true); walletService.getAddress(vm.originWallet, false, function onReturnWalletAddress(err, returnAddr) { if (err) { - return cb(err); + ongoingProcess.set('connectingShapeshift', false); + popupService.showAlert(gettextCatalog.getString('Shapeshift Error'), err.toString(), function () { + $ionicHistory.goBack(); + }); + return; } walletService.getAddress(toWallet, false, function onWithdrawalWalletAddress(err, withdrawalAddr) { if (err) { - return cb(err); + ongoingProcess.set('connectingShapeshift', false); + popupService.showAlert(gettextCatalog.getString('Shapeshift Error'), err.toString(), function () { + $ionicHistory.goBack(); + }); + return; } - // Need to use the correct service to do it. - var amount = parseFloat(satoshis / 100000000); - - shapeshiftService.shiftIt(vm.originWallet.coin, toWallet.coin, withdrawalAddr, returnAddr, amount, function onShiftIt(err, shapeshiftData) { - if (err) { - return cb(err); - } else { - vm.destination.kind = 'shapeshift'; - vm.destination.address = toAddress; - tx.toAddress = shapeshiftData.toAddress; - vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId; - vm.memoExpanded = !!vm.memo; + shapeshiftService.shiftIt(vm.originWallet.coin, toWallet.coin, withdrawalAddr, returnAddr, function onShiftIt(err, shapeshiftData) { + if (err && err != null) { ongoingProcess.set('connectingShapeshift', false); - cb(); - } - }); - }); - }); - } - - function onShareTransaction() { - var explorerTxUrl = 'https://explorer.bitcoin.com/' + tx.coin + '/tx/' + lastTxId; - if (platformInfo.isCordova) { - var text = gettextCatalog.getString('Take a look at this Bitcoin Cash transaction here: ') + explorerTxUrl; - if (coin === 'btc') { - text = gettextCatalog.getString('Take a look at this Bitcoin transaction here: ') + explorerTxUrl; - } - window.plugins.socialsharing.share(text, null, null, null); - } else { - ionicToast.show(gettextCatalog.getString('Copied to clipboard'), 'bottom', false, 3000); - clipboardService.copyToClipboard(explorerTxUrl); - } - - } - - function startExpirationTimer(expirationTime) { - vm.paymentExpired = false; - setExpirationTime(); - - countDown = $interval(function() { - setExpirationTime(); - }, 1000); - - function setExpirationTime() { - console.log('setExpirationTime()'); - var now = Math.floor(Date.now() / 1000); - - if (now > expirationTime) { - setExpiredValues(); - return; - } - - var totalSecs = expirationTime - now; - var m = Math.floor(totalSecs / 60); - var s = totalSecs % 60; - vm.remainingTimeStr = m + ":" + ('0' + s).slice(-2); - }; - - function setExpiredValues() { - vm.paymentExpired = true; - vm.remainingTimeStr = gettextCatalog.getString('Expired'); - vm.readyToSend = false; - if (countDown) $interval.cancel(countDown); - $timeout(function() { - $scope.$apply(); - }); - }; - }; - - function updateSendAmounts() { - if (typeof satoshis !== 'number') { - return; - } - - var cryptoAmount = ''; - var cryptoCurrencyCode = ''; - var amountStr = txFormatService.formatAmountStr(coin, satoshis); - if (amountStr) { - var amountParts = amountStr.split(' '); - cryptoAmount = amountParts[0]; - cryptoCurrencyCode = amountParts.length > 1 ? amountParts[1] : ''; - } - // Want to avoid flashing of amount strings so do all formatting after this has returned. - txFormatService.formatAlternativeStr(coin, satoshis, function(v) { - if (!v) { - vm.primaryAmount = cryptoAmount; - vm.primaryCurrency = cryptoCurrencyCode; - vm.secondaryAmount = ''; - vm.secondaryCurrency = ''; - return; - } - vm.secondaryAmount = vm.primaryAmount; - vm.secondaryCurrency = vm.primaryCurrency; - - var fiatParts = v.split(' '); - var fiatAmount = fiatParts[0]; - var fiatCurrency = fiatParts.length > 1 ? fiatParts[1] : ''; - - if (priceDisplayIsFiat) { - vm.primaryAmount = fiatAmount; - vm.primaryCurrency = fiatCurrency; - vm.secondaryAmount = cryptoAmount; - vm.secondaryCurrency = cryptoCurrencyCode; - } else { - vm.primaryAmount = cryptoAmount; - vm.primaryCurrency = cryptoCurrencyCode; - vm.secondaryAmount = fiatAmount; - vm.secondaryCurrency = fiatCurrency; - } - }); - } - - function onSuccessConfirm() { - vm.sendStatus = ''; - $ionicHistory.nextViewOptions({ - disableAnimate: true, - historyRoot: true - }); - $state.go('tabs.send').then(function() { - $ionicHistory.clearHistory(); - $state.transitionTo('tabs.home'); - }); - }; - - function setButtonText(isMultisig, isPayPro) { - if (isPayPro) { - if (vm.isCordova) { - vm.buttonText = gettextCatalog.getString('Slide to pay'); - } else { - vm.buttonText = gettextCatalog.getString('Click to pay'); - } - } else if (isMultisig) { - if (vm.isCordova) { - vm.buttonText = gettextCatalog.getString('Slide to accept'); - } else { - vm.buttonText = gettextCatalog.getString('Click to accept'); - } - } else { - if (vm.isCordova) { - vm.buttonText = gettextCatalog.getString('Slide to send'); - } else { - vm.buttonText = gettextCatalog.getString('Click to send'); - } - } - } - - function setNotReady(msg, criticalError) { - vn.readyToSend = false; - vm.notReadyMessage = msg; - $scope.criticalError = criticalError; - $log.warn('Not ready to make the payment:' + msg); - $timeout(function() { - $scope.$apply(); - }); - }; - - function setSendError(msg) { - $scope.sendStatus = ''; - vm.readyToSend = false; - $timeout(function() { - $scope.$apply(); - }); - popupService.showAlert(gettextCatalog.getString('Error at confirm'), bwcError.msg(msg), function () { - $ionicHistory.goBack(); - }); - }; - - function setupTx(tx) { - if (tx.coin === 'bch') { - tx.displayAddress = bitcoinCashJsService.readAddress(tx.toAddress).cashaddr; - } else { - tx.displayAddress = tx.toAddress; - } - - addressbookService.get(tx.coin+tx.toAddress, function(err, addr) { // Check if the recipient is a contact - if (!err && addr) { - tx.toName = addr.name; - tx.toEmail = addr.email; - tx.recipientType = 'contact'; - } - }); - - vm.showAddress = false; - - - setButtonText(vm.originWallet.credentials.m > 1, !!tx.paypro); - - if (tx.paypro) - startExpirationTimer(tx.paypro.expires); - - popupService.showConfirm(null, 'Do you want this transaction to be sent without a fee?', 'Yes', 'No', function(ok) { - if(ok){ - tx.feeRate = 0; - // tx.feeLevel = 'free'; - usingCustomFee = true; - } - updateTx(tx, vm.originWallet, { - dryRun: true - }, function(err) { - $timeout(function() { - $scope.$apply(); - }, 10); - - }); - }); - - - - // setWalletSelector(tx.coin, tx.network, tx.amount, function(err) { - // if (err) { - // return exitWithError('Could not update wallets'); - // } - // - // if (vm.wallets.length > 1) { - // vm.showWalletSelector(); - // } else if (vm.wallets.length) { - // setWallet(vm.wallets[0], tx); - // } - // }); - } - - function showSendMaxWarning(wallet, sendMaxInfo) { - var feeAlternative = '', - msg = ''; - - function verifyExcludedUtxos() { - var warningMsg = []; - if (sendMaxInfo.utxosBelowFee > 0) { - warningMsg.push(gettextCatalog.getString("A total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", { - amountBelowFeeStr: txFormatService.formatAmountStr(wallet.coin, sendMaxInfo.amountBelowFee) - })); - } - - if (sendMaxInfo.utxosAboveMaxSize > 0) { - warningMsg.push(gettextCatalog.getString("A total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded.", { - amountAboveMaxSizeStr: txFormatService.formatAmountStr(vm.originWallet.coin, sendMaxInfo.amountAboveMaxSize) - })); - } - return warningMsg.join('\n'); - }; - - feeAlternative = txFormatService.formatAlternativeStr(vm.originWallet.coin, sendMaxInfo.fee); - if (feeAlternative) { - msg = gettextCatalog.getString("{{feeAlternative}} will be deducted for bitcoin networking fees ({{fee}}).", { - fee: txFormatService.formatAmountStr(vm.originWallet.coin, sendMaxInfo.fee), - feeAlternative: feeAlternative - }); - } else { - msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees).", { - fee: txFormatService.formatAmountStr(vm.originWallet.coin, sendMaxInfo.fee) - }); - } - - var warningMsg = verifyExcludedUtxos(); - - if (!lodash.isEmpty(warningMsg)) - msg += '\n' + warningMsg; - - popupService.showAlert(null, msg, function() {}); - //popupService.showConfirm(null, msg, null, null, function() {}); - }; - - function statusChangeHandler(processName, showName, isOn) { - $log.debug('statusChangeHandler: ', processName, showName, isOn); - if ( - ( - processName === 'broadcastingTx' || - ((processName === 'signingTx') && vm.originWallet.m > 1) || - (processName == 'sendingTx' && !vm.originWallet.canSign() && !vm.originWallet.isPrivKeyExternal()) - ) && !isOn) { - // Show the popup - vm.sendStatus = 'success'; - - // Clear the send flow service state - sendFlowService.state.clear(); - - if ($state.current.name === "tabs.send.review") { // XX SP: Otherwise all open wallets on other devices play this sound if you have been in a send flow before on that device. - soundService.play('misc/payment_sent.mp3'); - } - - var channel = "firebase"; - if (platformInfo.isNW) { - channel = "ga"; - } - // When displaying Fiat, if the formatting fails, the crypto will be the primary amount. - var amount = unitFromSat * satoshis; - var log = new window.BitAnalytics.LogEvent("transfer_success", [{ - "coin": vm.originWallet.coin, - "type": "outgoing", - "amount": amount, - "fees": vm.feeCrypto - }], [channel, "adjust"]); - window.BitAnalytics.LogEventHandlers.postEvent(log); - - $timeout(function() { - $scope.$digest(); - }, 100); - } else if (showName) { - vm.sendStatus = showName; - } - }; - - function updateTx(tx, wallet, opts, cb) { - ongoingProcess.set('calculatingFee', true); - - if (opts.clearCache) { - tx.txp = {}; - } - - // $scope.tx = tx; - - // function updateAmount() { - // if (!tx.amount) return; - // - // // Amount - // tx.amountStr = txFormatService.formatAmountStr(originWallet.coin, tx.amount); - // tx.amountValueStr = tx.amountStr.split(' ')[0]; - // tx.amountUnitStr = tx.amountStr.split(' ')[1]; - // txFormatService.formatAlternativeStr(wallet.coin, tx.amount, function(v) { - // var parts = v.split(' '); - // tx.alternativeAmountStr = v; - // tx.alternativeAmountValueStr = parts[0]; - // tx.alternativeAmountUnitStr = (parts.length > 0) ? parts[1] : ''; - // }); - // } - // - // updateAmount(); - // refresh(); - - var feeServiceLevel = usingMerchantFee && vm.originWallet.coin == 'btc' ? 'urgent' : tx.feeLevel; - feeService.getFeeRate(vm.originWallet.coin, tx.network, feeServiceLevel, function(err, feeRate) { - if (err) { - ongoingProcess.set('calculatingFee', false); - return cb(err); - } - - var msg; - // if (tx.feeLevel == 'free'){ - // tx.feeRate = 0; - // } - // else - if (usingCustomFee) { - msg = gettextCatalog.getString('Custom'); - tx.feeLevelName = msg; - } else if (usingMerchantFee) { - $log.info('Using Merchant Fee:' + tx.feeRate + ' vs. Urgent level:' + feeRate); - msg = gettextCatalog.getString('Suggested by Merchant'); - tx.feeLevelName = msg; - } else { - tx.feeLevelName = feeService.feeOpts[tx.feeLevel]; - tx.feeRate = feeRate; - - } - - - getSendMaxInfo(lodash.clone(tx), wallet, function(err, sendMaxInfo) { - if (err) { - ongoingProcess.set('calculatingFee', false); - var msg = gettextCatalog.getString('Error getting SendMax information'); - return setSendError(msg); - } - - if (sendMaxInfo) { - - $log.debug('Send max info', sendMaxInfo); - - if (tx.sendMax && sendMaxInfo.amount == 0) { - ongoingProcess.set('calculatingFee', false); - setNotReady(gettextCatalog.getString('Insufficient confirmed funds')); - popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee'), function () { + popupService.showAlert(gettextCatalog.getString('Shapeshift Error'), err.toString(), function () { $ionicHistory.goBack(); }); - return cb('no_funds'); + } else { + vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId; + vm.memoExpanded = !!vm.memo; + tx.toAddress = shapeshiftData.toAddress; + vm.destination.address = toAddress; + vm.destination.kind = 'shapeshift'; } - - tx.sendMaxInfo = sendMaxInfo; - tx.amount = tx.sendMaxInfo.amount; - satoshis = tx.amount; - updateSendAmounts(); - ongoingProcess.set('calculatingFee', false); - $timeout(function() { - showSendMaxWarning(wallet, sendMaxInfo); - }, 200); - } - - // txp already generated for this wallet? - if (tx.txp[wallet.id]) { - ongoingProcess.set('calculatingFee', false); - vm.readyToSend = true; - updateSendAmounts(); - $scope.$apply(); - return cb(); - } - - console.log('calling getTxp() from getSendMaxInfo cb.'); - getTxp(lodash.clone(tx), wallet, opts.dryRun, function(err, txp) { - ongoingProcess.set('calculatingFee', false); - if (err) { - if (err.message == 'Insufficient funds') { - setNotReady(gettextCatalog.getString('Insufficient funds')); - popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee')); - return cb('no_funds'); - } else - return cb(err); - } - - txp.feeStr = txFormatService.formatAmountStr(wallet.coin, txp.fee); - txFormatService.formatAlternativeStr(wallet.coin, txp.fee, function(v) { - // txp.alternativeFeeStr = v; - // if (txp.alternativeFeeStr.substring(0, 4) == '0.00') - // txp.alternativeFeeStr = '< ' + txp.alternativeFeeStr; - vm.feeFiat = v; - vm.fiatCurrency = config.wallet.settings.alternativeIsoCode; - if (v.substring(0, 1) === "<") { - vm.feeLessThanACent = true; - } - - console.log("fiat", vm.feeFiat); - - }); - - var per = (txp.fee / (txp.amount + txp.fee) * 100); - var perString = per.toFixed(2); - txp.feeRatePerStr = (perString == '0.00' ? '< ' : '') + perString + '%'; - txp.feeToHigh = per > FEE_TOO_HIGH_LIMIT_PERCENTAGE; - vm.feeCrypto = (unitFromSat * txp.fee).toFixed(8); - vm.feeIsHigh = txp.feeToHigh; - console.log("crypto", vm.feeCrypto); - - - tx.txp[wallet.id] = txp; - $log.debug('Confirm. TX Fully Updated for wallet:' + wallet.id, tx); - vm.readyToSend = true; - updateSendAmounts(); - console.log('readyToSend:', vm.readyToSend); - $scope.$apply(); - - return cb(); }); }); }); } } -})(); + + function onShareTransaction() { + var explorerTxUrl = 'https://explorer.bitcoin.com/' + tx.coin + '/tx/' + lastTxId; + if (platformInfo.isCordova) { + var text = gettextCatalog.getString('Take a look at this Bitcoin Cash transaction here: ') + explorerTxUrl; + if (coin === 'btc') { + text = gettextCatalog.getString('Take a look at this Bitcoin transaction here: ') + explorerTxUrl; + } + window.plugins.socialsharing.share(text, null, null, null); + } else { + ionicToast.show(gettextCatalog.getString('Copied to clipboard'), 'bottom', false, 3000); + clipboardService.copyToClipboard(explorerTxUrl); + } + + } + + function startExpirationTimer(expirationTime) { + vm.paymentExpired = false; + setExpirationTime(); + + countDown = $interval(function() { + setExpirationTime(); + }, 1000); + + function setExpirationTime() { + console.log('setExpirationTime()'); + var now = Math.floor(Date.now() / 1000); + + if (now > expirationTime) { + setExpiredValues(); + return; + } + + var totalSecs = expirationTime - now; + var m = Math.floor(totalSecs / 60); + var s = totalSecs % 60; + vm.remainingTimeStr = m + ":" + ('0' + s).slice(-2); + }; + + function setExpiredValues() { + vm.paymentExpired = true; + vm.remainingTimeStr = gettextCatalog.getString('Expired'); + vm.readyToSend = false; + if (countDown) $interval.cancel(countDown); + $timeout(function() { + $scope.$apply(); + }); + }; + }; + + function updateSendAmounts() { + if (typeof satoshis !== 'number') { + return; + } + + var cryptoAmount = ''; + var cryptoCurrencyCode = ''; + var amountStr = txFormatService.formatAmountStr(coin, satoshis); + if (amountStr) { + var amountParts = amountStr.split(' '); + cryptoAmount = amountParts[0]; + cryptoCurrencyCode = amountParts.length > 1 ? amountParts[1] : ''; + } + // Want to avoid flashing of amount strings so do all formatting after this has returned. + txFormatService.formatAlternativeStr(coin, satoshis, function(v) { + if (!v) { + vm.primaryAmount = cryptoAmount; + vm.primaryCurrency = cryptoCurrencyCode; + vm.secondaryAmount = ''; + vm.secondaryCurrency = ''; + return; + } + vm.secondaryAmount = vm.primaryAmount; + vm.secondaryCurrency = vm.primaryCurrency; + + var fiatParts = v.split(' '); + var fiatAmount = fiatParts[0]; + var fiatCurrency = fiatParts.length > 1 ? fiatParts[1] : ''; + + if (priceDisplayIsFiat) { + vm.primaryAmount = fiatAmount; + vm.primaryCurrency = fiatCurrency; + vm.secondaryAmount = cryptoAmount; + vm.secondaryCurrency = cryptoCurrencyCode; + } else { + vm.primaryAmount = cryptoAmount; + vm.primaryCurrency = cryptoCurrencyCode; + vm.secondaryAmount = fiatAmount; + vm.secondaryCurrency = fiatCurrency; + } + }); + } + + function onSuccessConfirm() { + vm.sendStatus = ''; + $ionicHistory.nextViewOptions({ + disableAnimate: true, + historyRoot: true + }); + $state.go('tabs.send').then(function() { + $ionicHistory.clearHistory(); + $state.transitionTo('tabs.home'); + }); + }; + + function setButtonText(isMultisig, isPayPro) { + if (isPayPro) { + if (vm.isCordova) { + vm.buttonText = gettextCatalog.getString('Slide to pay'); + } else { + vm.buttonText = gettextCatalog.getString('Click to pay'); + } + } else if (isMultisig) { + if (vm.isCordova) { + vm.buttonText = gettextCatalog.getString('Slide to accept'); + } else { + vm.buttonText = gettextCatalog.getString('Click to accept'); + } + } else { + if (vm.isCordova) { + vm.buttonText = gettextCatalog.getString('Slide to send'); + } else { + vm.buttonText = gettextCatalog.getString('Click to send'); + } + } + } + + function setNotReady(msg, criticalError) { + vn.readyToSend = false; + vm.notReadyMessage = msg; + $scope.criticalError = criticalError; + $log.warn('Not ready to make the payment:' + msg); + $timeout(function() { + $scope.$apply(); + }); + }; + + function setSendError(msg) { + $scope.sendStatus = ''; + vm.readyToSend = false; + $timeout(function() { + $scope.$apply(); + }); + popupService.showAlert(gettextCatalog.getString('Error at confirm'), bwcError.msg(msg), function () { + $ionicHistory.goBack(); + }); + }; + + function setupTx(tx) { + if (tx.coin === 'bch') { + tx.displayAddress = bitcoinCashJsService.readAddress(tx.toAddress).cashaddr; + } else { + tx.displayAddress = tx.toAddress; + } + + addressbookService.get(tx.coin+tx.toAddress, function(err, addr) { // Check if the recipient is a contact + if (!err && addr) { + tx.toName = addr.name; + tx.toEmail = addr.email; + tx.recipientType = 'contact'; + } + }); + + vm.showAddress = false; + + + setButtonText(vm.originWallet.credentials.m > 1, !!tx.paypro); + + if (tx.paypro) + startExpirationTimer(tx.paypro.expires); + + updateTx(tx, vm.originWallet, { + dryRun: true + }, function(err) { + $timeout(function() { + $scope.$apply(); + }, 10); + + }); + + // setWalletSelector(tx.coin, tx.network, tx.amount, function(err) { + // if (err) { + // return exitWithError('Could not update wallets'); + // } + // + // if (vm.wallets.length > 1) { + // vm.showWalletSelector(); + // } else if (vm.wallets.length) { + // setWallet(vm.wallets[0], tx); + // } + // }); + } + + function showSendMaxWarning(wallet, sendMaxInfo) { + var feeAlternative = '', + msg = ''; + + function verifyExcludedUtxos() { + var warningMsg = []; + if (sendMaxInfo.utxosBelowFee > 0) { + warningMsg.push(gettextCatalog.getString("A total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", { + amountBelowFeeStr: txFormatService.formatAmountStr(wallet.coin, sendMaxInfo.amountBelowFee) + })); + } + + if (sendMaxInfo.utxosAboveMaxSize > 0) { + warningMsg.push(gettextCatalog.getString("A total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded.", { + amountAboveMaxSizeStr: txFormatService.formatAmountStr(vm.originWallet.coin, sendMaxInfo.amountAboveMaxSize) + })); + } + return warningMsg.join('\n'); + }; + + feeAlternative = txFormatService.formatAlternativeStr(vm.originWallet.coin, sendMaxInfo.fee); + if (feeAlternative) { + msg = gettextCatalog.getString("{{feeAlternative}} will be deducted for bitcoin networking fees ({{fee}}).", { + fee: txFormatService.formatAmountStr(vm.originWallet.coin, sendMaxInfo.fee), + feeAlternative: feeAlternative + }); + } else { + msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees).", { + fee: txFormatService.formatAmountStr(vm.originWallet.coin, sendMaxInfo.fee) + }); + } + + var warningMsg = verifyExcludedUtxos(); + + if (!lodash.isEmpty(warningMsg)) + msg += '\n' + warningMsg; + + popupService.showAlert(null, msg, function() {}); + }; + + function statusChangeHandler(processName, showName, isOn) { + $log.debug('statusChangeHandler: ', processName, showName, isOn); + if ( + ( + processName === 'broadcastingTx' || + ((processName === 'signingTx') && vm.originWallet.m > 1) || + (processName == 'sendingTx' && !vm.originWallet.canSign() && !vm.originWallet.isPrivKeyExternal()) + ) && !isOn) { + vm.sendStatus = 'success'; + + if ($state.current.name === "tabs.send.review") { // XX SP: Otherwise all open wallets on other devices play this sound if you have been in a send flow before on that device. + soundService.play('misc/payment_sent.mp3'); + } + + var channel = "firebase"; + if (platformInfo.isNW) { + channel = "ga"; + } + // When displaying Fiat, if the formatting fails, the crypto will be the primary amount. + var amount = unitFromSat * satoshis; + var log = new window.BitAnalytics.LogEvent("transfer_success", [{ + "coin": vm.originWallet.coin, + "type": "outgoing", + "amount": amount, + "fees": vm.feeCrypto + }], [channel, "adjust"]); + window.BitAnalytics.LogEventHandlers.postEvent(log); + + $timeout(function() { + $scope.$digest(); + }, 100); + } else if (showName) { + vm.sendStatus = showName; + } + }; + + function updateTx(tx, wallet, opts, cb) { + ongoingProcess.set('calculatingFee', true); + + if (opts.clearCache) { + tx.txp = {}; + } + + // $scope.tx = tx; + + // function updateAmount() { + // if (!tx.amount) return; + // + // // Amount + // tx.amountStr = txFormatService.formatAmountStr(originWallet.coin, tx.amount); + // tx.amountValueStr = tx.amountStr.split(' ')[0]; + // tx.amountUnitStr = tx.amountStr.split(' ')[1]; + // txFormatService.formatAlternativeStr(wallet.coin, tx.amount, function(v) { + // var parts = v.split(' '); + // tx.alternativeAmountStr = v; + // tx.alternativeAmountValueStr = parts[0]; + // tx.alternativeAmountUnitStr = (parts.length > 0) ? parts[1] : ''; + // }); + // } + // + // updateAmount(); + // refresh(); + + var feeServiceLevel = usingMerchantFee && vm.originWallet.coin == 'btc' ? 'urgent' : tx.feeLevel; + feeService.getFeeRate(vm.originWallet.coin, tx.network, feeServiceLevel, function(err, feeRate) { + if (err) { + ongoingProcess.set('calculatingFee', false); + return cb(err); + } + + var msg; + if (usingCustomFee) { + msg = gettextCatalog.getString('Custom'); + tx.feeLevelName = msg; + } else if (usingMerchantFee) { + $log.info('Using Merchant Fee:' + tx.feeRate + ' vs. Urgent level:' + feeRate); + msg = gettextCatalog.getString('Suggested by Merchant'); + tx.feeLevelName = msg; + } else { + tx.feeLevelName = feeService.feeOpts[tx.feeLevel]; + tx.feeRate = feeRate; + } + + getSendMaxInfo(lodash.clone(tx), wallet, function(err, sendMaxInfo) { + if (err) { + ongoingProcess.set('calculatingFee', false); + var msg = gettextCatalog.getString('Error getting SendMax information'); + return setSendError(msg); + } + + if (sendMaxInfo) { + + $log.debug('Send max info', sendMaxInfo); + + if (tx.sendMax && sendMaxInfo.amount == 0) { + ongoingProcess.set('calculatingFee', false); + setNotReady(gettextCatalog.getString('Insufficient confirmed funds')); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee'), function () { + $ionicHistory.goBack(); + }); + return cb('no_funds'); + } + + tx.sendMaxInfo = sendMaxInfo; + tx.amount = tx.sendMaxInfo.amount; + satoshis = tx.amount; + updateSendAmounts(); + ongoingProcess.set('calculatingFee', false); + $timeout(function() { + showSendMaxWarning(wallet, sendMaxInfo); + }, 200); + } + + // txp already generated for this wallet? + if (tx.txp[wallet.id]) { + ongoingProcess.set('calculatingFee', false); + vm.readyToSend = true; + updateSendAmounts(); + $scope.$apply(); + return cb(); + } + + console.log('calling getTxp() from getSendMaxInfo cb.'); + getTxp(lodash.clone(tx), wallet, opts.dryRun, function(err, txp) { + ongoingProcess.set('calculatingFee', false); + if (err) { + if (err.message == 'Insufficient funds') { + setNotReady(gettextCatalog.getString('Insufficient funds')); + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee')); + return cb('no_funds'); + } else + return cb(err); + } + + txp.feeStr = txFormatService.formatAmountStr(wallet.coin, txp.fee); + txFormatService.formatAlternativeStr(wallet.coin, txp.fee, function(v) { + // txp.alternativeFeeStr = v; + // if (txp.alternativeFeeStr.substring(0, 4) == '0.00') + // txp.alternativeFeeStr = '< ' + txp.alternativeFeeStr; + vm.feeFiat = v; + vm.fiatCurrency = config.wallet.settings.alternativeIsoCode; + if (v.substring(0, 1) === "<") { + vm.feeLessThanACent = true; + } + + console.log("fiat", vm.feeFiat); + + }); + + var per = (txp.fee / (txp.amount + txp.fee) * 100); + var perString = per.toFixed(2); + txp.feeRatePerStr = (perString == '0.00' ? '< ' : '') + perString + '%'; + txp.feeToHigh = per > FEE_TOO_HIGH_LIMIT_PERCENTAGE; + vm.feeCrypto = (unitFromSat * txp.fee).toFixed(8); + vm.feeIsHigh = txp.feeToHigh; + console.log("crypto", vm.feeCrypto); + + + tx.txp[wallet.id] = txp; + $log.debug('Confirm. TX Fully Updated for wallet:' + wallet.id, tx); + vm.readyToSend = true; + updateSendAmounts(); + console.log('readyToSend:', vm.readyToSend); + $scope.$apply(); + + return cb(); + }); + }); + }); + } + +} diff --git a/src/js/controllers/shapeshift.js b/src/js/controllers/shapeshift.js index 652f54c34..43e0790d1 100644 --- a/src/js/controllers/shapeshift.js +++ b/src/js/controllers/shapeshift.js @@ -6,11 +6,27 @@ angular.module('copayApp.controllers').controller('shapeshiftController', functi $scope.showMyAddress = showMyAddress; + function generateAddress(wallet, cb) { + if (!wallet) return; + walletService.getAddress(wallet, false, function(err, addr) { + if (err) { + popupService.showAlert(err); + } + return cb(addr); + }); + } + + function showToWallets() { + $scope.toWallets = $scope.fromWallet.coin === 'btc' ? walletsBch : walletsBtc; + $scope.onToWalletSelect($scope.toWallets[0]); + $scope.singleToWallet = $scope.toWallets.length === 1; + } + $scope.$on("$ionicView.beforeEnter", function(event, data) { walletsBtc = profileService.getWallets({coin: 'btc'}); walletsBch = profileService.getWallets({coin: 'bch'}); $scope.fromWallets = lodash.filter(walletsBtc.concat(walletsBch), function(w) { - return (w.status && w.status.balance && w.status.balance.availableAmount > 0); + return w.status.balance.availableAmount > 0; }); $scope.singleFromWallet = $scope.fromWallets.length === 1; @@ -46,7 +62,18 @@ angular.module('copayApp.controllers').controller('shapeshiftController', functi id: 'shapeshift' } }; - sendFlowService.start(stateParams); + + // Starting new send flow, so ensure everything is reset + sendFlowService.clear(); + $state.go('tabs.home').then(function() { + $ionicHistory.clearHistory(); + $state.go('tabs.send').then(function() { + $timeout(function () { + sendFlowService.pushState(stateParams); + $state.transitionTo('tabs.send.origin'); + }, 60); + }); + }); } function showMyAddress() { diff --git a/src/js/controllers/tab-home.controller.js b/src/js/controllers/tab-home.js similarity index 88% rename from src/js/controllers/tab-home.controller.js rename to src/js/controllers/tab-home.js index f78f156f1..318fcece2 100644 --- a/src/js/controllers/tab-home.controller.js +++ b/src/js/controllers/tab-home.js @@ -43,20 +43,21 @@ angular.module('copayApp.controllers').controller('tabHomeController', }); } - latestReleaseService.checkLatestRelease(function(err, newReleaseData) { - if (err) { - $log.warn(err); - return; - } - if (newReleaseData) { - $scope.newRelease = true; - $scope.newReleaseText = gettextCatalog.getString('There is a new version of {{appName}} available', { - appName: $scope.name - }); - $scope.newReleaseNotes = newReleaseData.releaseNotes; - } - }); - } + if ($scope.isNW) { + latestReleaseService.checkLatestRelease(function(err, newRelease) { + if (err) { + $log.warn(err); + return; + } + if (newRelease) { + $scope.newRelease = true; + $scope.updateText = gettextCatalog.getString('There is a new version of {{appName}} available', { + appName: $scope.name + }); + } + }); + } + }; function onEnter(event, data) { $ionicNavBarDelegate.showBar(true); @@ -108,24 +109,31 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.$apply(); }, 10); }); - } + }; function onLeave (event, data) { lodash.each(listeners, function(x) { x(); }); - } + }; $scope.createdWithinPastDay = function(time) { return timeService.withinPastDay(time); }; $scope.startFreshSend = function() { - sendFlowService.start(); + sendFlowService.clear(); + $state.go('tabs.send'); } - $scope.showUpdatePopup = function() { - latestReleaseService.showUpdatePopup(); + $scope.openExternalLink = function() { + var url = 'https://github.com/Bitcoin-com/Wallet/releases/latest'; + var optIn = true; + var title = gettextCatalog.getString('Update Available'); + var message = gettextCatalog.getString('An update to this app is available. For your security, please update to the latest version.'); + var okText = gettextCatalog.getString('View Update'); + var cancelText = gettextCatalog.getString('Go Back'); + externalLinkService.open(url, optIn, title, message, okText, cancelText); }; $scope.openBannerUrl = function() { diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 645e46739..66d1799f8 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -2,7 +2,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', function($rootScope, $scope, $timeout, $log, $ionicModal, $state, $ionicHistory, $ionicPopover, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService, bwcError, bitcoinCashJsService, $ionicNavBarDelegate, sendFlowService, txFormatService, soundService, clipboardService) { - var CLOSE_NORMAL = 1000; var listeners = []; $scope.bchAddressType = { type: 'cashaddr' }; var bchAddresses = {}; @@ -11,63 +10,20 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.isCordova = platformInfo.isCordova; $scope.isNW = platformInfo.isNW; - var currentAddressSocket = null; - var paymentSubscriptionObj = { op:'addr_sub' }; + var currentAddressSocket = {}; + var paymentSubscriptionObj = { op:"addr_sub" } + + var config; $scope.displayBalanceAsFiat = true; - $scope.$on('$ionicView.beforeLeave', onBeforeLeave); $scope.requestSpecificAmount = function() { - sendFlowService.start({ - toWalletId: $scope.wallet.credentials.walletId, - isRequestAmount: true + sendFlowService.pushState({ + toWalletId: $scope.wallet.credentials.walletId }); + $state.go('tabs.paymentRequest.amount'); }; - - function connectSocket() { - // Close existing socket if not connected with current address - if (currentAddressSocket) { - currentAddressSocket.close([CLOSE_NORMAL]); - } - - if ($scope.wallet.coin === 'bch') { - // listen to bch address - currentAddressSocket = new WebSocket('wss://ws.blockchain.info/bch/inv'); - paymentSubscriptionObj.addr = $scope.addrBchLegacy; - } else { - // listen to btc address - currentAddressSocket = new WebSocket('wss://ws.blockchain.info/inv'); - paymentSubscriptionObj.addr = $scope.addr; - } - - // create subscription to address - var msg = JSON.stringify(paymentSubscriptionObj); - currentAddressSocket.onopen = function (event) { - currentAddressSocket.send(msg); - }; - - // listen for response - currentAddressSocket.onmessage = function (event) { - //console.log("message received:" + event.data); - receivedPayment(event.data); - }; - - currentAddressSocket.onclose = function(event) { - if (event.code !== CLOSE_NORMAL) { - $log.debug('Socket was closed abnormally. Reconnect will be attempted in 1 second.'); - $timeout(function() { - connectSocket(); - }, 1000); - } - }; - - currentAddressSocket.onerror = function(err) { - console.error('Socket encountered error: ', err, 'Closing socket'); - currentAddressSocket.close(); - }; - } - $scope.setAddress = function(newAddr, copyAddress) { $scope.addr = null; if (!$scope.wallet || $scope.generatingAddress || !$scope.wallet.isComplete()) return; @@ -80,24 +36,49 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi popupService.showAlert(err); } - if ($scope.wallet.coin === 'bch') { - bchAddresses = bitcoinCashJsService.translateAddresses(addr); - $scope.addr = bchAddresses[$scope.bchAddressType.type]; - $scope.addrBchLegacy = bchAddresses['legacy']; - } else { - $scope.addr = addr; + //close existing socket + if (currentAddressSocket.close === 'function') { + currentAddressSocket.close(); } - connectSocket(); + if ($scope.wallet.coin == 'bch') { + bchAddresses = bitcoinCashJsService.translateAddresses(addr); + $scope.addr = bchAddresses[$scope.bchAddressType.type]; + $scope.addrBchLegacy = bchAddresses['legacy']; + + // listen to bch address + currentAddressSocket = new WebSocket("wss://ws.blockchain.info/bch/inv"); + paymentSubscriptionObj.addr = bchAddresses['legacy']; + + } else { + $scope.addr = addr; + + // listen to btc address + currentAddressSocket = new WebSocket("wss://ws.blockchain.info/inv"); + paymentSubscriptionObj.addr = $scope.addr + } if (copyAddress === true) { try { clipboardService.copyToClipboard($scope.wallet.coin == 'bch' && $scope.bchAddressType.type == 'cashaddr' ? 'bitcoincash:' + $scope.addr : $scope.addr); } catch (error) { - $log.debug('Error copying to clipboard:'); + $log.debug("Error copying to clipboard:"); $log.debug(error); } } + // create subscription + var msg = JSON.stringify(paymentSubscriptionObj); + currentAddressSocket.onopen = function (event) { + //console.log("message sent: " + msg); + currentAddressSocket.send(msg); + } + + + // listen for response + currentAddressSocket.onmessage = function (event) { + //console.log("message received:" + event.data); + receivedPayment(event.data); + } $timeout(function() { $scope.$apply(); @@ -183,6 +164,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi // Notify new tx $scope.$emit('bwsEvent', $scope.wallet.id); + $scope.$apply(function () { $scope.showingPaymentReceived = true; }); @@ -251,10 +233,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi } }; - function onBeforeLeave() { - currentAddressSocket.close([CLOSE_NORMAL]); - } - $scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.wallets = profileService.getWallets(); $scope.singleWallet = $scope.wallets.length == 1; @@ -280,6 +258,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi configService.whenAvailable(function(_config) { $scope.displayBalanceAsFiat = _config.wallet.settings.priceDisplay === 'fiat'; + config = _config; }); }); diff --git a/src/js/controllers/tab-scan.controller.js b/src/js/controllers/tab-scan.js similarity index 89% rename from src/js/controllers/tab-scan.controller.js rename to src/js/controllers/tab-scan.js index 14368ee1c..4a654d91d 100644 --- a/src/js/controllers/tab-scan.controller.js +++ b/src/js/controllers/tab-scan.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabScanController', function(gettextCatalog, popupService, $scope, $log, $timeout, scannerService, incomingDataService, $state, $ionicHistory, $rootScope, $ionicNavBarDelegate) { +angular.module('copayApp.controllers').controller('tabScanController', function($scope, $log, $timeout, scannerService, incomingData, $state, $ionicHistory, $rootScope, $ionicNavBarDelegate) { var scannerStates = { unauthorized: 'unauthorized', @@ -111,18 +111,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function( // Sometimes (testing in Chrome, when reading QR Code) data is an object // that has a string data.result. contents = contents.result || contents; - incomingDataService.redir(contents, function onError(err) { - if (err) { - var title = gettextCatalog.getString('Scan Failed'); - popupService.showAlert(title, err.message, function onAlertShown() { - // Enable another scan since we won't receive incomingDataMenu.menuHidden - activate(); - }); - } else { - scannerService.resumePreview(); - - } - }); + incomingData.redir(contents); } $rootScope.$on('incomingDataMenu.menuHidden', function() { diff --git a/src/js/controllers/tab-send.controller.js b/src/js/controllers/tab-send.js similarity index 80% rename from src/js/controllers/tab-send.controller.js rename to src/js/controllers/tab-send.js index 03a9562e8..9ac6c35cb 100644 --- a/src/js/controllers/tab-send.controller.js +++ b/src/js/controllers/tab-send.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabSendController', function(bitcoinUriService, $scope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, platformInfo, sendFlowService, gettextCatalog, configService, $ionicPopup, $ionicNavBarDelegate, clipboardService, incomingDataService) { +angular.module('copayApp.controllers').controller('tabSendController', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, $ionicLoading, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, sendFlowService, bwcError, gettextCatalog, scannerService, configService, bitcoinCashJsService, $ionicPopup, $ionicNavBarDelegate, clipboardService) { var clipboardHasAddress = false; var clipboardHasContent = false; var originalList; @@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function( $scope.$on("$ionicView.enter", function(event, data) { - var stateParams = sendFlowService.state.getClone(); + var stateParams = sendFlowService.getStateClone(); $scope.fromWallet = profileService.getWallet(stateParams.fromWalletId); clipboardService.readFromClipboard(function(text) { @@ -39,9 +39,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function( $scope.clipboardHasAddress = false; $scope.clipboardHasContent = false; - var parsed = bitcoinUriService.parse(text); - console.log('parsed', parsed); - if (parsed.isValid && parsed.publicAddress && parsed.coin === 'bch' && !parsed.testnet) { // CashAddr + if ((text.indexOf('bitcoincash:') === 0 || text[0] === 'C' || text[0] === 'H' || text[0] === 'p' || text[0] === 'q') && text.replace('bitcoincash:', '').length === 42) { // CashAddr $scope.clipboardHasAddress = true; } else if ((text[0] === "1" || text[0] === "3" || text.substring(0, 3) === "bc1") && text.length >= 26 && text.length <= 35) { // Legacy Addresses $scope.clipboardHasAddress = true; @@ -62,6 +60,11 @@ angular.module('copayApp.controllers').controller('tabSendController', function( }); $scope.findContact = function(search) { + + if (incomingData.redir(search)) { + return; + } + if (!search || search.length < 1) { $scope.list = originalList; $timeout(function() { @@ -70,16 +73,12 @@ angular.module('copayApp.controllers').controller('tabSendController', function( return; } - var params = sendFlowService.state.getClone(); - params.data = search; - sendFlowService.start(params, function onError() { - var result = lodash.filter(originalList, function(item) { - var val = item.name; - return lodash.startsWith(val.toLowerCase(), search.toLowerCase()); - }); - - $scope.list = result; + var result = lodash.filter(originalList, function(item) { + var val = item.name; + return lodash.startsWith(val.toLowerCase(), search.toLowerCase()); }); + + $scope.list = result; }; var hasWallets = function() { @@ -185,18 +184,27 @@ angular.module('copayApp.controllers').controller('tabSendController', function( $log.debug('Got toAddress:' + toAddress + ' | ' + item.name); - var stateParams = sendFlowService.state.getClone(); - stateParams.toAddress = toAddress; + var stateParams = sendFlowService.getStateClone(); + stateParams.toAddress = toAddress, stateParams.coin = item.coin; - sendFlowService.start(stateParams); + sendFlowService.pushState(stateParams); + + if (!stateParams.fromWalletId) { // If we have no toAddress or fromWallet + $state.transitionTo('tabs.send.origin'); + } else { + $state.transitionTo('tabs.send.amount'); + } + }); }; $scope.startWalletToWalletTransfer = function() { console.log('startWalletToWalletTransfer()'); - var params = sendFlowService.state.getClone(); - params.isWalletTransfer = true; - sendFlowService.start(params); + var params = sendFlowService.getStateClone(); + sendFlowService.pushState(params); + $state.transitionTo('tabs.send.wallet-to-wallet', { + fromWalletId: sendFlowService.fromWalletId + }); } // This could probably be enhanced refactoring the routes abstract states @@ -230,7 +238,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function( }); if (data.direction == "back") { - sendFlowService.state.clear(); + sendFlowService.clear(); } }); diff --git a/src/js/controllers/tabsController.js b/src/js/controllers/tabsController.js index b78274ecb..b3de6c70f 100644 --- a/src/js/controllers/tabsController.js +++ b/src/js/controllers/tabsController.js @@ -1,13 +1,11 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabsController', function($rootScope, $log, $scope, $state, $stateParams, $timeout, platformInfo, incomingDataService, lodash, popupService, gettextCatalog, scannerService, sendFlowService) { +angular.module('copayApp.controllers').controller('tabsController', function($rootScope, $log, $scope, $state, $stateParams, $timeout, platformInfo, incomingData, lodash, popupService, gettextCatalog, scannerService, sendFlowService) { $scope.onScan = function(data) { - incomingDataService.redir(data, function onError(err) { - if (err) { - popupService.showAlert(gettextCatalog.getString('Error'), err.message); - } - }); + if (!incomingData.redir(data)) { + popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid data')); + } }; $scope.setScanFn = function(scanFn) { @@ -18,7 +16,8 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro }; $scope.startFreshSend = function() { - sendFlowService.start(); + sendFlowService.clear(); + $state.go('tabs.send'); }; $scope.importInit = function() { @@ -29,6 +28,7 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro }; $scope.chooseScanner = function() { + sendFlowService.clear(); var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP; if (!isWindowsPhoneApp) { @@ -38,14 +38,10 @@ angular.module('copayApp.controllers').controller('tabsController', function($ro scannerService.useOldScanner(function(err, contents) { if (err) { - popupService.showAlert(gettextCatalog.getString('Error'), err.message); - } else { - incomingDataService.redir(contents, function onError(err) { - if (err) { - popupService.showAlert(gettextCatalog.getString('Error'), err.message); - } - }); + popupService.showAlert(gettextCatalog.getString('Error'), err); + return; } + incomingData.redir(contents); }); }; diff --git a/src/js/controllers/wallet-selector.controller.js b/src/js/controllers/wallet-selector.controller.js deleted file mode 100644 index 036727333..000000000 --- a/src/js/controllers/wallet-selector.controller.js +++ /dev/null @@ -1,204 +0,0 @@ -'use strict'; - -(function () { - -angular - .module('copayApp.controllers') - .controller('walletSelectorController', walletSelectorController); - - function walletSelectorController ($scope, $state, sendFlowService, configService, gettextCatalog, ongoingProcess, profileService, walletService, txFormatService) { - var fromWalletId = ''; - var priceDisplayAsFiat = false; - var unitDecimals = 0; - var unitsFromSatoshis = 0; - - $scope.$on("$ionicView.beforeEnter", onBeforeEnter); - $scope.$on("$ionicView.enter", onEnter); - - function onBeforeEnter(event, data) { - if (data.direction == "back") { - sendFlowService.state.pop(); - } - - $scope.params = sendFlowService.state.getClone(); - - console.log('walletSelector onBeforeEnter after back sendflow', $scope.params); - - var config = configService.getSync().wallet.settings; - priceDisplayAsFiat = config.priceDisplay === 'fiat'; - unitDecimals = config.unitDecimals; - unitsFromSatoshis = 1 / config.unitToSatoshi; - - if ($scope.params.isWalletTransfer) { - $scope.sendFlowTitle = gettextCatalog.getString('Transfer between wallets'); - } else if (!$scope.params.thirdParty) { - $scope.sendFlowTitle = gettextCatalog.getString('Send'); - } - - $scope.coin = false; // Wallets to show (for destination screen or contacts) - $scope.type = $scope.params['fromWalletId'] ? 'destination' : 'origin'; // origin || destination - fromWalletId = $scope.params['fromWalletId']; - - if ($scope.type === 'destination' && $scope.params.toAddress) { - $state.transitionTo(getNextStep($scope.params)); - } - - if ($scope.params.coin) { - $scope.coin = $scope.params.coin; // Contacts have a coin embedded - } - - if ($scope.params.amount) { // There is an amount, so presume that it is a payment request - $scope.sendFlowTitle = gettextCatalog.getString('Payment Request'); - $scope.specificAmount = $scope.specificAlternativeAmount = ''; - $scope.isPaymentRequest = true; - } - if ($scope.params.thirdParty) { - $scope.thirdParty = $scope.params.thirdParty; - } - }; - - function onEnter (event, data) { - configService.whenAvailable(function(config) { - $scope.selectedPriceDisplay = config.wallet.settings.priceDisplay; - }); - - if ($scope.thirdParty) { - // Third party services specific logic - handleThirdPartyIfShapeshift(); - } - - prepareWalletLists(); - formatRequestedAmount(); - }; - - function formatRequestedAmount() { - if ($scope.params.amount) { - var cryptoAmount = (unitsFromSatoshis * $scope.params.amount).toFixed(unitDecimals); - var cryptoCoin = $scope.coin.toUpperCase(); - - txFormatService.formatAlternativeStr($scope.coin, $scope.params.amount, function onFormatAlternativeStr(formatted){ - if (formatted) { - var fiatParts = formatted.split(' '); - var fiatAmount = fiatParts[0]; - var fiatCurrrency = fiatParts.length > 1 ? fiatParts[1] : ''; - - if (priceDisplayAsFiat) { - $scope.requestAmount = fiatAmount; - $scope.requestCurrency = fiatCurrrency; - - $scope.requestAmountSecondary = cryptoAmount; - $scope.requestCurrencySecondary = cryptoCoin; - } else { - $scope.requestAmount = cryptoAmount; - $scope.requestCurrency = cryptoCoin; - - $scope.requestAmountSecondary = fiatAmount; - $scope.requestCurrencySecondary = fiatCurrrency; - } - $scope.$apply(); - } - }); - } - } - - function handleThirdPartyIfShapeshift() { - console.log($scope.thirdParty, $scope.coin); - if ($scope.thirdParty.id === 'shapeshift' && $scope.type === 'destination') { // Shapeshift wants to know the - $scope.coin = profileService.getWallet(fromWalletId).coin; - if ($scope.coin === 'bch') { - $scope.coin = 'btc'; - } else { - $scope.coin = 'bch'; - } - } - } - - function prepareWalletLists() { - var walletsAll = []; - var walletsSufficientFunds = []; - $scope.walletsInsufficientFunds = []; // For origin screen - - if ($scope.type === 'origin') { - $scope.headerTitle = gettextCatalog.getString('Choose a wallet to send from'); - - if ($scope.params.amount || $scope.coin) { - - walletsAll = profileService.getWallets({coin: $scope.coin}); - ongoingProcess.set('scanning', true); - walletsAll.forEach(function forWallet(wallet) { - if (!wallet.status && !wallet.cachedStatus) { - walletService.getStatus(wallet, {}, function(err, status) { - wallet.status = status; - if (status.availableBalanceSat > ($scope.params.amount ? $scope.params.amount : 0)) { - walletsSufficientFunds.push(wallet); - } else { - $scope.walletsInsufficientFunds.push(wallet); - } - if ($scope.coin === 'btc') { // As this is a promise - $scope.walletsBtc = walletsSufficientFunds; - } else { - $scope.walletsBch = walletsSufficientFunds; - } - ongoingProcess.set('scanning', false); - }); - } else { - var walletStatus = null; - if (wallet.status && wallet.status.isValid) { - walletStatus = wallet.status; - } else if (wallet.cachedStatus && wallet.status.isValid) { - walletStatus = wallet.cachedStatus; - } - - if (walletStatus && walletStatus.availableBalanceSat > ($scope.params.amount ? $scope.params.amount : 0)) { - walletsSufficientFunds.push(wallet); - } else { - $scope.walletsInsufficientFunds.push(wallet); - } - ongoingProcess.set('scanning', false); - } - }); - - if ($scope.coin === 'btc') { - $scope.walletsBtc = walletsSufficientFunds; - } else { - $scope.walletsBch = walletsSufficientFunds; - } - } else { - $scope.walletsBch = profileService.getWallets({coin: 'bch', hasFunds: true}); - $scope.walletsBtc = profileService.getWallets({coin: 'btc', hasFunds: true}); - $scope.walletsInsufficientFunds = profileService.getWallets({coin: $scope.coin, hasNoFunds: true}); - } - - } else if ($scope.type === 'destination') { - if (!$scope.coin) { // Allow for the coin to be set by a third party - $scope.fromWallet = profileService.getWallet(fromWalletId); - $scope.coin = $scope.fromWallet.coin; // Only show wallets with the select origin wallet coin - } - $scope.headerTitle = gettextCatalog.getString('Choose a wallet to send to'); - - if ($scope.coin === 'btc') { // if no specific coin is set or coin is set btc - $scope.walletsBtc = profileService.getWallets({coin: $scope.coin}); - } else { - $scope.walletsBch = profileService.getWallets({coin: $scope.coin}); - } - } - } - - - - $scope.useWallet = function(wallet) { - var params = sendFlowService.state.getClone(); - if ($scope.type === 'origin') { // we're on the origin screen, set wallet to send from - params.fromWalletId = wallet.id; - } else { // we're on the destination screen, set wallet to send to - params.toWalletId = wallet.id; - } - sendFlowService.goNext(params); - }; - - $scope.goBack = function() { - sendFlowService.router.goBack(); - } - - } -})(); \ No newline at end of file diff --git a/src/js/controllers/wallet-details.controller.js b/src/js/controllers/walletDetails.js similarity index 66% rename from src/js/controllers/wallet-details.controller.js rename to src/js/controllers/walletDetails.js index 429420741..ec787a5f4 100644 --- a/src/js/controllers/wallet-details.controller.js +++ b/src/js/controllers/walletDetails.js @@ -1,52 +1,16 @@ 'use strict'; -angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicHistory, profileService, lodash, configService, platformInfo, walletService, txpModalService, externalLinkService, popupService, addressbookService, sendFlowService, storageService, $ionicScrollDelegate, $window, bwcError, gettextCatalog, timeService, feeService, appConfigService, rateService, walletHistoryService) { - // Desktop can display 13 rows of transactions, bump it up to a nice round 15. - var DISPLAY_PAGE_SIZE = 15; - var currentTxHistoryDisplayPage = 0; - var completeTxHistory = [] +angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, $ionicHistory, profileService, lodash, configService, platformInfo, walletService, txpModalService, externalLinkService, popupService, addressbookService, sendFlowService, storageService, $ionicScrollDelegate, $window, bwcError, gettextCatalog, timeService, feeService, appConfigService, rateService) { + + var HISTORY_SHOW_LIMIT = 10; + var currentTxHistoryPage = 0; var listeners = []; - - // For gradual migration for doing it properly - $scope.vm = { - allowInfiniteScroll: false, - gettingCachedHistory: true, - gettingInitialHistory: true, - updatingTxHistory: false, - fetchedAllTxHistory: false, - //updateTxHistoryError: false - updateTxHistoryFailed: false - }; - - // Need flag for when to allow infinite scroll at bottom - // - ie not when loading initial data and there is no more cached data - - $scope.amountIsCollapsible = false; - $scope.color = '#888888'; - - $scope.filteredTxHistory = []; + $scope.txps = []; + $scope.completeTxHistory = []; + $scope.openTxpModal = txpModalService.open; $scope.isCordova = platformInfo.isCordova; $scope.isAndroid = platformInfo.isAndroid; $scope.isIOS = platformInfo.isIOS; - $scope.isSearching = false; - $scope.openTxpModal = txpModalService.open; - $scope.requiresMultipleSignatures = false; - $scope.showBalanceButton = false; - $scope.status = null; - // Displaying 50 transactions when entering the screen takes a while, so only display a subset - // of everything we have, not the complete history. - $scope.txHistory = []; // This is what is displayed - $scope.txHistorySearchResults = []; - $scope.txps = []; - $scope.updatingStatus = false; - $scope.updateStatusError = null; - $scope.updatingTxHistoryProgress = 0; - $scope.wallet = null; - $scope.walletId = ''; - $scope.walletNotRegistered = false; - - - var channel = "ga"; if (platformInfo.isCordova) { @@ -55,11 +19,34 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun var log = new window.BitAnalytics.LogEvent("wallet_details_open", [], [channel]); window.BitAnalytics.LogEventHandlers.postEvent(log); + $scope.amountIsCollapsible = !$scope.isAndroid; + $scope.openExternalLink = function(url, target) { externalLinkService.open(url, target); }; var setPendingTxps = function(txps) { + + /* Uncomment to test multiple outputs */ + + // var txp = { + // message: 'test multi-output', + // fee: 1000, + // createdOn: new Date() / 1000, + // outputs: [], + // wallet: $scope.wallet + // }; + // + // function addOutput(n) { + // txp.outputs.push({ + // amount: 600, + // toAddress: '2N8bhEwbKtMvR2jqMRcTCQqzHP6zXGToXcK', + // message: 'output #' + (Number(n) + 1) + // }); + // }; + // lodash.times(15, addOutput); + // txps.push(txp); + if (!txps) { $scope.txps = []; return; @@ -86,7 +73,6 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.updatingStatus = true; $scope.updateStatusError = null; $scope.walletNotRegistered = false; - $scope.vm.fetchedAllTxHistory = false; walletService.getStatus($scope.wallet, { force: !!force, @@ -170,97 +156,68 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun if (err) return; $timeout(function() { walletService.startScan($scope.wallet, function() { - $scope.updateAll(true, true); + $scope.updateAll(); $scope.$apply(); }); }); }); }; + var updateTxHistory = function(cb) { + if (!cb) cb = function() {}; + $scope.updateTxHistoryError = false; + $scope.updatingTxHistoryProgress = 0; + + feeService.getFeeLevels($scope.wallet.coin, function(err, levels) { + walletService.getTxHistory($scope.wallet, { + feeLevels: levels + }, function(err, txHistory) { + $scope.updatingTxHistory = false; + if (err) { + $scope.txHistory = null; + $scope.updateTxHistoryError = true; + return; + } + + applyCurrencyAliases(txHistory); + + var config = configService.getSync(); + var fiatCode = config.wallet.settings.alternativeIsoCode; + lodash.each(txHistory, function(t) { + var r = rateService.toFiat(t.amount, fiatCode, $scope.wallet.coin); + t.alternativeAmountStr = r.toFixed(2) + ' ' + fiatCode; + }); + + $scope.completeTxHistory = txHistory; + + $scope.showHistory(); + $timeout(function() { + $scope.$apply(); + }); + return cb(); + }); + }); + }; + function applyCurrencyAliases(txHistory) { var defaults = configService.getDefaults(); var configCache = configService.getSync(); - lodash.each(txHistory, function onTx(tx) { - tx.amountUnitStr = $scope.wallet.coin == 'btc' + lodash.each(txHistory, function(t) { + t.amountUnitStr = $scope.wallet.coin == 'btc' ? (configCache.bitcoinAlias || defaults.bitcoinAlias) : (configCache.bitcoinCashAlias || defaults.bitcoinCashAlias); - tx.amountUnitStr = tx.amountUnitStr.toUpperCase(); + t.amountUnitStr = t.amountUnitStr.toUpperCase(); }); } - function formatTxHistoryForDisplay(txHistory) { - applyCurrencyAliases(txHistory); - - var config = configService.getSync(); - var fiatCode = config.wallet.settings.alternativeIsoCode; - lodash.each(txHistory, function(t) { - var r = rateService.toFiat(t.amount, fiatCode, $scope.wallet.coin); - t.alternativeAmountStr = r.toFixed(2) + ' ' + fiatCode; - }); - } - - - function updateTxHistoryFromCachedData() { - $scope.vm.gettingCachedHistory = true; - walletHistoryService.getCachedTxHistory($scope.wallet.id, function onGetCachedTxHistory(err, txHistory){ - $scope.vm.gettingCachedHistory = false; - if (err) { - // Don't display an error because we are also requesting the history. - $log.error('Error getting cached tx history.', err); - return; - } - - if (!txHistory) { - $log.debug('No cached tx history.'); - return; - } - - formatTxHistoryForDisplay(txHistory); - - completeTxHistory = txHistory; - showHistory(false); - $scope.$apply(); - }); - } - - function fetchAndShowTxHistory(getLatest, flushCacheOnNew) { - $scope.vm.updatingTxHistory = true; - - walletHistoryService.updateLocalTxHistoryByPage($scope.wallet, getLatest, flushCacheOnNew, function onUpdateLocalTxHistoryByPage(err, txHistory, fetchedAllTransactions) { - $scope.vm.gettingInitialHistory = false; - $scope.vm.updatingTxHistory = false; - $scope.$broadcast('scroll.infiniteScrollComplete'); - - if (err) { - console.error('pagination Failed to get history.', err); - $scope.vm.updateTxHistoryFailed = true; - return; - } - - if (fetchedAllTransactions) { - $scope.vm.fetchedAllTxHistory = true; - } - - formatTxHistoryForDisplay(txHistory); - - completeTxHistory = txHistory; - showHistory(true); - $scope.$apply(); - }); - } - - - function showHistory(showAll) { - if (completeTxHistory) { - $scope.txHistory = showAll ? completeTxHistory : completeTxHistory.slice(0, (currentTxHistoryDisplayPage + 1) * DISPLAY_PAGE_SIZE); - $scope.vm.allowInfiniteScroll = !$scope.vm.fetchedAllTxHistory && !(completeTxHistory.length === $scope.txHistory.length && $scope.vm.gettingInitialHistory); - } else { - $scope.vm.allowInfiniteScroll = false; + $scope.showHistory = function() { + if ($scope.completeTxHistory) { + $scope.txHistory = $scope.completeTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT); + $scope.txHistoryShowMore = $scope.completeTxHistory.length > $scope.txHistory.length; } - } - + }; $scope.getDate = function(txCreated) { var date = new Date(txCreated * 1000); @@ -299,35 +256,24 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun return !tx.confirmations || tx.confirmations === 0; }; - // on-infinite="showMore()" $scope.showMore = function() { - // Check if we have more than we are displaying - if (completeTxHistory.length > $scope.txHistory.length) { - currentTxHistoryDisplayPage++; - showHistory(false); + $timeout(function() { + currentTxHistoryPage++; + $scope.showHistory(); $scope.$broadcast('scroll.infiniteScrollComplete'); - return; - } - - if ($scope.vm.updatingTxHistory) { - return; - } - - fetchAndShowTxHistory(false, false); + }, 100); }; - // on-refresh="onRefresh()" $scope.onRefresh = function() { $timeout(function() { $scope.$broadcast('scroll.refreshComplete'); }, 300); - $scope.updateAll(true, false); + $scope.updateAll(true); }; - $scope.updateAll = function(forceStatusUpdate, flushTxCacheOnNew)  { - updateStatus(forceStatusUpdate); - //updateTxHistory(cb); - fetchAndShowTxHistory(true, flushTxCacheOnNew); + $scope.updateAll = function(force, cb)  { + updateStatus(force); + updateTxHistory(cb); }; $scope.hideToggle = function() { @@ -337,36 +283,103 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun }; var prevPos; - $scope.txHistoryPaddingBottom = 0; + function getScrollPosition() { var scrollPosition = $ionicScrollDelegate.getScrollPosition(); - - $timeout(function() { - getScrollPosition(); - }, 200); - if (!scrollPosition) { + $window.requestAnimationFrame(function() { + getScrollPosition(); + }); return; } var pos = scrollPosition.top; - if (pos > 0) { - $scope.txHistoryPaddingBottom = "200px"; - } if (pos === prevPos) { + $window.requestAnimationFrame(function() { + getScrollPosition(); + }); return; } prevPos = pos; - $scope.scrollPosition = pos; + refreshAmountSection(pos); + }; + + function refreshAmountSection(scrollPos) { + var AMOUNT_HEIGHT_BASE = 210; + $scope.showBalanceButton = false; + if ($scope.status) { + $scope.showBalanceButton = ($scope.status.totalBalanceSat != $scope.status.spendableAmount); + if ($scope.showBalanceButton) { + AMOUNT_HEIGHT_BASE = 270; + } + } + if (!$scope.amountIsCollapsible) { + var t = ($scope.showBalanceButton ? 15 : 45); + $scope.amountScale = 'translateY(' + t + 'px)'; + return; + } + + scrollPos = scrollPos || 0; + var amountHeight = AMOUNT_HEIGHT_BASE - scrollPos; + if (amountHeight < 80) { + amountHeight = 80; + } + var contentMargin = amountHeight; + if (contentMargin > AMOUNT_HEIGHT_BASE) { + contentMargin = AMOUNT_HEIGHT_BASE; + } + + var amountScale = (amountHeight / AMOUNT_HEIGHT_BASE); + if (amountScale < 0.5) { + amountScale = 0.5; + } + if (amountScale > 1.1) { + amountScale = 1.1; + } + + var s = amountScale; + + // Make space for the balance button when it needs to display. + var TOP_NO_BALANCE_BUTTON = 115; + var TOP_BALANCE_BUTTON = 30; + var top = TOP_NO_BALANCE_BUTTON; + if ($scope.showBalanceButton) { + top = TOP_BALANCE_BUTTON; + } + + var amountTop = ((amountScale - 0.80) / 0.80) * top; + if (amountTop < -2) { + amountTop = -2; + } + if (amountTop > top) { + amountTop = top; + } + + var t = amountTop; + + $scope.altAmountOpacity = (amountHeight - 100) / 80; + $scope.buttonsOpacity = (amountHeight - 140) / 70; + $window.requestAnimationFrame(function() { + $scope.amountHeight = amountHeight + 'px'; + $scope.contentMargin = contentMargin + 'px'; + $scope.amountScale = 'scale3d(' + s + ',' + s + ',' + s + ') translateY(' + t + 'px)'; + $scope.$digest(); + getScrollPosition(); + }); } var scrollWatcherInitialized; $scope.$on("$ionicView.enter", function(event, data) { if ($scope.isCordova && $scope.isAndroid) setAndroidStatusBarColor(); + if (scrollWatcherInitialized || !$scope.amountIsCollapsible) { + return; + } scrollWatcherInitialized = true; }); $scope.$on("$ionicView.beforeEnter", function(event, data) { + sendFlowService.clear(); + configService.whenAvailable(function (config) { $scope.selectedPriceDisplay = config.wallet.settings.priceDisplay; @@ -380,7 +393,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun if (!$scope.wallet) return; $scope.requiresMultipleSignatures = $scope.wallet.credentials.m > 1; - $scope.vm.gettingInitialHistory = true; + $scope.updatingTxHistory = true; addressbookService.list(function(err, ab) { if (err) $log.error(err); @@ -390,25 +403,21 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun listeners = [ $rootScope.$on('bwsEvent', function(e, walletId) { if (walletId == $scope.wallet.id && e.type != 'NewAddress') - $scope.updateAll(false, false); + $scope.updateAll(); }), $rootScope.$on('Local/TxAction', function(e, walletId) { if (walletId == $scope.wallet.id) - $scope.updateAll(false, false); + $scope.updateAll(); }), ]; }); var refreshInterval; - $scope.$on("$ionicView.afterEnter", function onAfterEnter(event, data) { - updateTxHistoryFromCachedData(); - $scope.updateAll(true, true); - // refreshAmountSection(); + $scope.$on("$ionicView.afterEnter", function(event, data) { + $scope.updateAll(); + refreshAmountSection(); refreshInterval = $interval($scope.onRefresh, 10 * 1000); - $timeout(function() { - getScrollPosition(); - }, 1000); }); $scope.$on("$ionicView.afterLeave", function(event, data) { @@ -468,10 +477,16 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun } $scope.goToSend = function() { - sendFlowService.start({ + sendFlowService.startSend({ fromWalletId: $scope.wallet.id }); + // Go home first so that the Home tab works properly + $state.go('tabs.home').then(function () { + $ionicHistory.clearHistory(); + $state.go('tabs.send'); + }); + }; $scope.goToReceive = function() { $state.go('tabs.home', { diff --git a/src/js/controllers/walletSelectorController.js b/src/js/controllers/walletSelectorController.js new file mode 100644 index 000000000..777871e44 --- /dev/null +++ b/src/js/controllers/walletSelectorController.js @@ -0,0 +1,210 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('walletSelectorController', function($scope, $rootScope, $state, $log, $ionicHistory, sendFlowService, configService, gettextCatalog, profileService, txFormatService) { + + var fromWalletId = ''; + var priceDisplayAsFiat = false; + var unitDecimals = 0; + var unitsFromSatoshis = 0; + + $scope.$on("$ionicView.beforeEnter", onBeforeEnter); + $scope.$on("$ionicView.enter", onEnter); + + function onBeforeEnter(event, data) { + if (data.direction == "back") { + sendFlowService.popState(); + } + console.log('walletSelector onBeforeEnter after back sendflow', sendFlowService.state); + + $scope.params = sendFlowService.getStateClone(); + + var config = configService.getSync().wallet.settings; + priceDisplayAsFiat = config.priceDisplay === 'fiat'; + unitDecimals = config.unitDecimals; + unitsFromSatoshis = 1 / config.unitToSatoshi; + + switch($state.current.name) { + case 'tabs.send.wallet-to-wallet': + $scope.sendFlowTitle = gettextCatalog.getString('Transfer between wallets'); + break; + case 'tabs.send.destination': + if ($scope.params.fromWalletId && !$scope.params.thirdParty) { + $scope.sendFlowTitle = gettextCatalog.getString('Transfer between wallets'); + } + break; + default: + if (!$scope.params.thirdParty) { + $scope.sendFlowTitle = gettextCatalog.getString('Send'); + } + // nop + } + + $scope.coin = false; // Wallets to show (for destination screen or contacts) + $scope.type = $scope.params['fromWalletId'] ? 'destination' : 'origin'; // origin || destination + fromWalletId = $scope.params['fromWalletId']; + + if ($scope.type === 'destination' && $scope.params.toAddress) { + $state.transitionTo(getNextStep($scope.params)); + } + + if ($scope.params.coin) { + $scope.coin = $scope.params.coin; // Contacts have a coin embedded + } + + if ($scope.params.amount) { // There is an amount, so presume that it is a payment request + $scope.sendFlowTitle = gettextCatalog.getString('Payment Request'); + $scope.specificAmount = $scope.specificAlternativeAmount = ''; + $scope.isPaymentRequest = true; + } + if ($scope.params.thirdParty) { + $scope.thirdParty = $scope.params.thirdParty; + } + }; + + function onEnter (event, data) { + configService.whenAvailable(function(config) { + $scope.selectedPriceDisplay = config.wallet.settings.priceDisplay; + }); + + if ($scope.thirdParty) { + // Third party services specific logic + handleThirdPartyIfShapeshift(); + } + + prepareWalletLists(); + formatRequestedAmount(); + }; + + function formatRequestedAmount() { + if ($scope.params.amount) { + var cryptoAmount = (unitsFromSatoshis * $scope.params.amount).toFixed(unitDecimals); + var cryptoCoin = $scope.coin.toUpperCase(); + + txFormatService.formatAlternativeStr($scope.coin, $scope.params.amount, function onFormatAlternativeStr(formatted){ + if (formatted) { + var fiatParts = formatted.split(' '); + var fiatAmount = fiatParts[0]; + var fiatCurrrency = fiatParts.length > 1 ? fiatParts[1] : ''; + + if (priceDisplayAsFiat) { + $scope.requestAmount = fiatAmount; + $scope.requestCurrency = fiatCurrrency; + + $scope.requestAmountSecondary = cryptoAmount; + $scope.requestCurrencySecondary = cryptoCoin; + } else { + $scope.requestAmount = cryptoAmount; + $scope.requestCurrency = cryptoCoin; + + $scope.requestAmountSecondary = fiatAmount; + $scope.requestCurrencySecondary = fiatCurrrency; + } + } + }); + } + } + + function getNextStep(params) { + if (!params.toWalletId && !params.toAddress) { // If we have no toAddress or fromWallet + return 'tabs.send.destination'; + } else if (!params.amount) { // If we have no amount + return 'tabs.send.amount'; + } else { // If we do have them + return 'tabs.send.review'; + } + } + + function handleThirdPartyIfShapeshift() { + console.log($scope.thirdParty, $scope.coin); + if ($scope.thirdParty.id === 'shapeshift' && $scope.type === 'destination') { // Shapeshift wants to know the + $scope.coin = profileService.getWallet(fromWalletId).coin; + if ($scope.coin === 'bch') { + $scope.coin = 'btc'; + } else { + $scope.coin = 'bch'; + } + } + } + + function prepareWalletLists() { + var walletsAll = []; + var walletsSufficientFunds = []; + $scope.walletsInsufficientFunds = []; // For origin screen + + if ($scope.type === 'origin') { + $scope.headerTitle = gettextCatalog.getString('Choose a wallet to send from'); + + if ($scope.params.amount) { + + walletsAll = profileService.getWallets({coin: $scope.coin}); + + walletsAll.forEach(function forWallet(wallet){ + if (wallet.status.availableBalanceSat > $scope.params.amount) { + walletsSufficientFunds.push(wallet); + } else { + $scope.walletsInsufficientFunds.push(wallet); + } + }); + + if ($scope.coin === 'btc') { + $scope.walletsBtc = walletsSufficientFunds; + } else { + $scope.walletsBch = walletsSufficientFunds; + } + + } else if ($scope.coin) { + walletsAll = profileService.getWallets({coin: $scope.coin}); + walletsAll.forEach(function forWallet(wallet){ + if (wallet.status.availableBalanceSat > 0) { + walletsSufficientFunds.push(wallet); + } else { + $scope.walletsInsufficientFunds.push(wallet); + } + }); + + if ($scope.coin === 'btc') { + $scope.walletsBtc = walletsSufficientFunds; + } else { + $scope.walletsBch = walletsSufficientFunds; + } + } else { + $scope.walletsBch = profileService.getWallets({coin: 'bch', hasFunds: true}); + $scope.walletsBtc = profileService.getWallets({coin: 'btc', hasFunds: true}); + $scope.walletsInsufficientFunds = profileService.getWallets({coin: $scope.coin, hasNoFunds: true}); + } + + } else if ($scope.type === 'destination') { + if (!$scope.coin) { // Allow for the coin to be set by a third party + $scope.fromWallet = profileService.getWallet(fromWalletId); + $scope.coin = $scope.fromWallet.coin; // Only show wallets with the select origin wallet coin + } + $scope.headerTitle = gettextCatalog.getString('Choose a wallet to send to'); + + if ($scope.coin === 'btc') { // if no specific coin is set or coin is set btc + $scope.walletsBtc = profileService.getWallets({coin: $scope.coin}); + } else { + $scope.walletsBch = profileService.getWallets({coin: $scope.coin}); + } + } + } + + + + $scope.useWallet = function(wallet) { + var params = sendFlowService.getStateClone(); + if ($scope.type === 'origin') { // we're on the origin screen, set wallet to send from + params.fromWalletId = wallet.id; + } else { // we're on the destination screen, set wallet to send to + params.toWalletId = wallet.id; + } + sendFlowService.pushState(params); + var nextStep = getNextStep(params); + console.log('walletSelector nextStep', nextStep); + $state.transitionTo(nextStep, $scope.params); + }; + + $scope.goBack = function() { + $ionicHistory.goBack(); + } + +}); \ No newline at end of file diff --git a/src/js/directives/incomingDataMenu.js b/src/js/directives/incomingDataMenu.js index 78856e62f..21478102b 100644 --- a/src/js/directives/incomingDataMenu.js +++ b/src/js/directives/incomingDataMenu.js @@ -1,28 +1,23 @@ 'use strict'; angular.module('copayApp.directives') - .directive('incomingDataMenu', function($timeout, $rootScope, $state, externalLinkService, sendFlowService, bitcoinCashJsService) { + .directive('incomingDataMenu', function($timeout, $rootScope, $state, externalLinkService) { return { restrict: 'E', templateUrl: 'views/includes/incomingDataMenu.html', link: function(scope, element, attrs) { $rootScope.$on('incomingDataMenu.showMenu', function(event, data) { $timeout(function() { - scope.data = data; - - if (scope.data.parsed.privateKey) { - scope.type = "privateKey"; - } else if (scope.data.parsed.url) { - scope.type = "url"; - } else if (scope.data.parsed.publicAddress) { - scope.type = "bitcoinAddress"; - var prefix = scope.data.parsed.isTestnet ? 'bchtest:' : 'bitcoincash:'; - scope.data.toAddress = (prefix + scope.data.parsed.publicAddress.cashAddr) || scope.data.parsed.publicAddress.legacy || scope.data.parsed.publicAddress.bitpay; - } else { - scope.type = "text"; - } - + scope.data = data.data; + scope.type = data.type; scope.showMenu = true; + scope.https = false; + + if (scope.type === 'url') { + if (scope.data.indexOf('https://') === 0) { + scope.https = true; + } + } }); }); scope.hide = function() { @@ -33,9 +28,18 @@ angular.module('copayApp.directives') externalLinkService.open(url); }; scope.sendPaymentToAddress = function(bitcoinAddress) { + var noPrefixInAddress = 0; + if (bitcoinAddress.toLowerCase().indexOf('bitcoin') < 0) { + noPrefixInAddress = 1; + } scope.showMenu = false; - sendFlowService.start({ - data: bitcoinAddress + $state.go('tabs.send').then(function() { + $timeout(function() { + $state.transitionTo('tabs.send.amount', { + toAddress: bitcoinAddress, + noPrefix: noPrefixInAddress + }); + }, 50); }); }; scope.addToAddressBook = function(bitcoinAddress) { diff --git a/src/js/directives/shapeshiftCoinTrader.js b/src/js/directives/shapeshiftCoinTrader.js index 793f380fb..60cc66bdf 100644 --- a/src/js/directives/shapeshiftCoinTrader.js +++ b/src/js/directives/shapeshiftCoinTrader.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.directives').directive('shapeshiftCoinTrader', function($interval, shapeshiftApiService, profileService, incomingDataService, ongoingProcess) { +angular.module('copayApp.directives').directive('shapeshiftCoinTrader', function($interval, shapeshiftApiService, profileService, incomingData, ongoingProcess) { return { restrict: 'E', transclude: true, @@ -111,8 +111,7 @@ angular.module('copayApp.directives').directive('shapeshiftCoinTrader', function orderId: $scope.depositInfo.orderId }; - // How to handle this - if (incomingDataService.redir(sendAddress, 'shapeshift', shapeshiftData)) { + if (incomingData.redir(sendAddress, 'shapeshift', shapeshiftData)) { ongoingProcess.set('connectingShapeshift', false); return; } diff --git a/src/js/directives/slideToAccept.js b/src/js/directives/slideToAccept.js index 830bed677..3f4db0ef9 100644 --- a/src/js/directives/slideToAccept.js +++ b/src/js/directives/slideToAccept.js @@ -116,8 +116,7 @@ angular.module('copayApp.directives') function getTransformStyle(translatePct) { return { - 'transform': 'translateX(' + translatePct + '%)', - '-webkit-transform': 'translateX(' + translatePct + '%)' + 'transform': 'translateX(' + translatePct + '%)' }; } diff --git a/src/js/directives/wallet-balance.directive.js b/src/js/directives/walletBalanceDirective.js similarity index 81% rename from src/js/directives/wallet-balance.directive.js rename to src/js/directives/walletBalanceDirective.js index 4d8ca2875..1fea59203 100644 --- a/src/js/directives/wallet-balance.directive.js +++ b/src/js/directives/walletBalanceDirective.js @@ -12,7 +12,6 @@ totalBalanceSat: '@', // The Wallet object is sometimes not stringify()-able, so not interpolatable, // so can't be passed to a directive. - walletCoin: '@', walletStatus: '@', walletCachedBalance: '@', walletCachedBalanceUpdatedOn: '@', @@ -32,6 +31,7 @@ }); function displayCryptoBalance(walletStatus, walletCachedBalance, walletCachedBalanceUpdatedOn, walletCachedStatus) { + console.log('displayCryptoBalance()'); if (walletStatus && walletStatus.isValid && walletStatus.totalBalanceStr) { setDisplay(walletStatus.totalBalanceStr, ''); @@ -52,7 +52,7 @@ setDisplay('', ''); } - function displayFiatBalance(walletStatus, walletCachedStatus, walletCoin) { + function displayFiatBalance(walletStatus, walletCachedStatus) { var displayAmount = ''; if (walletStatus && walletStatus.isValid && walletStatus.alternativeBalanceAvailable) { displayAmount = walletStatus.totalBalanceAlternative + ' ' + walletStatus.alternativeIsoCode; @@ -66,7 +66,7 @@ return; } - getFiatBalance(walletStatus, walletCachedStatus, walletCoin); + getFiatBalance(wallet); } function formatBalance() { @@ -94,30 +94,19 @@ } if (displayAsFiat) { - displayFiatBalance(walletStatusObj, walletCachedStatusObj, $scope.walletCoin); + displayFiatBalance(walletStatusObj, walletCachedStatusObj); } } - function getFiatBalance(walletStatus, walletCachedStatus, walletCoin) { - var totalBalanceSat = null; - - if (walletStatus && walletStatus.isValid) { - totalBalanceSat = walletStatus.totalBalanceSat - } else if (walletCachedStatus && walletCachedStatus.isValid) { - totalBalanceSat = walletCachedStatus.totalBalanceSat - } - - // 0 is valid - if (totalBalanceSat === null) { - $log.warn('Abandoning call to get fiat balance, because no valid wallet status (cached or otherwise).'); + function getFiatBalance(wallet) { + if (!(wallet.status && wallet.status.isValid)) { + $log.warn('Abandoning call to get fiat balance, because no valid wallet status.'); return; } - txFormatService.formatAlternativeStr(walletCoin, totalBalanceSat, function onFormatAlernativeStr(formatted) { + txFormatService.formatAlternativeStr(wallet.coin, wallet.status.totalBalanceSat, function onFormatAlernativeStr(formatted) { if (formatted) { setDisplay(formatted, ''); - } else { - $log.error('Failed to format fiat balance of wallet.'); } }); } diff --git a/src/js/services/bitcoin-uri.service.js b/src/js/services/bitcoin-uri.service.js deleted file mode 100644 index 3da84f3da..000000000 --- a/src/js/services/bitcoin-uri.service.js +++ /dev/null @@ -1,416 +0,0 @@ -'use strict'; - -// https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki -// https://github.com/bitcoin/bips/blob/master/bip-0072.mediawiki - -(function(){ - - angular - .module('bitcoincom.services') - .factory('bitcoinUriService', bitcoinUriService); - - function bitcoinUriService(bitcoinCashJsService, bwcService, $log) { - var bch = bitcoinCashJsService.getBitcoinCashJs(); - var bitcore = bwcService.getBitcore(); - - var service = { - parse: parse - }; - - return service; - - function bitpayAddrOnMainnet(address) { - var Address = bch.Address; - var BitpayFormat = Address.BitpayFormat; - - var mainnet = bch.Networks.mainnet; - - var result = null; - if (address[0] == 'C') { - try { - result = Address.fromString(address, mainnet, 'pubkeyhash', BitpayFormat); - } catch (e) {}; - - } else if (address[0] == 'H') { - try { - result = Address.fromString(address, mainnet, 'scripthash', BitpayFormat); - } catch (e) {}; - - } - return result; - } - - function cashAddrOnMainnet(address) { - var Address = bch.Address; - var CashAddrFormat = Address.CashAddrFormat; - - var mainnet = bch.Networks.mainnet; - - var prefixed = 'bitcoincash:' + address; - var result = null; - if (address[0] == 'q') { - try { - result = Address.fromString(prefixed, mainnet, 'pubkeyhash', CashAddrFormat); - } catch (e) {}; - - } else if (address[0] == 'p') { - try { - result = Address.fromString(prefixed, mainnet, 'scripthash', CashAddrFormat); - } catch (e) {}; - - } - return result; - } - - function cashAddrOnTestnet(address) { - var Address = bch.Address; - var CashAddrFormat = Address.CashAddrFormat; - - var testnet = bch.Networks.testnet; - - var prefixed = 'bchtest:' + address; - var result = null; - if (address[0] == 'q') { - try { - result = Address.fromString(prefixed, testnet, 'pubkeyhash', CashAddrFormat); - } catch (e) {}; - - } else if (address[0] == 'p') { - try { - result = Address.fromString(prefixed, testnet, 'scripthash', CashAddrFormat); - } catch (e) {}; - - } - return result; - } - - function infoFromWalletImportText(data) { - var split = data.split('|'); - // Copay seems to use extra parameter for coin. - if (split.length < 5 || split.length > 6) { - return null; - } - - var type = parseInt(split[0], 10); - if (isNaN(type)) { - return null; - } - - var data = split[1]; - var network = split[2]; - if (!(network === 'livenet' || network === 'testnet')) { - return null; - } - var isTestnet = network === 'testnet'; - - var derivationPath = split[3]; - if (!/^m\/\d+'\/\d+'\/\d+'$/.test(derivationPath)) { - return null; - } - - var hasPassphraseText = split[4]; - if (!(hasPassphraseText === 'true' || hasPassphraseText === 'false')) { - return null; - } - var hasPassphrase = hasPassphraseText === 'true'; - - var coin; // Intentionally undefined as may not be present - if (split.length > 5) { - var coinText = split[5]; - if (!(coinText === 'bch' || coinText === 'btc')) { - return null; - } - coin = coinText; - } - - return { - type: type, - data: data, - isTestnet: isTestnet, - derivationPath: derivationPath, - hasPassphrase: hasPassphrase, - coin: coin - }; - } - - /* - For parsing: - BIP21 - BIP72 - - returns: - { - amount: '', - amountInSatoshis: 0, - bareUrl: '', - coin: '', - copayInvitation: '', - import: { // testnet info in root, coin info in root if available - data: '', - derivationPath: '', - hasPassphrase: false, - type: 1, - }, - isValid: false, - label: '', - message: '', - other: { - somethingIDontUnderstand: 'Its value' - }, - privateKey: { - encrypted: '', - wif: '' - }'', - publicAddress: { - bitpay: '', - cashAddr: '', - legacy: '', - }, - req: { - "req-param0": '', - "req-param1": '' - }, - testnet: false, - url: '' // For BIP70 - } - - Only fields that are present in the data are defined in the returned object. Both privateKey and publicAddress only have 1 field defined, if they exist at all. - The exception to this is the coin property, which is determined from other data, such as the prefix or address type. - - */ - - function parse(data) { - var parsed = { - isValid: false - }; - - if (typeof data !== 'string') { - return parsed; - } - - // Identify prefix - var trimmed = data.trim(); - var colonSplit = /^([\w-]*):?(.*)$/.exec(trimmed); - if (!colonSplit) { - return parsed; - } - - var addressAndParams = ''; - var preColonLower = colonSplit[1].toLowerCase(); - if (preColonLower === 'bitcoin') { - parsed.coin = 'btc'; - addressAndParams = colonSplit[2].trim(); - console.log('Is btc'); - - } else if (/^(?:bitcoincash)|(?:bitcoin-cash)$/.test(preColonLower)) { - parsed.coin = 'bch'; - parsed.test = false; - addressAndParams = colonSplit[2].trim(); - console.log('Is bch'); - - } else if (/^(?:bchtest)$/.test(preColonLower)) { - parsed.coin = 'bch'; - parsed.isTestnet = true; - addressAndParams = colonSplit[2].trim(); - console.log('Is bch'); - - } else if (colonSplit[2] === '') { - // No colon and no coin specifier. - addressAndParams = colonSplit[1].trim(); - console.log('No prefix.'); - - } else if (/^https?$/.test(colonSplit[1])) { // Plain URL - addressAndParams = trimmed; - - } else if (colonSplit[2].indexOf('|') == 0) { // Import - addressAndParams = trimmed - } else { - // Something we don't recognise - return parsed; - } - - // Remove erroneous leading slashes - //var leadingSlashes = /^\/*([^\/]+(?:.*))$/.exec(addressAndParams); - var leadingSlashes = /^\/*(.*)$/.exec(addressAndParams); - if (!leadingSlashes) { - return parsed; - } - addressAndParams = leadingSlashes[1]; - - var questionMarkSplit = /^([^\?]*)\??([^\?]*)$/.exec(addressAndParams); - if (!questionMarkSplit) { - return parsed; - } - - var address = questionMarkSplit[1]; - var params = questionMarkSplit[2]; - - if (params.length > 0) { - var paramsSplit = params.split('&'); - var others; - var req; - var paramCount = paramsSplit.length; - for(var i = 0; i < paramCount; i++) { - var param = paramsSplit[i]; - var valueSplit = param.split('='); - if (valueSplit.length !== 2) { - return parsed; - } - - var key = valueSplit[0]; - var value = valueSplit[1]; - var decodedValue = decodeURIComponent(value); - switch(key) { - case 'amount': - var amount = parseFloat(decodedValue); - if (amount) { // Checking for NaN, or no numbers at all etc. & convert to satoshi - parsed.amount = decodedValue; // Need to check if a currency is precised - parsed.amountInSatoshis = amount * 100000000 - } else { - return parsed; - } - break; - - case 'label': - parsed.label = decodedValue; - break; - - case 'message': - parsed.message = decodedValue; - break; - - case 'r': - // Could use a more comprehesive regex to test URL validity, but then how would we know - // which part of the validation it failed? - if (decodedValue.startsWith('https://')) { - parsed.url = decodedValue; - } else { - return parsed; - } - break; - - default: - if (key.startsWith('req-')) { - req = req || {}; - req[key] = decodedValue; - } else { - others = others || {}; - others[key] = decodedValue; - } - } - - }; - } - - parsed.others = others; - parsed.req = req; - - - if (address) { - var addressLowerCase = address.toLowerCase(); - var copayInvitationRe = /^[0-9A-HJ-NP-Za-km-z]{70,80}$/; - //var legacyRe = /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/; - //var legacyTestnetRe = /^[mn][a-km-zA-HJ-NP-Z1-9]{25,34}$/; - var privateKeyEncryptedRe = /^6P[1-9A-HJ-NP-Za-km-z]{56}$/; - var privateKeyForUncompressedPublicKeyRe = /^5[1-9A-HJ-NP-Za-km-z]{50}$/; - var privateKeyForUncompressedPublicKeyTestnetRe = /^9[1-9A-HJ-NP-Za-km-z]{50}$/; - var privateKeyForCompressedPublicKeyRe = /^[KL][1-9A-HJ-NP-Za-km-z]{51}$/; - var privateKeyForCompressedPublicKeyTestnetRe = /^[c][1-9A-HJ-NP-Za-km-z]{51}$/; - var urlRe = /^https?:\/\/.+/; - - var bitpayAddrMainnet = bitpayAddrOnMainnet(address); - var cashAddrTestnet = cashAddrOnTestnet(addressLowerCase); - var cashAddrMainnet = cashAddrOnMainnet(addressLowerCase); - var importInfo = infoFromWalletImportText(address); - var privateKey = ''; - - if (parsed.isTestnet && cashAddrTestnet) { - parsed.address = addressLowerCase; - parsed.coin = 'bch'; - parsed.publicAddress = { - cashAddr: addressLowerCase - }; - parsed.isValid = true; - - } else if (cashAddrMainnet) { - parsed.coin = 'bch'; - parsed.publicAddress = { - cashAddr: addressLowerCase - }; - parsed.isTestnet = false; - parsed.isValid = true; - - } else if (bitcore.Address.isValid(address, 'livenet')) { - parsed.publicAddress = { - legacy: address - }; - parsed.isTestnet = false; - parsed.isValid = true; - - } else if (bitcore.Address.isValid(address, 'testnet')) { - parsed.publicAddress = { - legacy: address - }; - parsed.isTestnet = true; - parsed.isValid = true; - - } else if (bitpayAddrMainnet) { - parsed.coin = 'bch'; - parsed.publicAddress = { - bitpay: address - }; - parsed.isTestnet = false; - parsed.isValid = true; - - } else if (copayInvitationRe.test(address) ) { - parsed.copayInvitation = address; - parsed.isValid = true; - - } else if (privateKeyForUncompressedPublicKeyRe.test(address) || privateKeyForCompressedPublicKeyRe.test(address)) { - privateKey = address; - try { - new bitcore.PrivateKey(privateKey, 'livenet'); - parsed.privateKey = { wif: privateKey }; - parsed.isTestnet = false; - parsed.isValid = true; - } catch (e) {} - - } else if (privateKeyForUncompressedPublicKeyTestnetRe.test(address) || privateKeyForCompressedPublicKeyTestnetRe.test(address)) { - privateKey = address; - try { - new bitcore.PrivateKey(privateKey, 'testnet'); - parsed.privateKey = { wif: privateKey }; - parsed.isTestnet = true; - parsed.isValid = true; - } catch (e) {} - - } else if (privateKeyEncryptedRe.test(address)) { - parsed.privateKey = { encrypted: address }; - parsed.isValid = true; - - } else if (urlRe.test(address)) { - parsed.bareUrl = trimmed; - parsed.isValid = true; - - } else if (importInfo) { - parsed.import = { - type: importInfo.type, - data: importInfo.data, - derivationPath: importInfo.derivationPath, - hasPassphrase: importInfo.hasPassphrase - }; - parsed.coin = importInfo.coin; - parsed.isTestnet = importInfo.isTestnet; - parsed.isValid = true; - } - - } else { - parsed.isValid = !!parsed.url; // BIP72 - } - - return parsed; - } - - } - -})(); diff --git a/src/js/services/bitcoin-uri.service.spec.js b/src/js/services/bitcoin-uri.service.spec.js deleted file mode 100644 index 2ddbd0d2e..000000000 --- a/src/js/services/bitcoin-uri.service.spec.js +++ /dev/null @@ -1,429 +0,0 @@ -describe('bitcoinUriService', function() { - var bitcoinUriService; - - beforeEach(function() { - module('bitcoinCashJsModule'); - module('bitcoincom.services'); - module('bwcModule'); - - inject(function($injector){ - bitcoinUriService = $injector.get('bitcoinUriService'); - }); - }); - - - it('Bitcoin BIP72', function() { - - var parsed = bitcoinUriService.parse('bitcoin:?r=https://bitpay.com/i/CwzbKP3k3JNgXJBfuoerDr'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('btc'); - expect(parsed.isTestnet).toBeUndefined(); - expect(parsed.publicAddress).toBeUndefined(); - expect(parsed.url).toBe('https://bitpay.com/i/CwzbKP3k3JNgXJBfuoerDr'); - }); - - it('Bitcoin Cash BIP72', function() { - - var parsed = bitcoinUriService.parse('bitcoincash:?r=https://bitpay.com/i/SmHdie5dvBnG5kouZzEPzu'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress).toBeUndefined(); - expect(parsed.isTestnet).toBeUndefined(); - expect(parsed.url).toBe('https://bitpay.com/i/SmHdie5dvBnG5kouZzEPzu'); - }); - - it('Bitcoin Cash prefix with legacy address', function() { - - var parsed = bitcoinUriService.parse('bitcoincash:1G9FA9fFnHfTYxvmXeAbBD9FwzPAVMbd3j'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.legacy).toBe('1G9FA9fFnHfTYxvmXeAbBD9FwzPAVMbd3j'); - expect(parsed.isTestnet).toBe(false); - }); - - it('Bitcoin Cash prefix with legacy address on testnet', function() { - - var parsed = bitcoinUriService.parse('bitcoincash:mkDQrKfSFD441JxrD1iPBsJFExgkvrPGQn'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.legacy).toBe('mkDQrKfSFD441JxrD1iPBsJFExgkvrPGQn'); - expect(parsed.isTestnet).toBe(true); - }); - - it('Bitcoin Cash uri with extended params', function() { - - var parsed = bitcoinUriService.parse('bitcoincash:qr8v2vqnzntykakht43rqmxq8cdjzjp795fc3vsjgc?unknown=something&mystery=Melton%20probang&req-one=ichi&req-beta=Ni%20san'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.others.mystery).toBe('Melton probang'); - expect(parsed.others.unknown).toBe('something'); - expect(parsed.publicAddress.cashAddr).toBe('qr8v2vqnzntykakht43rqmxq8cdjzjp795fc3vsjgc'); - expect(parsed.req['req-beta']).toBe('Ni san'); - expect(parsed.req['req-one']).toBe('ichi'); - expect(parsed.isTestnet).toBe(false); - }); - - it('Bitcoin Cash uri with invalid amount', function() { - - var parsed = bitcoinUriService.parse('bitcoincash:qq0knhwj4d5zy3kdph24w6etq58vwzua6sm7lhcmuk?amount=three'); - - expect(parsed.isValid).toBe(false); - }); - - - it('Bitcoin testnet address', function() { - - var parsed = bitcoinUriService.parse('mtWcoToWhbtPoCby5fvs8xdBujT5GGenD4'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBeUndefined(); - expect(parsed.publicAddress.legacy).toBe('mtWcoToWhbtPoCby5fvs8xdBujT5GGenD4'); - expect(parsed.isTestnet).toBe(true); - }); - - it('Bitcoin uri', function() { - - var parsed = bitcoinUriService.parse('bitcoin:15yCdKWVKRvfXMJpPYZBqMhiGKwjKzZdLN'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('btc'); - expect(parsed.publicAddress.legacy).toBe('15yCdKWVKRvfXMJpPYZBqMhiGKwjKzZdLN'); - expect(parsed.isTestnet).toBe(false); - }); - - it('Bitcoin uri with encoded label', function() { - - var parsed = bitcoinUriService.parse('bitcoin:1MxudKDEBWZ1yjizUSf6htacenNtb3DWbT?label=Mr.%20Smith'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('btc'); - expect(parsed.label).toBe('Mr. Smith'); - expect(parsed.publicAddress.legacy).toBe('1MxudKDEBWZ1yjizUSf6htacenNtb3DWbT'); - expect(parsed.isTestnet).toBe(false); - }); - - it('Bitcoin uri with params', function() { - - var parsed = bitcoinUriService.parse('bitcoin:12nCRhMDfxVnuF3uYMXv2fNxBohNmacfWu?amount=20.3&label=Luke-Jr&message=Donation%20for%20project%20xyz'); - - expect(parsed.isValid).toBe(true); - expect(parsed.amount).toBe('20.3'); - expect(parsed.amountInSatoshis).toBe(2030000000); - expect(parsed.coin).toBe('btc'); - expect(parsed.label).toBe('Luke-Jr'); - expect(parsed.publicAddress.legacy).toBe('12nCRhMDfxVnuF3uYMXv2fNxBohNmacfWu'); - expect(parsed.message).toBe('Donation for project xyz'); - expect(parsed.isTestnet).toBe(false); - }); - - it('Bitcoin uri with slash', function() { - - var parsed = bitcoinUriService.parse('bitcoin:/1GhpYmbRaf73AZRxDwAGr6653iZBGzdgeA'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('btc'); - expect(parsed.publicAddress.legacy).toBe('1GhpYmbRaf73AZRxDwAGr6653iZBGzdgeA'); - expect(parsed.isTestnet).toBe(false); - }); - - it('Bitcoin uri with slashes', function() { - - var parsed = bitcoinUriService.parse('bitcoin://18PCPhgZJjLxe9g3Q1BXLpL5aVut1fW3aX'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('btc'); - expect(parsed.publicAddress.legacy).toBe('18PCPhgZJjLxe9g3Q1BXLpL5aVut1fW3aX'); - expect(parsed.isTestnet).toBe(false); - }); - - it('Bitcoin uri with space', function() { - - var parsed = bitcoinUriService.parse('bitcoin: 19cPoKU5ZazY8NkLEsxK7drBqJnpGkax3d'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('btc'); - expect(parsed.publicAddress.legacy).toBe('19cPoKU5ZazY8NkLEsxK7drBqJnpGkax3d'); - expect(parsed.isTestnet).toBe(false); - }); - - it('Bitpay without prefix', function() { - - var parsed = bitcoinUriService.parse('CJoRov8TirekvajiimQpb5Hk95evA7H2Yz'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.bitpay).toBe('CJoRov8TirekvajiimQpb5Hk95evA7H2Yz'); - expect(parsed.isTestnet).toBe(false); - }); - - it('legacy address', function() { - - var parsed = bitcoinUriService.parse('1JXeGEu7bNEAYu6URT6dU6g1Ys6ffSAWYW'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBeUndefined(); - expect(parsed.publicAddress.legacy).toBe('1JXeGEu7bNEAYu6URT6dU6g1Ys6ffSAWYW'); - expect(parsed.isTestnet).toBe(false); - }); - - it('cashAddr testnet with prefix', function() { - - var parsed = bitcoinUriService.parse('bchtest:qpcz6pmurq9ctg5848trzz9zmuuygj4q5qam7ph3gt'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qpcz6pmurq9ctg5848trzz9zmuuygj4q5qam7ph3gt'); - expect(parsed.isTestnet).toBe(true); - }); - - it('cashAddr uppercase', function() { - - var parsed = bitcoinUriService.parse('BITCOINCASH:QZZG9NMC5VX8GAP6XFATX3TWNSDN2YRMCSSULSMY44'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qzzg9nmc5vx8gap6xfatx3twnsdn2yrmcssulsmy44'); - expect(parsed.isTestnet).toBe(false); - }); - - it('cashAddr with dash', function() { - - var parsed = bitcoinUriService.parse('bitcoin-cash:qpshfu3dk5s3e7zdcgdcun6xgxtra6uyxs7g580js0'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qpshfu3dk5s3e7zdcgdcun6xgxtra6uyxs7g580js0'); - expect(parsed.isTestnet).toBe(false); - }); - - it('cashAddr with prefix', function() { - - var parsed = bitcoinUriService.parse('bitcoincash:qrq9p82a247lecv08ldk5p5h6ahtnjzpqcnh8yhq92'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qrq9p82a247lecv08ldk5p5h6ahtnjzpqcnh8yhq92'); - expect(parsed.isTestnet).toBe(false); - }); - - it('cashAddr with slash', function() { - - var parsed = bitcoinUriService.parse('bitcoincash:/qzdectfmuw0xxztfx7mh045830dqcshj85hr44l35a'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qzdectfmuw0xxztfx7mh045830dqcshj85hr44l35a'); - expect(parsed.isTestnet).toBe(false); - }); - - it('cashAddr with slashes', function() { - - var parsed = bitcoinUriService.parse('bitcoincash://qpj966w8utue75lqqq3rlgh20zkz3rmydqpq8syv9c'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qpj966w8utue75lqqq3rlgh20zkz3rmydqpq8syv9c'); - expect(parsed.isTestnet).toBe(false); - }); - - it('cashAddr with space', function() { - - var parsed = bitcoinUriService.parse('bitcoincash: qpar9ldle8z6alcwgclejdhc24ha2xrg0szs5802ce'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qpar9ldle8z6alcwgclejdhc24ha2xrg0szs5802ce'); - expect(parsed.isTestnet).toBe(false); - }); - - - it('cashAddr with space on testnet', function() { - - var parsed = bitcoinUriService.parse('bchtest: qqjxkmtaxk4nv6w9h5ht2fjcj9c7ruh0fu7cnxsx5j'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qqjxkmtaxk4nv6w9h5ht2fjcj9c7ruh0fu7cnxsx5j'); - expect(parsed.isTestnet).toBe(true); - }); - - it('cashAddr without prefix', function() { - - var parsed = bitcoinUriService.parse('qqen2y3l28dpk0dzsag8w027ds96u7z4pc0uxtl0nq'); - - expect(parsed.isValid).toBe(true); - expect(parsed.coin).toBe('bch'); - expect(parsed.publicAddress.cashAddr).toBe('qqen2y3l28dpk0dzsag8w027ds96u7z4pc0uxtl0nq'); - expect(parsed.isTestnet).toBe(false); - }); - - it('copay invitation', function() { - - var parsed = bitcoinUriService.parse('PD5B7rEEj72st9d5nFszyuKxJP6FAGS7idVC2SMqiMxUcWVd8JifZDJw1UgjUctxefUFE3Sz6qLbch'); - - expect(parsed.isValid).toBe(true); - expect(parsed.copayInvitation).toBe('PD5B7rEEj72st9d5nFszyuKxJP6FAGS7idVC2SMqiMxUcWVd8JifZDJw1UgjUctxefUFE3Sz6qLbch'); - }); - - - it ('import BCH wallet no password', function() { - var parsed = bitcoinUriService.parse("1|suggest route obvious broccoli good position hidden tone history around final lobster|livenet|m/44'/0'/0'|false"); - - expect(parsed.isValid).toBe(true); - expect(parsed.import.type).toBe(1); - expect(parsed.import.data).toBe('suggest route obvious broccoli good position hidden tone history around final lobster'); - expect(parsed.isTestnet).toBe(false); - expect(parsed.import.derivationPath).toBe("m/44'/0'/0'"); - expect(parsed.import.hasPassphrase).toBe(false); - }); - - it ('import BCH wallet with passphrase', function() { - var parsed = bitcoinUriService.parse("1|fringe hazard all hobby trap myth fire stand sock empty soon east|livenet|m/44'/0'/0'|true"); - - expect(parsed.isValid).toBe(true); - expect(parsed.import.type).toBe(1); - expect(parsed.import.data).toBe('fringe hazard all hobby trap myth fire stand sock empty soon east'); - expect(parsed.isTestnet).toBe(false); - expect(parsed.import.derivationPath).toBe("m/44'/0'/0'"); - expect(parsed.import.hasPassphrase).toBe(true); - }); - - it ('import BTC wallet testnet', function() { - // From copay - var parsed = bitcoinUriService.parse("1|cat wealth column firm wet sauce tornado era feature monster click eyebrow|testnet|m/44'/1'/0'|false|btc"); - - expect(parsed.isValid).toBe(true); - expect(parsed.import.type).toBe(1); - expect(parsed.import.data).toBe('cat wealth column firm wet sauce tornado era feature monster click eyebrow'); - expect(parsed.isTestnet).toBe(true); - expect(parsed.import.derivationPath).toBe("m/44'/1'/0'"); - expect(parsed.import.hasPassphrase).toBe(false); - }); - - // Invalid addresses from https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md - it('invalid cashAddr style 1', function() { - var parsed = bitcoinUriService.parse('prefix:x64nx6hz'); - expect(parsed.isValid).toBe(false); - }); - - it('invalid cashAddr style 2', function() { - var parsed = bitcoinUriService.parse('p:gpf8m4h7'); - expect(parsed.isValid).toBe(false); - }); - - it('invalid cashAddr style 3', function() { - var parsed = bitcoinUriService.parse('bitcoincash:qpzry9x8gf2tvdw0s3jn54khce6mua7lcw20ayyn'); - expect(parsed.isValid).toBe(false); - }); - - it('invalid cashAddr style 4', function() { - var parsed = bitcoinUriService.parse('bchtest:testnetaddress4d6njnut'); - expect(parsed.isValid).toBe(false); - }); - - it('invalid cashAddr style 5', function() { - var parsed = bitcoinUriService.parse('bchreg:555555555555555555555555555555555555555555555udxmlmrz'); - expect(parsed.isValid).toBe(false); - }); - - it('non-string', function() { - - var parsed = bitcoinUriService.parse([1, 2, 3, 4]); - - expect(parsed.isValid).toBe(false); - }); - - it('private key encrypted with BIP38', function() { - - var parsed = bitcoinUriService.parse('6PRN5nEDmX842gsBzJryPu8Tw5kcsaQq1GPLcjVQPcEStvbFAtz11JX9pX'); - - expect(parsed.isValid).toBe(true); - expect(parsed.privateKey.encrypted).toBe('6PRN5nEDmX842gsBzJryPu8Tw5kcsaQq1GPLcjVQPcEStvbFAtz11JX9pX'); - }); - - it('private key for compressed pubkey mainnet', function() { - - var parsed = bitcoinUriService.parse('5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ'); - - expect(parsed.isValid).toBe(true); - expect(parsed.privateKey.wif).toBe('5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ'); - expect(parsed.isTestnet).toBe(false); - }); - - it('private key for compressed pubkey mainnet with wrong checksum', function() { - - var parsed = bitcoinUriService.parse('5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTu'); - - expect(parsed.isValid).toBe(false); - }); - - it('private key for compressed pubkey testnet', function() { - - var parsed = bitcoinUriService.parse('cNJFgo1driFnPcBdBX8BrJrpxchBWXwXCvNH5SoSkdcF6JXXwHMm'); - - expect(parsed.isValid).toBe(true); - expect(parsed.privateKey.wif).toBe('cNJFgo1driFnPcBdBX8BrJrpxchBWXwXCvNH5SoSkdcF6JXXwHMm'); - expect(parsed.isTestnet).toBe(true); - }); - - it('private key for compressed pubkey testnet with wrong checksum', function() { - - var parsed = bitcoinUriService.parse('cNJFgo1driFnPcBdBX8BrJrpxchBWXwXCvNH5SoSkdcF6JXXwHMM'); - - expect(parsed.isValid).toBe(false); - }); - - it('private key for uncompressed pubkey mainnet', function() { - - var parsed = bitcoinUriService.parse('L18V3rAhCKEioPnJ4BHLCCsaYa8eSNFrMjNQ2EdwgeAdmBSnTMwx'); - - expect(parsed.isValid).toBe(true); - expect(parsed.privateKey.wif).toBe('L18V3rAhCKEioPnJ4BHLCCsaYa8eSNFrMjNQ2EdwgeAdmBSnTMwx'); - expect(parsed.isTestnet).toBe(false); - }); - - it('private key for uncompressed pubkey mainnet with wrong checksum', function() { - - var parsed = bitcoinUriService.parse('L18V3rAhCKEioPnJ4BHLCCsaYa8eSNFrMjNQ2EdwgeAdmBSnTTwx'); - - expect(parsed.isValid).toBe(false); - }); - - it('private key for uncompressed pubkey testnet', function() { - - var parsed = bitcoinUriService.parse('92Pg46rUhgTT7romnV7iGW6W1gbGdeezqdbJCzShkCsYNzyyNcc'); - - expect(parsed.isValid).toBe(true); - expect(parsed.privateKey.wif).toBe('92Pg46rUhgTT7romnV7iGW6W1gbGdeezqdbJCzShkCsYNzyyNcc'); - expect(parsed.isTestnet).toBe(true); - }); - - it('private key for uncompressed pubkey testnet with wrong checksum', function() { - - var parsed = bitcoinUriService.parse('92Pg46rUhgTT7romnV7iGW6W1gbGdeezqdbJCzShkCsYNzyyNcC'); - - expect(parsed.isValid).toBe(false); - }); - - it('URL only, http', function() { - - var parsed = bitcoinUriService.parse('http://paperwallet.bitcoin.com'); - - expect(parsed.isValid).toBe(true); - expect(parsed.bareUrl).toBe('http://paperwallet.bitcoin.com'); - }); - - it('URL only, https with query', function() { - - var parsed = bitcoinUriService.parse('https://purse.io/?one=two&three=four'); - - expect(parsed.isValid).toBe(true); - expect(parsed.bareUrl).toBe('https://purse.io/?one=two&three=four'); - }); - -}); \ No newline at end of file diff --git a/src/js/services/bitcoincomService.js b/src/js/services/bitcoincomService.js index 62a75b4d1..68fd51a8a 100644 --- a/src/js/services/bitcoincomService.js +++ b/src/js/services/bitcoincomService.js @@ -85,9 +85,7 @@ angular.module('copayApp.services').factory('bitcoincomService', function(gettex }; var register = function() { - if (!platformInfo.isAndroid) { // To comply with Google Play policies - nextStepsService.register(cashGamesItem); - } + nextStepsService.register(cashGamesItem); nextStepsService.register(newsItem); nextStepsService.register(poolItem); nextStepsService.register(toolsItem); diff --git a/src/js/services/configService.js b/src/js/services/configService.js index 6f2c0ec67..72cc4825f 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -18,7 +18,7 @@ angular.module('copayApp.services').factory('configService', function(storageSer }, bwscash: { - url: 'https://bws.freepages.dk/bws/api' + url: 'https://bwscash.bitcoin.com/bws/api' }, download: { diff --git a/src/js/services/feeService.js b/src/js/services/feeService.js index 5189527b2..bba972b81 100644 --- a/src/js/services/feeService.js +++ b/src/js/services/feeService.js @@ -12,7 +12,6 @@ angular.module('copayApp.services').factory('feeService', function($log, $timeou normal: gettext('Normal'), economy: gettext('Economy'), superEconomy: gettext('Super Economy'), -// free: gettext('No fee (works only for BCH)'), custom: gettext('Custom') }; @@ -32,7 +31,6 @@ angular.module('copayApp.services').factory('feeService', function($log, $timeou root.getFeeRate = function(coin, network, feeLevel, cb) { if (feeLevel == 'custom') return cb(); -// if (feeLevel == 'free') return cb(null, 0); network = network || 'livenet'; @@ -50,8 +48,8 @@ angular.module('copayApp.services').factory('feeService', function($log, $timeou }) }); } - var feeRate = feeLevelRate.feePerKb; + var feeRate = feeLevelRate.feePerKb; if (!fromCache) $log.debug('Dynamic fee: ' + feeLevel + '/' + network + ' ' + (feeLevelRate.feePerKb / 1000).toFixed() + ' SAT/B'); diff --git a/src/js/services/incoming-data.service.js b/src/js/services/incoming-data.service.js deleted file mode 100644 index eece6d17c..000000000 --- a/src/js/services/incoming-data.service.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -/** - * incomingDataService is an intermediate to redirect either to the sendFlow - * or to import/join a wallet. - */ -angular.module('copayApp.services').factory('incomingDataService', function(bitcoinUriService, $log, $state, $rootScope, scannerService, sendFlowService, gettextCatalog) { - - var root = {}; - - root.showMenu = function(data) { - $rootScope.$broadcast('incomingDataMenu.showMenu', data); - }; - - root.redir = function(data, cbError) { - var parsed = bitcoinUriService.parse(data); - - console.log(parsed); - $log.debug(parsed); - - - if (parsed.isValid) { - if (parsed.isTestnet) { - if (cbError) { - var errorMessage = gettextCatalog.getString('Testnet is not supported.'); - cbError(new Error(errorMessage)); - } - } else { - scannerService.pausePreview(); - - /** - * Strategy for the action - */ - if (parsed.copayInvitation) { - $state.go('tabs.home').then(function() { - $state.transitionTo('tabs.add.join', { - url: data - }); - }); - } else if (parsed.import) { - $state.go('tabs.home').then(function() { - $state.transitionTo('tabs.add.import', { - code: data - }); - }); - } else if ( - !parsed.isValid - || parsed.privateKey - || (sendFlowService.state.isEmpty() && !parsed.url && !parsed.amount) - ) { - root.showMenu({ - original: data, - parsed: parsed - }); - } else { - var state = sendFlowService.state.getClone(); - state.data = data; - - sendFlowService.start(state, function onError(err) { - /** - * OnError, open the menu (link not validated) - */ - root.showMenu({ - original: data, - parsed: parsed - }); - }); - } - } - } else { - if (cbError) { - var errorMessage = gettextCatalog.getString('Data not recognised.'); - cbError(new Error(errorMessage)); - } - } - }; - - return root; -}); diff --git a/src/js/services/incomingData.js b/src/js/services/incomingData.js new file mode 100644 index 000000000..0bf708d8a --- /dev/null +++ b/src/js/services/incomingData.js @@ -0,0 +1,475 @@ +'use strict'; + +angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, bitcoreCash, $rootScope, payproService, scannerService, sendFlowService, appConfigService, popupService, gettextCatalog, bitcoinCashJsService) { + + var root = {}; + + root.showMenu = function(data) { + $rootScope.$broadcast('incomingDataMenu.showMenu', data); + }; + + root.redir = function(data, serviceId, serviceData) { + var originalAddress = null; + var noPrefixInAddress = 0; + + if (data.toLowerCase().indexOf('bitcoin') < 0) { + noPrefixInAddress = 1; + } + + if (typeof(data) == 'string' && !(/^bitcoin(cash)?:\?r=[\w+]/).exec(data) && (data.toLowerCase().indexOf('bitcoincash:') >= 0 || data[0] == 'q' || data[0] == 'p' || data[0] == 'C' || data[0] == 'H')) { + try { + noPrefixInAddress = 0; + + if (data[0] == 'p' || data[0] == 'q') { + data = 'bitcoincash:' + data; + } + var paramString = ''; + if (data.indexOf('?') >= 0) { + paramString = data.substring(data.indexOf('?')); + data = data.substring(0, data.indexOf('?')); + } + + if (data.indexOf('BITCOINCASH:') >= 0) { + data = data.toLowerCase(); + } + originalAddress = data.replace('bitcoincash:', ''); + var legacyAddress = bitcoinCashJsService.readAddress(data).legacy; + data = 'bitcoincash:' + legacyAddress + paramString; + } catch (ex) {} + } + + $log.debug('Processing incoming data: ' + data); + + function sanitizeUri(data) { + // Fixes when a region uses comma to separate decimals + var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i; + var match = regex.exec(data); + if (!match || match.length === 0) { + return data; + } + var value = match[0].replace(',', '.'); + var newUri = data.replace(regex, value); + + // mobile devices, uris like copay://glidera + newUri.replace('://', ':'); + + return newUri; + } + + function getParameterByName(name, url) { + if (!url) return; + name = name.replace(/[\[\]]/g, "\\$&"); + var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, " ")); + } + + function checkPrivateKey(privateKey) { + try { + new bitcore.PrivateKey(privateKey, 'livenet'); + } catch (err) { + return false; + } + return true; + } + + function goSend(addr, amount, message, coin, serviceId, serviceData) { + $state.go('tabs.send', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.send' ? false : true + }); + // Timeout is required to enable the "Back" button + $timeout(function() { + var params = sendFlowService.getStateClone(); + + if (amount) { + params.amount = amount; + } + + if (addr) { + params.toAddress = addr; + params.displayAddress = originalAddress ? originalAddress : addr; + } + + if (coin) { + params.coin = coin; + } + + if (noPrefixInAddress) { + params.noPrefixInAddress = noPrefixInAddress; + } + + if (serviceId) { + params.thirdParty = []; + params.thirdParty.id = serviceId; + params.thirdParty.data = serviceData; + sendFlowService.pushState(params); + $state.transitionTo('tabs.send.amount'); + } else { + sendFlowService.pushState(params); + $state.transitionTo('tabs.send.origin'); + } + }, 100); + } + // data extensions for Payment Protocol with non-backwards-compatible request + if ((/^bitcoin(cash)?:\?r=[\w+]/).exec(data)) { + var coin = data.indexOf('bitcoincash') >= 0 ? 'bch' : 'btc'; + data = decodeURIComponent(data.replace(/bitcoin(cash)?:\?r=/, '')); + if (coin == 'bch') { + payproService.getPayProDetailsViaHttp(data, function onGetPayProDetailsViaHttp(err, details) { + if (err) { + var message = err.toString(); + if (typeof err.data === 'string') { + // i.e. 'This invoice is no longer accepting payments' + message = gettextCatalog.getString(err.data); + } + popupService.showAlert(gettextCatalog.getString('Error'), message) + } else { + handlePayPro(details, coin); + } + }); + } else { + payproService.getPayProDetails(data, coin, function onGetPayProDetails(err, details) { + if (err) { + popupService.showAlert(gettextCatalog.getString('Error'), err); + } else { + handlePayPro(details, coin); + } + }); + } + return true; + } + + data = sanitizeUri(data); + + // Bitcoin URL + if (bitcore.URI.isValid(data)) { + var coin = 'btc'; + var parsed = new bitcore.URI(data); + + var addr = parsed.address ? parsed.address.toString() : ''; + var message = parsed.message; + + var amount = parsed.amount ? parsed.amount : ''; + + if (parsed.r) { + payproService.getPayProDetails(parsed.r, coin, function(err, details) { + if (err) { + if (addr && amount) goSend(addr, amount, message, coin, serviceId, serviceData); + else popupService.showAlert(gettextCatalog.getString('Error'), err); + } else handlePayPro(details, coin); + }); + } else { + goSend(addr, amount, message, coin, serviceId, serviceData); + } + return true; + // Cash URI + } else if (bitcoreCash.URI.isValid(data)) { + var coin = 'bch'; + var parsed = new bitcoreCash.URI(data); + + var addr = parsed.address ? parsed.address.toString() : ''; + var message = parsed.message; + + var amount = parsed.amount ? parsed.amount : ''; + + // paypro not yet supported on cash + if (parsed.r) { + payproService.getPayProDetails(parsed.r, coin, function(err, details) { + if (err) { + if (addr && amount) + goSend(addr, amount, message, coin, serviceId, serviceData); + else + popupService.showAlert(gettextCatalog.getString('Error'), err); + } + handlePayPro(details, coin); + }); + } else { + goSend(addr, amount, message, coin, serviceId, serviceData); + } + return true; + + // Cash URI with bitcoin (btc) address version number? + } else if (bitcore.URI.isValid(data.replace(/^bitcoincash:/,'bitcoin:'))) { + $log.debug('Handling bitcoincash URI with legacy address'); + var coin = 'bch'; + var parsed = new bitcore.URI(data.replace(/^bitcoincash:/,'bitcoin:')); + + var oldAddr = parsed.address ? parsed.address.toString() : ''; + if (!oldAddr) return false; + + var addr = ''; + + var a = bitcore.Address(oldAddr).toObject(); + addr = bitcoreCash.Address.fromObject(a).toString(); + + // Translate address + $log.debug('address transalated to:' + addr); + popupService.showConfirm( + gettextCatalog.getString('Bitcoin cash Payment'), + gettextCatalog.getString('Payment address was translated to new Bitcoin Cash address format: ' + addr), + gettextCatalog.getString('OK'), + gettextCatalog.getString('Cancel'), + function(ret) { + if (!ret) return false; + + var message = parsed.message; + var amount = parsed.amount ? parsed.amount : ''; + + // paypro not yet supported on cash + if (parsed.r) { + payproService.getPayProDetails(parsed.r, coin, function(err, details) { + if (err) { + if (addr && amount) + goSend(addr, amount, message, coin, serviceId, serviceData); + else + popupService.showAlert(gettextCatalog.getString('Error'), err); + } + handlePayPro(details, coin); + }); + } else { + goSend(addr, amount, message, coin, serviceId, serviceData); + } + } + ); + return true; + // Plain URL + } else if (/^https?:\/\//.test(data)) { + payproService.getPayProDetails(data, coin, function(err, details) { + if (err) { + if ($state.includes('tabs.scan')) { + root.showMenu({ + data: data, + type: 'url' + }); + } + return; + } + handlePayPro(details); + return true; + }); + // Plain Address + } else if (bitcore.Address.isValid(data, 'livenet') || bitcore.Address.isValid(data, 'testnet')) { + if ($state.includes('tabs.scan')) { + root.showMenu({ + data: data, + type: 'bitcoinAddress' + }); + } else { + goToAmountPage(data); + } + } else if (bitcoreCash.Address.isValid(data, 'livenet')) { + if ($state.includes('tabs.scan')) { + root.showMenu({ + data: data, + type: 'bitcoinAddress', + coin: 'bch', + }); + } else { + goToAmountPage(data, 'bch'); + } + } else if (data && data.indexOf(appConfigService.name + '://glidera') === 0) { + var code = getParameterByName('code', data); + $ionicHistory.nextViewOptions({ + disableAnimate: true + }); + $state.go('tabs.home', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.home' ? false : true + }).then(function() { + $ionicHistory.nextViewOptions({ + disableAnimate: true + }); + $state.transitionTo('tabs.buyandsell.glidera', { + code: code + }); + }); + return true; + + } else if (data && data.indexOf(appConfigService.name + '://coinbase') === 0) { + var code = getParameterByName('code', data); + $ionicHistory.nextViewOptions({ + disableAnimate: true + }); + $state.go('tabs.home', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.home' ? false : true + }).then(function() { + $ionicHistory.nextViewOptions({ + disableAnimate: true + }); + $state.transitionTo('tabs.buyandsell.coinbase', { + code: code + }); + }); + return true; + + // BitPayCard Authentication + } else if (data && data.indexOf(appConfigService.name + '://') === 0) { + + // Disable BitPay Card + if (!appConfigService._enabledExtensions.debitcard) return false; + + var secret = getParameterByName('secret', data); + var email = getParameterByName('email', data); + var otp = getParameterByName('otp', data); + var reason = getParameterByName('r', data); + + $state.go('tabs.home', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.home' ? false : true + }).then(function() { + switch (reason) { + default: + case '0': + /* For BitPay card binding */ + $state.transitionTo('tabs.bitpayCardIntro', { + secret: secret, + email: email, + otp: otp + }); + break; + } + }); + return true; + + // Join + } else if (data && data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) { + $state.go('tabs.home', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.home' ? false : true + }).then(function() { + $state.transitionTo('tabs.add.join', { + url: data + }); + }); + return true; + + // Old join + } else if (data && data.match(/^[0-9A-HJ-NP-Za-km-z]{70,80}$/)) { + $state.go('tabs.home', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.home' ? false : true + }).then(function() { + $state.transitionTo('tabs.add.join', { + url: data + }); + }); + return true; + } else if (data && (data.substring(0, 2) == '6P' || checkPrivateKey(data))) { + root.showMenu({ + data: data, + type: 'privateKey' + }); + } else if (data && ((data.substring(0, 2) == '1|') || (data.substring(0, 2) == '2|') || (data.substring(0, 2) == '3|'))) { + $state.go('tabs.home').then(function() { + $state.transitionTo('tabs.add.import', { + code: data + }); + }); + return true; + + } else { + if ($state.includes('tabs.scan')) { + root.showMenu({ + data: data, + type: 'text' + }); + } + } + return false; + }; + + function goToAmountPage(toAddress, coin) { + $state.go('tabs.send', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.send' ? false : true + }); + $timeout(function() { + var stateParams = { + toAddress: toAddress, + displayAddress: toAddress, + coin: coin, + noPrefix: 1 + }; + sendFlowService.pushState(stateParams); + $state.transitionTo('tabs.send.origin'); + }, 100); + } + + function handlePayPro(payProData, coin) { + + console.log(payProData); + + var toAddr = payProData.toAddress; + var amount = payProData.amount; + var paymentUrl = payProData.url; + var expires = payProData.expires; + var time = payProData.time; + + if (coin === 'bch') { + var displayAddr = payProData.outputs[0].address; + toAddr = bitcoinCashJsService.readAddress('bitcoincash:' + displayAddr).legacy; + amount = payProData.outputs[0].amount; + paymentUrl = payProData.paymentUrl; + expires = Math.floor(new Date(expires).getTime() / 1000) + time = Math.ceil(new Date(time).getTime() / 1000) + } + + var name = payProData.domain; + + if (payProData.memo.indexOf('eGifter') > -1) { + name = 'eGifter' + } else if (paymentUrl.indexOf('https://bitpay.com') > -1) { + name = 'BitPay'; + } + + var thirdPartyData = { + id: 'bip70', + amount: amount, + caTrusted: true, + name: name, + domain: payProData.domain, + expires: expires, + memo: payProData.memo, + network: 'livenet', + requiredFeeRate: payProData.requiredFeeRate, + selfSigned: 0, + time: time, + displayAddress: displayAddr, + toAddress: toAddr, + url: paymentUrl, + verified: true + }; + + var stateParams = { + amount: thirdPartyData.amount, + toAddress: thirdPartyData.toAddress, + coin: coin, + thirdParty: thirdPartyData + }; + + // fee + if (thirdPartyData.requiredFeeRate) { + stateParams.requiredFeeRate = thirdPartyData.requiredFeeRate * 1024; + } + + // This does not make sense, thirdPartyData gets added by stateParams below + //sendFlowService.pushState(thirdPartyData); + + scannerService.pausePreview(); + $state.go('tabs.send', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.send' ? false : true + }).then(function() { + $timeout(function() { + sendFlowService.pushState(stateParams); // Need to do more here + $state.transitionTo('tabs.send.origin'); + }); + }); + } + + return root; +}); diff --git a/src/js/services/latest-release.service.js b/src/js/services/latest-release.service.js deleted file mode 100644 index 85c50bb03..000000000 --- a/src/js/services/latest-release.service.js +++ /dev/null @@ -1,180 +0,0 @@ -'use strict'; - -(function() { - - angular - .module('bitcoincom.services') - .factory('latestReleaseService', latestReleaseService); - - function latestReleaseService($log, $http, $ionicPopup, configService, externalLinkService, gettextCatalog, platformInfo) { - - var service = { - // Functions - checkLatestRelease: checkLatestRelease, - requestLatestRelease: requestLatestRelease, - showUpdatePopup: showUpdatePopup - }; - - return service; - - function checkLatestRelease(cb) { - var releaseURL = configService.getDefaults().release.url; - - requestLatestRelease(releaseURL, function (err, releaseData) { - if (err) return cb(err); - var currentVersion = window.version; - var latestVersion = releaseData.tag_name; - - if (!verifyTagFormat(currentVersion)) - return cb('Cannot verify the format of version tag: ' + currentVersion); - if (!verifyTagFormat(latestVersion)) - return cb('Cannot verify the format of latest release tag: ' + latestVersion); - - var current = formatTagNumber(currentVersion); - var latest = formatTagNumber(latestVersion); - - if (latest.major < current.major || (latest.major === current.major && latest.minor <= current.minor)) { - return cb(null, false); - } - - var releaseSearchTerm = ""; - if (platformInfo.isNW) { // XX SP: DESKTOP: Check if the latest release is already available for current OS - var platform = process.platform; - if (platform === "darwin") { - releaseSearchTerm = "osx"; - } else if (platform === "win32") { - releaseSearchTerm = "win"; - } else if (platform === "linux") { - releaseSearchTerm = "linux"; - } - var foundNewVersion = false; - for (var i in releaseData.assets) { - if (releaseData.assets[i].name.indexOf(releaseSearchTerm) !== -1) { - foundNewVersion = true; - break; - } - } - } - - $log.debug('A new version is available: ' + latestVersion); - - var releaseNotes = false; - if (releaseData.body) { - var releaseLines = releaseData.body.split('\n'); - for (var lineNum in releaseLines) { - if (releaseLines[lineNum].substring(0, 2) === "# ") { - releaseLines[lineNum] = "" + releaseLines[lineNum].substring(2) + ""; - } else if (releaseLines[lineNum].substring(0, 2) === "- ") { - releaseLines[lineNum] = "• " + releaseLines[lineNum].substring(2); - } - } - releaseNotes = releaseLines.join('\n'); - } - - return cb(null, {latestVersion: latestVersion, releaseNotes: releaseNotes}); - }); - - function verifyTagFormat(tag) { - var regex = /^v?\d+\.\d+(\.\d+)?(-rc\d)?$/i; - return regex.exec(tag); - } - - function formatTagNumber(tag) { - var label = false; - if (tag.split("-")[1]) { // Move postfixes like "-rc2" to a variable - label = tag.split("-")[1]; - tag = tag.split("-")[0]; - } - - var formattedNumber = tag.replace(/^v/i, '').split('.'); - return { - major: +(formattedNumber[0] ? +formattedNumber[0] : 0), - minor: +(formattedNumber[1] ? +formattedNumber[1] : 0), - patch: +(formattedNumber[2] ? +formattedNumber[2] : 0), - label: label /* XX SP: Maybe we can use this in a later stage (with for example 1.0.0-rc2 the value will be "rc2" and false if there is no label) */ - }; - } - } - - function requestLatestRelease(releaseURL, cb) { - $log.debug('Retrieving latest release information...'); - - var request = { - url: releaseURL, - method: 'GET', - json: true - }; - - $http(request).then(function (release) { - $log.debug('Latest release: ' + release.data.name); - return cb(null, release.data); - }, function (err) { - return cb('Cannot get the release information: ' + err); - }); - } - - function showUpdatePopup() { - var buttons = []; - - if (!platformInfo.isIOS) { // There is no GitHub-release for iPhone - buttons.push({ - text: "GitHub", - type: 'button-positive', - onTap: function () { - var url = 'https://github.com/Bitcoin-com/Wallet/releases/latest'; - externalLinkService.open(url, false); - } - }); - } - if (platformInfo.isAndroid) { - buttons.unshift({ - text: "Google Play Store", - type: 'button-positive', - onTap: function () { - var url = 'https://play.google.com/store/apps/details?id=com.bitcoin.mwallet'; - externalLinkService.open(url, false); - } - }); - } - if (platformInfo.isIOS) { - buttons.unshift({ - text: "App Store", - type: 'button-positive', - onTap: function () { - var url = 'https://itunes.apple.com/app/id1252903728'; - externalLinkService.open(url, false); - } - }); - } else if (platformInfo.isNW) { - if (process.platform === 'darwin') { - buttons.unshift({ - text: "Mac App Store", - type: 'button-positive', - onTap: function () { - var url = 'https://itunes.apple.com/app/bitcoin-com-wallet/id1383072453'; - externalLinkService.open(url, false); - } - }); - } - } - - if (buttons.length === 1) { // There is only one source to download (probably on desktop, so open GitHub release page..) - buttons[0].onTap(); - } else { - buttons.push({ - text: gettextCatalog.getString('Go Back'), - type: 'button-positive', - onTap: function () { - return true; - } - }); - $ionicPopup.show({ - title: gettextCatalog.getString('Update Available'), - subTitle: gettextCatalog.getString('An update to this app is available. For your security, please update to the latest version.'), - cssClass: 'popup-update', - buttons: buttons - }); - } - } - } -})(); \ No newline at end of file diff --git a/src/js/services/latestReleaseService.js b/src/js/services/latestReleaseService.js new file mode 100644 index 000000000..87aace87f --- /dev/null +++ b/src/js/services/latestReleaseService.js @@ -0,0 +1,63 @@ +'use strict'; +angular.module('copayApp.services') + .factory('latestReleaseService', function latestReleaseServiceFactory($log, $http, configService) { + + var root = {}; + + root.checkLatestRelease = function(cb) { + var releaseURL = configService.getDefaults().release.url; + + requestLatestRelease(releaseURL, function(err, release) { + if (err) return cb(err); + var currentVersion = window.version; + var latestVersion = release.data.tag_name; + + if (!verifyTagFormat(currentVersion)) + return cb('Cannot verify the format of version tag: ' + currentVersion); + if (!verifyTagFormat(latestVersion)) + return cb('Cannot verify the format of latest release tag: ' + latestVersion); + + var current = formatTagNumber(currentVersion); + var latest = formatTagNumber(latestVersion); + + if (latest.major < current.major || (latest.major == current.major && latest.minor <= current.minor)) + return cb(null, false); + + $log.debug('A new version is available: ' + latestVersion); + return cb(null, true); + }); + + function verifyTagFormat(tag) { + var regex = /^v?\d+\.\d+\.\d+$/i; + return regex.exec(tag); + }; + + function formatTagNumber(tag) { + var formattedNumber = tag.replace(/^v/i, '').split('.'); + return { + major: +formattedNumber[0], + minor: +formattedNumber[1], + patch: +formattedNumber[2] + }; + }; + }; + + function requestLatestRelease(releaseURL, cb) { + $log.debug('Retrieving latest relsease information...'); + + var request = { + url: releaseURL, + method: 'GET', + json: true + }; + + $http(request).then(function(release) { + $log.debug('Latest release: ' + release.data.name); + return cb(null, release); + }, function(err) { + return cb('Cannot get the release information: ' + err); + }); + }; + + return root; + }); diff --git a/src/js/services/onGoingProcess.js b/src/js/services/onGoingProcess.js index 422be070f..147985dbb 100644 --- a/src/js/services/onGoingProcess.js +++ b/src/js/services/onGoingProcess.js @@ -52,7 +52,11 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti root.clear = function() { ongoingProcess = {}; - $ionicLoading.hide(); + if (isCordova && !isWindowsPhoneApp) { + window.plugins.spinnerDialog.hide(); + } else { + $ionicLoading.hide(); + } }; root.get = function(processName) { @@ -74,21 +78,28 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti root.onGoingProcessName = name; var showName = $filter('translate')(processNames[name] || name); - - if (root.onGoingProcessName) { - var tmpl; - if (isWindowsPhoneApp) tmpl = '
' + showName + '
'; - else tmpl = '
' + showName + '
'; - $ionicLoading.show({ - template: tmpl, - }); - } else { - $ionicLoading.hide(); - } if (customHandler) { customHandler(processName, showName, isOn); - } + } else if (root.onGoingProcessName) { + if (isCordova && !isWindowsPhoneApp) { + window.plugins.spinnerDialog.show(null, showName, root.clear); + } else { + + var tmpl; + if (isWindowsPhoneApp) tmpl = '
' + showName + '
'; + else tmpl = '
' + showName + '
'; + $ionicLoading.show({ + template: tmpl + }); + } + } else { + if (isCordova && !isWindowsPhoneApp) { + window.plugins.spinnerDialog.hide(); + } else { + $ionicLoading.hide(); + } + } }; return root; diff --git a/src/js/services/openURL.js b/src/js/services/openURL.js index 2cf8d95a5..0f4d6c666 100644 --- a/src/js/services/openURL.js +++ b/src/js/services/openURL.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('openURLService', function($rootScope, $ionicHistory, $document, $log, $state, platformInfo, lodash, profileService, incomingDataService, appConfigService) { +angular.module('copayApp.services').factory('openURLService', function($rootScope, $ionicHistory, $document, $log, $state, platformInfo, lodash, profileService, incomingData, appConfigService) { var root = {}; var handleOpenURL = function(args) { @@ -23,12 +23,9 @@ angular.module('copayApp.services').factory('openURLService', function($rootScop document.addEventListener('handleopenurl', handleOpenURL, false); - incomingDataService.redir(url, function onError(err) { - if (err) { - $log.warn('Unknown URL! : ' + url); - popupService.showAlert(gettextCatalog.getString('Error'), err.message); - } - }); + if (!incomingData.redir(url)) { + $log.warn('Unknown URL! : ' + url); + } }; var handleResume = function() { diff --git a/src/js/services/send-flow-router.service.js b/src/js/services/send-flow-router.service.js deleted file mode 100644 index 32aa8420b..000000000 --- a/src/js/services/send-flow-router.service.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -(function(){ - -angular - .module('bitcoincom.services') - .factory('sendFlowRouterService', sendFlowRouterService); - - function sendFlowRouterService( - sendFlowStateService - , $state, $ionicHistory, $timeout - ) { - - var service = { - // Functions - start: start, - goNext: goNext, - goBack: goBack, - }; - - return service; - - /** - * Start new send flow - */ - function start() { - var state = sendFlowStateService.state; - - if (state.isRequestAmount) { - $state.go('tabs.paymentRequest.amount'); - } else { - if ($state.current.name != 'tabs.send') { - $state.go('tabs.home').then(function () { - $ionicHistory.clearHistory(); - $state.go('tabs.send').then(function () { - $timeout(function () { - goNext(); - }, 60); - }); - }); - } else { - goNext(); - } - } - } - - /** - * Go to the next page - * Routing strategy : https://bitcoindotcom.atlassian.net/wiki/x/BQDWKQ - */ - function goNext() { - var state = sendFlowStateService.state; - - var needsDestination = !state.toWalletId && !state.toAddress; - var needsOrigin = !state.fromWalletId; - var needsAmount = !state.amount && !state.sendMax; - - if (needsDestination) { - if (!state.isWalletTransfer && !state.thirdParty) { - $state.go('tabs.send'); - return; - } else if (!needsOrigin) { - $state.go('tabs.send.destination'); - return; - } - } - - if (needsOrigin) { - $state.go('tabs.send.origin'); - } else if (needsAmount) { - $state.go('tabs.send.amount'); - } else { - $state.go('tabs.send.review'); - } - } - - /** - * Go to the previous page - */ - function goBack() { - $ionicHistory.goBack(); - } - }; - -})(); \ No newline at end of file diff --git a/src/js/services/send-flow-state.service.js b/src/js/services/send-flow-state.service.js deleted file mode 100644 index 960e6f306..000000000 --- a/src/js/services/send-flow-state.service.js +++ /dev/null @@ -1,142 +0,0 @@ -'use strict'; - -(function(){ - -angular - .module('bitcoincom.services') - .factory('sendFlowStateService', sendFlowStateService); - - function sendFlowStateService($log) { - - var service = { - // Variables - state: { - amount: 0, - displayAddress: null, - fromWalletId: '', - sendMax: false, - thirdParty: null, - toAddress: '', - toWalletId: '', - coin: '', - isRequestAmount: false, - isWalletTransfer: false - }, - previousStates: [], - - // Functions - init: init, - clear: clear, - getClone: getClone, - map: map, - pop: pop, - push: push, - isEmpty: isEmpty - }; - - return service; - - /** - * Init state & stack - * @param {Object} params - */ - function init(params) { - $log.debug("send-flow-state init()"); - - clear(); - - if (params) { - push(params); - } - } - - /** - * Clear a state & stack - */ - function clear() { - $log.debug("send-flow-state clear()"); - - clearCurrent(); - service.previousStates = []; - } - - /** - * Clear current state only - */ - function clearCurrent() { - $log.debug("send-flow-state clearCurrent()"); - - service.state = { - amount: 0, - displayAddress: null, - fromWalletId: '', - sendMax: false, - thirdParty: null, - toAddress: '', - toWalletId: '', - coin: '', - isRequestAmount: false, - isWalletTransfer: false - } - } - - /** - * Get a clone of the current state - */ - function getClone() { - var currentState = {}; - Object.keys(service.state).forEach(function forCurrentParam(key) { - if (typeof service.state[key] !== 'function' && key !== 'previousStates') { - currentState[key] = service.state[key]; - } - }); - return currentState; - } - - /** - * Fill in the current state from the params - * @param {Object} params - */ - function map(params) { - Object.keys(params).forEach(function forNewParam(key) { - service.state[key] = params[key]; - }); - } - - /** - * Pop state - */ - function pop() { - $log.debug('send-flow-state pop'); - - if (service.previousStates.length) { - var params = service.previousStates.pop(); - clearCurrent(); - map(params); - } else { - clear(); - } - } - - /** - * Push state - * @param {Object} params - */ - function push(params) { - $log.debug('send-flow-state push'); - - var currentParams = getClone(); - service.previousStates.push(currentParams); - clearCurrent(); - map(params); - } - - /** - * Is empty stack - */ - function isEmpty() { - return service.previousStates.length == 0; - } - }; - -})(); \ No newline at end of file diff --git a/src/js/services/send-flow.service.js b/src/js/services/send-flow.service.js deleted file mode 100644 index e8be2e487..000000000 --- a/src/js/services/send-flow.service.js +++ /dev/null @@ -1,148 +0,0 @@ -'use strict'; - -(function(){ - -angular - .module('bitcoincom.services') - .factory('sendFlowService', sendFlowService); - - function sendFlowService( - sendFlowStateService, sendFlowRouterService - , bitcoinUriService, payproService, bitcoinCashJsService - , popupService, gettextCatalog - , $state, $log - ) { - - var service = { - // Variables - state: sendFlowStateService, - router: sendFlowRouterService, - - // Functions - start: start, - goNext: goNext, - goBack: goBack - }; - - return service; - - /** - * Start a new send flow - * @param {Object} params - * @param {Function} onError - */ - function start(params, onError) { - $log.debug('send-flow start()'); - - if (params && params.data) { - var res = bitcoinUriService.parse(params.data); - - if (res.isValid) { - - // If BIP70 (url) - if (res.url) { - var url = res.url; - var coin = res.coin || ''; - payproService.getPayProDetails(url, coin, function onGetPayProDetails(err, payProData) { - if (err) { - popupService.showAlert(gettextCatalog.getString('Error'), err); - } else { - var name = payProData.domain; - - // Detect some merchant that we know - if (payProData.memo.indexOf('eGifter') > -1) { - name = 'eGifter' - } else if (paymentUrl.indexOf('https://bitpay.com') > -1) { - name = 'BitPay'; - } - - // Init thirdParty - var thirdPartyData = { - id: 'bip70', - caTrusted: true, - name: name, - domain: payProData.domain, - expires: payProData.expires, - memo: payProData.memo, - network: 'livenet', - requiredFeeRate: payProData.requiredFeeRate, - selfSigned: 0, - time: payProData.time, - url: payProData.url, - verified: true - }; - - // Fill in params - params.amount = payProData.amount, - params.toAddress = payProData.toAddress, - params.coin = coin, - params.thirdParty = thirdPartyData - } - - // Resolve - _next(); - }); - } else { - if (res.coin) { - params.coin = res.coin; - } - - if (res.amountInSatoshis) { - params.amount = res.amountInSatoshis; - } - - if (res.publicAddress) { - var prefix = res.isTestnet ? 'bchtest:' : 'bitcoincash:'; - params.displayAddress = res.publicAddress.cashAddr || res.publicAddress.legacy || res.publicAddress.bitpay; - var formatAddress = res.publicAddress.cashAddr ? prefix + params.displayAddress : params.displayAddress; - params.toAddress = bitcoinCashJsService.readAddress(formatAddress).legacy; - } - - _next(); - } - } else { - if (onError) { - onError(); - } - } - } else { - _next(); - } - - - // Next used for sync the async task - function _next() { - sendFlowStateService.init(params); - - // Routing strategy to -> send-flow-router.service - sendFlowRouterService.start(); - } - } - - /** - * Go to the next step - * @param {Object} state - */ - function goNext(state) { - $log.debug('send-flow goNext()'); - - // Save the current route before leaving - state.route = $state.current.name; - - // Save the state and redirect the user - sendFlowStateService.push(state); - sendFlowRouterService.goNext(); - } - - /** - * Go to the previous step - */ - function goBack() { - $log.debug('send-flow goBack()'); - - // Remove the state on top and redirect the user - sendFlowStateService.pop(); - sendFlowRouterService.goBack(); - } - } -})(); \ No newline at end of file diff --git a/src/js/services/sendFlowService.js b/src/js/services/sendFlowService.js new file mode 100644 index 000000000..62989b3c5 --- /dev/null +++ b/src/js/services/sendFlowService.js @@ -0,0 +1,103 @@ +'use strict'; + +(function(){ + +angular + .module('copayApp.services') + .factory('sendFlowService', sendFlowService); + + function sendFlowService($log) { + + var service = { + // A separate state variable so we can ensure it is cleared of everything, + // even other properties added that this service does not know about. (such as "coin") + state: { + amount: '', + displayAddress: null, + fromWalletId: '', + sendMax: false, + thirdParty: null, + toAddress: '', + toWalletId: '' + }, + previousStates: [], + + // Functions + clear: clear, + getStateClone: getStateClone, + map: map, + popState: popState, + pushState: pushState, + startSend: startSend + }; + + return service; + + function clear() { + console.log("sendFlow clear()"); + clearCurrent(); + service.previousStates = []; + } + + function clearCurrent() { + console.log("sendFlow clearCurrent()"); + service.state = { + amount: '', + displayAddress: null, + fromWalletId: '', + sendMax: false, + thirdParty: null, + toAddress: '', + toWalletId: '' + } + } + + /** + * Handy for debugging + */ + function getStateClone() { + var currentState = {}; + Object.keys(service.state).forEach(function forCurrentParam(key) { + if (typeof service.state[key] !== 'function' && key !== 'previousStates') { + currentState[key] = service.state[key]; + } + }); + return currentState; + } + + /** + * Clears all previous state + */ + function startSend(params) { + console.log('startSend()'); + clear(); + map(params); + } + + function map(params) { + Object.keys(params).forEach(function forNewParam(key) { + service.state[key] = params[key]; + }); + }; + + function popState() { + console.log('sendFlow pop'); + if (service.previousStates.length) { + var params = service.previousStates.pop(); + clearCurrent(); + map(params); + } else { + clear(); + } + }; + + function pushState(params) { + console.log('sendFlow push'); + var currentParams = getStateClone(); + service.previousStates.push(currentParams); + clearCurrent(); + map(params); + }; + }; + +})(); \ No newline at end of file diff --git a/src/js/services/shapeShiftApiService.js b/src/js/services/shapeShiftApiService.js index cc5fb0792..210ae0fbd 100644 --- a/src/js/services/shapeShiftApiService.js +++ b/src/js/services/shapeShiftApiService.js @@ -328,23 +328,18 @@ angular.module('copayApp.services').factory('shapeshiftApiService', function($q) $scope.amount, $scope.withdrawalAddress, $scope.coinIn, $scope.coinOut ); - console.log('shapeshiftApiService.FixedAmountTx()'); console.log(fixedTx); SSA.FixedAmountTx(fixedTx, function (data) { - console.log(data); - promise.resolve(data); + console.log(data) + return promise.resolve({ fixedTxData : data.success }); }); return promise.promise; }, NormalTx : function($scope){ var promise = $q.defer(); var normalTx = SSA.CreateNormalTx($scope.withdrawalAddress, $scope.coinIn, $scope.coinOut); - - console.log('shapeshiftApiService.NormalTx()'); - console.log(normalTx); SSA.NormalTx(normalTx, function (data) { - console.log(data); - promise.resolve(data); + promise.resolve({ normalTxData : data }); }); return promise.promise; }, @@ -365,12 +360,11 @@ angular.module('copayApp.services').factory('shapeshiftApiService', function($q) return promise.promise; }, ValidateAddress : function(address, coin) { - var promise = $q.defer(); - SSA.ValidateAdddress(address, coin, function onRequest(data){ - console.log(data); - promise.resolve(data); - }); - return promise.promise; + var promise = $q.defer(); + SSA.ValidateAdddress(address, coin, function(data){ + promise.resolve(data); + }); + return promise.promise; } }; }); diff --git a/src/js/services/shapeshift.service.js b/src/js/services/shapeshift.service.js deleted file mode 100644 index 73410e478..000000000 --- a/src/js/services/shapeshift.service.js +++ /dev/null @@ -1,112 +0,0 @@ -'use strict'; - -(function(){ - -angular - .module('bitcoincom.services') - .factory('shapeshiftService', shapeshiftService); - - function shapeshiftService(shapeshiftApiService, gettextCatalog) { - - var service = { - // Variables - coinIn: '', - coinOut: '', - withdrawalAddress: '', - returnAddress: '', - amount: '', - marketData: {}, - coins: { - 'BTC': {name: 'Bitcoin', symbol: 'BTC'}, - 'BCH': {name: 'Bitcoin Cash', symbol: 'BCH'} - }, - - // Functions - getMarketData: getMarketData, - shiftIt: shiftIt - }; - - return service; - - function handleError(response, defaultMessage, cb) { - if (response && typeof response.error === "string") { - cb(new Error(response.error)); - } else if (response && response.error && response.error.message) { - cb(new Error(response.error.message)); - } else { - cb(new Error(defaultMessage)); - } - } - - function getMarketData(coinIn, coinOut, cb) { - service.coinIn = coinIn; - service.coinOut = coinOut; - shapeshiftApiService - .marketInfo(service.coinIn, service.coinOut) - .then(function (response) { - if (!response || response.error) { - handleError(response, 'Invalid response from Shapeshift', cb); - } else { - service.marketData = response; - service.rateString = service.marketData.rate.toString() + ' ' + coinOut.toUpperCase() + '/' + coinIn.toUpperCase(); - cb(null, response); - } - }); - } - - function shiftIt(coinIn, coinOut, withdrawalAddress, returnAddress, amount, cb) { - // Test if the amount is correct depending on the min and max - if (!amount || typeof amount !== 'number') { - cb(new Error(gettextCatalog.getString('Amount is not defined'))); - } else if (amount < service.marketData.minimum) { - cb(new Error(gettextCatalog.getString('Amount is below the minimun'))); - } else if (amount > service.marketData.maxLimit) { - cb(new Error(gettextCatalog.getString('Amount is above the limit'))); - } else { - // Init service data - service.withdrawalAddress = withdrawalAddress; - service.returnAddress = returnAddress; - service.coinIn = coinIn; - service.coinOut = coinOut; - service.amount = amount; - - // Check the address - shapeshiftApiService - .ValidateAddress(withdrawalAddress, coinOut) - .then(function onSuccess(response) { - if (response && response.isvalid) { - // Prepare the transaction shapeshift side - shapeshiftApiService.NormalTx(service).then(function onResponse(response) { - // If error, return it - if (!response || response.error) { - handleError(response, gettextCatalog.getString('Invalid response from Shapeshift'), cb); - } else { - var txData = response; - - // If the content is not that it was expected, get back an error - if (!txData || !txData.orderId || !txData.deposit) { - cb(new Error(gettextCatalog.getString('Invalid response from Shapeshift'))); - } else { - // Get back the data - service.depositInfo = txData; - var shapeshiftData = { - coinIn: coinIn, - coinOut: coinOut, - toWalletId: service.toWalletId, - minAmount: service.marketData.minimum, - maxAmount: service.marketData.maxLimit, - orderId: txData.orderId, - toAddress: txData.deposit - }; - cb(null, shapeshiftData); - } - } - }); - } else { - cb(new Error(gettextCatalog.getString('Invalid address'))); - } - }); - } - } - } -})(); \ No newline at end of file diff --git a/src/js/services/shapeshiftService.js b/src/js/services/shapeshiftService.js new file mode 100644 index 000000000..1ce9672ce --- /dev/null +++ b/src/js/services/shapeshiftService.js @@ -0,0 +1,141 @@ +'use strict'; + +angular.module('copayApp.services').factory('shapeshiftService', function ($http, $interval, $log, lodash, moment, ongoingProcess, shapeshiftApiService, storageService, configService, incomingData, platformInfo, servicesService) { + var root = {}; + root.ShiftState = 'Shift'; + root.coinIn = ''; + root.coinOut = ''; + root.withdrawalAddress = ''; + root.returnAddress = ''; + root.amount = ''; + root.marketData = {}; + + root.getMarketDataIn = function (coin) { + if (coin === root.coinOut) return root.getMarketData(root.coinOut, root.coinIn); + return root.getMarketData(coin, root.coinOut); + }; + root.getMarketDataOut = function (coin) { + if (coin === root.coinIn) return root.getMarketData(root.coinOut, root.coinIn); + return root.getMarketData(root.coinIn, coin); + }; + root.getMarketData = function (coinIn, coinOut, cb) { + root.coinIn = coinIn; + root.coinOut = coinOut; + if (root.coinIn === undefined || root.coinOut === undefined) return; + shapeshiftApiService + .marketInfo(root.coinIn, root.coinOut) + .then(function (marketData) { + root.marketData = marketData; + root.rateString = root.marketData.rate.toString() + ' ' + coinOut.toUpperCase() + '/' + coinIn.toUpperCase(); + if (cb) { + cb(marketData); + } + }); + }; + + /*shapeshiftApiService.coins().then(function(coins){ + root.coins = coins; + root.coinIn = coins['BTC'].symbol; + root.coinOut = coins['BCH'].symbol; + root.getMarketData(root.coinIn, root.coinOut); + });*/ + + root.coins = { + 'BTC': {name: 'Bitcoin', symbol: 'BTC'}, + 'BCH': {name: 'Bitcoin Cash', symbol: 'BCH'} + }; + + function checkForError(data) { + if (data.err) return true; + return false; + } + + root.shiftIt = function (coinIn, coinOut, withdrawalAddress, returnAddress, cb) { + ongoingProcess.set('connectingShapeshift', true); + root.withdrawalAddress = withdrawalAddress; + root.returnAddress = returnAddress; + root.coinIn = coinIn; + root.coinOut = coinOut; + shapeshiftApiService.ValidateAddress(withdrawalAddress, coinOut).then(function (valid) { + var tx = ShapeShift(); + var coin; + console.log("Starting"); + tx.then(function (txData) { + console.log("Got txData", txData); + if (txData['fixedTxData']) { + txData = txData.fixedTxData; + if (checkForError(txData)) return cb(txData.err); + //console.log(txData) + var coinPair = txData.pair.split('_'); + txData.depositType = coinPair[0].toUpperCase(); + txData.withdrawalType = coinPair[1].toUpperCase(); + coin = root.coins[txData.depositType].name.toLowerCase(); + + txData.depositQR = coin + ":" + txData.deposit + "?amount=" + txData.depositAmount; + + root.txFixedPending = true; + + } else if (txData['normalTxData']) { + txData = txData.normalTxData; + if (checkForError(txData)) return cb(txData.err); + coin = root.coins[txData.depositType.toUpperCase()].name.toLowerCase(); + txData.depositQR = coin + ":" + txData.deposit; + } else if (txData['cancelTxData']) { + txData = txData.cancelTxData; + if (checkForError(txData)) return cb(txData.err); + if (root.txFixedPending) { + root.txFixedPending = false; + } + root.ShiftState = 'Shift'; + } + root.depositInfo = txData; + //console.log(root.marketData); + //console.log(root.depositInfo); + var sendAddress = txData.depositQR; + if (sendAddress && sendAddress.indexOf('bitcoin cash') >= 0) + sendAddress = sendAddress.replace('bitcoin cash', 'bitcoincash'); + + ongoingProcess.set('connectingShapeshift', false); + + root.ShiftState = 'Cancel'; + //root.GetStatus(); + //root.txInterval=$interval(root.GetStatus, 8000); + + var shapeshiftData = { + coinIn: coinIn, + coinOut: coinOut, + toWalletId: root.toWalletId, + minAmount: root.marketData.minimum, + maxAmount: root.marketData.maxLimit, + orderId: root.depositInfo.orderId, + toAddress: txData.deposit + }; + // + // if (incomingData.redir(sendAddress, 'shapeshift', shapeshiftData)) { + ongoingProcess.set('connectingShapeshift', false); + // return; + // } + cb(null, shapeshiftData); + }); + }) + }; + + function ShapeShift() { + if (parseFloat(root.amount) > 0) return shapeshiftApiService.FixedAmountTx(root); + return shapeshiftApiService.NormalTx(root); + } + + root.GetStatus = function () { + var address = root.depositInfo.deposit + shapeshiftApiService.GetStatusOfDepositToAddress(address).then(function (data) { + root.DepositStatus = data; + if (root.DepositStatus.status === 'complete') { + $interval.cancel(root.txInterval); + root.depositInfo = null; + root.ShiftState = 'Shift' + } + }); + }; + + return root; +}); diff --git a/src/js/services/uxLanguage.js b/src/js/services/uxLanguage.js index b8e7c3b09..1fa446f01 100644 --- a/src/js/services/uxLanguage.js +++ b/src/js/services/uxLanguage.js @@ -10,7 +10,7 @@ angular.module('copayApp.services') isoCode: 'en', rateCode: 'USD' }, { - name: 'Català', + name: 'català', isoCode: 'ca', rateCode: 'EUR' },{ @@ -59,6 +59,10 @@ angular.module('copayApp.services') name: 'Português', isoCode: 'pt', rateCode: 'EUR' + }, { + name: 'русский язык', + isoCode: 'ru', + rateCode: 'RUB' }, { name: '한국어', isoCode: 'ko', diff --git a/src/js/services/wallet-history.service.js b/src/js/services/wallet-history.service.js deleted file mode 100644 index 512a2d8b1..000000000 --- a/src/js/services/wallet-history.service.js +++ /dev/null @@ -1,275 +0,0 @@ -'use strict'; - -(function(){ - - angular - .module('bitcoincom.services') - .factory('walletHistoryService', walletHistoryService); - - function walletHistoryService(configService, storageService, lodash, $log, txFormatService) { - //var PAGE_SIZE = 50; - var PAGE_SIZE = 20; // For dev only - // How much to overlap on each end of the page, for mitigating inconsistent sort order. - var PAGE_OVERLAP_FRACTION = 0.2; - var PAGE_OVERLAP = Math.floor(PAGE_SIZE * PAGE_OVERLAP_FRACTION); - // The fraction of transactions in the new overlapping resultset that we already know about. - // If we know about at least this many, then there are probably no gaps. - var MIN_KNOWN_TX_OVERLAP_FRACTION = 0.5; - - var SAFE_CONFIRMATIONS = 6; - - var allTransactionsFetched = false; - var service = { - getCachedTxHistory: getCachedTxHistory, - updateLocalTxHistoryByPage: updateLocalTxHistoryByPage, - }; - return service; - - function addEarlyTransactions(walletId, cachedTxs, newTxs) { - - var cachedTxIndexFromId = {}; - cachedTxs.forEach(function forCachedTx(tx){ - cachedTxIndexFromId[tx.txid] = true; - }); - - var confirmationsUpdated = false; - var someTransactionsWereNew = false; - var overlappingTxsCount = 0; - - newTxs.forEach(function forNewTx(tx){ - if (typeof cachedTxIndexFromId[tx.txid] === "undefined") { - someTransactionsWereNew = true; - cachedTxs.push(tx); - } else { - var txUpdated = updateCachedTx(cachedTxs, cachedTxIndexFromId, tx); - confirmationsUpdated = confirmationsUpdated || txUpdated; - overlappingTxsCount++; - } - }); - - var overlappingTxFraction = overlappingTxsCount / Math.min(cachedTxs.length, PAGE_OVERLAP); - console.log('overlappingTxFraction:', overlappingTxFraction); - - if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION) { // We are good - if (someTransactionsWereNew) { - saveTxHistory(walletId, cachedTxs); - } else if (confirmationsUpdated) { - saveTxHistory(walletId, cachedTxs); - } else if (overlappingTxsCount === newTxs.length) { - allTransactionsFetched = true; - } - return cachedTxs; - } else { - // We might be missing some txs. - console.error('We might be missing some txs in the history.'); - // Our history is wrong, so remove it - we could instead, try to fetch data that was not so early. - storageService.removeTxHistory(walletId, function onRemoveTxHistory(){}); - return []; - } - - } - - function addLatestTransactions(walletId, cachedTxs, newTxs) { - var cachedTxIndexFromId = {}; - cachedTxs.forEach(function forCachedTx(tx, txIndex){ - cachedTxIndexFromId[tx.txid] = txIndex; - }); - - var someTransactionsWereNew = false; - var confirmationsUpdated = false; - var overlappingTxsCount = 0; - var uniqueNewTxs = []; - - newTxs.forEach(function forNewTx(tx){ - if (typeof cachedTxIndexFromId[tx.txid] === "undefined") { - someTransactionsWereNew = true; - uniqueNewTxs.push(tx); - } else { - var txUpdated = updateCachedTx(cachedTxs, cachedTxIndexFromId, tx); - confirmationsUpdated = confirmationsUpdated || txUpdated; - overlappingTxsCount++; - } - }); - - var overlappingTxFraction = overlappingTxsCount / Math.min(cachedTxs.length, PAGE_OVERLAP); - - if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION) { // We are good - if (someTransactionsWereNew) { - var allTxs = uniqueNewTxs.concat(cachedTxs); - saveTxHistory(walletId, allTxs); - return allTxs; - } else { - if (confirmationsUpdated) { - saveTxHistory(walletId, cachedTxs); - } - return cachedTxs; - } - } else { - // We might be missing some txs. - // Our history is wrong, so just include the latest ones - saveTxHistory(walletId, newTxs); - return newTxs; - } - - } - - // Only clear the cache once we have received new transactions from the server. - /** - * @param wallet - * @param start - * @param {function(err, txs)} cb - transactions is always an array, may be empty - */ - function fetchTxHistoryByPage(wallet, start, cb) { - var skip = Math.max(0, start - PAGE_OVERLAP); - var limit = PAGE_SIZE; - - var opts = { - skip: skip, - limit: limit - }; - wallet.getTxHistory(opts, function onTxHistory(err, txsFromServer) { - if (err) { - return cb(err, []); - } - - if (txsFromServer.length === 0) { - return cb(null, []); - } - - var processedTxs = processNewTxs(wallet, txsFromServer); - - return cb(null, processedTxs); - }); - } - - /** - * @param {string} walletId - * @param {function(error, txs)} cb - txs is always an array, may be empty - */ - function getCachedTxHistory(walletId, cb) { - console.log('txhistory updateLocalTxHistoryByPage()'); - storageService.getTxHistory(walletId, function onGetTxHistory(err, txHistoryString){ - if (err) { - return cb(err, []); - } - - if (!txHistoryString) { - return cb(null, []); - } - - try { - var txHistory = JSON.parse(txHistoryString); - return cb(null, txHistory); - } catch (e) { - $log.error('Failed to parse tx history.', e); - return cb(e, []); - } - }); - } - - function processNewTxs(wallet, txs) { - var now = Math.floor(Date.now() / 1000); - var txHistoryUnique = {}; - var processedTxs = []; - wallet.hasUnsafeConfirmed = false; - - lodash.each(txs, function(tx) { - tx = txFormatService.processTx(wallet.coin, tx); - - // no future transactions... - if (tx.time > now) - tx.time = now; - - if (tx.confirmations >= SAFE_CONFIRMATIONS) { - tx.safeConfirmed = SAFE_CONFIRMATIONS + '+'; - } else { - tx.safeConfirmed = false; - wallet.hasUnsafeConfirmed = true; - } - - if (tx.note) { - delete tx.note.encryptedEditedByName; - delete tx.note.encryptedBody; - } - - if (!txHistoryUnique[tx.txid]) { - processedTxs.push(tx); - txHistoryUnique[tx.txid] = true; - } else { - $log.debug('Ignoring duplicate TX in history: ' + tx.txid) - } - }); - - return processedTxs; - } - - function saveTxHistory(walletId, processedTxs) { - storageService.setTxHistory(processedTxs, walletId, function onSetTxHistory(error){ - if (error) { - $log.error('pagination Failed to save tx history.', error); - } - }); - } - - /** - * Returns true if the cached tx was updated - * @param {*} cachedTxs - * @param {*} cachedTxIndexFromId - Indices for cachedTxs, based on txid - * @param {*} tx - The most recent tx info - */ - function updateCachedTx(cachedTxs, cachedTxIndexFromId, tx) { - var updated = false; - var txIndex = cachedTxIndexFromId[tx.txid]; - var cachedTx = cachedTxs[txIndex]; - - if (cachedTx.confirmations < SAFE_CONFIRMATIONS && tx.confirmations > cachedTx.confirmations) { - cachedTxs[txIndex].confirmations = tx.confirmations; - updated = true; - } - return updated; - } - - function updateLocalTxHistoryByPage(wallet, getLatest, flushCacheOnNew, cb) { - console.log('txhistory updaetLocalTxHistoryByPage()'); - if (flushCacheOnNew) { - fetchTxHistoryByPage(wallet, 0, function onFetchTxHistory(err, txs){ - if (err) { - return cb(err, txs); - } - saveTxHistory(wallet.id, txs); - return cb(null, txs); - }); - } else { - getCachedTxHistory(wallet.id, function onCachedHistory(err, cachedTxs){ - if (err) { - $log.error('Failed to get cached tx history.', err); - return cb(err, []); - } - - var start = getLatest ? 0 : cachedTxs.length; - fetchTxHistoryByPage(wallet, start, function onFetchHistory(err, fetchedTxs){ - if (err) { - return cb(err); - } - - if (fetchedTxs.length === 0) { - return cb(null, cachedTxs, true /*fetchedAllTransactions*/); - } - - var txs = []; - if (getLatest) { - txs = addLatestTransactions(wallet.id, cachedTxs, fetchedTxs); - } else { - allTransactionsFetched = false; - txs = addEarlyTransactions(wallet.id, cachedTxs, fetchedTxs); - return cb(null, txs, allTransactionsFetched); - } - return cb(null, txs); - }); - - - }); - } - } - } -})(); \ No newline at end of file diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index d29f99272..647c69734 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -396,23 +396,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim return ret; }; - var skipped = 0; - - function fixTxsUnit(txs) { - if (!txs || !txs[0] || !txs[0].amountStr) return; - - var cacheCoin = txs[0].amountStr.split(' ')[1]; - - if (cacheCoin == 'bits') { - - $log.debug('Fixing Tx Cache Unit to: ' + wallet.coin) - lodash.each(txs, function(tx) { - tx.amountStr = txFormatService.formatAmountStr(wallet.coin, tx.amount); - tx.feeStr = txFormatService.formatAmountStr(wallet.coin, tx.fees); - }); - } - }; - var updateLocalTxHistory = function(wallet, opts, cb) { var FIRST_LIMIT = 5; var LIMIT = 50; @@ -423,10 +406,25 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim var progressFn = opts.progressFn || function() {}; var foundLimitTx = false; + if (opts.feeLevels) { opts.lowAmount = root.getLowAmount(wallet, opts.feeLevels); } + var fixTxsUnit = function(txs) { + if (!txs || !txs[0] || !txs[0].amountStr) return; + + var cacheCoin = txs[0].amountStr.split(' ')[1]; + + if (cacheCoin == 'bits') { + + $log.debug('Fixing Tx Cache Unit to: ' + wallet.coin) + lodash.each(txs, function(tx) { + tx.amountStr = txFormatService.formatAmountStr(wallet.coin, tx.amount); + tx.feeStr = txFormatService.formatAmountStr(wallet.coin, tx.fees); + }); + } + }; getSavedTxs(walletId, function(err, txsFromLocal) { if (err) return cb(err); @@ -437,14 +435,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null; var endingTs = confirmedTxs[0] ? confirmedTxs[0].time : null; - console.log('pagination Hard confirmed TXs. Got:' + confirmedTxs.length + '/' + txsFromLocal.length); + $log.debug('Confirmed TXs. Got:' + confirmedTxs.length + '/' + txsFromLocal.length); // First update progressFn(txsFromLocal, 0); wallet.completeHistory = txsFromLocal; function getNewTxs(newTxs, skip, next) { - console.log('pagination getNewTxs skip: ' + skip); getTxsFromServer(wallet, skip, endingTxid, requestLimit, function(err, res) { if (err) { $log.warn(bwcError.msg(err, 'Server Error')); //TODO @@ -457,7 +454,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim return next(err); } - console.log('pagination Result count: ' + res.length); // Check if new txs are founds, if yes, lets investigate in the 50 next // To be sure we are not missing txs by sorting (maybe a new tx is after the "endingTxid" var newDiscoveredTxs = res.filter(function (x) { @@ -466,7 +462,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }).length == 0; }); - console.log('pagination Discovering new TXs. Got:' + newDiscoveredTxs.length); + $log.debug('Discovering TXs. Got:' + newDiscoveredTxs.length); var shouldContinue = newDiscoveredTxs.length > 0; @@ -479,7 +475,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim skip = skip + requestLimit; - console.log('pagination Syncing TXs. Got:' + newTxs.length + ' Skip:' + skip, ' EndingTxid:', endingTxid, ' Continue:', shouldContinue); + $log.debug('Syncing TXs. Got:' + newTxs.length + ' Skip:' + skip, ' EndingTxid:', endingTxid, ' Continue:', shouldContinue); // TODO Dirty // do not sync all history, just looking for a single TX. @@ -496,16 +492,14 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim } // - shouldContinue = false; - - skipped = skip; if (!shouldContinue) { - console.log('pagination Finished Sync: New / soft confirmed Txs: ' + newTxs.length); + $log.debug('Finished Sync: New / soft confirmed Txs: ' + newTxs.length); return next(null, newTxs); } requestLimit = LIMIT; + getNewTxs(newTxs, skip, next); }); }; @@ -541,87 +535,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); } - - if (opts.getMoreTxs) { - var requestLimit = LIMIT; - getNewTxs([], skipped, function(err, txs) { - if (err) return cb(err); - - console.log(); - createReceivedEvents(txs); - - var newHistory = lodash.uniq(lodash.compact(txs.concat(confirmedTxs)), function(x) { - return x.txid; - }); - - - function updateNotes(cb2) { - if (!endingTs) return cb2(); - - $log.debug('Syncing notes from: ' + endingTs); - wallet.getTxNotes({ - minTs: endingTs - }, function(err, notes) { - if (err) { - $log.warn(err); - return cb2(); - }; - lodash.each(notes, function(note) { - $log.debug('Note for ' + note.txid); - lodash.each(newHistory, function(tx) { - if (tx.txid == note.txid) { - $log.debug('...updating note for ' + note.txid); - tx.note = note; - } - }); - }); - return cb2(); - }); - } - - function updateLowAmount(txs) { - if (!opts.lowAmount) return; - - lodash.each(txs, function(tx) { - tx.lowAmount = tx.amount < opts.lowAmount; - }); - }; - - updateLowAmount(txs); - - updateNotes(function() { - - // - if (foundLimitTx) { - $log.debug('Tx history read until limitTx: ' + opts.limitTx); - return cb(null, newHistory); - } - // - - var historyToSave = JSON.stringify(newHistory); - - lodash.each(txs, function(tx) { - tx.recent = true; - }) - - $log.debug('Tx History synced. Total Txs: ' + newHistory.length); - - // Final update - if (walletId == wallet.credentials.walletId) { - wallet.completeHistory = newHistory; - } - - return storageService.setTxHistory(historyToSave, walletId, function() { - $log.debug('Tx History saved.'); - return cb(null, newHistory); - }); - }); - }); - return; - } - - skipped = 0; - getNewTxs([], 0, function(err, txs) { if (err) return cb(err); @@ -690,19 +603,14 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim return storageService.setTxHistory(historyToSave, walletId, function() { $log.debug('Tx History saved.'); - return cb(null, newHistory); + + return cb(); }); }); }); }); }; - root.getMoreTxs = function(wallet, cb) { - var opts = {}; - opts.getMoreTxs = true; - updateLocalTxHistory(wallet, opts, cb); - }; - root.getTxNote = function(wallet, txid, cb) { wallet.getTxNote({ txid: txid @@ -726,6 +634,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }; root.getTx = function(wallet, txid, cb) { + function finish(list) { var tx = lodash.find(list, { txid: txid @@ -742,6 +651,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim limitTx: txid }, function(err, txHistory) { if (err) return cb(err); + finish(txHistory); }); } @@ -765,10 +675,16 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim root.getTxHistory = function(wallet, opts, cb) { opts = opts || {}; + var walletId = wallet.credentials.walletId; + if (!wallet.isComplete()) return cb(); - // var historyIsCached = wallet.completeHistory && wallet.completeHistory.isValid; - // if (historyIsCached && !opts.force) return cb(null, wallet.completeHistory); + function isHistoryCached() { + return wallet.completeHistory && wallet.completeHistory.isValid; + }; + + // disable caching + //if (isHistoryCached() && !opts.force) return cb(null, wallet.completeHistory); $log.debug('Updating Transaction History'); diff --git a/src/sass/buttons.scss b/src/sass/buttons.scss index 886d730c7..df0ce8945 100644 --- a/src/sass/buttons.scss +++ b/src/sass/buttons.scss @@ -1,5 +1,5 @@ %button-standard { - width: 90%; + width: 85%; max-width: 300px; margin-left: auto; margin-right: auto; diff --git a/src/sass/components/fee-summary.scss b/src/sass/components/fee-summary.scss index 88c43ab02..e09af4be3 100644 --- a/src/sass/components/fee-summary.scss +++ b/src/sass/components/fee-summary.scss @@ -1,11 +1,11 @@ .fee-summary { - background-color: #F2F2F2; - box-sizing: border-box; + position: relative; display: flex; flex-direction: column; - padding: 5px 12px 15px; - position: relative; width: 100%; + padding: 5px 12px 15px; + box-sizing: border-box; + background-color: #F2F2F2; &:before { content: ''; @@ -18,11 +18,12 @@ } .amount { + display: flex; + flex-direction: row; + justify-content: space-between; width: 100%; .fee-fiat { - display: inline; - &.positive { color: #70955F; } @@ -34,7 +35,6 @@ .fee-crypto { color: #A7A7A7; - float: right; } } } \ No newline at end of file diff --git a/src/sass/components/item.scss b/src/sass/components/item.scss index a6ac4143c..bb75ae8e0 100644 --- a/src/sass/components/item.scss +++ b/src/sass/components/item.scss @@ -27,7 +27,6 @@ left: 13px; top: 50%; padding: 0; - -webkit-transform: translate(0,-50%); transform: translate(0,-50%); } } diff --git a/src/sass/mixins/layout.scss b/src/sass/mixins/layout.scss index e7a1af9da..269a50320 100644 --- a/src/sass/mixins/layout.scss +++ b/src/sass/mixins/layout.scss @@ -59,8 +59,6 @@ .button { font-weight: bold; font-size: 19px; - line-height: 26px; - padding: 8px 6px; } } .button-first-contact img { diff --git a/src/sass/views/amount.scss b/src/sass/views/amount.scss index aba2fe6d9..bf4d3506a 100644 --- a/src/sass/views/amount.scss +++ b/src/sass/views/amount.scss @@ -350,7 +350,6 @@ .primary-amount-display { margin-right: 5px; word-break: break-all; - width: 100%; } } diff --git a/src/sass/views/review.scss b/src/sass/views/review.scss index d4f02f2f4..c530a1cef 100644 --- a/src/sass/views/review.scss +++ b/src/sass/views/review.scss @@ -6,10 +6,8 @@ } .fee-summary { - bottom: 92px; - bottom: calc(92px + constant(safe-area-inset-bottom)); /* iOS 11.0 */ - bottom: calc(92px + env(safe-area-inset-bottom)); /* iOS 11.2 */ position: absolute; + bottom: 92px; } .shapeshift-banner, .bitpay-banner, .egifter-banner { @@ -19,5 +17,4 @@ .warning { color: $v-warning-color-2; } - } \ No newline at end of file diff --git a/src/sass/views/tab-home.scss b/src/sass/views/tab-home.scss index aed37705e..55080ab7b 100644 --- a/src/sass/views/tab-home.scss +++ b/src/sass/views/tab-home.scss @@ -83,14 +83,14 @@ .button { border: 2px solid; border-radius: 47px; - padding: 8px 2px 8px 2px; + padding: 0 15px 0 15px; text-align: center; width: 100%; max-width: 300px; font-size: 19px; font-weight: bolder; - min-height: 0; - line-height: 19px; + min-height: auto; + line-height: 36px; } } .wallet-coin-logo { @@ -173,11 +173,6 @@ font-weight: 700; color: #444; } - .release-notes { - white-space: pre; - white-space: pre-line; - text-align: left; - } .button { width: 100%; border: none; @@ -195,13 +190,3 @@ top:11px; } } -.popup-update { - .popup-buttons { - display: block; - } - .popup-buttons .button{ - display:block; - min-width: 100% !important; - margin-top: 4px; - } -} \ No newline at end of file diff --git a/src/sass/views/tab-receive.scss b/src/sass/views/tab-receive.scss index 0b406254d..40dc79504 100644 --- a/src/sass/views/tab-receive.scss +++ b/src/sass/views/tab-receive.scss @@ -84,9 +84,6 @@ width: 100%; } .payment-received-container { - svg { - max-height: 400px; - } margin: 0 20px; .payment-received-amount { font-size: 1.8em; diff --git a/src/sass/views/tab-send.scss b/src/sass/views/tab-send.scss index 564e90d66..bf77984fd 100644 --- a/src/sass/views/tab-send.scss +++ b/src/sass/views/tab-send.scss @@ -105,7 +105,7 @@ width: auto; margin: 2px 0 4px; } - min-height: 65px; + height: 60px; line-height: 16px; margin-right: 0px; width: 95%; diff --git a/src/sass/views/walletDetails.scss b/src/sass/views/walletDetails.scss index e8b64ef45..858229d85 100644 --- a/src/sass/views/walletDetails.scss +++ b/src/sass/views/walletDetails.scss @@ -1,4 +1,3 @@ -$wallet-details-collapse-transition: all 0.25s ease-in-out; .wallet-details { &__tx-amount { font-size: 16px; @@ -138,20 +137,6 @@ $wallet-details-collapse-transition: all 0.25s ease-in-out; margin-top: 20px; margin-top: env(safe-area-inset-top); } - &.collapse { - ion-content { - margin-top: 40px; - } - .amount { - &__scale, &__error { - -webkit-transform: scale3d(0.5, 0.5, 0.5) translateY(0px); - transform: scale3d(0.5, 0.5, 0.5) translateY(0px); - } - } - .amount-alternative, .send-receive-buttons, .wallet-details-wallet-info { - opacity: 0; - } - } } .bar-header { border: 0; @@ -167,14 +152,13 @@ $wallet-details-collapse-transition: all 0.25s ease-in-out; background-color: inherit !important; } ion-content { + + &.collapsible { + margin-top: 230px; + } + padding-top: 0; top: 0; - transition: $wallet-details-collapse-transition; - - margin-top: 185px; - @media only screen and (max-height:500px) { - margin-top: 165px; - } margin-bottom: 16px; .scroll { @@ -215,7 +199,7 @@ $wallet-details-collapse-transition: all 0.25s ease-in-out; width: 100%; position: absolute; bottom: 20px; - transition: $wallet-details-collapse-transition; + >.col { padding: 5px 10px; margin-bottom: 0; @@ -223,37 +207,30 @@ $wallet-details-collapse-transition: all 0.25s ease-in-out; .button { border: 2px solid; border-radius: 47px; - padding: 6px 2px 6px 2px; + padding: 0 15px 0 15px; text-align: center; width: 100%; max-width: 300px; font-size: 19px; font-weight: bolder; - min-height: 0; - line-height: 19px; + min-height: auto; + line-height: 36px; } } } .amount { - align-items: center; - color: #fff; - display: block; - - height: 230px; - @media only screen and (max-height:500px) { - height: 210px; - } - - justify-content: center; - padding-top: 40px; - text-align: center; - transition: $wallet-details-collapse-transition; width: 100%; + text-align: center; + color: #fff; + height: 230px; + padding-top: 40px; + display: block; + align-items: center; + justify-content: center; &__balance { -webkit-transform: scale3d(1, 1, 1) translateY(45px); transform: scale3d(1, 1, 1) translateY(45px); - transition: $wallet-details-collapse-transition; } &__updating { @@ -263,7 +240,6 @@ $wallet-details-collapse-transition: all 0.25s ease-in-out; &-alternative { line-height: 36px; - transition: $wallet-details-collapse-transition; } &__button-balance { @@ -279,7 +255,6 @@ $wallet-details-collapse-transition: all 0.25s ease-in-out; &__error { font-size: 14px; padding: 35px 20px; - opacity: 1; } } @@ -366,6 +341,4 @@ a.item { .loading-wallet svg { margin-top: 0; - width: 16px; - height: 16px; } \ No newline at end of file diff --git a/src/shim/shim.js b/src/shim/shim.js index 6f9abc0ae..495848f05 100644 --- a/src/shim/shim.js +++ b/src/shim/shim.js @@ -8,56 +8,4 @@ if (!ArrayBuffer['isView']) { ArrayBuffer.isView = function(a) { return a !== null && typeof(a) === "object" && a['buffer'] instanceof ArrayBuffer; }; -} - -// https://tc39.github.io/ecma262/#sec-array.prototype.includes -if (!Array.prototype.includes) { - Object.defineProperty(Array.prototype, 'includes', { - value: function(searchElement, fromIndex) { - - if (this == null) { - throw new TypeError('"this" is null or not defined'); - } - - // 1. Let O be ? ToObject(this value). - var o = Object(this); - - // 2. Let len be ? ToLength(? Get(O, "length")). - var len = o.length >>> 0; - - // 3. If len is 0, return false. - if (len === 0) { - return false; - } - - // 4. Let n be ? ToInteger(fromIndex). - // (If fromIndex is undefined, this step produces the value 0.) - var n = fromIndex | 0; - - // 5. If n ≥ 0, then - // a. Let k be n. - // 6. Else n < 0, - // a. Let k be len + n. - // b. If k < 0, let k be 0. - var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); - - function sameValueZero(x, y) { - return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y)); - } - - // 7. Repeat, while k < len - while (k < len) { - // a. Let elementK be the result of ? Get(O, ! ToString(k)). - // b. If SameValueZero(searchElement, elementK) is true, return true. - if (sameValueZero(o[k], searchElement)) { - return true; - } - // c. Increase k by 1. - k++; - } - - // 8. Return false - return false; - } - }); } \ No newline at end of file diff --git a/test/karma.conf.js b/test/karma.conf.js index 22efcd1c8..b4f64af73 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -17,7 +17,7 @@ module.exports = function(config) { files: [ 'node_modules/angular/angular.js', - 'bitanalytics/bitanalytics.js', + 'bitanalytics/bitanalytics-0.1.0.js', // From Gruntfile.js 'bower_components/qrcode-generator/js/qrcode.js', diff --git a/www/css/main.css b/www/css/main.css index 83c50fe17..8602ba35d 100644 --- a/www/css/main.css +++ b/www/css/main.css @@ -10083,7 +10083,7 @@ ion-view.deflash-blue:before, ion-view#view-amount:before, ion-view#view-confirm .onboarding .button.button-white.button-standard, .onboarding .button.button-green.button-standard, .onboarding .button.button-assertive.button-standard, #shapeshift .button-shapeshift { - width: 90%; + width: 85%; max-width: 300px; margin-left: auto; margin-right: auto; @@ -10195,7 +10195,6 @@ ion-view.deflash-blue:before, ion-view#view-amount:before, ion-view#view-confirm .button { border-radius: 6px; } .button.button-full { - border-radius: 0; display: block; } .button-green { border-color: #FFF; @@ -10264,8 +10263,8 @@ ion-view.deflash-blue:before, ion-view#view-amount:before, ion-view#view-confirm color: #FFFFFF; text-decoration: none; } .button-white-outline.active, .button-white-outline.activated { - border-color: #FFFFFF; - background-color: #FFFFFF; } + border-color: #FFF; + background-color: #FAFAFA; } .button-white-outline.button-outline { border-color: #FFFFFF; background: transparent; @@ -10633,7 +10632,7 @@ qrcode { #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.long .primary-amount-display { font-size: 2em; } } #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .primary-amount-display { - font-size: 1.2em; } + font-size: 0.9em; } @media (min-width: 375px) { #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long input, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .unit, #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount.very-long .primary-amount-display { font-size: 1.3em; } } @@ -10660,8 +10659,7 @@ qrcode { line-height: 1em; } #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .primary-amount .primary-amount-display { margin-right: 5px; - word-break: break-all; - width: 100%; } + word-break: break-all; } #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .alternative-amount { color: #6F6F70; } #view-amount .scroll-content .send-amount .send-amount-tool .send-amount-tool-input .switch-currencies { @@ -10682,33 +10680,30 @@ qrcode { justify-content: space-between; margin: 0 14px; } #view-amount .scroll-content .send-amount-extras .available-funds { - color: #6F6F70; - text-align: left; } - #view-amount .scroll-content .send-amount-extras .change-currency { - text-align: right; } + color: #6F6F70; } #view-amount .scroll-content .send-amount-extras .warning { color: #b7664d; } - #view-amount .scroll-content .send-amount-extras .extra { - flex: 1; + #view-amount .scroll-content .send-amount-extras .extra, + #view-amount .scroll-content .send-amount-extras button.extra { + /*display: flex;*/ + flex: 0 1 auto; } + #view-amount .scroll-content .send-amount-extras button.extra { + background: none; + border: none; + color: #000; + font-family: 'ProximaNova'; + font-size: 14px; + line-height: normal; + min-height: auto; + min-width: auto; + padding: 0; } + #view-amount .scroll-content .send-amount-extras .button .icon:before { + font-size: 14px; line-height: normal; } - #view-amount .scroll-content .send-amount-extras .extra .button { - background: none; - border: none; - border-radius: 0; - color: #000; - font-family: 'ProximaNova'; - font-size: 14px; - line-height: normal; - min-height: auto; - min-width: auto; - padding: 0; } - #view-amount .scroll-content .send-amount-extras .extra .button .icon:before { - font-size: 14px; - line-height: normal; } - #view-amount .scroll-content .send-amount-extras .extra .button span { - display: flex; - align-items: center; - justify-content: center; } + #view-amount .scroll-content .send-amount-extras .button span { + display: flex; + align-items: center; + justify-content: center; } #view-amount .scroll-content .button.no-margin { margin: 0; } #view-amount .scroll-content .notification-warning { @@ -10944,14 +10939,14 @@ qrcode { #tab-home .buttons .button { border: 2px solid; border-radius: 47px; - padding: 8px 2px 8px 2px; + padding: 0 15px 0 15px; text-align: center; width: 100%; max-width: 300px; font-size: 19px; font-weight: bolder; - min-height: 0; - line-height: 19px; } + min-height: auto; + line-height: 36px; } #tab-home .wallet-coin-logo { vertical-align: middle; @@ -11018,10 +11013,6 @@ qrcode { #tab-home .release .title { font-weight: 700; color: #444; } - #tab-home .release .release-notes { - white-space: pre; - white-space: pre-line; - text-align: left; } #tab-home .release .button { width: 100%; border: none; } @@ -11034,14 +11025,6 @@ qrcode { #tab-home .badge { top: 11px; } -.popup-update .popup-buttons { - display: block; } - -.popup-update .popup-buttons .button { - display: block; - min-width: 100% !important; - margin-top: 4px; } - #tab-receive .button-share { color: #fff; box-shadow: none; @@ -11118,8 +11101,6 @@ qrcode { #tab-receive .payment-received-container { margin: 0 20px; } - #tab-receive .payment-received-container svg { - max-height: 400px; } #tab-receive .payment-received-container .payment-received-amount { font-size: 1.8em; display: block; @@ -11226,7 +11207,7 @@ qrcode { margin: auto; margin-top: 18px; } #tab-send .send-wrapper .buttons .button { - min-height: 65px; + height: 60px; line-height: 16px; margin-right: 0px; width: 95%; @@ -11303,9 +11284,7 @@ qrcode { margin-top: 18px; } #tab-send .sendTip .buttons .button { font-weight: bold; - font-size: 19px; - line-height: 26px; - padding: 8px 6px; } + font-size: 19px; } #tab-send .sendTip .button-first-contact img { height: 19px; width: 19px; @@ -11941,13 +11920,6 @@ qrcode { #walletDetails .bp-content.status-bar { margin-top: 20px; margin-top: env(safe-area-inset-top); } - #walletDetails .bp-content.collapse ion-content { - margin-top: 40px; } - #walletDetails .bp-content.collapse .amount__scale, #walletDetails .bp-content.collapse .amount__error { - -webkit-transform: scale3d(0.5, 0.5, 0.5) translateY(0px); - transform: scale3d(0.5, 0.5, 0.5) translateY(0px); } - #walletDetails .bp-content.collapse .amount-alternative, #walletDetails .bp-content.collapse .send-receive-buttons, #walletDetails .bp-content.collapse .wallet-details-wallet-info { - opacity: 0; } #walletDetails .bar-header { border: 0; background: #eeb640; } @@ -11960,12 +11932,9 @@ qrcode { #walletDetails ion-content { padding-top: 0; top: 0; - transition: all 0.25s ease-in-out; - margin-top: 185px; margin-bottom: 16px; } - @media only screen and (max-height: 500px) { - #walletDetails ion-content { - margin-top: 165px; } } + #walletDetails ion-content.collapsible { + margin-top: 230px; } #walletDetails ion-content .scroll { background: #f8f8f9; min-height: 300px; } @@ -11996,45 +11965,38 @@ qrcode { justify-content: space-evenly; width: 100%; position: absolute; - bottom: 20px; - transition: all 0.25s ease-in-out; } + bottom: 20px; } #walletDetails .amount-wrapper .send-receive-buttons > .col { padding: 5px 10px; margin-bottom: 0; } #walletDetails .amount-wrapper .send-receive-buttons .button { border: 2px solid; border-radius: 47px; - padding: 6px 2px 6px 2px; + padding: 0 15px 0 15px; text-align: center; width: 100%; max-width: 300px; font-size: 19px; font-weight: bolder; - min-height: 0; - line-height: 19px; } + min-height: auto; + line-height: 36px; } #walletDetails .amount { - align-items: center; - color: #fff; - display: block; - height: 230px; - justify-content: center; - padding-top: 40px; + width: 100%; text-align: center; - transition: all 0.25s ease-in-out; - width: 100%; } - @media only screen and (max-height: 500px) { - #walletDetails .amount { - height: 210px; } } + color: #fff; + height: 230px; + padding-top: 40px; + display: block; + align-items: center; + justify-content: center; } #walletDetails .amount__balance { -webkit-transform: scale3d(1, 1, 1) translateY(45px); - transform: scale3d(1, 1, 1) translateY(45px); - transition: all 0.25s ease-in-out; } + transform: scale3d(1, 1, 1) translateY(45px); } #walletDetails .amount__updating { z-index: 999; margin-top: -2.1rem; } #walletDetails .amount-alternative { - line-height: 36px; - transition: all 0.25s ease-in-out; } + line-height: 36px; } #walletDetails .amount__button-balance { background-color: transparent; border: 1px solid rgba(255, 255, 255, 0.25); @@ -12044,8 +12006,7 @@ qrcode { vertical-align: middle; } #walletDetails .amount__error { font-size: 14px; - padding: 35px 20px; - opacity: 1; } + padding: 35px 20px; } #walletDetails .no-alternative { padding-top: 45px; } #walletDetails .item.item-footer { @@ -12110,9 +12071,7 @@ a.item { font-size: 0.9em; } .loading-wallet svg { - margin-top: 0; - width: 16px; - height: 16px; } + margin-top: 0; } #advanced-settings .list .item:before { display: block; @@ -12166,9 +12125,7 @@ a.item { margin-top: 18px; } #shapeshift .empty-case .buttons .button { font-weight: bold; - font-size: 19px; - line-height: 26px; - padding: 8px 6px; } + font-size: 19px; } #shapeshift .empty-case .button-first-contact img { height: 19px; width: 19px; @@ -13855,7 +13812,6 @@ click-to-accept { height: 92px; width: 100%; } click-to-accept .click-to-accept__button.button.button-primary.button-standard { - border-radius: 0; height: 100%; max-width: 9999px; width: 100%; } @@ -13962,8 +13918,6 @@ slide-to-accept { height: 92px; width: 100%; background: #494949; } - slide-to-accept .slide .button { - border-radius: 0; } slide-to-accept .slide__listener { height: 100%; width: 100%; @@ -15395,25 +15349,20 @@ log-options #check-bar .checkbox-icon { #cash-scan a { cursor: pointer; } -#view-review slide-to-accept, #view-review slide-to-accept-success { - margin-bottom: constant(safe-area-inset-bottom); - /* iOS 11.0 */ - margin-bottom: env(safe-area-inset-bottom); - /* iOS 11.2 */ } - -#view-review .fee-summary { - bottom: 92px; - bottom: calc(92px + constant(safe-area-inset-bottom)); - /* iOS 11.0 */ - bottom: calc(92px + env(safe-area-inset-bottom)); - /* iOS 11.2 */ - position: absolute; } - -#view-review .shapeshift-banner, #view-review .bitpay-banner, #view-review .egifter-banner { - box-shadow: none; } - -#view-review .warning { - color: #b7664d; } +#view-review { + background-color: #494949; } + #view-review slide-to-accept, #view-review slide-to-accept-success { + margin-bottom: constant(safe-area-inset-bottom); + /* iOS 11.0 */ + margin-bottom: env(safe-area-inset-bottom); + /* iOS 11.2 */ } + #view-review .fee-summary { + position: absolute; + bottom: 92px; } + #view-review .shapeshift-banner, #view-review .bitpay-banner, #view-review .egifter-banner { + box-shadow: none; } + #view-review .warning { + color: #b7664d; } .gravatar { border-radius: 3px; @@ -15446,7 +15395,6 @@ log-options #check-bar .checkbox-icon { left: 13px; top: 50%; padding: 0; - -webkit-transform: translate(0, -50%); transform: translate(0, -50%); } .item .item-content.item-content-compact { @@ -15515,8 +15463,8 @@ ion-content.padded-bottom-cta-with-summary { overflow: hidden; text-overflow: ellipsis; } .address-frame.expanded { - white-space: normal; - text-overflow: clip; } + white-space: pre-wrap; + word-break: break-all; } .address-frame .prefix { color: #000000; } .address-frame .mid { @@ -15559,13 +15507,13 @@ ion-content.padded-bottom-cta-with-summary { transform: scale(1, 1); } .fee-summary { - background-color: #F2F2F2; - box-sizing: border-box; + position: relative; display: flex; flex-direction: column; + width: 100%; padding: 5px 12px 15px; - position: relative; - width: 100%; } + box-sizing: border-box; + background-color: #F2F2F2; } .fee-summary:before { content: ''; position: absolute; @@ -15575,16 +15523,16 @@ ion-content.padded-bottom-cta-with-summary { height: 15px; background: linear-gradient(to bottom, rgba(242, 242, 242, 0) 0%, #f2f2f2 100%); } .fee-summary .amount { + display: flex; + flex-direction: row; + justify-content: space-between; width: 100%; } - .fee-summary .amount .fee-fiat { - display: inline; } - .fee-summary .amount .fee-fiat.positive { - color: #70955F; } - .fee-summary .amount .fee-fiat.negative { - color: #C24633; } + .fee-summary .amount .fee-fiat.positive { + color: #70955F; } + .fee-summary .amount .fee-fiat.negative { + color: #C24633; } .fee-summary .amount .fee-crypto { - color: #A7A7A7; - float: right; } + color: #A7A7A7; } .formatted-amount { display: inline-block; } @@ -15609,9 +15557,6 @@ ion-content.padded-bottom-cta-with-summary { margin-left: 5px; text-transform: uppercase; } -.wallet-balance-directive { - display: inline-block; } - /* This is for rules that don't yet have a home. * Our goal is to delete this file. Search the regex: /class=".*CLASS.*?"/ */ diff --git a/www/views/amount.html b/www/views/amount.html index 51397f3bf..939937be8 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -53,12 +53,11 @@
-
+
diff --git a/www/views/includes/community.html b/www/views/includes/community.html index ad7dcb169..86841a77c 100644 --- a/www/views/includes/community.html +++ b/www/views/includes/community.html @@ -26,7 +26,7 @@
- Share the Wallet App + Share the Wallet App
diff --git a/www/views/includes/incomingDataMenu.html b/www/views/includes/incomingDataMenu.html index e60d7e956..ca4b78dfc 100644 --- a/www/views/includes/incomingDataMenu.html +++ b/www/views/includes/incomingDataMenu.html @@ -9,21 +9,21 @@
- {{data.original}} + {{data}}
- +
Add as a contact
- +
Send payment to this address
- +
Copy to clipboard
@@ -38,11 +38,11 @@
Text
- {{data.original}} + {{data}}
-
+
Copy to clipboard
@@ -57,40 +57,16 @@
Private Key
- {{data.original}} + {{data}}
-
+
Sweep paper wallet
- - -
Copy to clipboard
- -
- - Cancel - - - - - - + +
Auditable diff --git a/www/views/paperWallet.html b/www/views/paperWallet.html index 26415a5d0..a8d3d2ee4 100644 --- a/www/views/paperWallet.html +++ b/www/views/paperWallet.html @@ -1,6 +1,6 @@ - {{'Sweep Paper Wallet' | translate}} + {{'Sweep paper wallet' | translate}} @@ -45,19 +45,19 @@
- No Bitcoin Cash wallet to transfer funds to found. + No Bitcoin Cash wallet to transfer funds to found.
-

No Bitcoin Cash found.

+

No Bitcoin Cash found

-

Bitcoin Core found:

+

Bitcoin found:

{{btcBalanceText}}
@@ -95,13 +95,13 @@
- No Bitcoin Core wallet to transfer funds to found. + No Bitcoin wallet to transfer funds to found.
-

No Bitcoin Core found.

+

No Bitcoin found

-
{{newReleaseText}}
-
+
{{updateText}}
- -
+
Download
diff --git a/www/views/tab-send.html b/www/views/tab-send.html index b8c2b7884..0b62fe0a5 100644 --- a/www/views/tab-send.html +++ b/www/views/tab-send.html @@ -17,13 +17,14 @@

{{fromWallet.name}}

+ +
diff --git a/www/views/walletDetails.html b/www/views/walletDetails.html index 302a2b7a4..6e05862aa 100644 --- a/www/views/walletDetails.html +++ b/www/views/walletDetails.html @@ -16,74 +16,79 @@ } -
+
-
+
-
+
{{updateStatusError}}
-
+
This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information.
+ ng-style="{'transform': amountScale}" + ng-class="{amount__balance: amountIsCollapsible}">
+ ng-if="status.totalBalanceStr && wallet.network == 'livenet'" + ng-style="{opacity: altAmountOpacity}">
+ ng-style="{'transform': amountScale}" + ng-if="status.totalBalanceStr" + ng-class="{amount__balance: amountIsCollapsible}">
+ ng-if="status.totalBalanceAlternative && wallet.network == 'livenet'" + ng-style="{opacity: altAmountOpacity}">
-
[Balance Hidden] -
+
Tap and hold to show
-
+
[Scanning Funds] -
+
Please wait
-
+
-
+
Receive @@ -113,18 +118,136 @@
-
+
- + + +
+ +
+ +
+ {{updateStatusError}} +
+ +
+ This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information. +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ [Balance Hidden] +
+ Tap and hold to show +
+
+ + +
+ [Scanning Funds] +
+ Please wait +
+
+ + +
+ +
+ +
+ +
+ +
+
+
+ Receive +
+
+
+
+ Buy Bitcoin +
+
+ Send +
+
+
+ +
+
+ +
+
+ + + Wallet not backed up @@ -161,29 +284,29 @@
+ ng-show="!txHistory[0] && !updatingTxHistory && !updateTxHistoryError && !updateStatusError" translate> No transactions yet
+ ng-show="!txHistory[0] && !updatingTxHistory && updateTxHistoryError" translate> Could not update transaction history
-
+
Updating transaction history. Please stand by.
{{updatingTxHistoryProgress}} transactions downloaded
-
+
diff --git a/www/views/walletSelector.html b/www/views/walletSelector.html index a9712adf9..2e4c4bc31 100644 --- a/www/views/walletSelector.html +++ b/www/views/walletSelector.html @@ -13,7 +13,7 @@
{{requestAmountSecondary}} {{requestCurrencySecondary}}
-
+
{{headerTitle}}