├── .gitignore ├── LICENSE ├── README.md ├── package ├── linux │ └── Authenticator Wallet.png ├── macosx │ └── Authenticator Wallet.icns └── windows │ └── Authenticator Wallet.ico ├── pom.xml └── src ├── main ├── java │ ├── authenticator │ │ ├── Authenticator.java │ │ ├── BAApplicationParameters.java │ │ ├── BASE.java │ │ ├── BipSSS │ │ │ ├── BipSSS.java │ │ │ ├── Gf256.java │ │ │ └── SSSUtils.java │ │ ├── GCM │ │ │ ├── GCMSender.java │ │ │ └── dispacher │ │ │ │ ├── Device.java │ │ │ │ ├── Dispacher.java │ │ │ │ └── MessageBuilder.java │ │ ├── Utils │ │ │ ├── CryptoUtils.java │ │ │ ├── CurrencyConverter │ │ │ │ ├── Currency.java │ │ │ │ ├── CurrencyConverterSingelton.java │ │ │ │ └── exceptions │ │ │ │ │ └── CurrencyConverterSingeltonNoDataException.java │ │ │ ├── EncodingUtils.java │ │ │ ├── FileUtils.java │ │ │ ├── KeyUtils.java │ │ │ ├── OneName │ │ │ │ ├── OneName.java │ │ │ │ ├── OneNameAdapter.java │ │ │ │ ├── OneNameListener.java │ │ │ │ └── exceptions │ │ │ │ │ ├── CannotSaveOneNameImageException.java │ │ │ │ │ └── CannotSetOneNameProfileException.java │ │ │ └── SafeList.java │ │ ├── db │ │ │ ├── ConfigFile.java.orig │ │ │ ├── dbBase.java │ │ │ ├── exceptions │ │ │ │ ├── AccountWasNotFoundException.java │ │ │ │ └── CouldNotOpenConfigFileException.java │ │ │ ├── settingsDB.java │ │ │ └── walletDB.java │ │ ├── helpers │ │ │ └── BAApplication.java │ │ ├── hierarchy │ │ │ ├── BAHierarchy.java │ │ │ ├── HierarchyUtils.java │ │ │ └── exceptions │ │ │ │ ├── IncorrectPathException.java │ │ │ │ ├── KeyIndexOutOfRangeException.java │ │ │ │ ├── NoAccountCouldBeFoundException.java │ │ │ │ └── NoUnusedKeyException.java │ │ ├── listeners │ │ │ ├── BAGeneralEventsAdapter.java │ │ │ └── BAGeneralEventsListener.java │ │ ├── network │ │ │ ├── BANetworkInfo.java │ │ │ ├── CannotProcessRequestPayload.java │ │ │ ├── GetRequestIDPayload.java │ │ │ ├── PongPayload.java │ │ │ ├── TCPListener.java │ │ │ ├── TrustedPeerNodes.java │ │ │ ├── UpNp.java │ │ │ └── exceptions │ │ │ │ └── TCPListenerCouldNotStartException.java │ │ ├── operations │ │ │ ├── BAOperation.java │ │ │ ├── BAWalletRestorer.java │ │ │ ├── OperationsFactory.java │ │ │ ├── OperationsUtils │ │ │ │ ├── CommunicationObjects │ │ │ │ │ └── SignMessage.java │ │ │ │ ├── PairingProtocol.java │ │ │ │ ├── PairingQRCode.java │ │ │ │ ├── PaperSSSQR.java │ │ │ │ ├── PaperWalletQR.java │ │ │ │ └── SignProtocol.java │ │ │ ├── exceptions │ │ │ │ └── BAOperationNetworkRequirementsNotAvailableException.java │ │ │ └── listeners │ │ │ │ ├── OperationListener.java │ │ │ │ └── OperationListenerAdapter.java │ │ ├── protobuf │ │ │ ├── AuthWalletHierarchy.java │ │ │ ├── BAHierarchy.proto │ │ │ ├── ProtoConfig.java │ │ │ ├── ProtoSettings.java │ │ │ ├── config.proto │ │ │ └── configSettings.proto │ │ └── walletCore │ │ │ ├── WalletOperation.java │ │ │ ├── WalletWrapper.java │ │ │ ├── exceptions │ │ │ ├── AddressNotWatchedByWalletException.java │ │ │ ├── AddressWasNotFoundException.java │ │ │ ├── CannotBroadcastTransactionException.java │ │ │ ├── CannotGetAccountFilteredTransactionsException.java │ │ │ ├── CannotGetAccountUsedAddressesException.java │ │ │ ├── CannotGetAddressException.java │ │ │ ├── CannotGetHDKeyException.java │ │ │ ├── CannotGetPendingRequestsException.java │ │ │ ├── CannotReadFromConfigurationFileException.java │ │ │ ├── CannotRemovePendingRequestException.java │ │ │ ├── CannotWriteToConfigurationFileException.java │ │ │ ├── NoWalletPasswordException.java │ │ │ └── UnableToCompleteTxSigningException.java │ │ │ └── utils │ │ │ ├── BAPassword.java │ │ │ ├── BalanceUpdater.java │ │ │ ├── CoinsReceivedNotificationSender.java │ │ │ └── WalletListener.java │ └── wallettemplate │ │ ├── AccountsController.java │ │ ├── CoinJoinController.java │ │ ├── Controller.java │ │ ├── ControllerHelpers │ │ ├── AsyncTask.java │ │ ├── SendTxHelper.java │ │ ├── SendTxOverlayHelper.java │ │ ├── TableTx.java │ │ ├── ThrottledRunnableExecutor.java │ │ └── UIUpdateHelper.java │ │ ├── Main.java │ │ ├── NotImplementedYetController.java │ │ ├── OneNameController.java │ │ ├── OneNameControllerDisplay.java │ │ ├── PairWallet.java │ │ ├── RemoteUpdateWindow.java │ │ ├── SettingsController.java │ │ ├── ShowSeedController.java │ │ ├── ShutDownController.java │ │ ├── controls │ │ ├── BitcoinAddressValidator.java │ │ ├── DisplayAccountCell.java │ │ ├── ScrollPaneContentManager.java │ │ └── SendToCell.java │ │ ├── startup │ │ ├── AddAccountWindow.java │ │ ├── RestoreAccountCell.java │ │ ├── RestoreProcessCell.java │ │ ├── SSSRestoreCell.java │ │ ├── StartupController.java │ │ ├── StartupControllerHelper.java │ │ ├── TestSSSCell.java │ │ ├── TestSSSResultCell.java │ │ ├── TestSSSWindow.java │ │ └── backup │ │ │ ├── PaperSSSController.java │ │ │ └── PaperWalletController.java │ │ └── utils │ │ ├── AlertWindowController.java │ │ ├── BaseUI.java │ │ ├── GuiUtils.java │ │ ├── ImageUtils.java │ │ ├── TextFieldValidator.java │ │ ├── TextUtils.java │ │ ├── ThrottledRunLater.java │ │ └── dialogs │ │ ├── BADialog.java │ │ ├── BADialogBase.java │ │ └── DialogFactory.java └── resources │ └── wallettemplate │ ├── DefaultAvatar.png │ ├── DisplayOneName.fxml │ ├── OneName.fxml │ ├── SendToCell.fxml │ ├── Settings.fxml │ ├── ShutDownWarning.fxml │ ├── Tor_color.png │ ├── Tor_grey.png │ ├── accounts │ ├── account_cell.fxml │ ├── accounts.fxml │ ├── accounts_display_bg.png │ ├── btnAddAccount.png │ ├── btnSettingsSmall.png │ ├── close.png │ └── closeSettingsWindow.png │ ├── accounts_icons │ ├── authenticator_logo_small.png │ ├── bitcoin_logo_plain_small.png │ └── btnSettingsSmall.png │ ├── apps │ ├── btnAccounts.png │ ├── btnAccounts@2x.png │ ├── btnAddressBook.png │ ├── btnAddressBook@2x.png │ ├── btnBitcoinAuthenticator.png │ ├── btnBitcoinAuthenticator@2x.png │ ├── btnBnB.png │ ├── btnBnB@2x.png │ ├── btnCoinControl.png │ ├── btnCoinControl@2x.png │ ├── btnCoinJoin.png │ ├── btnCoinJoin@2x.png │ ├── btnCoinbase.png │ ├── btnCoinbase@2x.png │ ├── btnDonate.png │ ├── btnDonate@2x.png │ ├── btnLocalBitcoins.png │ ├── btnLocalBitcoins@2x.png │ ├── btnLocks.png │ ├── btnLocks@2x.png │ ├── btnOneName.png │ ├── btnOneName@2x.png │ ├── btnSettings.png │ └── btnSettings@2x.png │ ├── auth1.png │ ├── auth2.png │ ├── authenticator_logo_plain_small.png │ ├── background.png │ ├── bitcoin_logo_plain.png │ ├── bitcoin_logo_small.png │ ├── btnApps_grey.png │ ├── btnApps_grey@2x.png │ ├── btnApps_white.png │ ├── btnApps_white@2x.png │ ├── btnAvatar.png │ ├── btnBitcoinAuthenticator.png │ ├── btnBitcoinAuthenticator@2x.png │ ├── btnLocked.png │ ├── btnLocked@2x.png │ ├── btnOverview_grey.png │ ├── btnOverview_grey@2x.png │ ├── btnOverview_white.png │ ├── btnOverview_white@2x.png │ ├── btnReceive_grey.png │ ├── btnReceive_grey@2x.png │ ├── btnReceive_white.png │ ├── btnReceive_white@2x.png │ ├── btnSend_grey.png │ ├── btnSend_grey@2x.png │ ├── btnSend_white.png │ ├── btnSend_white@2x.png │ ├── btnTransactions_grey.png │ ├── btnTransactions_grey@2x.png │ ├── btnTransactions_white.png │ ├── btnTransactions_white@2x.png │ ├── btnUnlocked.png │ ├── btnUnlocked@2x.png │ ├── checkpoints │ ├── checkpoints.testnet │ ├── close.png │ ├── coinjoin.fxml │ ├── coinjoin.png │ ├── connection0.png │ ├── connection1.png │ ├── connection2.png │ ├── connection3.png │ ├── gui.fxml │ ├── in-out.png │ ├── in.png │ ├── ivAddress.png │ ├── ivSync.png │ ├── lockbackground.png │ ├── minimize.png │ ├── net_green.png │ ├── net_grey.png │ ├── net_yellow.png │ ├── on_script.png │ ├── on_symbol.png │ ├── out.png │ ├── ovrImage.png │ ├── pairing │ ├── BAApp.fxml │ ├── baPhone.jpg │ ├── btnBitcoinAuthenticator.png │ └── btnHelp.png │ ├── passwords.html │ ├── phone.png │ ├── progress-green.png │ ├── progress-red.png │ ├── progress-yellow.png │ ├── remote_update │ ├── RemoteUpdateWindow.fxml │ └── splashBackground.png │ ├── rocket.png │ ├── show_seed.fxml │ ├── startup │ ├── 2fa1.png │ ├── 2fa2.png │ ├── 2fa3.png │ ├── AddPairedAccount.fxml │ ├── AddStandardAccount.fxml │ ├── PaperWallet.png │ ├── PaperWalletSSS.png │ ├── SSSRestoreCell.fxml │ ├── TestSSS.fxml │ ├── TestSSSCell.fxml │ ├── TestSSSResultCell.fxml │ ├── btnNewWallet.png │ ├── btnP2KH.png │ ├── btnPaperWallet.png │ ├── btnRestore.png │ ├── btnSSS.png │ ├── btnSave.png │ ├── failed_icon.png │ ├── googleplay.png │ ├── logo.png │ ├── restore_account_cell.fxml │ ├── restore_process_cell.fxml │ ├── success_icon.png │ └── walletstartup.fxml │ ├── trash.png │ └── utils │ ├── GUI.css │ ├── alert.fxml │ ├── controls │ └── bitcoin_address.fxml │ ├── dialogs │ ├── confirmDialog.fxml │ ├── infoDialog.fxml │ └── inputDialog.fxml │ └── text-validation.css └── test └── java └── authenticator ├── AuthenticatorTest.java ├── CoinsReceivedNotificationTest.java ├── CryptoUtilsTest.java ├── FileUtilsTest.java ├── GCM └── MessageBuilderTest.java ├── backup ├── QRBackupTest.java └── SSSBackupTest.java ├── network ├── GetRequestIDPayloadTest.java └── PongPayloadTest.java ├── operations ├── PairingQRTest.java ├── PairingTest.java ├── SignTransactionTest.java └── UpdateIPsTest.java └── walletCore └── utils ├── CoinsReceivedNotificationSenderTest.java └── WalletListenerTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | local.properties 2 | .classpath 3 | .project 4 | .settings/ 5 | .idea/ 6 | consensus-microdesc 7 | certificates 8 | cached-microdescs 9 | state 10 | cached-microdescs.new 11 | *.config 12 | *.spvchain 13 | *.wallet 14 | *.orig 15 | PairingQRCode.png 16 | bin/ 17 | gen/ 18 | target/ 19 | packages/ 20 | proguard/ 21 | /target/ 22 | /dist/ 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Bitcoin Authenticator 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BitcoinAuthenticator - Wallet 2 | ==================== 3 | 4 | ###IMPORTANT - This project is under development. 5 | [![Coverage Status](https://coveralls.io/repos/negedzuregal/BitcoinAuthWallet/badge.png?branch=develop)](https://coveralls.io/r/negedzuregal/BitcoinAuthWallet?branch=develop) 6 | 7 | 8 | ####What Is This ? 9 | ![alt tag](https://raw.githubusercontent.com/cpacia/BitcoinAuthenticator/master/res/drawable-xhdpi/ic_icon_action_bar.png) 10 | 11 | Bitcoin Authenticator is a P2P bitcoin wallet and [android application](https://github.com/cpacia/BitcoinAuthenticator) for creating a 2 factor transaction authentication and authorization. Bitcoin Authenticator is composed of a desktop wallet and an [android application](https://github.com/cpacia/BitcoinAuthenticator), by pairing the two together they create an P2SH bitcoin address. Any bitcoins that are transferred to that address will require the authentication and digital signature of both the desktop wallet and the android Authenticator app. 12 | 13 | ####How do i get the android application ? 14 | [Click here](https://github.com/cpacia/BitcoinAuthenticator) 15 | 16 | #### Building requirements for the BitcoinAuthenticator wallet 17 | 1. Install Java 8 18 | 2. [Eclipse Luna, Support for java 8](http://www.eclipse.org/home/index.php) (Obviously, only if you work with eclipse) 19 | 20 | ## Building 21 | 22 | #####With Maven 23 | 1. Clone the project:
24 | ``` 25 | $ git clone https://github.com/negedzuregal/BitcoinAuthWallet.git 26 | ``` 27 | 2. 28 | ``` 29 | $ cd BitcoinAuthWallet 30 | ``` 31 | 3. build:
32 | ``` 33 | $mvn clean package 34 | ``` 35 | 36 | #### Protobuf class 37 | From the Protobuf folder(/src/main/java/authenticator/protobuf): 38 | ``` 39 | $ protoc .proto --java_out=../../ --proto_path=./ --proto_path= 40 | ``` 41 | 42 | For protobuf-install-directory see [this](http://stackoverflow.com/questions/20069295/importing-google-protobuf-descriptor-proto-in-java-protocol-buffers) 43 | 44 | #### Importing Into Eclipse 45 | 1. In Eclipse: 46 | ``` 47 | File -> Import -> existing maven project 48 | ``` 49 | 3. Run with JVM assertion flag:
50 | ``` 51 | Run -> Run Configurations -> arguments -> add -ea in VM Arguments 52 | ``` 53 | 54 | ## Native Installer 55 | 1. build:
56 | ``` 57 | $mvn clean package 58 | ``` 59 | 2. Set jh (OSX/ Linux): 60 | ``` 61 | $ jh=$JAVA_HOME/bin 62 | ``` 63 |
64 | Set jh (Windows): 65 | ``` 66 | c:\ set jh=%JAVA_HOME%/bin 67 | ``` 68 | 3. Build (OSX/ Linux): 69 | ``` 70 | $ $jh/javafxpackager -deploy -v -native -outdir . -outdir packages -outfile BTCAuthenticator -srcdir target -srcfiles wallettemplate-app.jar -appclass wallettemplate.Main -name "Authenticator Wallet" -title "Authenticator Wallet" 71 | ``` 72 |
73 | Build (Windows): 74 | ``` 75 | c:\ "%jh%/javafxpackager.exe" -deploy -v -native -outdir . -outdir packages -outfile BTCAuthenticator -srcdir target -srcfiles wallettemplate-app.jar -appclass wallettemplate.Main -name "Authenticator Wallet" -title "Authenticator Wallet" 76 | ``` 77 | 78 | ## Development 79 | - Check our future development proposals [here](https://docs.google.com/spreadsheets/d/1o5ZS_L8OppZJit46SzpauJOthI0ncWuIgmo6ZtPevOU/edit?usp=sharing) 80 | 81 | ## Testing 82 | - Our UX testing checklist [here](https://docs.google.com/spreadsheets/d/1Tcg6E1ZxlYmg9TjcGjNhZoP0vHRUZT_O_2SzJJVfcKQ/edit?usp=sharing) 83 | - Unit testing coverage is low, any contribution will be much appreciated ! 84 | 85 | ## Contacts 86 | If you have any questions feel free to contact us: 87 |
ctpacia@gmail.com (Chris Pacia) 88 |
alonmuroch@gmail.com (Alon Muroch)
-------------------------------------------------------------------------------- /package/linux/Authenticator Wallet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/package/linux/Authenticator Wallet.png -------------------------------------------------------------------------------- /package/macosx/Authenticator Wallet.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/package/macosx/Authenticator Wallet.icns -------------------------------------------------------------------------------- /package/windows/Authenticator Wallet.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/package/windows/Authenticator Wallet.ico -------------------------------------------------------------------------------- /src/main/java/authenticator/BASE.java: -------------------------------------------------------------------------------- 1 | package authenticator; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import com.google.common.util.concurrent.AbstractService; 7 | 8 | public class BASE extends AbstractService{ 9 | public Logger LOG; 10 | public BASE(Class t) 11 | { 12 | LOG = LoggerFactory.getLogger(t); 13 | } 14 | 15 | @Override 16 | protected void doStart() { 17 | // TODO Auto-generated method stub 18 | 19 | } 20 | @Override 21 | protected void doStop() { 22 | // TODO Auto-generated method stub 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/authenticator/BipSSS/SSSUtils.java: -------------------------------------------------------------------------------- 1 | package authenticator.BipSSS; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import authenticator.BipSSS.BipSSS.Share; 7 | 8 | public class SSSUtils { 9 | public List getAllPossibleCombinations(List shares, int len){ 10 | List ret = new ArrayList(); 11 | 12 | getCombination(shares, len, 0, new Share[len], ret); 13 | return ret; 14 | } 15 | 16 | private void getCombination(List arr, int len, int startPosition, Share[] result, List finalRsult){ 17 | if (len == 0){ 18 | Share[] temp = new Share[result.length]; 19 | System.arraycopy(result, 0, temp, 0, result.length); 20 | finalRsult.add(temp); 21 | return; 22 | } 23 | for (int i = startPosition; i <= arr.size() - len; i++){ 24 | //result[result.length - len] = arr[i]; 25 | //combinations2(arr, len-1, i+1, result); 26 | 27 | result[result.length - len] = arr.get(i); 28 | getCombination(arr, len-1, i+1, result, finalRsult); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/authenticator/GCM/GCMSender.java: -------------------------------------------------------------------------------- 1 | package authenticator.GCM; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | 6 | import com.google.android.gcm.server.Message; 7 | import com.google.android.gcm.server.MulticastResult; 8 | import com.google.android.gcm.server.Sender; 9 | 10 | import authenticator.GCM.dispacher.MessageBuilder; 11 | 12 | public class GCMSender { 13 | 14 | public void sender(ArrayList devicesList,MessageBuilder msg) 15 | { 16 | final String GCM_API_KEY = "AIzaSyCKpWWEQk6UDW6ZSAeJfYVyuHcJg1g2V_o"; 17 | Sender sender = new Sender(GCM_API_KEY); 18 | //ArrayList devicesList = new ArrayList(); 19 | //devicesList.add("APA91bGr1kYu7L6oKUfyCEhg0ofuGoFYdRbqj1QHBFAMVI_eFkYSp2NU3u01MfQ92jhBUVY4qhCYKO-xERCq3t52yKih671fEkNPHS_YIVfrvuj9PcD8_ETAoKdhHAnWpNZkofbFjOzdD0uMamTOQ0_xIoRymcm8DjeZ5zi6sfXryJ-bykS4nd0"); 20 | String data = msg.toString();//"{Data:Hello World}"; 21 | Message message = new Message.Builder() 22 | .collapseKey("1") 23 | .timeToLive(3) 24 | .delayWhileIdle(true) 25 | .addData("data",data) 26 | .build(); 27 | MulticastResult result; 28 | try { 29 | result = sender.send(message, devicesList, 1); 30 | // sender.send(message, devicesList, 1); 31 | 32 | System.out.println(result.toString()); 33 | if (result.getResults() != null) { 34 | int canonicalRegId = result.getCanonicalIds(); 35 | if (canonicalRegId != 0) { 36 | } 37 | } else { 38 | int error = result.getFailure(); 39 | System.out.println(error); 40 | } 41 | } catch (IOException e) { 42 | // TODO Auto-generated catch block 43 | e.printStackTrace(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/authenticator/GCM/dispacher/Device.java: -------------------------------------------------------------------------------- 1 | package authenticator.GCM.dispacher; 2 | 3 | import javax.crypto.SecretKey; 4 | 5 | public class Device { 6 | public byte[] chaincode; 7 | public byte[] mPubKey; 8 | public byte[] gcmRegId; 9 | public byte[] pairingID; 10 | public SecretKey sharedsecret; 11 | 12 | public Device(){ } 13 | public Device(byte[] chain, 14 | byte[] pubKey, 15 | byte[] gcm, 16 | byte[] pairID, 17 | SecretKey secret) 18 | { 19 | chaincode = chain; 20 | mPubKey = pubKey; 21 | gcmRegId = gcm; 22 | pairingID = pairID; 23 | sharedsecret = secret; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/authenticator/GCM/dispacher/Dispacher.java: -------------------------------------------------------------------------------- 1 | package authenticator.GCM.dispacher; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.DataOutputStream; 5 | import java.io.IOException; 6 | import java.net.ServerSocket; 7 | import java.net.Socket; 8 | import java.util.ArrayList; 9 | 10 | import org.json.JSONException; 11 | import org.xml.sax.SAXException; 12 | 13 | import authenticator.Authenticator; 14 | import authenticator.GCM.GCMSender; 15 | import authenticator.network.UpNp; 16 | import authenticator.protobuf.ProtoConfig.ATGCMMessageType; 17 | 18 | /** 19 | * A wrapper class for dispaching GCM notifications to devices. 20 | * 21 | * @author alon 22 | * 23 | */ 24 | public class Dispacher { 25 | DataOutputStream outStream; 26 | DataInputStream inStream; 27 | 28 | public Dispacher(){} 29 | public Dispacher(DataOutputStream out,DataInputStream in) 30 | { 31 | outStream = out; 32 | inStream = in; 33 | } 34 | 35 | public String dispachMessage(ATGCMMessageType msgType, Device device, String ... args) throws JSONException, IOException 36 | { 37 | switch (msgType){ 38 | /** 39 | * arg: 40 | * [0] - Custom msg 41 | * [1] - external IP 42 | * [2] - Internal IP 43 | */ 44 | case SignTX: 45 | if(device.gcmRegId != null) 46 | { 47 | MessageBuilder msgGCM = null; 48 | try { 49 | 50 | msgGCM = new MessageBuilder(ATGCMMessageType.SignTX, 51 | new String[]{new String(device.pairingID), 52 | args[1], 53 | args[2], 54 | args[0]}); 55 | ArrayList devicesList = new ArrayList(); 56 | devicesList.add(new String(device.gcmRegId)); 57 | GCMSender sender = new GCMSender(); 58 | sender.sender(devicesList,msgGCM); 59 | 60 | } catch (Exception e) { 61 | // TODO Auto-generated catch block 62 | e.printStackTrace(); 63 | } 64 | if(msgGCM != null) 65 | return msgGCM.getString("RequestID"); 66 | return null; 67 | } 68 | else 69 | ;//TODO 70 | break; 71 | /** 72 | * arg: 73 | * [0] - external IP 74 | * [1] - Internal IP 75 | */ 76 | case UpdatePendingRequestIPs: 77 | if(device.gcmRegId != null) 78 | { 79 | MessageBuilder msgGCM = null; 80 | try { 81 | msgGCM = new MessageBuilder(ATGCMMessageType.UpdatePendingRequestIPs, 82 | new String[]{new String(device.pairingID), 83 | args[0], 84 | args[1], 85 | ""}); 86 | ArrayList devicesList = new ArrayList(); 87 | devicesList.add(new String(device.gcmRegId)); 88 | GCMSender sender = new GCMSender(); 89 | sender.sender(devicesList,msgGCM); 90 | 91 | } catch (Exception e) { e.printStackTrace(); } 92 | return null; 93 | } 94 | else 95 | ;//TODO 96 | break; 97 | /** 98 | * arg: 99 | * [0] - Custom msg 100 | */ 101 | case CoinsReceived: 102 | if(device.gcmRegId != null) 103 | { 104 | MessageBuilder msgGCM = null; 105 | try { 106 | 107 | msgGCM = new MessageBuilder(ATGCMMessageType.CoinsReceived, 108 | new String[]{new String(device.pairingID), args[0]}); 109 | ArrayList devicesList = new ArrayList(); 110 | devicesList.add(new String(device.gcmRegId)); 111 | GCMSender sender = new GCMSender(); 112 | sender.sender(devicesList,msgGCM); 113 | 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | } 117 | return null; 118 | } 119 | else 120 | ; 121 | break; 122 | } 123 | return null; 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/authenticator/GCM/dispacher/MessageBuilder.java: -------------------------------------------------------------------------------- 1 | package authenticator.GCM.dispacher; 2 | 3 | import java.math.BigInteger; 4 | import java.security.MessageDigest; 5 | import java.security.NoSuchAlgorithmException; 6 | import java.sql.Timestamp; 7 | 8 | import org.json.JSONException; 9 | import org.json.JSONObject; 10 | 11 | import authenticator.protobuf.ProtoConfig.ATGCMMessageType; 12 | 13 | 14 | public class MessageBuilder extends JSONObject{ 15 | public MessageBuilder(ATGCMMessageType type,String ... arg) throws JSONException 16 | { 17 | JSONObject reqPayload; 18 | switch (type){ 19 | /** 20 | * arg -
21 | * 0 - WalletID
22 | * 1 - ExternalIP
23 | * 2 - LocalIP
24 | * 3 - CustomMsg
25 | * 4 - tmp, for testing purposes
26 | */ 27 | case SignTX: 28 | if(arg.length > 4) 29 | this.put("tmp", arg[4]); 30 | else 31 | this.put("tmp", new Timestamp( new java.util.Date().getTime() )); 32 | this.put("WalletID", arg[0]); 33 | this.put("RequestType", ATGCMMessageType.SignTX_VALUE); 34 | reqPayload = new JSONObject(); 35 | reqPayload.put("ExternalIP", arg[1]); 36 | reqPayload.put("LocalIP", arg[2]); 37 | this.put("ReqPayload", reqPayload); 38 | this.put("CustomMsg", arg[3]); // TODO localize 39 | this.put("RequestID", getRequestIDDigest(this)); 40 | break; 41 | /** 42 | * arg -
43 | * 0 - WalletID
44 | * 1 - ExternalIP
45 | * 2 - LocalIP
46 | * 3 - CustomMsg
47 | */ 48 | case UpdatePendingRequestIPs: 49 | this.put("tmp", new Timestamp( new java.util.Date().getTime() )); 50 | this.put("WalletID", arg[0]); 51 | this.put("RequestType", ATGCMMessageType.UpdatePendingRequestIPs_VALUE); 52 | reqPayload = new JSONObject(); 53 | reqPayload.put("ExternalIP", arg[1]); 54 | reqPayload.put("LocalIP", arg[2]); 55 | this.put("ReqPayload", reqPayload); 56 | this.put("CustomMsg", arg[3]); // TODO localize 57 | break; 58 | /** 59 | * arg -
60 | * 0 - WalletID
61 | * 1 - CustomMsg
62 | */ 63 | case CoinsReceived: 64 | this.put("tmp", new Timestamp( new java.util.Date().getTime() )); 65 | this.put("WalletID", arg[0]); 66 | this.put("RequestType", ATGCMMessageType.CoinsReceived_VALUE); 67 | this.put("CustomMsg", arg[1]); 68 | break; 69 | } 70 | } 71 | 72 | private String getConcatinatedPayload(MessageBuilder msg) throws JSONException{ 73 | String ReqPayload = msg.get("ReqPayload").toString(); 74 | String tmp = msg.get("tmp").toString(); 75 | String RequestType = msg.get("RequestType").toString(); 76 | String WalletID = msg.get("WalletID").toString(); 77 | return ReqPayload + 78 | tmp + 79 | RequestType + 80 | WalletID; 81 | } 82 | 83 | private String getRequestIDDigest(MessageBuilder msg) throws JSONException 84 | { 85 | MessageDigest md = null; 86 | try {md = MessageDigest.getInstance("SHA-1");} 87 | catch(NoSuchAlgorithmException e) {e.printStackTrace();} 88 | byte[] digest = md.digest(getConcatinatedPayload(msg).getBytes()); 89 | String ret = new BigInteger(1, digest).toString(16); 90 | //Make sure it is 40 chars, if less pad with 0, if more substringit 91 | if(ret.length() > 40) 92 | { 93 | ret = ret.substring(0, 39); 94 | } 95 | else if(ret.length() < 40) 96 | { 97 | int paddingNeeded = 40 - ret.length(); 98 | String padding = ""; 99 | for(int i=0;i currenciesList; 24 | 25 | static public boolean isReady = false; 26 | /** 27 | * Requires downloading the currency data in an async process.
28 | * Use this method as follows:
29 | * new CurrencyConverterSingelton(new CurrencyConverterListener(){ }); 30 | * 31 | * @param listener 32 | */ 33 | public CurrencyConverterSingelton(String[] lstCurrencies, CurrencyConverterListener listener){ 34 | currenciesList = Arrays.asList(lstCurrencies); 35 | if(isReady == false){ 36 | currencies = new CurrencyList(); 37 | try { 38 | getCurrencies(currenciesList, listener, this); 39 | } catch (IOException | JSONException e) { 40 | e.printStackTrace(); 41 | if(listener != null) 42 | listener.onErrorGettingCurrencyData(e); 43 | } 44 | } 45 | else if(listener != null){ 46 | listener.onFinishedGettingCurrencyData(this); 47 | } 48 | } 49 | 50 | public static void CANNOT_EXECUTE_ASYNC_SO_CHECK_IS_READY() throws CurrencyConverterSingeltonNoDataException{ 51 | if(CurrencyConverterSingelton.isReady != true) 52 | throw new CurrencyConverterSingeltonNoDataException("No Currency Data"); 53 | } 54 | 55 | /** 56 | * 57 | * 58 | * @param lstCurrencies 59 | * @param listener 60 | * @param self 61 | * @throws IOException 62 | * @throws JSONException 63 | */ 64 | private void getCurrencies(List lstCurrencies, final CurrencyConverterListener listener, CurrencyConverterSingelton self) throws IOException, JSONException{ 65 | // TODO - download more than one currency 66 | String s = "https://api.bitcoinaverage.com/ticker/global/" + lstCurrencies.get(0) + "/"; 67 | EncodingUtils.readFromUrl(s, new AsyncCompletionHandler(){ 68 | @Override 69 | public Response onCompleted(Response arg0) throws Exception { 70 | String res = arg0.getResponseBody(); 71 | JSONObject json = new JSONObject(res); 72 | //double last = json.getDouble("last"); 73 | CurrencyConverterSingelton.currencies.add(new Currency(lstCurrencies.get(0), json)); 74 | 75 | if(listener != null) 76 | listener.onFinishedGettingCurrencyData(self); 77 | 78 | CurrencyConverterSingelton.isReady = true; 79 | 80 | return null; 81 | } 82 | }); 83 | } 84 | 85 | public interface CurrencyConverterListener{ 86 | public void onFinishedGettingCurrencyData(CurrencyConverterSingelton currencies); 87 | public void onErrorGettingCurrencyData(Exception e); 88 | } 89 | 90 | public class CurrencyList{ 91 | private List lst; 92 | 93 | public CurrencyList() { 94 | lst = new ArrayList(); 95 | } 96 | 97 | public void add(Currency c) { 98 | lst.add(c); 99 | } 100 | 101 | public Currency get(int index) { 102 | return lst.get(index); 103 | } 104 | 105 | public Currency get(String upperCaseCurrencyCode) { 106 | for(Currency c: lst) { 107 | if(c.UPPERCASE_CURRENCY_CODE.equals(upperCaseCurrencyCode)) 108 | return c; 109 | } 110 | return null; 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/authenticator/Utils/CurrencyConverter/exceptions/CurrencyConverterSingeltonNoDataException.java: -------------------------------------------------------------------------------- 1 | package authenticator.Utils.CurrencyConverter.exceptions; 2 | 3 | public class CurrencyConverterSingeltonNoDataException extends Exception{ 4 | public CurrencyConverterSingeltonNoDataException(String msg){ 5 | super(msg); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/Utils/EncodingUtils.java: -------------------------------------------------------------------------------- 1 | package authenticator.Utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | import java.io.Reader; 8 | import java.net.URL; 9 | import java.net.URLConnection; 10 | import java.util.Formatter; 11 | 12 | import org.json.JSONException; 13 | import org.json.JSONObject; 14 | import org.spongycastle.util.encoders.Hex; 15 | import org.bitcoinj.core.Transaction; 16 | import org.bitcoinj.crypto.DeterministicKey; 17 | 18 | import com.ning.http.client.AsyncCompletionHandler; 19 | import com.ning.http.client.AsyncHttpClient; 20 | import com.ning.http.client.Response; 21 | 22 | public class EncodingUtils { 23 | 24 | /**For reading the JSON*/ 25 | private static String readAll(Reader rd) throws IOException { 26 | StringBuilder sb = new StringBuilder(); 27 | int cp; 28 | while ((cp = rd.read()) != -1) { 29 | sb.append((char) cp); 30 | } 31 | return sb.toString(); 32 | } 33 | 34 | /**Reads JSON object from a URL*/ 35 | public static void readFromUrl(String url, AsyncCompletionHandler listener) throws IOException { 36 | AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); 37 | asyncHttpClient.prepareGet(url).execute(new AsyncCompletionHandler(){ 38 | 39 | @Override 40 | public Response onCompleted(Response response) throws Exception { 41 | listener.onCompleted(response); 42 | asyncHttpClient.closeAsynchronously(); 43 | return null; 44 | } 45 | 46 | }); 47 | 48 | } 49 | 50 | static public String getAbsolutePathForFile(String fileName) throws IOException 51 | { 52 | return new java.io.File( "." ).getCanonicalPath() + "/" + fileName; 53 | } 54 | 55 | public static String getStringTransaction(Transaction tx) 56 | { 57 | //Convert tx to byte array for sending. 58 | String formatedTx = null; 59 | final StringBuilder sb = new StringBuilder(); 60 | Formatter formatter = new Formatter(sb); 61 | try { 62 | ByteArrayOutputStream os = new ByteArrayOutputStream(); 63 | tx.bitcoinSerialize(os); 64 | byte[] bytes = os.toByteArray(); 65 | for (byte b : bytes) { 66 | formatter.format("%02x", b); 67 | } 68 | formatedTx = sb.toString(); 69 | }catch (IOException e) { 70 | } finally { 71 | formatter.close(); 72 | } 73 | return formatedTx; 74 | } 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/authenticator/Utils/KeyUtils.java: -------------------------------------------------------------------------------- 1 | package authenticator.Utils; 2 | 3 | public class KeyUtils { 4 | 5 | public static byte[] hexStringToByteArray(String s) { 6 | int len = s.length(); 7 | byte[] data = new byte[len / 2]; 8 | for (int i = 0; i < len; i += 2) { 9 | data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) 10 | + Character.digit(s.charAt(i+1), 16)); 11 | } 12 | return data; 13 | } 14 | final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); 15 | public static String bytesToHex(byte[] bytes) { 16 | char[] hexChars = new char[bytes.length * 2]; 17 | for ( int j = 0; j < bytes.length; j++ ) { 18 | int v = bytes[j] & 0xFF; 19 | hexChars[j * 2] = hexArray[v >>> 4]; 20 | hexChars[j * 2 + 1] = hexArray[v & 0x0F]; 21 | } 22 | return new String(hexChars); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/authenticator/Utils/OneName/OneNameAdapter.java: -------------------------------------------------------------------------------- 1 | package authenticator.Utils.OneName; 2 | 3 | import javafx.scene.image.Image; 4 | import authenticator.protobuf.ProtoConfig.AuthenticatorConfiguration.ConfigOneNameProfile; 5 | 6 | public class OneNameAdapter implements OneNameListener{ 7 | 8 | @Override 9 | public void getOneNameData(ConfigOneNameProfile data) { 10 | // TODO Auto-generated method stub 11 | 12 | } 13 | 14 | @Override 15 | public void getOneNameAvatarImage(ConfigOneNameProfile one, Image img) { 16 | // TODO Auto-generated method stub 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/authenticator/Utils/OneName/OneNameListener.java: -------------------------------------------------------------------------------- 1 | package authenticator.Utils.OneName; 2 | 3 | import authenticator.protobuf.ProtoConfig.AuthenticatorConfiguration.ConfigOneNameProfile; 4 | import javafx.scene.image.Image; 5 | 6 | public interface OneNameListener { 7 | public void getOneNameData(ConfigOneNameProfile data); 8 | public void getOneNameAvatarImage(ConfigOneNameProfile one, Image img); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/authenticator/Utils/OneName/exceptions/CannotSaveOneNameImageException.java: -------------------------------------------------------------------------------- 1 | package authenticator.Utils.OneName.exceptions; 2 | 3 | public class CannotSaveOneNameImageException extends Exception{ 4 | public CannotSaveOneNameImageException(String msg){ 5 | super(msg); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/Utils/OneName/exceptions/CannotSetOneNameProfileException.java: -------------------------------------------------------------------------------- 1 | package authenticator.Utils.OneName.exceptions; 2 | 3 | public class CannotSetOneNameProfileException extends Exception{ 4 | public CannotSetOneNameProfileException(String msg){ 5 | super(msg); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/Utils/SafeList.java: -------------------------------------------------------------------------------- 1 | package authenticator.Utils; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class SafeList{ 6 | private ArrayList data; 7 | public SafeList(){ 8 | data = new ArrayList(); 9 | } 10 | 11 | public SafeList(ArrayList arr){ 12 | data = arr; 13 | } 14 | 15 | public synchronized void add(Object object) { 16 | data.add(object); 17 | } 18 | 19 | public synchronized void removeAtIndex(int index) { 20 | data.remove(index); 21 | } 22 | 23 | public synchronized void remove(Object obj) { 24 | data.remove(obj); 25 | } 26 | 27 | public synchronized Object getObjectAtIndex(int index) { 28 | return data.get(index); 29 | } 30 | 31 | public synchronized ArrayList getAll() { 32 | return data; 33 | } 34 | 35 | public synchronized void clear(int index) { 36 | data.clear(); 37 | } 38 | 39 | public synchronized int size() { 40 | return data.size(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/authenticator/db/dbBase.java: -------------------------------------------------------------------------------- 1 | package authenticator.db; 2 | 3 | import java.io.IOException; 4 | 5 | public class dbBase { 6 | public String filePath; 7 | 8 | public dbBase(String filePath) throws IOException{ 9 | this.filePath = filePath;//new java.io.File( "." ).getCanonicalPath() + "/" + fileName + ".config"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/authenticator/db/exceptions/AccountWasNotFoundException.java: -------------------------------------------------------------------------------- 1 | package authenticator.db.exceptions; 2 | 3 | public class AccountWasNotFoundException extends Exception{ 4 | public AccountWasNotFoundException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/db/exceptions/CouldNotOpenConfigFileException.java: -------------------------------------------------------------------------------- 1 | package authenticator.db.exceptions; 2 | 3 | public class CouldNotOpenConfigFileException extends Exception{ 4 | public CouldNotOpenConfigFileException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/helpers/BAApplication.java: -------------------------------------------------------------------------------- 1 | 2 | package authenticator.helpers; 3 | 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import wallettemplate.Main; 8 | import authenticator.BAApplicationParameters; 9 | import authenticator.BAApplicationParameters.WrongOperatingSystemException; 10 | 11 | import org.bitcoinj.core.NetworkParameters; 12 | import org.bitcoinj.kits.WalletAppKit; 13 | import org.bitcoinj.params.MainNetParams; 14 | import org.bitcoinj.params.TestNet3Params; 15 | 16 | import javafx.application.Application; 17 | import javafx.application.Platform; 18 | import javafx.stage.Stage; 19 | 20 | /** 21 | * The basic BitcoinAuthenticator Javafx application. Covers functionalities like command line params and general app instantiations 22 | * @author alon 23 | * 24 | */ 25 | public class BAApplication extends Application{ 26 | 27 | public static BAApplicationParameters ApplicationParams; 28 | public WalletAppKit bitcoin; 29 | 30 | public BAApplication(){ } 31 | 32 | /** 33 | * Must be called on start() 34 | * @param appName 35 | * @throws WrongOperatingSystemException 36 | */ 37 | public boolean BAInit() throws WrongOperatingSystemException{ 38 | ApplicationParams = new BAApplicationParameters(getParameters().getNamed(),getParameters().getRaw()); 39 | return ApplicationParams.getShouldLaunchProgram(); 40 | } 41 | 42 | //###################### 43 | // 44 | // JavaFX Functions 45 | // 46 | //###################### 47 | 48 | @Override 49 | public void start(Stage primaryStage) throws Exception { 50 | 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return ApplicationParams.toString(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/authenticator/hierarchy/HierarchyUtils.java: -------------------------------------------------------------------------------- 1 | package authenticator.hierarchy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import authenticator.hierarchy.exceptions.IncorrectPathException; 7 | import authenticator.protobuf.AuthWalletHierarchy.HierarchyPurpose; 8 | 9 | import org.bitcoinj.crypto.ChildNumber; 10 | import org.bitcoinj.crypto.DeterministicKey; 11 | import com.google.common.collect.ImmutableList; 12 | 13 | public class HierarchyUtils { 14 | 15 | /** 16 | * If the path is full (following BIP 44) than will check for path correctness 17 | * 18 | * @param path 19 | * @param isFullPath 20 | * @return 21 | * @throws IncorrectPathException 22 | */ 23 | public static ChildNumber getKeyIndexFromPath(ImmutableList path, boolean isFullPath) throws IncorrectPathException{ 24 | if(isFullPath && path.size() < 5) 25 | throw new IncorrectPathException("Cannot parse key path, incorrect path."); 26 | 27 | return path.get(path.size() - 1); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/authenticator/hierarchy/exceptions/IncorrectPathException.java: -------------------------------------------------------------------------------- 1 | package authenticator.hierarchy.exceptions; 2 | 3 | public class IncorrectPathException extends Exception{ 4 | public IncorrectPathException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/hierarchy/exceptions/KeyIndexOutOfRangeException.java: -------------------------------------------------------------------------------- 1 | package authenticator.hierarchy.exceptions; 2 | 3 | public class KeyIndexOutOfRangeException extends Exception{ 4 | public KeyIndexOutOfRangeException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/hierarchy/exceptions/NoAccountCouldBeFoundException.java: -------------------------------------------------------------------------------- 1 | package authenticator.hierarchy.exceptions; 2 | 3 | public class NoAccountCouldBeFoundException extends Exception{ 4 | public NoAccountCouldBeFoundException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/hierarchy/exceptions/NoUnusedKeyException.java: -------------------------------------------------------------------------------- 1 | package authenticator.hierarchy.exceptions; 2 | 3 | public class NoUnusedKeyException extends Exception{ 4 | public NoUnusedKeyException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/listeners/BAGeneralEventsAdapter.java: -------------------------------------------------------------------------------- 1 | package authenticator.listeners; 2 | 3 | import java.util.List; 4 | 5 | import javax.annotation.Nullable; 6 | 7 | import javafx.scene.image.Image; 8 | import authenticator.network.BANetworkInfo; 9 | import authenticator.operations.OperationsUtils.SignProtocol.AuthenticatorAnswerType; 10 | import authenticator.protobuf.ProtoConfig.ATAddress; 11 | import authenticator.protobuf.ProtoConfig.AuthenticatorConfiguration.ConfigOneNameProfile; 12 | import authenticator.protobuf.ProtoConfig.PendingRequest; 13 | 14 | import org.bitcoinj.core.Transaction; 15 | import org.bitcoinj.core.TransactionConfidence.ConfidenceType; 16 | 17 | public class BAGeneralEventsAdapter implements BAGeneralEventsListener{ 18 | 19 | @Override 20 | public void onBalanceChanged(Transaction tx, 21 | HowBalanceChanged howBalanceChanged, ConfidenceType confidence) { 22 | // TODO Auto-generated method stub 23 | 24 | } 25 | 26 | @Override 27 | public void onAuthenticatorSigningResponse(Transaction tx, 28 | String pairingID, PendingRequest pendingReq, 29 | AuthenticatorAnswerType answerType, String str) { 30 | // TODO Auto-generated method stub 31 | 32 | } 33 | 34 | @Override 35 | public void onAddressMarkedAsUsed(ATAddress address) { 36 | // TODO Auto-generated method stub 37 | 38 | } 39 | 40 | @Override 41 | public void onOneNameIdentityChanged(@Nullable ConfigOneNameProfile profile, @Nullable Image profileImage) { 42 | // TODO Auto-generated method stub 43 | 44 | } 45 | 46 | @Override 47 | public void onBlockchainDownloadChange(float progress) { 48 | // TODO Auto-generated method stub 49 | 50 | } 51 | 52 | @Override 53 | public void onWalletSettingsChange() { 54 | // TODO Auto-generated method stub 55 | 56 | } 57 | 58 | @Override 59 | public void onAccountsModified(AccountModificationType type, int accountIndex) { 60 | // TODO Auto-generated method stub 61 | 62 | } 63 | 64 | @Override 65 | public void onAuthenticatorNetworkStatusChange(BANetworkInfo info) { 66 | // TODO Auto-generated method stub 67 | 68 | } 69 | 70 | @Override 71 | public void onPendingRequestUpdate(List requests, 72 | PendingRequestUpdateType updateType) { 73 | // TODO Auto-generated method stub 74 | 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/authenticator/listeners/BAGeneralEventsListener.java: -------------------------------------------------------------------------------- 1 | package authenticator.listeners; 2 | 3 | import java.util.List; 4 | 5 | import javax.annotation.Nullable; 6 | 7 | import javafx.scene.image.Image; 8 | 9 | import org.bitcoinj.core.Transaction; 10 | import org.bitcoinj.core.TransactionConfidence.ConfidenceType; 11 | 12 | import authenticator.network.BANetworkInfo; 13 | import authenticator.operations.OperationsUtils.SignProtocol; 14 | import authenticator.protobuf.ProtoConfig.ATAddress; 15 | import authenticator.protobuf.ProtoConfig.AuthenticatorConfiguration; 16 | import authenticator.protobuf.ProtoConfig.AuthenticatorConfiguration.ConfigOneNameProfile; 17 | import authenticator.protobuf.ProtoConfig.PendingRequest; 18 | 19 | public interface BAGeneralEventsListener { 20 | /** 21 | * Will be called if something changed in the wallet's accounts.
22 | * accountIndex could be -1 if cannot pass account index 23 | * 24 | * @param type 25 | * @param accountIndex 26 | */ 27 | public void onAccountsModified(AccountModificationType type, int accountIndex); 28 | public enum AccountModificationType{ 29 | ActiveAccountChanged, 30 | NewAccount, 31 | AccountDeleted, 32 | AccountBeenModified; 33 | }; 34 | 35 | /** 36 | * The profile param will be null if the identity was deleted. 37 | * @param profile 38 | * @param profileImage 39 | */ 40 | public void onOneNameIdentityChanged(@Nullable ConfigOneNameProfile profile, @Nullable Image profileImage); 41 | 42 | 43 | /** 44 | * Will update when:
45 | *
    46 | *
  1. Account spent funds
  2. 47 | *
  3. Account received funds
  4. 48 | *
  5. Account's confirmed/ unconfirmed balance is changed
  6. 49 | *
50 | * May be called multiple times if tx contains several changes
51 | * 52 | * @param walletID 53 | * @param @Nullable tx - could be null to just update the UI 54 | * @param howBalanceChanged 55 | * @param confidence 56 | */ 57 | public void onBalanceChanged(@Nullable Transaction tx, HowBalanceChanged howBalanceChanged, ConfidenceType confidence); 58 | public enum HowBalanceChanged{ 59 | ReceivedCoins, 60 | SentCoins; 61 | }; 62 | 63 | /** 64 | * Will be fired when the {@link authenticator.operations.OperationsFactory#SIGN_AND_BROADCAST_AUTHENTICATOR_TX_OPERATION Authenticator Tx Sign Operation} completes 65 | * @param tx 66 | * @param pairingID 67 | * @param pendingReq 68 | * @param answerType 69 | * @param str 70 | */ 71 | public void onAuthenticatorSigningResponse(Transaction tx, 72 | String pairingID, 73 | @Nullable PendingRequest pendingReq, 74 | SignProtocol.AuthenticatorAnswerType answerType, 75 | @Nullable String str); 76 | 77 | /** 78 | * Will be fired whenever an address is marked as used (coins received to it) 79 | * 80 | * @param address 81 | */ 82 | public void onAddressMarkedAsUsed(ATAddress address); 83 | 84 | /** 85 | * will pass a value between 0 and 1 indicating the download progress.
86 | * Will pass 1 when finished. 87 | * @param progress 88 | */ 89 | public void onBlockchainDownloadChange(float progress); 90 | 91 | /** 92 | * Called whenever the UI changed the settings. This call should be handled by you in your UI implementation.
93 | * Call {@link authenticator.Authenticator#fireOnWalletSettingsChange fireOnWalletSettingsChange} 94 | */ 95 | public void onWalletSettingsChange(); 96 | 97 | /** 98 | * Will be called after the {@link authenticator.network.TCPListener TCPListener} tried its startup process. 99 | * 100 | * @param info 101 | */ 102 | public void onAuthenticatorNetworkStatusChange(BANetworkInfo info); 103 | 104 | /** 105 | * Will be called whenever a {@link authenticator.protobuf.ProtoConfig.PendingRequest PendingRequest} is been added or removed. 106 | */ 107 | public void onPendingRequestUpdate(List requests, PendingRequestUpdateType updateType); 108 | public enum PendingRequestUpdateType{ 109 | RequestAdded, 110 | RequestDeleted; 111 | }; 112 | } -------------------------------------------------------------------------------- /src/main/java/authenticator/network/BANetworkInfo.java: -------------------------------------------------------------------------------- 1 | package authenticator.network; 2 | 3 | public class BANetworkInfo { 4 | public String EXTERNAL_IP = null; 5 | public String INTERNAL_IP = null; 6 | 7 | /** 8 | * Network Requirements flags 9 | */ 10 | public boolean PORT_FORWARDED = false; 11 | public boolean SOCKET_OPERATIONAL = false; 12 | 13 | public BANetworkInfo() { 14 | 15 | } 16 | 17 | public BANetworkInfo(String ext, String internl){ 18 | EXTERNAL_IP = ext; 19 | INTERNAL_IP = internl; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/authenticator/network/CannotProcessRequestPayload.java: -------------------------------------------------------------------------------- 1 | package authenticator.network; 2 | 3 | import java.security.InvalidKeyException; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | import javax.crypto.SecretKey; 7 | 8 | import org.json.JSONException; 9 | import org.json.JSONObject; 10 | 11 | import authenticator.Utils.CryptoUtils; 12 | import authenticator.Utils.CryptoUtils.CouldNotEncryptPayload; 13 | 14 | public class CannotProcessRequestPayload extends JSONObject{ 15 | private byte[] payload; 16 | private byte[] encryptedPayload; 17 | 18 | public CannotProcessRequestPayload(String desc, SecretKey secretKey) throws CouldNotEncryptPayload { 19 | 20 | try { 21 | put("CANNOT_PROCESS_REQUEST", ""); 22 | put("WHY",desc); 23 | payload = this.toString().getBytes(); 24 | encryptedPayload = CryptoUtils.encryptPayloadWithChecksum(payload, secretKey); 25 | } catch (JSONException e) { 26 | // TODO Auto-generated catch block 27 | e.printStackTrace(); 28 | } 29 | 30 | } 31 | 32 | public byte[] toEncryptedBytes() { 33 | return encryptedPayload; 34 | } 35 | 36 | public int getPayloadSize() { 37 | return encryptedPayload.length; 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/authenticator/network/GetRequestIDPayload.java: -------------------------------------------------------------------------------- 1 | package authenticator.network; 2 | 3 | import java.security.InvalidKeyException; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | import javax.crypto.SecretKey; 7 | 8 | import org.json.JSONException; 9 | import org.json.JSONObject; 10 | 11 | import authenticator.Utils.CryptoUtils; 12 | import authenticator.Utils.CryptoUtils.CouldNotEncryptPayload; 13 | 14 | /** 15 | * When receiving a request ID payload form the authenticator, this payload will be sent to confirm connection 16 | * 17 | * @author Alon Muroch 18 | * 19 | */ 20 | public class GetRequestIDPayload extends JSONObject{ 21 | private byte[] payload; 22 | private String requestID; 23 | private String pairingID; 24 | 25 | public GetRequestIDPayload(byte[] payloadBytes) throws JSONException{ 26 | payload = payloadBytes; 27 | 28 | JSONObject jo = new JSONObject(new String(payload)); 29 | requestID = jo.getString("requestID"); 30 | pairingID = jo.getString("pairingID"); 31 | } 32 | 33 | public String getRequestID() { 34 | return requestID; 35 | } 36 | 37 | public String getPairingID() { 38 | return pairingID; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/authenticator/network/PongPayload.java: -------------------------------------------------------------------------------- 1 | package authenticator.network; 2 | 3 | import java.security.InvalidKeyException; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | import javax.crypto.SecretKey; 7 | 8 | import org.json.JSONException; 9 | import org.json.JSONObject; 10 | 11 | import authenticator.Utils.CryptoUtils; 12 | import authenticator.Utils.CryptoUtils.CouldNotEncryptPayload; 13 | 14 | /** 15 | * When receiving a request ID payload form the authenticator, this payload will be sent to confirm connection 16 | * 17 | * @author Alon Muroch 18 | * 19 | */ 20 | public class PongPayload extends JSONObject{ 21 | private byte[] payload; 22 | 23 | public PongPayload() throws CouldNotEncryptPayload{ 24 | 25 | try { 26 | put("WELCOME_BACK_AUTHENTICATOR", ""); 27 | payload = this.toString().getBytes(); 28 | 29 | } catch (JSONException e) { 30 | // TODO Auto-generated catch block 31 | e.printStackTrace(); 32 | } 33 | 34 | } 35 | 36 | public byte[] getBytes() { 37 | return payload; 38 | } 39 | 40 | public int getPayloadSize() { 41 | return payload.length; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/authenticator/network/TrustedPeerNodes.java: -------------------------------------------------------------------------------- 1 | package authenticator.network; 2 | 3 | import java.net.InetAddress; 4 | import java.net.UnknownHostException; 5 | 6 | import org.bitcoinj.core.PeerAddress; 7 | 8 | public class TrustedPeerNodes { 9 | private static String[] MAIN_NET = new String[]{ 10 | "riker.plan99.net", 11 | // IPV6 12 | "InductiveSoul.US", 13 | "caffeinator.net", 14 | "messier.bzfx.net", 15 | // IPV4 16 | "bitcoin.coinprism.com", 17 | "btcnode1.evolyn.net", 18 | "InductiveSoul.US", 19 | }; 20 | 21 | public static PeerAddress[] MAIN_NET() { 22 | PeerAddress[] ret = new PeerAddress[MAIN_NET.length]; 23 | 24 | for(int i=0; i< MAIN_NET.length; i++) 25 | try { 26 | ret[i] = new PeerAddress(InetAddress.getByName(MAIN_NET[i])); 27 | } catch (UnknownHostException e) { e.printStackTrace(); } 28 | 29 | return ret; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/authenticator/network/exceptions/TCPListenerCouldNotStartException.java: -------------------------------------------------------------------------------- 1 | package authenticator.network.exceptions; 2 | 3 | public class TCPListenerCouldNotStartException extends Exception{ 4 | public TCPListenerCouldNotStartException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/authenticator/operations/OperationsUtils/CommunicationObjects/SignMessage.java: -------------------------------------------------------------------------------- 1 | package authenticator.operations.OperationsUtils.CommunicationObjects; 2 | 3 | import java.io.IOException; 4 | import java.io.StringWriter; 5 | import java.util.ArrayList; 6 | import java.util.Iterator; 7 | 8 | import org.json.simple.JSONArray; 9 | import org.json.simple.JSONObject; 10 | import org.json.simple.JSONValue; 11 | import org.json.simple.parser.JSONParser; 12 | import org.json.simple.parser.ParseException; 13 | import org.spongycastle.util.encoders.Hex; 14 | 15 | import authenticator.Utils.EncodingUtils; 16 | 17 | public class SignMessage extends JSONObject{ 18 | private static final long serialVersionUID = 1L; 19 | //Vars 20 | public int version; 21 | public int numInputs; 22 | public boolean testnet; 23 | public String transaction; 24 | public ArrayList keyIndexArr; 25 | 26 | public SignMessage(){ 27 | 28 | } 29 | //Serialization 30 | @SuppressWarnings("unchecked") 31 | public byte[] serializeToBytes(){ 32 | this.put("version", version); 33 | this.put("testnet", testnet); 34 | this.put("ins_n", numInputs); 35 | this.put("tx", transaction); 36 | JSONArray keylist = new JSONArray(); 37 | for (int a=0; a deserializeToBytes(byte[] payload) throws ParseException{ 51 | ArrayList sigs = new ArrayList(); 52 | String strJson = new String(payload); 53 | JSONParser parser=new JSONParser(); 54 | Object obj = parser.parse(strJson); 55 | JSONObject jsonObject = (JSONObject) obj; 56 | int version = ((Long) jsonObject.get("version")).intValue(); 57 | int numSigs = ((Long) jsonObject.get("sigs_n")).intValue(); 58 | JSONArray msg = (JSONArray) jsonObject.get("siglist"); 59 | Iterator iterator = msg.iterator(); 60 | JSONArray jsonlist = new JSONArray(); 61 | while (iterator.hasNext()) { 62 | jsonlist.add(iterator.next()); 63 | } 64 | JSONObject jsonObj = (JSONObject) obj; 65 | for(int i=0; i publickeys, ArrayList childkeyindex){ 99 | assert(publickeys.size() == childkeyindex.size()); 100 | this.keyIndexArr = new ArrayList(); 101 | for(int i=0;i 29 | */ 30 | static public boolean checkIfNotificationShouldBeSentToPairedDeviceOnReceivedCoins(WalletOperation wo, Transaction tx) { 31 | Coin enter = wo.getTxValueSentToMe(tx); 32 | Coin exit = wo.getTxValueSentFromMe(tx); 33 | // return true only if we receive coins but dont send any. The logic is, if the Tx sends coins from the wallet, 34 | // most probably and received coins will be change. 35 | if (exit.compareTo(Coin.ZERO) == 0 && enter.compareTo(Coin.ZERO) > 0) { 36 | return true; 37 | } 38 | return false; 39 | } 40 | 41 | static public void send(WalletOperation wo, Transaction tx, HowBalanceChanged howBalanceChanged) { 42 | send(wo, new Dispacher(null,null), tx, howBalanceChanged); 43 | } 44 | 45 | static public void send(WalletOperation wo, Dispacher disp, Transaction tx, HowBalanceChanged howBalanceChanged) { 46 | if(howBalanceChanged == HowBalanceChanged.ReceivedCoins) 47 | for (TransactionOutput out : tx.getOutputs()){ 48 | Script scr = out.getScriptPubKey(); 49 | String addrStr = scr.getToAddress(wo.getNetworkParams()).toString(); 50 | if(wo.isWatchingAddress(addrStr)){ 51 | ATAddress add = wo.findAddressInAccounts(addrStr); 52 | if(add == null) 53 | continue; 54 | 55 | // incoming sum 56 | Coin receivedSum = out.getValue(); 57 | 58 | ATAccount account = null; 59 | try { 60 | account = wo.getAccount(add.getAccountIndex()); 61 | if(account.getAccountType() != WalletAccountType.AuthenticatorAccount) 62 | continue; 63 | PairedAuthenticator pairing = wo.getPairingObjectForAccountIndex(account.getIndex()); 64 | SecretKey secretkey = new SecretKeySpec(Hex.decode(pairing.getAesKey()), "AES"); 65 | byte[] gcmID = pairing.getGCM().getBytes(); 66 | assert(gcmID != null); 67 | Device d = new Device(pairing.getChainCode().getBytes(), 68 | pairing.getMasterPublicKey().getBytes(), 69 | gcmID, 70 | pairing.getPairingID().getBytes(), 71 | secretkey); 72 | 73 | System.out.println("Sending a Coins Received Notification"); 74 | disp.dispachMessage(ATGCMMessageType.CoinsReceived, d, new String[]{ "Coins Received: " + receivedSum.toFriendlyString() }); 75 | } 76 | catch (AccountWasNotFoundException | JSONException | IOException e1) { 77 | e1.printStackTrace(); 78 | } 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/authenticator/walletCore/utils/WalletListener.java: -------------------------------------------------------------------------------- 1 | package authenticator.walletCore.utils; 2 | 3 | import org.bitcoinj.core.AbstractWalletEventListener; 4 | import org.bitcoinj.core.Coin; 5 | import org.bitcoinj.core.Transaction; 6 | import org.bitcoinj.core.TransactionConfidence; 7 | import org.bitcoinj.core.Wallet; 8 | 9 | import authenticator.Authenticator; 10 | import authenticator.listeners.BAGeneralEventsListener.HowBalanceChanged; 11 | import authenticator.walletCore.WalletOperation; 12 | import authenticator.walletCore.WalletOperation.BAOperationState; 13 | 14 | /** 15 | *A basic listener to keep track of balances and transaction state.
16 | *Will mark addresses as "used" when any amount of bitcoins were transfered to the address. 17 | * 18 | * @author alon 19 | * 20 | */ 21 | public class WalletListener extends AbstractWalletEventListener { 22 | WalletOperation walletOp; 23 | public WalletListener(WalletOperation wo) { 24 | walletOp = wo; 25 | } 26 | 27 | @Override 28 | public void onWalletChanged(Wallet wallet) { 29 | /** 30 | * used for confidence change UI update 31 | */ 32 | if(walletOp.getOperationalState() == BAOperationState.READY_AND_OPERATIONAL) 33 | BalanceUpdater.updateBalaceNonBlocking(walletOp, wallet, new Runnable(){ 34 | @Override 35 | public void run() { 36 | notifyBalanceUpdate(wallet,null); 37 | } 38 | }); 39 | } 40 | 41 | @Override 42 | public void onCoinsSent(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { 43 | /** 44 | * Notify balance onCoinsSent() only if we don't receive any coins. 45 | * The idea is that if we have a Tx that sends and receives coins to this wallet, 46 | * notify only onCoinsReceived() so we won't send multiple update balance calls. 47 | * 48 | * If the Tx only sends coins, do update the balance from here. 49 | */ 50 | if(tx.getValueSentToMe(wallet).signum() == 0) 51 | BalanceUpdater.updateBalaceNonBlocking(walletOp, wallet, new Runnable(){ 52 | @Override 53 | public void run() { 54 | notifyBalanceUpdate(wallet,tx); 55 | } 56 | }); 57 | } 58 | 59 | @Override 60 | public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { 61 | /** 62 | * the {org.bitcoinj.wallet.DefaultCoinSelector} can only choose candidates if they 63 | * originated from the wallet, so this fix is so incoming tx (originated elsewhere) 64 | * could be spent if not confirmed 65 | */ 66 | tx.getConfidence().setSource(TransactionConfidence.Source.SELF); 67 | 68 | BalanceUpdater.updateBalaceNonBlocking(walletOp, wallet, new Runnable(){ 69 | @Override 70 | public void run() { 71 | notifyBalanceUpdate(wallet,tx); 72 | } 73 | }); 74 | } 75 | 76 | private void notifyBalanceUpdate(Wallet wallet, Transaction tx){ 77 | if(tx != null){ 78 | if(tx.getValueSentToMe(wallet).signum() > 0){ 79 | Authenticator.fireOnBalanceChanged(tx, HowBalanceChanged.ReceivedCoins, tx.getConfidence().getConfidenceType()); 80 | } 81 | else if(tx.getValueSentFromMe(wallet).signum() > 0){ 82 | Authenticator.fireOnBalanceChanged(tx, HowBalanceChanged.SentCoins, tx.getConfidence().getConfidenceType()); 83 | } 84 | } 85 | else 86 | Authenticator.fireOnBalanceChanged(null, null, null); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/CoinJoinController.java: -------------------------------------------------------------------------------- 1 | package wallettemplate; 2 | 3 | import javafx.fxml.FXML; 4 | import wallettemplate.utils.BaseUI; 5 | 6 | public class CoinJoinController extends BaseUI{ 7 | public Main.OverlayUI overlayUi; 8 | 9 | public void initialize() { 10 | super.initialize(CoinJoinController.class); 11 | } 12 | 13 | @FXML protected void close(){ 14 | overlayUi.done(); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/wallettemplate/ControllerHelpers/AsyncTask.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.ControllerHelpers; 2 | 3 | import javafx.application.Platform; 4 | 5 | /** 6 | * 7 | * @author Victor Oliveira 8 | */ 9 | public abstract class AsyncTask { 10 | 11 | private boolean daemon = true; 12 | 13 | abstract protected void onPreExecute(); 14 | 15 | abstract protected void doInBackground(); 16 | 17 | /** 18 | * This method runs on the UI thread 19 | */ 20 | abstract protected void onPostExecute(); 21 | 22 | abstract protected void progressCallback(Object... params); 23 | 24 | public void publishProgress(final Object... params) { 25 | Platform.runLater(new Runnable() { 26 | @Override 27 | public void run() { 28 | progressCallback(params); 29 | } 30 | }); 31 | } 32 | 33 | private final Thread backGroundThread = new Thread(new Runnable() { 34 | @Override 35 | public void run() { 36 | 37 | doInBackground(); 38 | 39 | Platform.runLater(new Runnable() { 40 | @Override 41 | public void run() { 42 | onPostExecute(); 43 | } 44 | }); 45 | } 46 | }); 47 | 48 | public void execute() { 49 | 50 | Platform.runLater(new Runnable() { 51 | @Override 52 | public void run() { 53 | 54 | onPreExecute(); 55 | 56 | backGroundThread.setDaemon(daemon); 57 | backGroundThread.start(); 58 | } 59 | }); 60 | } 61 | 62 | public void setDaemon(boolean daemon) { 63 | this.daemon = daemon; 64 | } 65 | 66 | public void interrupt(){ 67 | this.backGroundThread.interrupt(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/ControllerHelpers/TableTx.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.ControllerHelpers; 2 | 3 | import org.bitcoinj.core.Transaction; 4 | 5 | import javafx.scene.control.Label; 6 | import javafx.scene.image.Image; 7 | import javafx.scene.image.ImageView; 8 | import javafx.scene.layout.VBox; 9 | import javafx.scene.text.Text; 10 | 11 | public class TableTx { 12 | 13 | private Transaction T; 14 | private String txid; 15 | private VBox confirmations; 16 | private VBox inOut; 17 | private String date; 18 | private String toFrom; 19 | private String description; 20 | private Text amount; 21 | 22 | public TableTx (Transaction pT, String ptxid, VBox pConfirmations, VBox pInOut, String pDate, String pToFrom, String pDescription, Text pAmount){ 23 | this.T = pT; 24 | this.txid = ptxid; 25 | this.confirmations = pConfirmations; 26 | this.inOut = pInOut; 27 | this.date = pDate; 28 | this.toFrom = pToFrom; 29 | this.description = pDescription; 30 | this.amount = pAmount; 31 | } 32 | 33 | public Transaction getTransaction(){ 34 | return T; 35 | } 36 | 37 | public String getTxid(){ 38 | return txid; 39 | } 40 | 41 | public VBox getConfirmations(){ 42 | return confirmations; 43 | } 44 | 45 | public void setConfirmations(VBox pConfirmations){ 46 | this.confirmations = pConfirmations; 47 | } 48 | 49 | public VBox getInOut(){ 50 | return inOut; 51 | } 52 | 53 | public String getDate(){ 54 | return date; 55 | } 56 | 57 | public String getToFrom(){ 58 | return toFrom; 59 | } 60 | 61 | public void setToFrom(String pToFrom){ 62 | this.toFrom = pToFrom; 63 | } 64 | 65 | public String getDescription(){ 66 | return description; 67 | } 68 | 69 | public void setDescription(String pDescription){ 70 | this.description = pDescription; 71 | } 72 | 73 | public Text getAmount(){ 74 | return amount; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/ControllerHelpers/ThrottledRunnableExecutor.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.ControllerHelpers; 2 | 3 | import java.util.Timer; 4 | import java.util.TimerTask; 5 | 6 | public class ThrottledRunnableExecutor { 7 | private boolean shouldExecute; 8 | private int delay; 9 | private int period; 10 | private Runnable runnable; 11 | 12 | Timer timer; 13 | TimerTask task; 14 | 15 | public ThrottledRunnableExecutor(int delay, int period, Runnable runnable){ 16 | this.period = period; 17 | this.delay = delay; 18 | this.runnable = runnable; 19 | } 20 | public ThrottledRunnableExecutor(int period, Runnable runnable){ 21 | this(0, period, runnable); 22 | } 23 | 24 | public void start(){ 25 | shouldExecute = false; 26 | 27 | task = new TimerTask(){ 28 | @Override 29 | public void run() { 30 | if(shouldExecute){ 31 | runnable.run(); 32 | shouldExecute = false; 33 | } 34 | } 35 | }; 36 | 37 | timer = new Timer("Update Timer"); 38 | timer.scheduleAtFixedRate(task, delay, period); 39 | } 40 | 41 | public void execute(){ 42 | shouldExecute = true; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/NotImplementedYetController.java: -------------------------------------------------------------------------------- 1 | package wallettemplate; 2 | 3 | import static wallettemplate.utils.GuiUtils.informationalAlert; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | 8 | import javax.annotation.Nullable; 9 | 10 | import javafx.scene.image.Image; 11 | import javafx.util.Duration; 12 | import authenticator.Authenticator; 13 | import authenticator.operations.BAOperation; 14 | import authenticator.operations.OperationsFactory; 15 | import authenticator.operations.OperationsUtils.PairingProtocol; 16 | import authenticator.operations.OperationsUtils.PairingProtocol.PairingStage; 17 | import authenticator.operations.OperationsUtils.PairingProtocol.PairingStageUpdater; 18 | import authenticator.operations.OperationsUtils.PairingQRCode; 19 | import authenticator.operations.listeners.OperationListener; 20 | import authenticator.operations.listeners.OperationListenerAdapter; 21 | import authenticator.protobuf.ProtoConfig.PairedAuthenticator; 22 | import wallettemplate.utils.BaseUI; 23 | import wallettemplate.utils.GuiUtils; 24 | import javafx.application.Platform; 25 | import javafx.event.ActionEvent; 26 | import javafx.event.EventHandler; 27 | import javafx.fxml.FXML; 28 | import javafx.scene.control.Button; 29 | import javafx.scene.control.Hyperlink; 30 | import javafx.scene.control.TextArea; 31 | import javafx.scene.control.TextField; 32 | import javafx.scene.control.Label; 33 | import javafx.scene.control.Tooltip; 34 | import javafx.scene.image.ImageView; 35 | import javafx.scene.input.MouseEvent; 36 | import javafx.animation.Animation; 37 | import javafx.animation.Interpolator; 38 | import javafx.animation.ScaleTransition; 39 | import javafx.animation.TranslateTransition; 40 | import javafx.scene.control.ProgressIndicator; 41 | import javafx.scene.layout.HBox; 42 | import javafx.scene.layout.Pane; 43 | import javafx.scene.text.Text; 44 | 45 | public class NotImplementedYetController extends BaseUI{ 46 | 47 | @FXML private Label lblClose; 48 | 49 | public Main.OverlayUI overlayUi; 50 | 51 | private double xOffset = 0; 52 | private double yOffset = 0; 53 | 54 | @SuppressWarnings("restriction") 55 | public void initialize() { 56 | super.initialize(NotImplementedYetController.class); 57 | 58 | Tooltip.install(lblClose, new Tooltip("Close Window")); 59 | lblClose.setOnMousePressed(new EventHandler(){ 60 | @Override 61 | public void handle(MouseEvent t) { 62 | done(); 63 | } 64 | }); 65 | } 66 | 67 | @FXML protected void drag1(MouseEvent event) { 68 | xOffset = event.getSceneX(); 69 | yOffset = event.getSceneY(); 70 | } 71 | 72 | @FXML protected void drag2(MouseEvent event) { 73 | Main.stage.setX(event.getScreenX() - xOffset); 74 | Main.stage.setY(event.getScreenY() - yOffset); 75 | } 76 | 77 | public void done() { 78 | if(overlayUi != null) 79 | overlayUi.done(); 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/OneNameControllerDisplay.java: -------------------------------------------------------------------------------- 1 | package wallettemplate; 2 | 3 | import java.io.IOException; 4 | 5 | 6 | import org.json.JSONException; 7 | 8 | import wallettemplate.controls.BitcoinAddressValidator; 9 | import wallettemplate.utils.BaseUI; 10 | import authenticator.Authenticator; 11 | import authenticator.Utils.OneName.OneName; 12 | import javafx.application.Platform; 13 | import javafx.collections.ObservableList; 14 | import javafx.event.ActionEvent; 15 | import javafx.fxml.FXML; 16 | import javafx.scene.control.Button; 17 | import javafx.scene.control.ScrollPane; 18 | import javafx.scene.control.TextField; 19 | import javafx.scene.input.MouseEvent; 20 | import javafx.scene.layout.AnchorPane; 21 | import javafx.scene.web.WebEngine; 22 | import javafx.scene.web.WebHistory; 23 | import javafx.scene.web.WebView; 24 | 25 | public class OneNameControllerDisplay extends BaseUI{ 26 | @FXML private WebView webView; 27 | static WebEngine engine; 28 | @FXML private Button done; 29 | public Main.OverlayUI overlayUi; 30 | private double xOffset = 0; 31 | private double yOffset = 0; 32 | 33 | String oneNameID; 34 | 35 | // Called by FXMLLoader 36 | public void initialize() { 37 | super.initialize(OneNameControllerDisplay.class); 38 | engine = webView.getEngine(); 39 | } 40 | 41 | @Override 42 | public void updateUIForParams(){ 43 | if(this.hasParameters()) { 44 | oneNameID = arrParams.get(0).toString(); 45 | } 46 | 47 | if(oneNameID != null) 48 | loadOneName(oneNameID); 49 | else 50 | loadOneName(Authenticator.getWalletOperation().getOnename().getOnename()); 51 | } 52 | 53 | private void loadOneName(String onename){ 54 | engine.load("https://onename.io/" + onename); 55 | } 56 | 57 | @FXML protected void drag1(MouseEvent event) { 58 | xOffset = event.getSceneX(); 59 | yOffset = event.getSceneY(); 60 | } 61 | 62 | @FXML protected void drag2(MouseEvent event) { 63 | Main.stage.setX(event.getScreenX() - xOffset); 64 | Main.stage.setY(event.getScreenY() - yOffset); 65 | } 66 | 67 | public void btnBack(ActionEvent event) { goBack(); } 68 | public String goBack() 69 | { 70 | final WebHistory history = engine.getHistory(); 71 | ObservableList entryList=history.getEntries(); 72 | int currentIndex=history.getCurrentIndex(); 73 | // Out("currentIndex = "+currentIndex); 74 | // Out(entryList.toString().replace("],","]\n")); 75 | 76 | Platform.runLater(new Runnable() { public void run() { history.go(-1); } }); 77 | return entryList.get(currentIndex>0?currentIndex-1:currentIndex).getUrl(); 78 | } 79 | 80 | public void btnForward(ActionEvent event) { goForward(); } 81 | public String goForward() 82 | { 83 | final WebHistory history=engine.getHistory(); 84 | ObservableList entryList=history.getEntries(); 85 | int currentIndex=history.getCurrentIndex(); 86 | // Out("currentIndex = "+currentIndex); 87 | // Out(entryList.toString().replace("],","]\n")); 88 | 89 | Platform.runLater(new Runnable() { public void run() { history.go(1); } }); 90 | return entryList.get(currentIndex resourceLoaderClass; 21 | 22 | private RemoteUpdateWindowListener listener; 23 | 24 | @FXML public VBox progressBox; 25 | @FXML public VBox okBox; 26 | 27 | @FXML public Label lblTitle; 28 | @FXML public Label lblDetails; 29 | @FXML public ProgressBar progressBar; 30 | 31 | public RemoteUpdateWindow(Class loaderClss) { 32 | resourceLoaderClass = loaderClss; 33 | } 34 | 35 | private void loadFXML() { 36 | dialogStage = new Stage(); 37 | try { 38 | FXMLLoader loader = new FXMLLoader(); 39 | loader.setController(this); 40 | loader.setLocation(getViewURL()); 41 | 42 | Scene scene; 43 | scene = new Scene((AnchorPane) loader.load()); 44 | final String file = TextFieldValidator.class.getResource("GUI.css").toString(); 45 | scene.getStylesheets().add(file); 46 | dialogStage.setScene(scene); 47 | dialogStage.initStyle(StageStyle.UNDECORATED); 48 | } catch (IOException e) { 49 | e.printStackTrace(); 50 | } 51 | } 52 | 53 | private URL getViewURL() { 54 | return resourceLoaderClass.getResource(getViewPath()); 55 | } 56 | 57 | private String getViewPath() { 58 | return "remote_update/RemoteUpdateWindow.fxml"; 59 | } 60 | 61 | private void initialize() { 62 | dialogStage.setTitle("Updates"); 63 | 64 | this.lblDetails.setVisible(false); 65 | this.okBox.setVisible(false); 66 | } 67 | 68 | public void show() { 69 | loadFXML(); 70 | dialogStage.show(); 71 | initialize(); 72 | } 73 | 74 | public void close() { 75 | dialogStage.close(); 76 | } 77 | 78 | public ProgressBar getProgressBar() { 79 | return progressBar; 80 | } 81 | 82 | public void setToFailedConnectionMode(String details) { 83 | this.lblDetails.setVisible(true); 84 | this.okBox.setVisible(true); 85 | this.progressBox.setVisible(false); 86 | 87 | this.lblTitle.setText("Failed Downloading Updates"); 88 | this.lblDetails.setText(details); 89 | } 90 | 91 | public void setListener(RemoteUpdateWindowListener l) { 92 | this.listener = l; 93 | } 94 | 95 | /* 96 | * 97 | * Button Actions 98 | * 99 | */ 100 | 101 | @FXML protected void done(ActionEvent event){ 102 | dialogStage.close(); 103 | if(listener != null) 104 | listener.UserPressedOk(RemoteUpdateWindow.this); 105 | } 106 | 107 | public interface RemoteUpdateWindowListener { 108 | public void UserPressedOk(RemoteUpdateWindow window); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/ShowSeedController.java: -------------------------------------------------------------------------------- 1 | package wallettemplate; 2 | 3 | import static wallettemplate.utils.GuiUtils.informationalAlert; 4 | 5 | import java.io.IOException; 6 | import java.util.List; 7 | 8 | import org.json.JSONException; 9 | 10 | import org.bitcoinj.wallet.DeterministicSeed; 11 | import com.google.common.base.Joiner; 12 | 13 | import wallettemplate.controls.BitcoinAddressValidator; 14 | import wallettemplate.utils.BaseUI; 15 | import authenticator.Authenticator; 16 | import authenticator.Utils.OneName.OneName; 17 | import authenticator.walletCore.exceptions.NoWalletPasswordException; 18 | import javafx.application.Platform; 19 | import javafx.collections.ObservableList; 20 | import javafx.event.ActionEvent; 21 | import javafx.event.EventHandler; 22 | import javafx.fxml.FXML; 23 | import javafx.scene.control.Button; 24 | import javafx.scene.control.ContextMenu; 25 | import javafx.scene.control.MenuItem; 26 | import javafx.scene.control.ScrollPane; 27 | import javafx.scene.control.TextField; 28 | import javafx.scene.input.Clipboard; 29 | import javafx.scene.input.ClipboardContent; 30 | import javafx.scene.input.MouseEvent; 31 | import javafx.scene.layout.AnchorPane; 32 | import javafx.scene.control.Label; 33 | 34 | public class ShowSeedController extends BaseUI{ 35 | @FXML private Label lblSeed; 36 | @FXML private Button done; 37 | public Main.OverlayUI overlayUi; 38 | 39 | 40 | // Called by FXMLLoader 41 | @SuppressWarnings("restriction") 42 | public void initialize() { 43 | super.initialize(ShowSeedController.class); 44 | try { 45 | DeterministicSeed seed = Authenticator.getWalletOperation().getWalletSeed(Main.UI_ONLY_WALLET_PW); 46 | List mnemonic = seed.getMnemonicCode(); 47 | String seedStr = Joiner.on(" ").join(mnemonic); 48 | lblSeed.setText(seedStr); 49 | } catch (NoWalletPasswordException e) { 50 | informationalAlert("Unfortunately, you messed up.", 51 | "You need to enter the correct password."); 52 | return; 53 | } 54 | 55 | // right click copy context menu 56 | final ContextMenu contextMenu = new ContextMenu(); 57 | MenuItem item1 = new MenuItem("Copy"); 58 | item1.setOnAction(new EventHandler() { 59 | @SuppressWarnings("restriction") 60 | public void handle(ActionEvent e) { 61 | @SuppressWarnings("restriction") 62 | Clipboard clipboard = Clipboard.getSystemClipboard(); 63 | ClipboardContent content = new ClipboardContent(); 64 | content.putString(lblSeed.getText().toString()); 65 | clipboard.setContent(content); 66 | } 67 | }); 68 | contextMenu.getItems().addAll(item1); 69 | lblSeed.setContextMenu(contextMenu); 70 | } 71 | 72 | @FXML protected void exit(MouseEvent event) { 73 | overlayUi.done(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/ShutDownController.java: -------------------------------------------------------------------------------- 1 | package wallettemplate; 2 | 3 | import javafx.animation.RotateTransition; 4 | import javafx.scene.image.ImageView; 5 | import javafx.util.Duration; 6 | import wallettemplate.utils.BaseUI; 7 | 8 | public class ShutDownController extends BaseUI{ 9 | public ImageView ivSpinner; 10 | 11 | public void initialize() { 12 | super.initialize(ShutDownController.class); 13 | startSyncRotation(); 14 | } 15 | 16 | private RotateTransition rt; 17 | private void startSyncRotation(){ 18 | if(rt == null){ 19 | rt = new RotateTransition(Duration.millis(2000),ivSpinner); 20 | rt.setByAngle(360); 21 | rt.setCycleCount(10000); 22 | } 23 | rt.play(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/controls/BitcoinAddressValidator.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.controls; 2 | 3 | import org.bitcoinj.core.Address; 4 | import org.bitcoinj.core.AddressFormatException; 5 | import org.bitcoinj.core.NetworkParameters; 6 | import javafx.scene.Node; 7 | import javafx.scene.control.TextField; 8 | import wallettemplate.utils.TextFieldValidator; 9 | 10 | /** 11 | * Given a text field, some network params and optionally some nodes, will make the text field an angry red colour 12 | * if the address is invalid for those params, and enable/disable the nodes. 13 | */ 14 | public class BitcoinAddressValidator { 15 | private NetworkParameters params; 16 | private Node[] nodes; 17 | 18 | public BitcoinAddressValidator(NetworkParameters params, TextField field, Node... nodes) { 19 | this.params = params; 20 | this.nodes = nodes; 21 | 22 | // Handle the red highlighting, but don't highlight in red just when the field is empty because that makes 23 | // the example/prompt address hard to read. 24 | new TextFieldValidator(field, text -> text.isEmpty() || testAddr(text)); 25 | // However we do want the buttons to be disabled when empty so we apply a different test there. 26 | field.textProperty().addListener((observableValue, prev, current) -> { 27 | toggleButtons(current); 28 | }); 29 | toggleButtons(field.getText()); 30 | } 31 | 32 | private void toggleButtons(String current) { 33 | boolean valid = testAddr(current); 34 | for (Node n : nodes) n.setDisable(!valid); 35 | } 36 | 37 | private boolean testAddr(String text) { 38 | try { 39 | new Address(params, text); 40 | return true; 41 | } catch (AddressFormatException e) { 42 | return false; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/controls/ScrollPaneContentManager.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.controls; 2 | 3 | import javafx.collections.ObservableList; 4 | import javafx.scene.Node; 5 | import javafx.scene.layout.Priority; 6 | import javafx.scene.layout.VBox; 7 | 8 | public class ScrollPaneContentManager extends VBox{ 9 | public ScrollPaneContentManager(){ 10 | super(); 11 | } 12 | 13 | public ScrollPaneContentManager setScrollStyle(String style) 14 | { 15 | this.setStyle(style);//"-fx-background-color: white"); 16 | return this; 17 | } 18 | 19 | public ScrollPaneContentManager setSpacingBetweenItems(double spacing) 20 | { 21 | this.setSpacing(spacing); 22 | return this; 23 | } 24 | 25 | public ScrollPaneContentManager addItem(Node e) 26 | { 27 | this.getChildren().add(e); 28 | return this; 29 | } 30 | 31 | public void removeNodeAtIndex(int index) 32 | { 33 | this.getChildren().remove(index); 34 | } 35 | 36 | public void removeNode(Node n){ 37 | this.getChildren().remove(n); 38 | } 39 | 40 | public ScrollPaneContentManager clearAll() 41 | { 42 | this.getChildren().clear(); 43 | return this; 44 | } 45 | 46 | public int getCount() 47 | { 48 | return this.getChildren().size(); 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/wallettemplate/startup/RestoreAccountCell.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.startup; 2 | 3 | import java.awt.Button; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.net.URL; 7 | 8 | import org.json.JSONException; 9 | 10 | import org.bitcoinj.core.Coin; 11 | 12 | import wallettemplate.Main; 13 | import wallettemplate.Main.OverlayUI; 14 | import authenticator.Utils.OneName.OneName; 15 | import authenticator.protobuf.ProtoConfig.WalletAccountType; 16 | import javafx.animation.TranslateTransition; 17 | import javafx.event.ActionEvent; 18 | import javafx.fxml.FXML; 19 | import javafx.scene.control.Label; 20 | import javafx.scene.control.TextField; 21 | import javafx.fxml.FXMLLoader; 22 | import javafx.scene.input.MouseEvent; 23 | import javafx.scene.layout.Region; 24 | import javafx.scene.Node; 25 | import javafx.scene.image.ImageView; 26 | import javafx.util.Duration; 27 | import javafx.scene.image.Image; 28 | 29 | public class RestoreAccountCell extends Region{ 30 | @FXML private Label lblAccountType; 31 | @FXML private Label lblAccountID; 32 | @FXML private Label lblAccountName; 33 | @FXML private ImageView ivLogo; 34 | 35 | AccountCellListener listener; 36 | 37 | @SuppressWarnings("restriction") 38 | public RestoreAccountCell(WalletAccountType type, AccountCellListener r) { 39 | this.listener = r; 40 | this.loadFXML(); 41 | this.setSnapToPixel(true); 42 | if(type == WalletAccountType.StandardAccount) 43 | ivLogo.setImage(new Image("/wallettemplate/bitcoin_logo_small.png")); 44 | else 45 | ivLogo.setImage(new Image("wallettemplate/authenticator_logo_plain_small.png")); 46 | } 47 | 48 | public String getAccountTypeName() { return lblAccountType.getText(); } 49 | public void setAccountTypeName(String value){ 50 | lblAccountType.setText(value); 51 | } 52 | 53 | public int getAccountID(){ return Integer.parseInt(lblAccountID.getText()); } 54 | public void setAccountID(String value){ 55 | lblAccountID.setText(value); 56 | } 57 | 58 | public String getAccountName(){ return lblAccountName.getText(); } 59 | public void setAccountName(String value){ 60 | lblAccountName.setText(value); 61 | } 62 | 63 | @SuppressWarnings("restriction") 64 | private void loadFXML() { 65 | FXMLLoader loader = new FXMLLoader(); 66 | loader.setController(this); 67 | loader.setLocation(this.getViewURL()); 68 | try { 69 | Node root = (Node) loader.load(); 70 | this.getChildren().add(root); 71 | } 72 | catch (IOException ex) { 73 | ex.printStackTrace(); 74 | } 75 | } 76 | 77 | private String getViewPath() { 78 | return "startup/restore_account_cell.fxml"; 79 | } 80 | 81 | private URL getViewURL() { 82 | return Main.class.getResource(this.getViewPath()); 83 | } 84 | 85 | @FXML protected void close(ActionEvent event){ 86 | if(this.listener != null) 87 | this.listener.close(this); 88 | } 89 | 90 | public interface AccountCellListener{ 91 | public void close(RestoreAccountCell cell); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/startup/RestoreProcessCell.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.startup; 2 | 3 | import java.awt.Button; 4 | import java.io.IOException; 5 | import java.net.URL; 6 | 7 | import org.json.JSONException; 8 | 9 | import org.bitcoinj.core.Coin; 10 | 11 | import wallettemplate.Main; 12 | import wallettemplate.Main.OverlayUI; 13 | import authenticator.Utils.OneName.OneName; 14 | import authenticator.protobuf.ProtoConfig.WalletAccountType; 15 | import javafx.animation.TranslateTransition; 16 | import javafx.event.ActionEvent; 17 | import javafx.fxml.FXML; 18 | import javafx.scene.control.Label; 19 | import javafx.scene.control.TextField; 20 | import javafx.fxml.FXMLLoader; 21 | import javafx.scene.input.MouseEvent; 22 | import javafx.scene.layout.Region; 23 | import javafx.scene.Node; 24 | import javafx.scene.image.ImageView; 25 | import javafx.util.Duration; 26 | import javafx.scene.image.Image; 27 | 28 | public class RestoreProcessCell extends Region{ 29 | @FXML private Label lblTxID; 30 | @FXML private Label lblCoinsReceived; 31 | @FXML private Label lblCoinsSent; 32 | @FXML private Label lblConfidence; 33 | @FXML private Label lblStatus; 34 | 35 | @SuppressWarnings("restriction") 36 | public RestoreProcessCell() { 37 | this.loadFXML(); 38 | this.setSnapToPixel(true); 39 | } 40 | 41 | public String getCoinsReceived() { return lblCoinsReceived.getText(); } 42 | public void setCoinsReceived(String value){ 43 | lblCoinsReceived.setText(value); 44 | } 45 | 46 | public int getCoinsSent(){ return Integer.parseInt(lblCoinsSent.getText()); } 47 | public void setCoinsSent(String value){ 48 | lblCoinsSent.setText(value); 49 | } 50 | 51 | public String getTxID(){ return lblTxID.getText(); } 52 | public void setTxID(String value){ 53 | lblTxID.setText(value); 54 | } 55 | 56 | public String getStatus(){ return lblStatus.getText(); } 57 | public void setStatus(String value){ 58 | lblStatus.setText(value); 59 | } 60 | 61 | public String getConfidence(){ return lblConfidence.getText(); } 62 | public void setConfidence(String value){ 63 | lblConfidence.setText(value); 64 | } 65 | 66 | @SuppressWarnings("restriction") 67 | private void loadFXML() { 68 | FXMLLoader loader = new FXMLLoader(); 69 | loader.setController(this); 70 | loader.setLocation(this.getViewURL()); 71 | try { 72 | Node root = (Node) loader.load(); 73 | this.getChildren().add(root); 74 | } 75 | catch (IOException ex) { 76 | ex.printStackTrace(); 77 | } 78 | } 79 | 80 | private String getViewPath() { 81 | return "startup/restore_process_cell.fxml"; 82 | } 83 | 84 | private URL getViewURL() { 85 | return Main.class.getResource(this.getViewPath()); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/startup/SSSRestoreCell.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.startup; 2 | 3 | import java.awt.Button; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.net.URL; 7 | 8 | import org.json.JSONException; 9 | 10 | import org.bitcoinj.core.Coin; 11 | 12 | import wallettemplate.Main; 13 | import wallettemplate.Main.OverlayUI; 14 | import authenticator.Utils.OneName.OneName; 15 | import authenticator.protobuf.ProtoConfig.WalletAccountType; 16 | import javafx.animation.TranslateTransition; 17 | import javafx.event.ActionEvent; 18 | import javafx.fxml.FXML; 19 | import javafx.scene.control.Label; 20 | import javafx.scene.control.TextField; 21 | import javafx.fxml.FXMLLoader; 22 | import javafx.scene.layout.Region; 23 | import javafx.scene.Node; 24 | 25 | public class SSSRestoreCell extends Region{ 26 | @FXML private TextField txf; 27 | @FXML private Label lbl; 28 | 29 | @SuppressWarnings("restriction") 30 | public SSSRestoreCell() { 31 | this.loadFXML(); 32 | this.setSnapToPixel(true); 33 | } 34 | 35 | public void setLabel(String value){ 36 | lbl.setText(value); 37 | } 38 | public String getShareStr(){ return txf.getText(); } 39 | 40 | @SuppressWarnings("restriction") 41 | private void loadFXML() { 42 | FXMLLoader loader = new FXMLLoader(); 43 | loader.setController(this); 44 | loader.setLocation(this.getViewURL()); 45 | try { 46 | Node root = (Node) loader.load(); 47 | this.getChildren().add(root); 48 | } 49 | catch (IOException ex) { 50 | ex.printStackTrace(); 51 | } 52 | } 53 | 54 | private String getViewPath() { 55 | return "startup/SSSRestoreCell.fxml"; 56 | } 57 | 58 | private URL getViewURL() { 59 | return Main.class.getResource(this.getViewPath()); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/startup/StartupControllerHelper.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.startup; 2 | 3 | import javafx.beans.value.ObservableValue; 4 | import javafx.scene.control.TextField; 5 | 6 | public class StartupControllerHelper { 7 | 8 | public static void SSSValidator(TextField txf, ObservableValue observable, Number oldValue, Number newValue){ 9 | if(newValue.intValue() > oldValue.intValue()){ 10 | char ch = txf.getText().charAt(oldValue.intValue()); 11 | //Check if the new character is the number or other's 12 | if(!(ch >= '0' && ch <= '9')){ 13 | //if it's not number then just setText to previous one 14 | txf.setText(txf.getText().substring(0,txf.getText().length()-1)); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/startup/TestSSSCell.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.startup; 2 | 3 | import java.awt.Button; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.net.URL; 7 | 8 | import org.json.JSONException; 9 | 10 | import org.bitcoinj.core.Coin; 11 | 12 | import wallettemplate.Main; 13 | import wallettemplate.Main.OverlayUI; 14 | import authenticator.Utils.OneName.OneName; 15 | import authenticator.protobuf.ProtoConfig.WalletAccountType; 16 | import javafx.animation.TranslateTransition; 17 | import javafx.event.ActionEvent; 18 | import javafx.fxml.FXML; 19 | import javafx.scene.control.Label; 20 | import javafx.scene.control.TextField; 21 | import javafx.fxml.FXMLLoader; 22 | import javafx.scene.input.MouseEvent; 23 | import javafx.scene.layout.Region; 24 | import javafx.scene.Node; 25 | import javafx.scene.image.ImageView; 26 | import javafx.util.Duration; 27 | import javafx.scene.image.Image; 28 | 29 | public class TestSSSCell extends Region{ 30 | @FXML private Label lblPiece; 31 | 32 | 33 | @SuppressWarnings("restriction") 34 | public TestSSSCell() { 35 | this.loadFXML(); 36 | this.setSnapToPixel(true); 37 | } 38 | 39 | public String getPiece(){ return lblPiece.getText(); } 40 | public void setPiece(String value){ 41 | lblPiece.setText(value); 42 | } 43 | 44 | @SuppressWarnings("restriction") 45 | private void loadFXML() { 46 | FXMLLoader loader = new FXMLLoader(); 47 | loader.setController(this); 48 | loader.setLocation(this.getViewURL()); 49 | try { 50 | Node root = (Node) loader.load(); 51 | this.getChildren().add(root); 52 | } 53 | catch (IOException ex) { 54 | ex.printStackTrace(); 55 | } 56 | } 57 | 58 | private String getViewPath() { 59 | return "startup/TestSSSCell.fxml"; 60 | } 61 | 62 | private URL getViewURL() { 63 | return Main.class.getResource(this.getViewPath()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/startup/TestSSSResultCell.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.startup; 2 | 3 | import java.awt.Button; 4 | import java.io.IOException; 5 | import java.net.URL; 6 | 7 | import org.json.JSONException; 8 | 9 | import org.bitcoinj.core.Coin; 10 | 11 | import wallettemplate.Main; 12 | import wallettemplate.Main.OverlayUI; 13 | import authenticator.Utils.OneName.OneName; 14 | import authenticator.protobuf.ProtoConfig.WalletAccountType; 15 | import javafx.animation.TranslateTransition; 16 | import javafx.event.ActionEvent; 17 | import javafx.fxml.FXML; 18 | import javafx.scene.control.Label; 19 | import javafx.scene.control.TextField; 20 | import javafx.fxml.FXMLLoader; 21 | import javafx.scene.input.MouseEvent; 22 | import javafx.scene.layout.Region; 23 | import javafx.scene.Node; 24 | import javafx.scene.image.ImageView; 25 | import javafx.util.Duration; 26 | import javafx.scene.image.Image; 27 | 28 | public class TestSSSResultCell extends Region{ 29 | @FXML private Label lbl; 30 | @FXML private ImageView imgView; 31 | 32 | 33 | @SuppressWarnings("restriction") 34 | public TestSSSResultCell() { 35 | this.loadFXML(); 36 | this.setSnapToPixel(true); 37 | } 38 | 39 | public String getResult(){ return lbl.getText(); } 40 | public void setResult(String value){ 41 | lbl.setText(value); 42 | } 43 | 44 | public void setIcon(Image value){ 45 | imgView.setImage(value); 46 | } 47 | 48 | @SuppressWarnings("restriction") 49 | private void loadFXML() { 50 | FXMLLoader loader = new FXMLLoader(); 51 | loader.setController(this); 52 | loader.setLocation(this.getViewURL()); 53 | try { 54 | Node root = (Node) loader.load(); 55 | this.getChildren().add(root); 56 | } 57 | catch (IOException ex) { 58 | ex.printStackTrace(); 59 | } 60 | } 61 | 62 | private String getViewPath() { 63 | return "startup/TestSSSResultCell.fxml"; 64 | } 65 | 66 | private URL getViewURL() { 67 | return Main.class.getResource(this.getViewPath()); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/startup/backup/PaperSSSController.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.startup.backup; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.File; 5 | import java.io.IOException; 6 | 7 | import javax.imageio.ImageIO; 8 | import wallettemplate.utils.BaseUI; 9 | import authenticator.BipSSS.BipSSS.Share; 10 | import authenticator.operations.OperationsUtils.PaperSSSQR; 11 | 12 | public class PaperSSSController extends BaseUI{ 13 | 14 | public PaperSSSController(){ 15 | super(PaperSSSController.class); 16 | } 17 | 18 | public static void createAndSavePaperSSS(Share share, long creationTime, File destinationFolder) throws IOException{ 19 | PaperSSSQR maker = new PaperSSSQR(); 20 | BufferedImage bi = maker.generatePaperWallet(share, creationTime); 21 | 22 | // save 23 | String fileName = "paper share number " + share.shareNumber + ".png"; 24 | File outputfile = new File(destinationFolder.getAbsolutePath() + File.separator + fileName); 25 | if(outputfile != null) 26 | ImageIO.write(bi, "png", outputfile); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/startup/backup/PaperWalletController.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.startup.backup; 2 | 3 | import java.awt.Color; 4 | import java.awt.Desktop; 5 | import java.awt.Font; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.image.BufferedImage; 9 | import java.io.ByteArrayInputStream; 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.net.URL; 13 | 14 | import javafx.embed.swing.SwingFXUtils; 15 | import javafx.scene.image.Image; 16 | import javafx.stage.FileChooser; 17 | 18 | import javax.imageio.ImageIO; 19 | 20 | import wallettemplate.Main; 21 | import wallettemplate.utils.BaseUI; 22 | import net.glxn.qrgen.QRCode; 23 | import net.glxn.qrgen.image.ImageType; 24 | import authenticator.operations.OperationsUtils.PaperWalletQR; 25 | 26 | import org.bitcoinj.core.Utils; 27 | import org.bitcoinj.crypto.DeterministicKey; 28 | import org.bitcoinj.crypto.HDKeyDerivation; 29 | import org.bitcoinj.wallet.DeterministicSeed; 30 | 31 | public class PaperWalletController extends BaseUI{ 32 | 33 | public PaperWalletController(){ 34 | super(PaperWalletController.class); 35 | } 36 | 37 | @SuppressWarnings("restriction") 38 | public static void createPaperWallet(String mnemonic, DeterministicSeed seed, long creationTime) throws IOException{ 39 | PaperWalletQR maker = new PaperWalletQR(); 40 | BufferedImage bi = maker.generatePaperWallet(mnemonic, seed, creationTime); 41 | 42 | // save 43 | String filepath = new java.io.File( "." ).getCanonicalPath() + "/" + "paperwallet" + ".png"; 44 | File wallet = new File(filepath); 45 | FileChooser fileChooser = new FileChooser(); 46 | fileChooser.setTitle("Save Paper Wallet"); 47 | fileChooser.setInitialFileName("paperwallet.png"); 48 | File outputfile = fileChooser.showSaveDialog(Main.startup); 49 | if(outputfile != null) 50 | ImageIO.write(bi, "png", outputfile); 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/AlertWindowController.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils; 2 | 3 | import javafx.scene.control.Button; 4 | import javafx.scene.control.Label; 5 | import javafx.stage.Stage; 6 | 7 | public class AlertWindowController { 8 | public Label messageLabel; 9 | public Label detailsLabel; 10 | public Button okButton; 11 | public Button cancelButton; 12 | public Button actionButton; 13 | 14 | /** Initialize this alert dialog for information about a crash. */ 15 | public void crashAlert(Stage stage, String crashMessage) { 16 | messageLabel.setText("Unfortunately, we screwed up and the app crashed. Sorry about that!"); 17 | detailsLabel.setText(crashMessage); 18 | 19 | cancelButton.setVisible(false); 20 | actionButton.setVisible(false); 21 | okButton.setOnAction(actionEvent -> stage.close()); 22 | } 23 | 24 | /** Initialize this alert for general information: OK button only, nothing happens on dismissal. */ 25 | public void informational(Stage stage, String message, String details) { 26 | messageLabel.setText(message); 27 | detailsLabel.setText(details); 28 | cancelButton.setVisible(false); 29 | actionButton.setVisible(false); 30 | okButton.setOnAction(actionEvent -> stage.close()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/BaseUI.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public class BaseUI { 9 | 10 | public Logger LOG; 11 | public BaseUI(){ } 12 | public BaseUI(Class t) 13 | { 14 | init(t); 15 | } 16 | 17 | public void initialize(Class t){ 18 | init(t); 19 | } 20 | 21 | private void init(Class t){ 22 | LOG = LoggerFactory.getLogger(t); 23 | } 24 | 25 | /** 26 | * For passing params to the controller 27 | * 28 | */ 29 | public ArrayList arrParams; 30 | public void setParams(ArrayList param) 31 | { 32 | arrParams = param; 33 | } 34 | 35 | public void updateUIForParams(){ 36 | 37 | } 38 | 39 | protected boolean hasParameters(){ 40 | if(arrParams == null) 41 | return false; 42 | if(arrParams.size() == 0) 43 | return false; 44 | 45 | return true; 46 | } 47 | 48 | public void cancel() { 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/GuiUtils.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils; 2 | 3 | import com.google.common.base.Throwables; 4 | 5 | import javafx.animation.*; 6 | import javafx.application.Platform; 7 | import javafx.fxml.FXMLLoader; 8 | import javafx.scene.Node; 9 | import javafx.scene.Scene; 10 | import javafx.scene.effect.GaussianBlur; 11 | import javafx.scene.layout.Pane; 12 | import javafx.stage.Modality; 13 | import javafx.stage.Stage; 14 | import javafx.util.Duration; 15 | 16 | import wallettemplate.Main; 17 | 18 | import java.io.IOException; 19 | import java.util.function.BiConsumer; 20 | 21 | import wallettemplate.utils.dialogs.BADialog; 22 | import static com.google.common.base.Preconditions.checkState; 23 | 24 | public class GuiUtils { 25 | 26 | public static void crashAlert(Throwable t) { 27 | t.printStackTrace(); 28 | Platform.exit(); 29 | } 30 | 31 | /** Show a GUI alert box for any unhandled exceptions that propagate out of this thread. */ 32 | public static void handleCrashesOnThisThread() { 33 | Thread.currentThread().setUncaughtExceptionHandler((thread, exception) -> { 34 | GuiUtils.crashAlert(Throwables.getRootCause(exception)); 35 | }); 36 | } 37 | 38 | public static void informationalAlert(String message, String details, Object... args) { 39 | //String formattedDetails = String.format(details, args); 40 | Runnable r = () -> { 41 | BADialog.info(Main.class, message, details).show(); 42 | };//runAlert((stage, controller) -> controller.informational(stage, message, formattedDetails)); 43 | if (Platform.isFxApplicationThread()) 44 | r.run(); 45 | else 46 | Platform.runLater(r); 47 | } 48 | 49 | private static final int UI_ANIMATION_TIME_MSEC = 350; 50 | 51 | public static void fadeIn(Node ui) { 52 | FadeTransition ft = new FadeTransition(Duration.millis(UI_ANIMATION_TIME_MSEC), ui); 53 | ft.setFromValue(0.0); 54 | ft.setToValue(1.0); 55 | ft.play(); 56 | } 57 | 58 | public static Animation fadeOut(Node ui) { 59 | FadeTransition ft = new FadeTransition(Duration.millis(UI_ANIMATION_TIME_MSEC), ui); 60 | ft.setFromValue(ui.getOpacity()); 61 | ft.setToValue(0.0); 62 | ft.play(); 63 | return ft; 64 | } 65 | 66 | public static Animation fadeOutAndRemove(Node ui, Pane parentPane) { 67 | Animation animation = fadeOut(ui); 68 | animation.setOnFinished(actionEvent -> parentPane.getChildren().remove(ui)); 69 | return animation; 70 | } 71 | 72 | public static void blurOut(Node node) { 73 | GaussianBlur blur = new GaussianBlur(0.0); 74 | node.setEffect(blur); 75 | Timeline timeline = new Timeline(); 76 | KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0); 77 | KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv); 78 | timeline.getKeyFrames().add(kf); 79 | timeline.play(); 80 | } 81 | 82 | public static void blurIn(Node node) { 83 | GaussianBlur blur = (GaussianBlur) node.getEffect(); 84 | Timeline timeline = new Timeline(); 85 | KeyValue kv = new KeyValue(blur.radiusProperty(), 0.0); 86 | KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv); 87 | timeline.getKeyFrames().add(kf); 88 | timeline.setOnFinished(actionEvent -> node.setEffect(null)); 89 | timeline.play(); 90 | } 91 | 92 | public static void checkGuiThread() { 93 | checkState(Platform.isFxApplicationThread()); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/ImageUtils.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.awt.image.RenderedImage; 5 | import java.io.ByteArrayInputStream; 6 | import java.io.ByteArrayOutputStream; 7 | import java.io.IOException; 8 | 9 | import javafx.scene.image.Image; 10 | 11 | import javax.imageio.ImageIO; 12 | 13 | public class ImageUtils { 14 | public static javafx.scene.image.Image javaFXImageFromBytes(byte[] data) throws IOException { 15 | return new Image(new ByteArrayInputStream(data)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/TextFieldValidator.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils; 2 | 3 | import javafx.scene.Scene; 4 | import javafx.scene.control.TextField; 5 | 6 | import java.util.function.Predicate; 7 | 8 | public class TextFieldValidator { 9 | private boolean valid; 10 | 11 | public TextFieldValidator(TextField textField, Predicate validator) { 12 | this.valid = validator.test(textField.getText()); 13 | apply(textField, valid); 14 | textField.textProperty().addListener((observableValue, prev, current) -> { 15 | boolean nowValid = validator.test(current); 16 | if (nowValid == valid) return; 17 | apply(textField, nowValid); 18 | valid = nowValid; 19 | }); 20 | } 21 | 22 | private static void apply(TextField textField, boolean nowValid) { 23 | if (nowValid) { 24 | textField.getStyleClass().remove("validation_error"); 25 | } else { 26 | textField.getStyleClass().add("validation_error"); 27 | } 28 | } 29 | 30 | public static void configureScene(Scene scene) { 31 | final String file = TextFieldValidator.class.getResource("text-validation.css").toString(); 32 | scene.getStylesheets().add(file); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/TextUtils.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils; 2 | 3 | import java.math.BigInteger; 4 | 5 | import authenticator.Authenticator; 6 | import authenticator.protobuf.ProtoSettings; 7 | import authenticator.protobuf.ProtoSettings.BitcoinUnit; 8 | 9 | import org.bitcoinj.core.Coin; 10 | 11 | import javafx.scene.text.Font; 12 | import javafx.scene.text.Text; 13 | import javafx.scene.text.TextBoundsType; 14 | 15 | public class TextUtils { 16 | 17 | static final Text helper; 18 | static final double DEFAULT_WRAPPING_WIDTH; 19 | static final double DEFAULT_LINE_SPACING; 20 | static final String DEFAULT_TEXT; 21 | static final TextBoundsType DEFAULT_BOUNDS_TYPE; 22 | static { 23 | helper = new Text(); 24 | DEFAULT_WRAPPING_WIDTH = helper.getWrappingWidth(); 25 | DEFAULT_LINE_SPACING = helper.getLineSpacing(); 26 | DEFAULT_TEXT = helper.getText(); 27 | DEFAULT_BOUNDS_TYPE = helper.getBoundsType(); 28 | } 29 | 30 | public static double computeTextWidth(Font font, String text, double help0) { 31 | // Toolkit.getToolkit().getFontLoader().computeStringWidth(field.getText(), 32 | // field.getFont()); 33 | 34 | helper.setText(text); 35 | helper.setFont(font); 36 | 37 | helper.setWrappingWidth(0.0D); 38 | helper.setLineSpacing(0.0D); 39 | double d = Math.min(helper.prefWidth(-1.0D), help0); 40 | helper.setWrappingWidth((int) Math.ceil(d)); 41 | d = Math.ceil(helper.getLayoutBounds().getWidth()); 42 | 43 | helper.setWrappingWidth(DEFAULT_WRAPPING_WIDTH); 44 | helper.setLineSpacing(DEFAULT_LINE_SPACING); 45 | helper.setText(DEFAULT_TEXT); 46 | return d; 47 | } 48 | 49 | /** 50 | * Coin is the amount in sathosies 51 | * 52 | * @param coin 53 | * @param unit 54 | * @return 55 | */ 56 | public static String coinAmountTextDisplay(Coin coin, BitcoinUnit unit) { 57 | double i = satoshiesToBitcoinUnit(coin.value, unit); 58 | String dp = Integer.toString(Authenticator.getWalletOperation().getDecimalPointFromSettings()); 59 | 60 | return String.format( "%." + dp +"f", i ) + " " + unit.getValueDescriptor().getOptions().getExtension(ProtoSettings.bitcoinUnitName); 61 | } 62 | 63 | /** 64 | * convert an amount represented by a unit to satoshies, e.g. 100 mBits will become 10,000,000 satoshies, 65 | * 66 | * @param in 67 | * @param unit 68 | * @return 69 | */ 70 | public static double bitcoinUnitToSatoshies(double in, BitcoinUnit unit) { 71 | switch(unit) { 72 | case BTC: 73 | in *= 100000000; 74 | break; 75 | case Millibits: 76 | in *= 100000; 77 | break; 78 | case Microbits: 79 | in *= 100; 80 | break; 81 | } 82 | 83 | return in; 84 | } 85 | 86 | /** 87 | * convert an amount in satoshies to unit amount, e.g. 10,000,000 satoshies to 100 mBits. 88 | * 89 | * @param in 90 | * @param unit 91 | * @return 92 | */ 93 | public static double satoshiesToBitcoinUnit(double in, BitcoinUnit unit) { 94 | switch(unit) { 95 | case BTC: 96 | in /= 100000000; 97 | break; 98 | case Millibits: 99 | in /= 100000; 100 | break; 101 | case Microbits: 102 | in /= 100; 103 | break; 104 | } 105 | 106 | return in; 107 | } 108 | 109 | public static String getAbbreviatedUnit (BitcoinUnit unit){ 110 | if (unit == BitcoinUnit.BTC){return "BTC";} 111 | else if (unit == BitcoinUnit.Millibits){return "mBTC";} 112 | else if (unit == BitcoinUnit.Microbits){return "µBTC";} 113 | return null; 114 | } 115 | } -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/ThrottledRunLater.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils; 2 | 3 | import javafx.application.Platform; 4 | 5 | import java.util.concurrent.atomic.AtomicBoolean; 6 | 7 | /** 8 | * A simple wrapper around {@link javafx.application.Platform#runLater(Runnable)} which will do nothing if the previous 9 | * invocation of runLater didn't execute on the JavaFX UI thread yet. In this way you can avoid flooding 10 | * the event loop if you have a background thread that for whatever reason wants to update the UI very 11 | * frequently. Without this class you could end up bloating up memory usage and causing the UI to stutter 12 | * if the UI thread couldn't keep up with your background worker. 13 | */ 14 | public class ThrottledRunLater implements Runnable { 15 | private final Runnable runnable; 16 | private final AtomicBoolean pending = new AtomicBoolean(); 17 | 18 | /** Created this way, the no-args runLater will execute this classes run method. */ 19 | public ThrottledRunLater() { 20 | this.runnable = null; 21 | } 22 | 23 | /** Created this way, the no-args runLater will execute the given runnable. */ 24 | public ThrottledRunLater(Runnable runnable) { 25 | this.runnable = runnable; 26 | } 27 | 28 | public void runLater(Runnable runnable) { 29 | if (!pending.getAndSet(true)) { 30 | Platform.runLater(() -> { 31 | pending.set(false); 32 | runnable.run(); 33 | }); 34 | } 35 | } 36 | 37 | public void runLater() { 38 | runLater(runnable != null ? runnable : this); 39 | } 40 | 41 | @Override 42 | public void run() { 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/dialogs/BADialog.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils.dialogs; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import org.apache.tools.ant.Main; 6 | 7 | public class BADialog extends BADialogBase{ 8 | 9 | public enum BADialogResponse { 10 | Yes, 11 | No, 12 | Ok, 13 | Cancel; 14 | } 15 | 16 | public interface BADialogResponseListner { 17 | public void onResponse(BADialogResponse response, @Nullable String input); 18 | } 19 | 20 | public static BADialog info(Class resourceClass, String title, String desc) { 21 | return DialogFactory.infoDialog(resourceClass, title, desc); 22 | } 23 | 24 | public static BADialog confirm(Class resourceClass, String title, String desc, BADialogResponseListner response) { 25 | return DialogFactory.confirmDialog(resourceClass, response, title, desc); 26 | } 27 | 28 | public static BADialog input(Class resourceClass, String title, String desc, BADialogResponseListner response) { 29 | return DialogFactory.inputDialog(resourceClass, response, title, desc); 30 | } 31 | 32 | public void show() { 33 | this.showDialog(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/wallettemplate/utils/dialogs/DialogFactory.java: -------------------------------------------------------------------------------- 1 | package wallettemplate.utils.dialogs; 2 | 3 | import org.apache.tools.ant.Main; 4 | 5 | import wallettemplate.utils.dialogs.BADialog.BADialogResponse; 6 | import wallettemplate.utils.dialogs.BADialog.BADialogResponseListner; 7 | 8 | public class DialogFactory { 9 | static BADialog infoDialog(Class resourceClass, String title, String desc) { 10 | BADialog ret = new BADialog(); 11 | ret.setViewPath("utils/dialogs/infoDialog.fxml") 12 | .setResourceClass(resourceClass) 13 | .setWindowTitle("info") 14 | .setTitle(title) 15 | .setDesc(desc); 16 | return ret; 17 | } 18 | 19 | static BADialog confirmDialog(Class resourceClass, BADialogResponseListner response, String title, String desc) { 20 | BADialog ret = new BADialog(); 21 | ret.setViewPath("utils/dialogs/confirmDialog.fxml") 22 | .setResourceClass(resourceClass) 23 | .setWindowTitle("Confirm") 24 | .setTitle(title) 25 | .setDesc(desc) 26 | .setResponseListener(response); 27 | return ret; 28 | } 29 | 30 | static BADialog inputDialog(Class resourceClass, BADialogResponseListner response, String title, String desc) { 31 | BADialog ret = new BADialog(); 32 | ret.setViewPath("utils/dialogs/inputDialog.fxml") 33 | .setResourceClass(resourceClass) 34 | .setWindowTitle("Please Complete") 35 | .setTitle(title) 36 | .setDesc(desc) 37 | .setResponseListener(response); 38 | return ret; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/DefaultAvatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/DefaultAvatar.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/DisplayOneName.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/SendToCell.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/ShutDownWarning.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/Tor_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/Tor_color.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/Tor_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/Tor_grey.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts/account_cell.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 26 | 27 | 28 | 29 | 30 | 31 | 39 | 40 | 41 | 42 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts/accounts_display_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/accounts/accounts_display_bg.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts/btnAddAccount.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/accounts/btnAddAccount.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts/btnSettingsSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/accounts/btnSettingsSmall.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/accounts/close.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts/closeSettingsWindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/accounts/closeSettingsWindow.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts_icons/authenticator_logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/accounts_icons/authenticator_logo_small.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts_icons/bitcoin_logo_plain_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/accounts_icons/bitcoin_logo_plain_small.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/accounts_icons/btnSettingsSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/accounts_icons/btnSettingsSmall.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnAccounts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnAccounts.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnAccounts@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnAccounts@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnAddressBook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnAddressBook.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnAddressBook@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnAddressBook@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnBitcoinAuthenticator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnBitcoinAuthenticator.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnBitcoinAuthenticator@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnBitcoinAuthenticator@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnBnB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnBnB.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnBnB@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnBnB@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnCoinControl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnCoinControl.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnCoinControl@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnCoinControl@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnCoinJoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnCoinJoin.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnCoinJoin@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnCoinJoin@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnCoinbase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnCoinbase.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnCoinbase@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnCoinbase@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnDonate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnDonate.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnDonate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnDonate@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnLocalBitcoins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnLocalBitcoins.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnLocalBitcoins@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnLocalBitcoins@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnLocks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnLocks.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnLocks@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnLocks@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnOneName.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnOneName.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnOneName@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnOneName@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnSettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnSettings.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/apps/btnSettings@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/apps/btnSettings@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/auth1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/auth1.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/auth2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/auth2.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/authenticator_logo_plain_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/authenticator_logo_plain_small.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/background.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/bitcoin_logo_plain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/bitcoin_logo_plain.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/bitcoin_logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/bitcoin_logo_small.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnApps_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnApps_grey.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnApps_grey@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnApps_grey@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnApps_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnApps_white.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnApps_white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnApps_white@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnAvatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnAvatar.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnBitcoinAuthenticator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnBitcoinAuthenticator.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnBitcoinAuthenticator@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnBitcoinAuthenticator@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnLocked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnLocked.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnLocked@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnLocked@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnOverview_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnOverview_grey.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnOverview_grey@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnOverview_grey@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnOverview_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnOverview_white.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnOverview_white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnOverview_white@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnReceive_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnReceive_grey.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnReceive_grey@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnReceive_grey@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnReceive_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnReceive_white.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnReceive_white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnReceive_white@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnSend_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnSend_grey.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnSend_grey@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnSend_grey@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnSend_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnSend_white.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnSend_white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnSend_white@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnTransactions_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnTransactions_grey.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnTransactions_grey@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnTransactions_grey@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnTransactions_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnTransactions_white.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnTransactions_white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnTransactions_white@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnUnlocked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnUnlocked.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/btnUnlocked@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/btnUnlocked@2x.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/checkpoints: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/checkpoints -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/checkpoints.testnet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/checkpoints.testnet -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/close.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/coinjoin.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 28 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/coinjoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/coinjoin.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/connection0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/connection0.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/connection1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/connection1.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/connection2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/connection2.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/connection3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/connection3.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/in-out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/in-out.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/in.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/ivAddress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/ivAddress.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/ivSync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/ivSync.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/lockbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/lockbackground.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/minimize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/minimize.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/net_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/net_green.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/net_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/net_grey.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/net_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/net_yellow.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/on_script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/on_script.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/on_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/on_symbol.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/out.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/ovrImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/ovrImage.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/pairing/baPhone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/pairing/baPhone.jpg -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/pairing/btnBitcoinAuthenticator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/pairing/btnBitcoinAuthenticator.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/pairing/btnHelp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/pairing/btnHelp.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/phone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/phone.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/progress-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/progress-green.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/progress-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/progress-red.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/progress-yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/progress-yellow.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/remote_update/RemoteUpdateWindow.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 27 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/startup/2fa1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/startup/2fa1.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/startup/2fa2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/startup/2fa2.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/startup/2fa3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/startup/2fa3.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/startup/AddPairedAccount.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 20 | 21 | 41 | 42 | 43 | 57 | 61 | 62 | 63 | 64 | 65 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/startup/restore_process_cell.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 27 | 28 | 29 | 36 | 37 | 38 | 39 | 46 | 47 | 48 | 49 | 50 | 57 | 58 | 59 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/startup/success_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/startup/success_icon.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitcoinAuthenticator/Wallet/e18dc199c7917bcb568ba0fae10480504d2e71a2/src/main/resources/wallettemplate/trash.png -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/utils/alert.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 27 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 54 | 55 | 56 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/utils/controls/bitcoin_address.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 29 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/utils/dialogs/confirmDialog.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 50 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/utils/dialogs/infoDialog.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/utils/dialogs/inputDialog.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 59 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/main/resources/wallettemplate/utils/text-validation.css: -------------------------------------------------------------------------------- 1 | .text-field.validation_error { 2 | -fx-background-color: red, 3 | linear-gradient( 4 | to bottom, 5 | derive(red,70%) 5%, 6 | derive(red,90%) 40% 7 | ); 8 | } 9 | 10 | .text-field.validation_warning { 11 | -fx-background-color: orange, 12 | linear-gradient( 13 | to bottom, 14 | derive(orange,70%) 5%, 15 | derive(orange,90%) 40% 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/authenticator/AuthenticatorTest.java: -------------------------------------------------------------------------------- 1 | package authenticator; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | import authenticator.listeners.BAGeneralEventsAdapter; 8 | import authenticator.listeners.BAGeneralEventsListener; 9 | 10 | public class AuthenticatorTest { 11 | 12 | @Test 13 | public void addAndFindGeneralListener() { 14 | new Authenticator(new BAApplicationParameters()); 15 | BAGeneralEventsListener l = new BAGeneralEventsAdapter(); 16 | Authenticator.addGeneralEventsListener(l); 17 | BAGeneralEventsListener returned = Authenticator.getGeneralListenerByIdentityHashCode(l); 18 | assertTrue(returned != null); 19 | } 20 | 21 | @Test 22 | public void deleteGeneralListener() { 23 | new Authenticator(new BAApplicationParameters()); 24 | BAGeneralEventsListener l = new BAGeneralEventsAdapter(); 25 | Authenticator.addGeneralEventsListener(l); 26 | 27 | Authenticator.removeGeneralListener(l); 28 | BAGeneralEventsListener returned = Authenticator.getGeneralListenerByIdentityHashCode(l); 29 | assertTrue(returned == null); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/authenticator/CoinsReceivedNotificationTest.java: -------------------------------------------------------------------------------- 1 | package authenticator; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.json.JSONException; 6 | import org.json.JSONObject; 7 | import org.junit.Test; 8 | 9 | import authenticator.GCM.dispacher.MessageBuilder; 10 | import authenticator.protobuf.ProtoConfig.ATGCMMessageType; 11 | 12 | public class CoinsReceivedNotificationTest { 13 | 14 | @Test 15 | public void test(){ 16 | try{ 17 | MessageBuilder b = new MessageBuilder(ATGCMMessageType.CoinsReceived, 18 | new String[]{"pairing id", "custom msg"}); 19 | String result = b.toString(); 20 | JSONObject objResult = new JSONObject(result); 21 | assertTrue(objResult.getString("WalletID").equals("pairing id")); 22 | assertTrue(objResult.getInt("RequestType") == ATGCMMessageType.CoinsReceived_VALUE); 23 | assertTrue(objResult.getString("CustomMsg").equals("custom msg")); 24 | } 25 | catch (JSONException e){ 26 | e.printStackTrace(); 27 | assertTrue(false); 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/authenticator/GCM/MessageBuilderTest.java: -------------------------------------------------------------------------------- 1 | package authenticator.GCM; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.json.JSONException; 6 | import org.json.JSONObject; 7 | import org.junit.Test; 8 | 9 | import authenticator.GCM.dispacher.MessageBuilder; 10 | import authenticator.protobuf.ProtoConfig.ATGCMMessageType; 11 | 12 | public class MessageBuilderTest { 13 | 14 | @Test 15 | public void signTXTest() { 16 | try { 17 | String[] args = new String[] { "wallet ID", 18 | "ext IP", 19 | "local IP", 20 | "my msg", 21 | "my time test"}; 22 | MessageBuilder mb = new MessageBuilder(ATGCMMessageType.SignTX, args); 23 | 24 | mb.getString("tmp"); // just make sure it exists 25 | assertTrue("wallet ID".equals(mb.getString("WalletID"))); 26 | assertTrue(ATGCMMessageType.SignTX_VALUE == mb.getInt("RequestType")); 27 | JSONObject reqPayload = new JSONObject(mb.getString("ReqPayload")); 28 | assertTrue("ext IP".equals(reqPayload.getString("ExternalIP"))); 29 | assertTrue("local IP".equals(reqPayload.getString("LocalIP"))); 30 | assertTrue("my msg".equals(mb.getString("CustomMsg"))); 31 | assertTrue("86b185e84f6e79e92d8b66b1384f08d056bd5e4f".equals(mb.getString("RequestID"))); 32 | 33 | } catch (JSONException e) { 34 | e.printStackTrace(); 35 | assertTrue(false); 36 | } 37 | } 38 | 39 | @Test 40 | public void updatePendingReqIPsTest() { 41 | try { 42 | String[] args = new String[] { "wallet ID", 43 | "ext IP", 44 | "local IP", 45 | "my msg"}; 46 | MessageBuilder mb = new MessageBuilder(ATGCMMessageType.UpdatePendingRequestIPs, args); 47 | 48 | mb.getString("tmp"); // just make sure it exists 49 | assertTrue("wallet ID".equals(mb.getString("WalletID"))); 50 | assertTrue(ATGCMMessageType.UpdatePendingRequestIPs_VALUE == mb.getInt("RequestType")); 51 | JSONObject reqPayload = new JSONObject(mb.getString("ReqPayload")); 52 | assertTrue("ext IP".equals(reqPayload.getString("ExternalIP"))); 53 | assertTrue("local IP".equals(reqPayload.getString("LocalIP"))); 54 | assertTrue("my msg".equals(mb.getString("CustomMsg"))); 55 | 56 | } catch (JSONException e) { 57 | e.printStackTrace(); 58 | assertTrue(false); 59 | } 60 | } 61 | 62 | @Test 63 | public void coinsReceivedTest() { 64 | try { 65 | String[] args = new String[] { "wallet ID", 66 | "my msg"}; 67 | MessageBuilder mb = new MessageBuilder(ATGCMMessageType.CoinsReceived, args); 68 | 69 | mb.getString("tmp"); // just make sure it exists 70 | assertTrue("wallet ID".equals(mb.getString("WalletID"))); 71 | assertTrue(ATGCMMessageType.CoinsReceived_VALUE == mb.getInt("RequestType")); 72 | assertTrue("my msg".equals(mb.getString("CustomMsg"))); 73 | 74 | } catch (JSONException e) { 75 | e.printStackTrace(); 76 | assertTrue(false); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/test/java/authenticator/backup/SSSBackupTest.java: -------------------------------------------------------------------------------- 1 | package authenticator.backup; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.IOException; 6 | import java.security.NoSuchAlgorithmException; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | import javax.crypto.KeyGenerator; 11 | import javax.crypto.SecretKey; 12 | 13 | import org.bitcoinj.core.NetworkParameters; 14 | import org.bitcoinj.params.MainNetParams; 15 | import org.junit.Test; 16 | import org.spongycastle.util.encoders.Hex; 17 | 18 | import authenticator.BipSSS.BipSSS; 19 | import authenticator.BipSSS.SSSUtils; 20 | import authenticator.BipSSS.BipSSS.EncodingFormat; 21 | import authenticator.BipSSS.BipSSS.Share; 22 | 23 | public class SSSBackupTest { 24 | 25 | @Test 26 | public void splitingTest() throws IOException { 27 | byte[] entropy = Hex.decode("55967fdf0e7fd5f0c78e849f37ed5b9fafcc94b5660486ee9ad97006b6590a4d"); 28 | 29 | assertTrue(splitAndCheck(entropy, entropy, 6, 5)); 30 | assertTrue(splitAndCheck(entropy, entropy, 6, 4)); 31 | assertTrue(splitAndCheck(entropy, entropy, 6, 3)); 32 | assertTrue(splitAndCheck(entropy, entropy, 6, 2)); 33 | assertTrue(splitAndCheck(entropy, entropy, 6, 1)); 34 | } 35 | 36 | @Test 37 | public void splitingInvalidTest() throws IOException, NoSuchAlgorithmException { 38 | byte[] entropy = Hex.decode("55967fdf0e7fd5f0c78e849f37ed5b9fafcc94b5660486ee9ad97006b6590a4d"); 39 | 40 | //Generate 256 bit key. 41 | KeyGenerator kgen = KeyGenerator.getInstance("AES"); 42 | kgen.init(256); 43 | // AES key 44 | SecretKey sharedsecret = kgen.generateKey(); 45 | byte[] expectedWrong = sharedsecret.getEncoded(); 46 | 47 | assertFalse(splitAndCheck(entropy, expectedWrong, 6, 5)); 48 | assertFalse(splitAndCheck(entropy, expectedWrong, 6, 4)); 49 | assertFalse(splitAndCheck(entropy, expectedWrong, 6, 3)); 50 | assertFalse(splitAndCheck(entropy, expectedWrong, 6, 2)); 51 | assertFalse(splitAndCheck(entropy, expectedWrong, 6, 1)); 52 | } 53 | 54 | private boolean splitAndCheck(byte[] entropy, byte[] expected, int numberOfPieces, int threshold) throws IOException { 55 | List shares = splitToShares(entropy, numberOfPieces, threshold); 56 | 57 | /* 58 | * test pieces 59 | */ 60 | 61 | // get all combinations 62 | SSSUtils ut = new SSSUtils(); 63 | BipSSS sss = new BipSSS(); 64 | List combinations = ut.getAllPossibleCombinations(shares, threshold); 65 | 66 | for(Share[] com:combinations){ 67 | boolean result = false; 68 | try { 69 | // res should be mnemonic entropy 70 | byte[] res = sss.combineSeed(Arrays.asList(com)); 71 | result = Arrays.equals(expected, res); 72 | 73 | } catch (Exception e) { 74 | e.printStackTrace(); 75 | return false; 76 | } 77 | 78 | if(result == false) 79 | return false; 80 | } 81 | 82 | return true; 83 | } 84 | 85 | private List splitToShares(byte[] entropy, int numberOfPieces, int threshold) throws IOException { 86 | List shares; 87 | NetworkParameters params = MainNetParams.get(); 88 | BipSSS sss = new BipSSS(); 89 | shares = sss.shard(entropy, threshold, numberOfPieces, EncodingFormat.SHORT, params); 90 | 91 | return shares; 92 | } 93 | 94 | @Test 95 | public void testIllegalPiecesAndThresholds() { 96 | byte[] entropy = Hex.decode("55967fdf0e7fd5f0c78e849f37ed5b9fafcc94b5660486ee9ad97006b6590a4d"); 97 | 98 | List shares; 99 | NetworkParameters params = MainNetParams.get(); 100 | BipSSS sss = new BipSSS(); 101 | 102 | int threshold = 6; 103 | int numberOfPieces = 5; 104 | 105 | Exception caught = null; 106 | try { 107 | shares = sss.shard(entropy, threshold, numberOfPieces, EncodingFormat.SHORT, params); 108 | } catch (Exception t) { 109 | caught = t; 110 | } 111 | assertNotNull(caught); 112 | assertSame(IllegalArgumentException.class, caught.getClass()); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/test/java/authenticator/network/GetRequestIDPayloadTest.java: -------------------------------------------------------------------------------- 1 | package authenticator.network; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.json.JSONException; 6 | import org.json.JSONObject; 7 | import org.junit.Test; 8 | 9 | import authenticator.GCM.dispacher.MessageBuilder; 10 | import authenticator.network.GetRequestIDPayload; 11 | import authenticator.protobuf.ProtoConfig.ATGCMMessageType; 12 | 13 | public class GetRequestIDPayloadTest { 14 | 15 | @Test 16 | public void validTest(){ 17 | JSONObject jo = new JSONObject(); 18 | try { 19 | jo.put("requestID", "the req id"); 20 | jo.put("pairingID", "the pairing id"); 21 | 22 | byte[] payload = jo.toString().getBytes(); 23 | GetRequestIDPayload reqPayload = new GetRequestIDPayload(payload); 24 | assertTrue("the req id".equals(reqPayload.getRequestID())); 25 | assertTrue("the pairing id".equals(reqPayload.getPairingID())); 26 | 27 | } catch (JSONException e) { 28 | e.printStackTrace(); 29 | assertTrue(false); 30 | } 31 | } 32 | 33 | @Test 34 | public void notValidTest(){ 35 | JSONObject jo = new JSONObject(); 36 | try { 37 | jo.put("requestID", "the req id"); 38 | jo.put("false", "the pairing id"); 39 | 40 | byte[] payload = jo.toString().getBytes(); 41 | GetRequestIDPayload reqPayload = new GetRequestIDPayload(payload); 42 | assertTrue("the req id".equals(reqPayload.getRequestID())); 43 | assertFalse("the pairing id".equals(reqPayload.getPairingID())); // doesnt get here because of parsing exception in GetRequestIDPayload 44 | 45 | } catch (JSONException e) { 46 | assertTrue(true); // should get here 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/authenticator/network/PongPayloadTest.java: -------------------------------------------------------------------------------- 1 | package authenticator.network; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.json.JSONException; 6 | import org.json.JSONObject; 7 | import org.junit.Test; 8 | 9 | import authenticator.GCM.dispacher.MessageBuilder; 10 | import authenticator.Utils.CryptoUtils.CouldNotEncryptPayload; 11 | import authenticator.network.GetRequestIDPayload; 12 | import authenticator.protobuf.ProtoConfig.ATGCMMessageType; 13 | 14 | public class PongPayloadTest { 15 | 16 | @Test 17 | public void validTest(){ 18 | try { 19 | PongPayload payload = new PongPayload(); 20 | byte[] b = payload.getBytes(); 21 | String s = new String(b); 22 | assertTrue(s.equals("{\"WELCOME_BACK_AUTHENTICATOR\":\"\"}")); 23 | assertTrue(payload.getPayloadSize() == 33); 24 | } catch (CouldNotEncryptPayload e) { 25 | e.printStackTrace(); 26 | assertTrue(false); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/authenticator/operations/UpdateIPsTest.java: -------------------------------------------------------------------------------- 1 | package authenticator.operations; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.json.JSONException; 6 | import org.json.JSONObject; 7 | import org.junit.Test; 8 | 9 | import authenticator.GCM.dispacher.MessageBuilder; 10 | import authenticator.protobuf.ProtoConfig.ATGCMMessageType; 11 | 12 | public class UpdateIPsTest { 13 | 14 | @Test 15 | public void test(){ 16 | try{ 17 | MessageBuilder b = new MessageBuilder(ATGCMMessageType.UpdatePendingRequestIPs, 18 | new String[]{"pairing id", 19 | "external ip", 20 | "local ip", 21 | "custom msg"}); 22 | String result = b.toString(); 23 | JSONObject objResult = new JSONObject(result); 24 | assertTrue(objResult.getString("WalletID").equals("pairing id")); 25 | 26 | assertTrue(objResult.getInt("RequestType") == ATGCMMessageType.UpdatePendingRequestIPs_VALUE); 27 | JSONObject payload = new JSONObject(objResult.getString("ReqPayload")); 28 | assertTrue(payload.getString("ExternalIP").equals("external ip")); 29 | assertTrue(payload.getString("LocalIP").equals("local ip")); 30 | 31 | assertTrue(objResult.getString("CustomMsg").equals("custom msg")); 32 | } 33 | catch (JSONException e){ 34 | e.printStackTrace(); 35 | assertTrue(false); 36 | } 37 | } 38 | 39 | } 40 | --------------------------------------------------------------------------------