Commit graph

110 commits

Author SHA1 Message Date
Sean Gilligan
188a0a7e45 walletfx: replace MainController.instance with app.mainWindowController() 2021-09-23 01:04:05 -07:00
Sean Gilligan
85725a18a6 walletfx: WalletApplication to improve encapsulation
* Make all public fields private and wrap with accessors
* Make `WalletAppKit` (was confusingly named `bitcoin`) field a member not a static
* Rename `bitcoin` to `walletAppKit`
2021-09-23 09:57:18 +02:00
Sean Gilligan
515a558ec2 walletfx: Extract MainWindowController abstract base class
* Extract `MainWindowController` from `wallettemplate.MainController`
* WalletApplication: `wallettemplate.MainController` with `MainWindowController`
2021-09-22 12:16:45 -07:00
Sean Gilligan
d1aa5e3d36 walletfx: Extract WalletApplication from WalletTemplate
* Extract abstract class `WalletApplication` from `WalletTemplate`
* `WalletTemplate` implements `loadController()` with resource names
* `MainController`: Add `scene` member and `scene()` method
2021-09-22 11:36:04 -07:00
Sean Gilligan
d8b6733c9c walletfx: Create WalletTemplate implementing AppDelegate
* Introduce `AppDelegate` class for delegating JavaFX `Application`
* Move almost all of `Main` to `WalletTemplate`

Rationale:

* The “template” JavaFX Application main class (`Main`) is now about 30 lines of code
* `Main` class allows easy switching between TestNet and MainNet (in fact it could become a command-line argument) and other configuration changes (e.g. `preferredOutputScriptType`)
* Prepares the way for the next steps of refactoring
2021-09-22 09:21:25 -07:00
Sean Gilligan
a7161eed8e walletfx: Move wallettemplate.controls to org.bitcoinj.walletfx 2021-09-21 07:56:17 -07:00
Sean Gilligan
9292bf3c43 walletfx: Refactor overlay, reduce usage of instance static globals
* OverlayController: rename init method, add rootController to params
* OverlayableStackPaneController: update to use updated initOverlay() method, 
          also pass this.getClass() into GuiUtils.getResource()
* GuiUtils.getResource(): replace reference to MainController.class with clazz parameter
* Main: Reduce visibility to “package” of 3 static globals
* MainController: Reduce visibility of `instance` static to “package”, initialize
                  addressControl by calling 2 initialization methods
* 4 other controllers: Update for OverlayController changes
* ClickableBitcoinAddress: OverlayController changes, eliminate use of Main.APP_NAME

Rationale:

* Decrease coupling
* Eliminate cross-package use of `Main` and `MainController` static globals
* Prepare for further refactoring — moving wallettemplate.controls package
  to org.bitcoinj.walletfx.controls
2021-09-21 09:39:08 +02:00
Sean Gilligan
93f0bb7a54 walletfx: Extract OverlayableStackPaneController
* Extract abstract class OverlayableStackPaneController from MainController
* Rename OverlayWindowController to OverlayController (Window was misleading)

Rationale:

1. Overlay functionality is independent of MainContoller’s wallet functions
2. Increases reusability of classes in module
3. Prepares for further refactoring
2021-09-20 12:20:38 -07:00
Sean Gilligan
44ca7f6689 walletfx: Introduce OverlayWindowController interface
Rationale:

1. Stronger typing makes code more readable and refactorable
2. Eliminates “automatic” reflection in MainController
3. Makes overlayUI field in implementing classes private
4. Is a step towards further refactoring and reusability
2021-09-19 12:35:38 -07:00
Sean Gilligan
17aeea2d75 walletfx: move OverlayUI from Main to MainController
Move OverlayUI and other related functionality from Main (Application) class
to MainController.

Motivation:

1. This simplifies the Main class
2. The code more logically belongs in the controller
3. The code being in the controller increases reusability
4. Is a first step towards additional refactoring made possible
   because MainController can subclass an abstract class and Main
   can’t because it must subclass Application
2021-09-19 19:04:12 +02:00
Sean Gilligan
1e7fc7aad5 walletfx: Hook up the unused “Primary” and “Secondary” buttons
I did this for two reasons:

1. So users will know why the buttons are there and that they work
2. A convenient way to test the informational alert function.
2021-09-18 17:42:33 -07:00
Sean Gilligan
e9980e73fa wallettemplate: rename package wallettemplate.utils to org.bitcoinj.walletfx.utils
This is a step towards (a renewed effort at) separating the wallettemplate
into a JavaFX wallet library and a template application.
2021-09-18 19:03:17 +02:00
Andreas Schildbach
a966cd38a1 Apply "Lambda can be replaced with method reference" refactoring. 2020-09-07 21:15:51 +02:00
Andreas Schildbach
e7b00b65f9 Apply "Statement lambda can be replaced with expression lambda" refactoring. 2020-09-07 21:13:14 +02:00
Andreas Schildbach
c08a4d97d3 Apply "Anonymous type can be replaced with lambda" refactoring. 2020-09-07 21:13:14 +02:00
Andreas Schildbach
4847a9df27 Apply "Explicit generic type can be replaced with <>" refactoring. 2020-09-07 21:10:44 +02:00
Andreas Schildbach
726c7291ac Wallet: Remove global coinSelector and allowSpendingUnconfirmedTransactions().
Coin selection is a per SendRequest, per createSend() or per getBalance() call affair.
Having it wallet-global can lead to race conditions, as sometimes experienced in the
WalletTest unit tests.
2019-07-26 20:30:27 +02:00
Sean Gilligan
3c5744a6cb AppDataDirectory: Move from wallettemplate/.utils to core/.utils
This allows usage in both wallettemplate and tools and replaces
similar code in BlockFileLoader.java in core.
Requires minor back-port of Path.of() functionality from JDK11.
2019-06-20 10:09:21 +02:00
Sean Gilligan
d446951ceb AppDataDirectory: Use lower-case appName for data dir on Windows/Linux/Unix. 2019-06-19 21:27:01 +02:00
Andreas Schildbach
ab2fb2f9cf KeyChainGroup: New CurrentKeyChangeEventListener that fires when a current key and/or address changes.
This also changes wallet-template to make use of the new listener for updating its current address in the UI.
2019-05-19 08:23:39 +02:00
Sean Gilligan
46195cd24e wallet-template: Put wallet data files in app data directory.
Previously WalletTemplate would store the .spvchain and .wallet files
in the app’s current working directory which could vary depending upon
how the app was launched.

This PR stores the app’s data files in the “app data directory” which
is always named “WalletTemplate” (APP_NAME) and located in the standard
location for application data directories on the current OS platform.

For macOS: `~/Library/Application Support/WalletTemplate`
For Linux/unix: `~/.WalletTemplate`
For Windows: ${APPDATA}/WalletTemplate  (where APPDATA is a standard
Windows environment variable)

Changes:

* Added AppDataDirectory class to return current dir Path
* Modified Main to use appDataDirectory rather than “.”
2019-04-29 10:29:45 +02:00
Sean Gilligan
88dd0028cd ClickableBitcoinAddress: Break out QRCodeImages utility class for QR Code FX image creation. 2019-04-24 11:21:12 +02:00
Sean Gilligan
2dbe4f21bc Use TestNet3 in WalletTemplate.
WalletTemplate is not a production-ready wallet and (for now, at least)
should default (currently hard-coded) to TestNet3.
2019-04-23 17:12:38 +02:00
Sean Gilligan
c2253d2e97 MainController: Replace EasyBind with two static methods.
This removes the dependency on EasyBind.
2019-04-22 09:06:09 +02:00
Sean Gilligan
3538d3342e ClickableBitcoinAddress: Write QR code directly to a JavaFX image, rather than transitioning through a PNG image.
This gets rid of the ZXing-JavaSE dependency.
2019-04-07 11:34:45 +02:00
Sean Gilligan
560e128458 build.gradle: Replace usage of QRGen by direct usage of ZXing 3.3.3 for generating QR codes. 2019-04-06 17:14:59 +02:00
Andreas Schildbach
f24a4aa19a Update Guava to 27.0.1-android. 2019-02-15 03:34:11 +01:00
Andreas Schildbach
bfe2a195b6 Receive to and send from native segwit addresses
- Hierarchical-deterministic derivation of native segwit addresses.
- Receive payments to native segwit addresses.
- Spend and sign payments from native segwit addresses.
- Watch-only wallets with native segwit addresses (zpub/vpub).
- WalletAppKit, Wallet-tool and Wallet-template are taught to deal with segwit-enabled wallets.

Be aware this adds a new field in the wallet protobuf: output_script_type in Key, which keeps track
of the script type of DeterministicKeyChains. Protobufs will be migrated; old DeterministicKeyChains
are assumed to be of type P2PKH.

Includes some code by Fabrice Drouin.
2019-02-11 16:48:37 +01:00
Andreas Schildbach
0d90157749 Wallet-template: Allow sending to Bech32 addresses. 2019-02-06 12:02:31 +01:00
Nicola Atzei
0833fe1cea In JavaDocs change <tt> tags to @code. 2019-01-04 18:36:59 +01:00
Andreas Schildbach
ad262de961 Migrate from SpongyCastle back to BouncyCastle.
Google moved their broken BouncyCastle out of the way with Android 3.0
(see 0ac85ead96%5E%21/).
2018-10-23 16:09:10 +02:00
Andreas Schildbach
8ee5e48171 Update to protobuf-java 3.5.1.
In the test data for DeterministicKeyChainTest all occurences of the (often invisible) 0x7f
character is replaced by its numerical literal "\177". This change is needed because a bug of
previous versions was fixed, which caused this character not being printed as text.
2018-03-13 21:55:47 +01:00
Andreas Schildbach
c35d892fa6 Add Utils.isLinux() and Utils.isMac() helpers. 2018-03-13 13:05:59 +01:00
Andreas Schildbach
4bbb7be059 Migrate fully qualified names to using imports. 2018-03-11 21:36:25 +01:00
Andreas Schildbach
fa5bdbb672 JavaDoc: Fix HTML structure. 2018-03-11 20:40:28 +01:00
Andreas Schildbach
7f5b6753f5 Use Address whereever possible in the API, rather than LegacyAddress.
This is a preparation for the remaining segwit changes. LegacyAddress
variables in unit tests are also changed.
2018-03-05 10:35:09 +01:00
Andreas Schildbach
e11119b64f Rename VersionedChecksummedBytes→PrefixedChecksummedBytes, Address→LegacyAddress and AbstractAddress→Address.
This also renames corresponding test classes and mentions in comments.
2018-02-28 16:57:16 +01:00
Andreas Schildbach
71a5b1b89f Remove some unused imports. 2018-02-23 20:09:41 +01:00
Andreas Schildbach
afc198600a Utils: Inline join(). 2017-06-02 16:55:40 +02:00
Andreas Schildbach
7e609a2409 Remove Orchid forked subproject and support for connecting via Tor. 2016-11-25 23:14:39 +01:00
Andreas Schildbach
3773a4343c Add a generic copyright statement to all license headers that don't have one.
Note it is not legally necessary to state copyright, but we think it makes things easier.
2016-06-06 21:32:02 +02:00
Andreas Schildbach
4e29e4fb00 Wallet: Make SendRequest a top level class. 2016-04-01 22:03:14 +02:00
Andreas Schildbach
1e66b9a8e3 Finish moving wallet related classes to .wallet package.
These classes are moved to .wallet:
- Wallet + WalletTest
- WalletExtension + WalletExtensionsTest
- WalletProtobufSerializer
- UnreadableWalletException

These classes are moved to .wallet.listeners:
- WalletEventListener
- WalletChangeEventListener
- WalletCoinsReceivedEventListener
- WalletCoinsSentEventListener
- WalletReorganizeEventListener
- ScriptsChangeEventListener
- AbstractWalletEventListener
- KeyChainEventListener
- AbstractKeyChainEventListener
2016-04-01 21:44:30 +02:00
Andreas Schildbach
c1938fec75 Harmonize license headers. 2016-03-26 19:55:05 +01:00
Andreas Schildbach
85f7c39aa5 Refresh bundled checkpoints and switch to textual format for easier audit. 2016-03-21 21:40:14 +01:00
Andreas Schildbach
9e52e4e0bf wallet-template: When constructing the wallet file name from the app's name, replace problematic characters so the filesystem doesn't throw up. 2016-02-29 16:41:49 +01:00
Ross Nicoll
aca39ee9de Split wallet events into single method interfaces 2016-02-06 20:01:38 +01:00
Kirill Vlasov
e3e8e8079d Constructors should only call non-overridable methods 2016-01-06 14:11:00 +01:00
Mike Hearn
9ba1be762a Wallet: flip argument ordering in deprecated Wallet.addEventListener to restore compatibility with 0.13 2015-10-05 17:12:55 +02:00
Andreas Schildbach
d4c7ce5c77 wallet-template: Fix warning about missing @Nullable annotation. 2015-08-24 18:54:00 +02:00