This commit contains rather hard to review diffs to the protobuf test datasets in .txt format.
To aid the review, this Python script can be used to convert the data from the old to the new
format:
```
import sys
file = open(sys.argv[1])
outfile = open(sys.argv[1] + ".lite", "w")
line = file.readline()
lines = []
def sortAndPrint(group, removeLastLB=False, removeFirstLB=False):
group.sort()
if removeFirstLB and group[0] == "\n":
group.remove("\n")
for i in range(len(group)):
if i == len(group) - 1 and removeLastLB:
group[i] = group[i].rstrip()
print(group[i], end="", file=outfile)
def sign32neg(value):
if 0x80000000 <= value <= 0xFFFFFFFF:
value &= 0x7FFFFFFF
value = int(value)
value = ~value
value ^= 0x7FFFFFFF
return value
def processPath(path):
parts = path.rstrip().split(":")
number = int(parts[1].lstrip())
if number >= 0x80000000:
number = sign32neg(number)
return parts[0] + ": " + str(number) + "\n"
groupcount = 0
while len(line) > 0:
if line.startswith("type:"):
if len(lines):
sortAndPrint(lines, removeFirstLB=groupcount==0)
groupcount += 1
lines.clear()
lines.append(line)
elif line.find("deterministic_key {") != -1:
structure = line
innerlines = []
line = file.readline()
while not line.startswith('}'):
if line.find("path") != -1: # preserve order of paths
pathlines = processPath(line)
line = file.readline()
if line.startswith('}'):
innerlines.append(pathlines)
continue
while line.find("path") != -1:
pathlines += processPath(line)
line = file.readline()
innerlines.append(pathlines)
if line.startswith('}'):
continue
if line.startswith(" sigsRequiredToSpend"):
line = line.replace("sigsRequiredToSpend", "sigs_required_to_spend")
innerlines.append(line)
line = file.readline()
innerlines.sort()
for l in innerlines:
structure += l
structure += line.rstrip() + "\n"
lines.append(structure)
elif line.find("path") != -1: # preserve order of paths
accountpathlines = processPath(line)
line = file.readline()
while line.find("path") != -1:
accountpathlines += processPath(line)
line = file.readline()
lines.append(accountpathlines)
lines.append(line)
else:
lines.append(line)
line = file.readline()
print(file=outfile)
sortAndPrint(lines, removeLastLB=True)
file.close()
outfile.close()
```
* Make the static field `estimatedKeyDerivationTime` private
* Refactor the calculation to a private, side-effect free function
* Replace `estimatedKeyDerivationTimeMsec()` with `initEstimatedKeyDerivationTime()`
** Don’t return a value that wasn’t unused anyway
** Make better use of CompletableFuture API
* Platform.runLater wasn’t needed because no JavaFX functions are called
* 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`
* Extract abstract class `WalletApplication` from `WalletTemplate`
* `WalletTemplate` implements `loadController()` with resource names
* `MainController`: Add `scene` member and `scene()` method
* 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
* 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
Problem: A transaction received from the network is added to all wallets
that find it relevant. If two wallets find the same transaction relevant
the same Transaction instance is added to both wallets.
Spending the outputs from this transaction can cause consistiency
issues, in particular if the outputs are spent in the same transaction,
as shown in WalletTest.oneTxTwoWallets. There are probably more issues
with having the same Transaction instance handled by two different
wallets.
Fix: Clone the transaction before adding it to the wallet.
AccessControlException is deprecated for removal in JDK 17.
its parent classes are:
`AccessControlException` <- `SecurityException` <- `RuntimeException`
It can be replaced with its parent `SecurityException` which is not deprecated and will behave almost identically in this one place where it is used.
* 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