Permalink
Browse files

windows installer now puts on jsmooth exe rather than jar

  • Loading branch information...
1 parent b52cf52 commit da440de0bd9529193e1124d3b90f899dbbd1d032 @jim618 jim618 committed Nov 7, 2011
View
33 COPYING
@@ -1,19 +1,22 @@
Copyright (c) 2011 MultiBit Developers
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following
+conditions:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall
+be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+OR OTHER DEALINGS IN THE SOFTWARE.
View
45 exe.jsmooth
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<jsmoothproject>
+<JVMSearchPath>registry</JVMSearchPath>
+<JVMSearchPath>javahome</JVMSearchPath>
+<JVMSearchPath>jrepath</JVMSearchPath>
+<JVMSearchPath>jdkpath</JVMSearchPath>
+<JVMSearchPath>exepath</JVMSearchPath>
+<JVMSearchPath>jview</JVMSearchPath>
+<arguments></arguments>
+<classPath>target/multibit-exe.jar</classPath>
+<embeddedJar>true</embeddedJar>
+<executableName>target/multibit.exe</executableName>
+<iconLocation>src/main/resources/images/multibit.png</iconLocation>
+<initialMemoryHeap>-1</initialMemoryHeap>
+<jarLocation>target/multibit-exe.jar</jarLocation>
+<mainClassName>org.multibit.MultiBitInExecutableJar</mainClassName>
+<maximumMemoryHeap>-1</maximumMemoryHeap>
+<maximumVersion></maximumVersion>
+<minimumVersion>1.6</minimumVersion>
+<skeletonName>Windowed Wrapper</skeletonName>
+<skeletonProperties>
+<key>Message</key>
+<value>Java has not been found on your computer. Do you want to download it?</value>
+</skeletonProperties>
+<skeletonProperties>
+<key>URL</key>
+<value>http://www.java.com</value>
+</skeletonProperties>
+<skeletonProperties>
+<key>SingleProcess</key>
+<value>0</value>
+</skeletonProperties>
+<skeletonProperties>
+<key>SingleInstance</key>
+<value>1</value>
+</skeletonProperties>
+<skeletonProperties>
+<key>JniSmooth</key>
+<value>0</value>
+</skeletonProperties>
+<skeletonProperties>
+<key>Debug</key>
+<value>0</value>
+</skeletonProperties>
+</jsmoothproject>
View
4 installer.jsmooth
@@ -9,10 +9,10 @@
<arguments></arguments>
<classPath>target/multibit-installer.jar</classPath>
<embeddedJar>true</embeddedJar>
-<executableName>target/multibit-installer.exe</executableName>
+<executableName>target/multibit-windows-installer.exe</executableName>
<iconLocation>src/main/resources/images/multibit.png</iconLocation>
<initialMemoryHeap>-1</initialMemoryHeap>
-<jarLocation>target/multibit-installer.jar</jarLocation>
+<jarLocation>target/multibit-windows-installer.jar</jarLocation>
<mainClassName>com.izforge.izpack.installer.Installer</mainClassName>
<maximumMemoryHeap>-1</maximumMemoryHeap>
<maximumVersion></maximumVersion>
View
148 pom.xml
@@ -80,15 +80,16 @@
**/Transaction.class, **/Transaction$*.class,
**/TransactionInput.class, **/TransactionInput$*.class,
**/Wallet.class, **/Wallet$*.class,
- **/WalletEventListener.class</excludes>
+ **/WalletEventListener.class,
+ **/DNSDiscovery.class</excludes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
- <!-- Put izPack2app into staging dir for production of installer later -->
+ <!-- Put izPack2app into linux staging dir for production of linux installer later -->
<execution>
- <id>unpack-shared-resources-ipack2app</id>
+ <id>unpack-shared-resources-ipack2app-linux</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
@@ -99,7 +100,24 @@
<classifier>izpack2app</classifier>
<type>zip</type>
<excludeTransitive>true</excludeTransitive>
- <outputDirectory>${staging.dir}</outputDirectory>
+ <outputDirectory>${staging.linux.dir}</outputDirectory>
+ </configuration>
+ </execution>
+
+ <!-- Put izPack2app into windows staging dir for production of windows installer later -->
+ <execution>
+ <id>unpack-shared-resources-ipack2app-windows</id>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <phase>install</phase>
+ <configuration>
+ <includeGroupIds>org.codehaus.izpack</includeGroupIds>
+ <includeArtifactIds>izpack-standalone-compiler</includeArtifactIds>
+ <classifier>izpack2app</classifier>
+ <type>zip</type>
+ <excludeTransitive>true</excludeTransitive>
+ <outputDirectory>${staging.windows.dir}</outputDirectory>
</configuration>
</execution>
</executions>
@@ -129,27 +147,31 @@
</executions>
</plugin>
- <!-- Produce staging directory with all resources used in creation of the IzPack installer and in creation of the Mac application bundle -->
+ <!-- Produce staging directory with all resources used in creation of the linux IzPack installer and in creation of the Mac application bundle -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
- <id>copy-resources-to-staging</id>
+ <id>copy-resources-to-staging-linux</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
- <outputDirectory>${basedir}/target/staging</outputDirectory>
+ <outputDirectory>${staging.linux.dir}</outputDirectory>
<resources>
<resource>
<directory>src/main/izpack</directory>
<includes>
<include>readme.txt</include>
- <include>install.xml</include>
<include>multibit.properties</include>
- <include>shortcutSpec.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/izpack/linux</directory>
+ <includes>
+ <include>install.xml</include>
</includes>
</resource>
<resource>
@@ -181,9 +203,63 @@
</resources>
</configuration>
</execution>
+
+ <!-- Produce staging directory with all resources used in creation of the windows IzPack installer -->
+ <execution>
+ <id>copy-resources-to-staging-windows</id>
+ <phase>install</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${staging.windows.dir}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/izpack</directory>
+ <includes>
+ <include>readme.txt</include>
+ <include>multibit.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/izpack/windows</directory>
+ <includes>
+ <include>install.xml</include>
+ <include>shortcutSpec.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources/images</directory>
+ <includes>
+ <include>installerLeft.png</include>
+ <include>multibit.bmp</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>multibit.blockchain</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>.</directory>
+ <includes>
+ <include>release_notes.txt</include>
+ <include>COPYING</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>target</directory>
+ <includes>
+ <include>multibit.exe</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
<!-- produce a Mac application bundle -->
- <!-- this plugin copies a skeleton App and then copies in the resources from the staging directory -->
+ <!-- this plugin copies a skeleton App and then copies in the resources from the linux staging directory -->
<!-- Note I have tried using http://mojo.codehaus.org/osxappbundle-maven-plugin/ but cannot get extra resources into my Java directory in the app -->
<execution>
<id>create-skeleton-Mac-application-bundle</id>
@@ -211,7 +287,7 @@
<outputDirectory>${basedir}/target/MultiBit.app/Contents/Resources/Java</outputDirectory>
<resources>
<resource>
- <directory>${basedir}/target/staging</directory>
+ <directory>${basedir}/target/staging.linux</directory>
<includes>
<include>multibit-exe.jar</include>
<include>readme.txt</include>
@@ -227,22 +303,34 @@
</executions>
</plugin>
- <!-- Produce IzPack installer from contents of staging directory -->
+ <!-- Produce linux IzPack installer from contents of linux staging directory -->
<plugin>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-maven-plugin</artifactId>
<version>1.0-alpha-5</version>
<executions>
<execution>
+ <id>create-linux-installer</id>
<phase>install</phase>
<goals>
<goal>izpack</goal>
</goals>
<configuration>
- <izpackBasedir>${staging.dir}</izpackBasedir>
- <installerFile>target/${project.build.finalName}-installer.jar</installerFile>
+ <izpackBasedir>${staging.linux.dir}</izpackBasedir>
+ <installerFile>target/${project.build.finalName}-linux-installer.jar</installerFile>
</configuration>
</execution>
+ <execution>
+ <id>create-windows-installer</id>
+ <phase>install</phase>
+ <goals>
+ <goal>izpack</goal>
+ </goals>
+ <configuration>
+ <izpackBasedir>${staging.windows.dir}</izpackBasedir>
+ <installerFile>target/${project.build.finalName}-windows-installer.jar</installerFile>
+ </configuration>
+ </execution>
</executions>
<dependencies>
<dependency>
@@ -269,7 +357,7 @@
<copy todir="${basedir}/target/MultiBit-mac/MultiBit.app">
<fileset dir="${basedir}/target/MultiBit.app" includes="**"/>
</copy>
- <copy file="${basedir}/target/staging/readme.txt" todir="${basedir}/target/MultiBit-mac"/>
+ <copy file="${basedir}/target/staging.linux/readme.txt" todir="${basedir}/target/MultiBit-mac"/>
<!-- Create Applications Symbolic link -->
@@ -305,10 +393,29 @@
<goal>run</goal>
</goals>
</execution>
+ <!-- Produce a Win32 exe from the multibit-exe.jar (no Maven plugin for JSmooth so drop down to ant) -->
+ <execution>
+ <id>jsmooth-installer2exe-exe</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <path id="jsmooth-classpathref">
+ <pathelement path="src/main/jsmooth/lib/jsmoothgen.jar"/>
+ <pathelement path="src/main/jsmooth/lib/jsmoothgen-ant.jar"/>
+ </path>
+ <taskdef name="jsmoothgen" classname="net.charabia.jsmoothgen.ant.JSmoothGen"
+ classpathref="jsmooth-classpathref"/>
+ <jsmoothgen project="exe.jsmooth" skeletonroot="src/main/jsmooth/skeletons"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
- <!-- Produce a Win32 exe from the generic IzPack installer (no Maven plugin for JSmooth so drop down to ant) -->
+ <!-- Produce a Win32 exe from the windows IzPack installer (no Maven plugin for JSmooth so drop down to ant) -->
<execution>
- <id>jsmooth-installer2exe</id>
+ <id>jsmooth-installer2exe-installer</id>
<phase>install</phase>
<configuration>
<tasks>
@@ -418,7 +525,10 @@
<!-- Source encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <!-- Location of staging directory for creation of IzPack installer -->
- <staging.dir>${project.build.directory}/staging</staging.dir>
+ <!-- Location of staging directory for creation of linux IzPack installer -->
+ <staging.linux.dir>${project.build.directory}/staging.linux</staging.linux.dir>
+
+ <!-- Location of staging directory for creation of windows IzPack installer -->
+ <staging.windows.dir>${project.build.directory}/staging.windows</staging.windows.dir>
</properties>
</project>
View
1 release_notes.txt
@@ -8,6 +8,7 @@ Enhancements
+ Visual indication of which panel you are on added.
+ 'Available to spend' now hidden when amount is equal to estimated balance
+ Added number of blocks as a tool tip to the "Online/ Connecting..." status label
++ MultiBit now supplied as an exe file for Windows.
Bug fixes
+ Fixed selection colour for Receive and Send bitcoin.
View
85 src/main/izpack/linux/install.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+
+<!--
+ A sample installation file.
+ Use it as a base for your own installers :-)
+
+ To compile it :
+ - go in the bin directory where you installed IzPack
+ - call "compile ../sample/install.xml -b ../sample"
+-->
+
+<installation version="1.0">
+
+ <!--
+ The info section.
+ The meaning of the tags should be natural ...
+ -->
+ <info>
+ <appname>MultiBit</appname>
+ <appsubpath>MultiBit-0.2.0beta2</appsubpath>
+ <appversion>0.2.0beta2</appversion>
+ <url>http://multibit.org/</url>
+ <uninstaller write="yes" />
+ <javaversion>1.6</javaversion>
+ </info>
+
+<variables>
+ <variable name="ShowCreateDirectoryMessage" value="false"/>
+</variables>
+
+ <!--
+ The gui preferences indication.
+ Sets the installer window to 640x480. It will not be able to change the size.
+ -->
+ <guiprefs width="640" height="480" resizable="yes"/>
+
+ <!--
+ The locale section.
+ Asks here to include the English langpacks.
+ -->
+ <locale>
+ <langpack iso3="eng"/>
+ </locale>
+
+ <!--
+ The resources section.
+ The ids must be these ones if you want to use the LicencePanel and/or the InfoPanel.
+ -->
+ <resources>
+ <res id="LicencePanel.licence" src="COPYING"/>
+ <res id="InfoPanel.info" src="readme.txt"/>
+ <res id="Installer.image" src="installerLeft.png" />
+ </resources>
+
+ <!--
+ The panels section.
+ We indicate here which panels we want to use. The order will be respected.
+ -->
+ <panels>
+ <panel classname="HelloPanel"/>
+ <panel classname="InfoPanel"/>
+ <panel classname="LicencePanel"/>
+ <panel classname="TargetPanel"/>
+ <panel classname="ShortcutPanel"/>
+ <panel classname="InstallPanel"/>
+ <panel classname="FinishPanel"/>
+ </panels>
+
+ <!--
+ The packs section.
+ We specify here our packs.
+ -->
+ <packs>
+ <pack name="MultiBit" required="yes">
+ <description>MultiBit install files.</description>
+ <file src="readme.txt" targetdir="$INSTALL_PATH"/>
+ <file src="multibit.properties" targetdir="$INSTALL_PATH"/>
+ <file src="multibit.bmp" targetdir="$INSTALL_PATH"/>
+ <file src="multibit.blockchain" targetdir="$INSTALL_PATH"/>
+ <file src="release_notes.txt" targetdir="$INSTALL_PATH"/>
+ <file src="COPYING" targetdir="$INSTALL_PATH"/>
+ <file src="multibit-exe.jar" targetdir="$INSTALL_PATH"/>
+ </pack>
+ </packs>
+</installation>
View
6 src/main/izpack/install.xml → src/main/izpack/windows/install.xml
@@ -17,8 +17,8 @@
-->
<info>
<appname>MultiBit</appname>
- <appsubpath>MultiBit-0.2.0beta1</appsubpath>
- <appversion>0.2.0beta1</appversion>
+ <appsubpath>MultiBit-0.2.0beta2</appsubpath>
+ <appversion>0.2.0beta2</appversion>
<url>http://multibit.org/</url>
<uninstaller write="yes" />
<javaversion>1.6</javaversion>
@@ -80,7 +80,7 @@
<file src="multibit.blockchain" targetdir="$INSTALL_PATH"/>
<file src="release_notes.txt" targetdir="$INSTALL_PATH"/>
<file src="COPYING" targetdir="$INSTALL_PATH"/>
- <file src="multibit-exe.jar" targetdir="$INSTALL_PATH"/>
+ <file src="multibit.exe" targetdir="$INSTALL_PATH"/>
</pack>
</packs>
<native type="izpack" name="ShellLink.dll"/>
View
2 src/main/izpack/shortcutSpec.xml → src/main/izpack/windows/shortcutSpec.xml
@@ -1,7 +1,7 @@
<shortcuts>
<programGroup defaultName="MultiBit" location="applications"/>
<shortcut name="MultiBit"
- target="$INSTALL_PATH/multibit-exe.jar"
+ target="$INSTALL_PATH/multibit.exe"
description="MultiBit"
workingDirectory="$INSTALL_PATH"
iconFile="$INSTALL_PATH/multibit.bmp"
View
114 src/main/java/com/google/bitcoin/discovery/DnsDiscovery.java
@@ -0,0 +1,114 @@
+/**
+ * Copyright 2011 John Sample
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.bitcoin.discovery;
+
+import com.google.bitcoin.core.NetworkParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Supports peer discovery through DNS.<p>
+ *
+ * This class does not support the testnet as currently there are no DNS servers providing testnet hosts.
+ * If this class is being used for testnet you must specify the hostnames to use.<p>
+ *
+ * Failure to resolve individual host names will not cause an Exception to be thrown.
+ * However, if all hosts passed fail to resolve a PeerDiscoveryException will be thrown during getPeers().
+ */
+public class DnsDiscovery implements PeerDiscovery {
+ private static final Logger log = LoggerFactory.getLogger(DnsDiscovery.class);
+
+ private String[] hostNames;
+ private NetworkParameters netParams;
+
+ public static final String[] defaultHosts = new String[]{
+ "dnsseed.bluematt.me", // Auto generated
+ "bitseed.xf2.org" // Static
+ // "bitseed.bitcoin.org.uk", // Static
+ };
+
+ /**
+ * Supports finding peers through DNS A records. Community run DNS entry points will be used.
+ *
+ * @param netParams Network parameters to be used for port information.
+ */
+ public DnsDiscovery(NetworkParameters netParams) {
+ this(getDefaultHostNames(), netParams);
+ }
+
+ /**
+ * Supports finding peers through DNS A records.
+ *
+ * @param hostNames Host names to be examined for seed addresses.
+ * @param netParams Network parameters to be used for port information.
+ */
+ public DnsDiscovery(String[] hostNames, NetworkParameters netParams) {
+ this.hostNames = hostNames;
+ this.netParams = netParams;
+ }
+
+ public InetSocketAddress[] getPeers() throws PeerDiscoveryException {
+ Set<InetSocketAddress> addresses = new HashSet<InetSocketAddress>();
+
+ /*
+ * Keep track of how many lookups failed vs. succeeded.
+ * We'll throw an exception only if all the lookups fail.
+ * We don't want to throw an exception if only one of many lookups fails.
+ */
+ int failedLookups = 0;
+
+ for (String hostName : hostNames) {
+ try {
+ InetAddress[] hostAddresses = InetAddress.getAllByName(hostName);
+
+ for (InetAddress inetAddress : hostAddresses) {
+ // DNS isn't going to provide us with the port.
+ // Grab the port from the specified NetworkParameters.
+ InetSocketAddress socketAddress = new InetSocketAddress(inetAddress, netParams.port);
+
+ // Only add the new address if it's not already in the combined list.
+ if (!addresses.contains(socketAddress)) {
+ addresses.add(socketAddress);
+ }
+ }
+ } catch (Exception e) {
+ failedLookups++;
+ log.info("DNS lookup for " + hostName + " failed.");
+
+ if (failedLookups == hostNames.length) {
+ // All the lookups failed.
+ // Throw the discovery exception and include the last inner exception.
+ throw new PeerDiscoveryException("DNS resolution for all hosts failed.", e);
+ }
+ }
+ }
+ return addresses.toArray(new InetSocketAddress[]{});
+ }
+
+ /**
+ * Returns the well known discovery host names on the production network.
+ */
+ public static String[] getDefaultHostNames() {
+ return defaultHosts;
+ }
+
+}
View
77 src/main/java/org/multibit/network/FileHandler.java
@@ -76,7 +76,8 @@ public PerWalletModelData loadFromFile(File walletFile) throws IOException {
* @param perWalletModelData
* TODO give notification of whether data was written to a backup
* file
- * @param isNew The savePerWalletModelData is completely new
+ * @param isNew
+ * The savePerWalletModelData is completely new
*/
public void savePerWalletModelData(PerWalletModelData perWalletModelData, boolean isNew) {
try {
@@ -85,11 +86,11 @@ public void savePerWalletModelData(PerWalletModelData perWalletModelData, boolea
return;
}
- // save the perWalletModelData if it is dirty
+ // save the perWalletModelData if it is dirty
if (perWalletModelData.isDirty() || perWalletModelData.isTransactionDirty() || isNew) {
// check dates and sizes of files
boolean filesHaveChanged = haveFilesChanged(perWalletModelData);
-
+
if (!filesHaveChanged || isNew) {
// normal write of data
@@ -140,7 +141,7 @@ public void savePerWalletModelData(PerWalletModelData perWalletModelData, boolea
new File(WalletInfo.createWalletInfoFilename(perWalletModelData.getWalletFilename())), true);
perWalletModelData.setWalletInfoBackupFilename(walletInfoBackupFilename);
}
-
+
// save the companion wallet info
if (walletInfo != null) {
walletInfo.writeToFile(walletInfoBackupFilename);
@@ -174,41 +175,44 @@ public boolean haveFilesChanged(PerWalletModelData perWalletModelData) {
WalletInfo walletInfo = perWalletModelData.getWalletInfo();
- synchronized (walletInfo) {
- String walletFileSize = "" + walletFile.length();
- String walletFileLastModified = "" + walletFile.lastModified();
- String walletInfoFileSize = "" + walletInfoFile.length();
- String walletInfoFileLastModified = "" + walletInfoFile.lastModified();
- if (walletInfo != null) {
- if (!walletFileSize.equals(walletInfo.getProperty(MultiBitModel.WALLET_FILE_SIZE))) {
- haveFilesChanged = true;
- }
+ if (walletInfo != null) {
+ synchronized (walletInfo) {
+ String walletFileSize = "" + walletFile.length();
+ String walletFileLastModified = "" + walletFile.lastModified();
+ String walletInfoFileSize = "" + walletInfoFile.length();
+ String walletInfoFileLastModified = "" + walletInfoFile.lastModified();
+ if (walletInfo != null) {
+ if (!walletFileSize.equals(walletInfo.getProperty(MultiBitModel.WALLET_FILE_SIZE))) {
+ haveFilesChanged = true;
+ }
- if (!walletFileLastModified.equals(walletInfo.getProperty(MultiBitModel.WALLET_FILE_LAST_MODIFIED))) {
- haveFilesChanged = true;
- }
+ if (!walletFileLastModified.equals(walletInfo.getProperty(MultiBitModel.WALLET_FILE_LAST_MODIFIED))) {
+ haveFilesChanged = true;
+ }
- if (!walletInfoFileSize.equals(walletInfo.getProperty(MultiBitModel.WALLET_INFO_FILE_SIZE))) {
- haveFilesChanged = true;
- }
+ if (!walletInfoFileSize.equals(walletInfo.getProperty(MultiBitModel.WALLET_INFO_FILE_SIZE))) {
+ haveFilesChanged = true;
+ }
- if (!walletInfoFileLastModified.equals(walletInfo.getProperty(MultiBitModel.WALLET_INFO_FILE_LAST_MODIFIED))) {
- haveFilesChanged = true;
+ if (!walletInfoFileLastModified
+ .equals(walletInfo.getProperty(MultiBitModel.WALLET_INFO_FILE_LAST_MODIFIED))) {
+ haveFilesChanged = true;
+ }
}
- }
- log.debug("Result of check of whether files have changed for wallet filename "
- + perWalletModelData.getWalletFilename() + " was " + haveFilesChanged + ".");
-
- // create backup filenames early if the files have changed
- // (it is then available in the tooltip)
- if (perWalletModelData.getWalletBackupFilename() == null) {
- try {
- perWalletModelData.setWalletBackupFilename(createBackupFilename(walletFile, false));
-
- perWalletModelData.setWalletInfoBackupFilename(createBackupFilename(
- new File(WalletInfo.createWalletInfoFilename(perWalletModelData.getWalletFilename())), true));
- } catch (IOException e) {
- log.error(e.getMessage(), e);
+ log.debug("Result of check of whether files have changed for wallet filename "
+ + perWalletModelData.getWalletFilename() + " was " + haveFilesChanged + ".");
+
+ // create backup filenames early if the files have changed
+ // (it is then available in the tooltip)
+ if (haveFilesChanged && perWalletModelData.getWalletBackupFilename() == null) {
+ try {
+ perWalletModelData.setWalletBackupFilename(createBackupFilename(walletFile, false));
+
+ perWalletModelData.setWalletInfoBackupFilename(createBackupFilename(
+ new File(WalletInfo.createWalletInfoFilename(perWalletModelData.getWalletFilename())), true));
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ }
}
}
}
@@ -225,6 +229,9 @@ public boolean haveFilesChanged(PerWalletModelData perWalletModelData) {
private void rememberFileSizesAndLastModified(File walletFile, WalletInfo walletInfo) {
// get the files' last modified data and sizes and store them in the
// wallet properties
+ if (walletFile == null || walletInfo == null) {
+ return;
+ }
long walletFileSize = walletFile.length();
long walletFileLastModified = walletFile.lastModified();
View
47 src/main/java/org/multibit/network/MultiBitService.java
@@ -165,9 +165,10 @@ private String getFilePrefix() {
*/
public PerWalletModelData addWalletFromFilename(String walletFilename) {
PerWalletModelData perWalletModelDataToReturn = null;
-
+
File walletFile = null;
boolean walletFileIsADirectory = false;
+ boolean newWalletCreated = false;
if (walletFilename != null) {
walletFile = new File(walletFilename);
@@ -182,7 +183,6 @@ public PerWalletModelData addWalletFromFilename(String walletFilename) {
} catch (IOException ioe) {
// TODO need to report back to user or will create a new
// wallet
- // this is ok - we will create a wallet
}
}
}
@@ -200,7 +200,7 @@ public PerWalletModelData addWalletFromFilename(String walletFilename) {
wallet = perWalletModelDataToReturn.getWallet();
}
- controller.fireWalletChanged();
+ newWalletCreated = true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -211,16 +211,20 @@ public PerWalletModelData addWalletFromFilename(String walletFilename) {
ECKey newKey = new ECKey();
wallet.keychain.add(newKey);
- PerWalletModelData newPerWalletModelData = controller.getModel().addWallet(wallet, walletFile.getAbsolutePath());
+ perWalletModelDataToReturn = controller.getModel().addWallet(wallet, walletFile.getAbsolutePath());
+
+ // create a wallet info
+ WalletInfo walletInfo = new WalletInfo(walletFile.getAbsolutePath());
+ perWalletModelDataToReturn.setWalletInfo(walletInfo);
// set a default description
String defaultDescription = controller.getLocaliser().getString(
"createNewWalletSubmitAction.defaultDescription");
- newPerWalletModelData.setWalletDescription(defaultDescription);
- controller.getFileHandler().savePerWalletModelData(newPerWalletModelData, false);
+ perWalletModelDataToReturn.setWalletDescription(defaultDescription);
- //controller.getModel().setWalletDescriptionByFilename(walletFile.getAbsolutePath(), defaultDescription);
- controller.fireNewWalletCreated();
+ controller.getFileHandler().savePerWalletModelData(perWalletModelDataToReturn, true);
+
+ newWalletCreated = true;
}
}
@@ -229,10 +233,11 @@ public PerWalletModelData addWalletFromFilename(String walletFilename) {
// addresses
ArrayList<ECKey> keys = wallet.keychain;
if (keys != null) {
- PerWalletModelData perWalletModelData = controller.getModel().getPerWalletModelDataByWalletFilename(
- walletFilename);
- if (perWalletModelData != null) {
- WalletInfo walletInfo = perWalletModelData.getWalletInfo();
+ if (!newWalletCreated) {
+ perWalletModelDataToReturn = controller.getModel().getPerWalletModelDataByWalletFilename(walletFilename);
+ }
+ if (perWalletModelDataToReturn != null) {
+ WalletInfo walletInfo = perWalletModelDataToReturn.getWalletInfo();
if (walletInfo != null) {
for (ECKey key : keys) {
if (key != null) {
@@ -249,6 +254,10 @@ public PerWalletModelData addWalletFromFilename(String walletFilename) {
// add wallet as PendingTransactionListener to PeerGroup
peerGroup.addPendingTransactionListener(wallet);
+
+ if (newWalletCreated) {
+ controller.fireNewWalletCreated();
+ }
}
return perWalletModelDataToReturn;
@@ -272,20 +281,22 @@ public void downloadBlockChain() {
* the amount to send to, in BTC, as a String
*/
- public Transaction sendCoins(PerWalletModelData perWalletModelData, String sendAddressString, String amount, BigInteger fee) throws java.io.IOException,
- AddressFormatException {
+ public Transaction sendCoins(PerWalletModelData perWalletModelData, String sendAddressString, String amount, BigInteger fee)
+ throws java.io.IOException, AddressFormatException {
// send the coins
Address sendAddress = new Address(networkParameters, sendAddressString);
- Transaction sendTransaction = perWalletModelData.getWallet().sendCoins(peerGroup, sendAddress, Utils.toNanoCoins(amount), fee);
+ Transaction sendTransaction = perWalletModelData.getWallet().sendCoins(peerGroup, sendAddress,
+ Utils.toNanoCoins(amount), fee);
assert sendTransaction != null; // We should never try to send more
// coins than we have!
// throw an exception if sendTransaction is null - no money
if (sendTransaction != null) {
log.debug("MultiBitService#sendCoins - Sent coins. Transaction hash is " + sendTransaction.getHashAsString());
-
+
controller.getFileHandler().savePerWalletModelData(perWalletModelData, false);
-
- // notify all of the pendingTransactionsListeners about the new transaction
+
+ // notify all of the pendingTransactionsListeners about the new
+ // transaction
peerGroup.processPendingTransaction(sendTransaction);
} else {
// transaction was null
View
2 src/main/java/org/multibit/viewsystem/swing/MultiBitFrame.java
@@ -963,7 +963,7 @@ private JComboBox createActiveWalletComboBox() {
index++;
}
activeWalletComboBox = new JComboBox(indexArray);
- activeWalletComboBox.setBorder(normalBorder);
+ activeWalletPanel.setBorder(normalBorder);
ComboBoxRenderer renderer = new ComboBoxRenderer();
renderer.setMinimumSize(new Dimension(200, 30));
View
2 src/main/resources/version.properties
@@ -1,2 +1,2 @@
# version of multibit
-version=0.2.0beta1
+version=0.2.0beta2

0 comments on commit da440de

Please sign in to comment.