mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-03-15 10:26:37 -04:00
integrate bitcoinj WalletAppKit
This commit is contained in:
parent
227985fdc7
commit
328ecf34fe
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@
|
||||
/bin
|
||||
.idea
|
||||
bitsquare.iml
|
||||
.spvchain
|
||||
.wallet
|
||||
|
78
pom.xml
78
pom.xml
@ -4,14 +4,21 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>bitsquare</groupId>
|
||||
<groupId>io.bitsquare</groupId>
|
||||
<artifactId>bitsquare</artifactId>
|
||||
<version>0.1</version>
|
||||
<version>0.01-SNAPSHOT</version>
|
||||
|
||||
<name>BitSquare</name>
|
||||
<description>A P2P Fiat-Bitcoin Exchange</description>
|
||||
<url>https://www.bitsquare.io</url>
|
||||
|
||||
<parent>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>bitcoinj-parent</artifactId>
|
||||
<version>0.12-SNAPSHOT</version>
|
||||
<relativePath>libs/bitcoinj/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache 2</name>
|
||||
@ -24,6 +31,31 @@
|
||||
<url>https://github.com/bitsquare/bitsquare</url>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-oss-snapshot</id>
|
||||
<snapshots/>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-oss-snapshot2</id>
|
||||
<snapshots/>
|
||||
<url>https://oss.sonatype.org/content/groups/public</url>
|
||||
</repository>
|
||||
<!-- bitcoin-j repo -->
|
||||
<repository>
|
||||
<id>bitcoinj-release</id>
|
||||
<releases />
|
||||
<url>http://distribution.bitcoinj.googlecode.com/git/releases</url>
|
||||
</repository>
|
||||
<!-- zxing repo -->
|
||||
<repository>
|
||||
<id>mvn-adamgent</id>
|
||||
<url>http://mvn-adamgent.googlecode.com/svn/maven/release</url>
|
||||
<name>Adam Gent Maven Repository</name>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
@ -33,24 +65,27 @@
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>io.bitsquare.BitSquare</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>bitcoinj</artifactId>
|
||||
<version>0.12-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@ -60,7 +95,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<version>1.7.6</version>
|
||||
</dependency>
|
||||
|
||||
@ -80,8 +115,14 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava-base</artifactId>
|
||||
<version>r03</version>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>16.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aquafx-project</groupId>
|
||||
<artifactId>aquafx</artifactId>
|
||||
<version>0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -97,6 +138,17 @@
|
||||
<version>8.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.jensd</groupId>
|
||||
<artifactId>fontawesomefx</artifactId>
|
||||
<version>8.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.glxn</groupId>
|
||||
<artifactId>qrgen</artifactId>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
@ -1,12 +1,18 @@
|
||||
package io.bitsquare;
|
||||
|
||||
import com.google.bitcoin.store.BlockStoreException;
|
||||
import com.google.bitcoin.utils.BriefLogFormatter;
|
||||
import com.google.bitcoin.utils.Threading;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import io.bitsquare.btc.IWalletFacade;
|
||||
import io.bitsquare.di.BitSquareModule;
|
||||
import io.bitsquare.di.GuiceFXMLLoader;
|
||||
import io.bitsquare.setup.ISetup;
|
||||
import io.bitsquare.setup.MockSetup;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
@ -18,6 +24,7 @@ import java.io.IOException;
|
||||
public class BitSquare extends Application
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(BitSquare.class);
|
||||
private IWalletFacade walletFacade;
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
@ -25,27 +32,66 @@ public class BitSquare extends Application
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage)
|
||||
public void start(Stage stage) throws Exception
|
||||
{
|
||||
Injector injector = Guice.createInjector(new BitSquareModule());
|
||||
ISetup setup = injector.getInstance(MockSetup.class);
|
||||
// Show the crash dialog for any exceptions that we don't handle and that hit the main loop.
|
||||
//GuiUtils.handleCrashesOnThisThread();
|
||||
try
|
||||
{
|
||||
init(stage);
|
||||
} catch (Throwable t)
|
||||
{
|
||||
// Nicer message for the case where the block store file is locked.
|
||||
if (Throwables.getRootCause(t) instanceof BlockStoreException)
|
||||
{
|
||||
//GuiUtils.informationalAlert("Already running", "This application is already running and cannot be started twice.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception
|
||||
{
|
||||
walletFacade.terminateWallet();
|
||||
|
||||
super.stop();
|
||||
}
|
||||
|
||||
private void init(Stage stage) throws IOException
|
||||
{
|
||||
// Make log output concise.
|
||||
BriefLogFormatter.init();
|
||||
|
||||
// Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means
|
||||
// we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
|
||||
// we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
|
||||
// a future version.
|
||||
Threading.USER_THREAD = Platform::runLater;
|
||||
|
||||
final Injector injector = Guice.createInjector(new BitSquareModule());
|
||||
walletFacade = injector.getInstance(IWalletFacade.class);
|
||||
|
||||
final ISetup setup = injector.getInstance(MockSetup.class);
|
||||
setup.applyPersistedData();
|
||||
|
||||
stage.setTitle("BitSquare");
|
||||
|
||||
GuiceFXMLLoader loader = new GuiceFXMLLoader(injector);
|
||||
try
|
||||
{
|
||||
Parent mainView = loader.load(BitSquare.class.getResourceAsStream("/io/bitsquare/gui/MainView.fxml"));
|
||||
Scene scene = new Scene(mainView, 800, 600);
|
||||
scene.getStylesheets().setAll(getClass().getResource("/io/bitsquare/gui/global.css").toExternalForm());
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// main view
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(injector);
|
||||
final Parent mainView = loader.load(BitSquare.class.getResourceAsStream("/io/bitsquare/gui/MainView.fxml"));
|
||||
final Scene scene = new Scene(mainView, 800, 600);
|
||||
stage.setScene(scene);
|
||||
|
||||
// apply css
|
||||
final String global = getClass().getResource("/io/bitsquare/gui/global.css").toExternalForm();
|
||||
// final String textValidation = getClass().getResource("/wallettemplate/utils/text-validation.css").toExternalForm();
|
||||
//scene.getStylesheets().setAll(global, textValidation);
|
||||
scene.getStylesheets().setAll(global);
|
||||
|
||||
stage.show();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,19 @@
|
||||
package io.bitsquare.btc;
|
||||
|
||||
import com.google.bitcoin.core.PeerEventListener;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public interface IWalletFacade
|
||||
{
|
||||
public static final String MAIN_NET = "MAIN_NET";
|
||||
public static final String TEST_NET = "TEST_NET";
|
||||
public static final String REG_TEST_NET = "REG_TEST_NET";
|
||||
|
||||
void initWallet(PeerEventListener peerEventListener);
|
||||
|
||||
void terminateWallet();
|
||||
|
||||
BigInteger getBalance();
|
||||
|
||||
boolean pay(BigInteger satoshisToPay, String destinationAddress);
|
||||
|
@ -1,52 +0,0 @@
|
||||
package io.bitsquare.btc;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Gateway to wallet
|
||||
*/
|
||||
public class MockWalletFacade implements IWalletFacade
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(MockWalletFacade.class);
|
||||
|
||||
private BigInteger balance;
|
||||
|
||||
public MockWalletFacade()
|
||||
{
|
||||
balance = new BigInteger("100000000");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getBalance()
|
||||
{
|
||||
return balance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(BigInteger satoshisToPay, String destinationAddress)
|
||||
{
|
||||
if (getBalance().subtract(satoshisToPay).longValue() > 0)
|
||||
{
|
||||
log.info("Pay " + satoshisToPay.toString() + " Satoshis to " + destinationAddress);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn("Not enough funds in wallet for paying " + satoshisToPay.toString() + " Satoshis.");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyPair createNewAddress()
|
||||
{
|
||||
//MOCK
|
||||
return new KeyPair(UUID.randomUUID().toString(), UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
97
src/main/java/io/bitsquare/btc/WalletFacade.java
Normal file
97
src/main/java/io/bitsquare/btc/WalletFacade.java
Normal file
@ -0,0 +1,97 @@
|
||||
package io.bitsquare.btc;
|
||||
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
||||
import com.google.bitcoin.core.PeerEventListener;
|
||||
import com.google.bitcoin.kits.WalletAppKit;
|
||||
import com.google.bitcoin.params.MainNetParams;
|
||||
import com.google.bitcoin.params.RegTestParams;
|
||||
import com.google.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.UUID;
|
||||
|
||||
public class WalletFacade implements IWalletFacade
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
|
||||
private NetworkParameters networkParameters;
|
||||
private WalletAppKit walletAppKit;
|
||||
|
||||
private BigInteger balance;
|
||||
|
||||
@Inject
|
||||
public WalletFacade(NetworkParameters networkParameters, WalletAppKit walletAppKit)
|
||||
{
|
||||
this.networkParameters = networkParameters;
|
||||
this.walletAppKit = walletAppKit;
|
||||
|
||||
balance = new BigInteger("100000000");
|
||||
}
|
||||
|
||||
public void initWallet(PeerEventListener peerEventListener)
|
||||
{
|
||||
if (networkParameters == RegTestParams.get())
|
||||
{
|
||||
walletAppKit.connectToLocalHost(); // You should run a regtest mode bitcoind locally.
|
||||
}
|
||||
else if (networkParameters == MainNetParams.get())
|
||||
{
|
||||
// Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
|
||||
// in the checkpoints file and then download the rest from the network. It makes things much faster.
|
||||
// Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
|
||||
// last months worth or more (takes a few seconds).
|
||||
walletAppKit.setCheckpoints(getClass().getResourceAsStream("/wallet/checkpoints"));
|
||||
}
|
||||
|
||||
// Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
|
||||
// or progress widget to keep the user engaged whilst we initialise, but we don't.
|
||||
walletAppKit.setDownloadListener(peerEventListener)
|
||||
.setBlockingStartup(false)
|
||||
.setUserAgent("BitSquare", "1.0");
|
||||
walletAppKit.startAsync();
|
||||
walletAppKit.awaitRunning();
|
||||
// Don't make the user wait for confirmations for now, as the intention is they're sending it their own money!
|
||||
walletAppKit.wallet().allowSpendingUnconfirmedTransactions();
|
||||
walletAppKit.peerGroup().setMaxConnections(11);
|
||||
|
||||
log.info(walletAppKit.wallet().toString());
|
||||
}
|
||||
|
||||
public void terminateWallet()
|
||||
{
|
||||
walletAppKit.stopAsync();
|
||||
walletAppKit.awaitTerminated();
|
||||
}
|
||||
|
||||
|
||||
//MOCK...
|
||||
@Override
|
||||
public BigInteger getBalance()
|
||||
{
|
||||
return balance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(BigInteger satoshisToPay, String destinationAddress)
|
||||
{
|
||||
if (getBalance().subtract(satoshisToPay).longValue() > 0)
|
||||
{
|
||||
log.info("Pay " + satoshisToPay.toString() + " Satoshis to " + destinationAddress);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn("Not enough funds in wallet for paying " + satoshisToPay.toString() + " Satoshis.");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyPair createNewAddress()
|
||||
{
|
||||
//MOCK
|
||||
return new KeyPair(UUID.randomUUID().toString(), UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
@ -1,10 +1,19 @@
|
||||
package io.bitsquare.di;
|
||||
|
||||
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
||||
import com.google.bitcoin.kits.WalletAppKit;
|
||||
import com.google.bitcoin.params.MainNetParams;
|
||||
import com.google.bitcoin.params.RegTestParams;
|
||||
import com.google.bitcoin.params.TestNet3Params;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.name.Named;
|
||||
import com.google.inject.name.Names;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.IWalletFacade;
|
||||
import io.bitsquare.btc.MockWalletFacade;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.crypto.ICryptoFacade;
|
||||
import io.bitsquare.crypto.MockCryptoFacade;
|
||||
import io.bitsquare.msg.IMessageFacade;
|
||||
@ -21,8 +30,12 @@ import io.bitsquare.trade.orderbook.MockOrderBook;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BitSquareModule extends AbstractModule
|
||||
{
|
||||
|
||||
|
||||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
@ -35,10 +48,62 @@ public class BitSquareModule extends AbstractModule
|
||||
bind(OrderBookFilterSettings.class).asEagerSingleton();
|
||||
|
||||
bind(ICryptoFacade.class).to(MockCryptoFacade.class).asEagerSingleton();
|
||||
bind(IWalletFacade.class).to(MockWalletFacade.class).asEagerSingleton();
|
||||
bind(IWalletFacade.class).to(WalletFacade.class).asEagerSingleton();
|
||||
bind(BlockChainFacade.class).asEagerSingleton();
|
||||
bind(IMessageFacade.class).to(MessageFacade.class).asEagerSingleton();
|
||||
|
||||
bind(TradingFacade.class).asEagerSingleton();
|
||||
|
||||
bind(String.class).annotatedWith(Names.named("networkType")).toInstance(IWalletFacade.MAIN_NET);
|
||||
bind(NetworkParameters.class).toProvider(NetworkParametersProvider.class).asEagerSingleton();
|
||||
bind(WalletAppKit.class).toProvider(WalletAppKitProvider.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class WalletAppKitProvider implements Provider<WalletAppKit>
|
||||
{
|
||||
private NetworkParameters networkParameters;
|
||||
|
||||
@Inject
|
||||
public WalletAppKitProvider(NetworkParameters networkParameters)
|
||||
{
|
||||
this.networkParameters = networkParameters;
|
||||
}
|
||||
|
||||
public WalletAppKit get()
|
||||
{
|
||||
return new WalletAppKit(networkParameters, new File("."), "bitsquare");
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkParametersProvider implements Provider<NetworkParameters>
|
||||
{
|
||||
private String networkType;
|
||||
|
||||
@Inject
|
||||
public NetworkParametersProvider(@Named("networkType") String networkType)
|
||||
{
|
||||
this.networkType = networkType;
|
||||
}
|
||||
|
||||
public NetworkParameters get()
|
||||
{
|
||||
NetworkParameters result = null;
|
||||
|
||||
switch (networkType)
|
||||
{
|
||||
case IWalletFacade.MAIN_NET:
|
||||
result = MainNetParams.get();
|
||||
break;
|
||||
case IWalletFacade.TEST_NET:
|
||||
result = TestNet3Params.get();
|
||||
break;
|
||||
case IWalletFacade.REG_TEST_NET:
|
||||
result = RegTestParams.get();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,13 +1,18 @@
|
||||
package io.bitsquare.gui;
|
||||
|
||||
import com.google.bitcoin.core.DownloadListener;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.btc.IWalletFacade;
|
||||
import io.bitsquare.di.GuiceFXMLLoader;
|
||||
import io.bitsquare.gui.trade.TradeController;
|
||||
import io.bitsquare.gui.util.Icons;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.Direction;
|
||||
import io.bitsquare.trade.orderbook.OrderBookFilter;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
@ -15,61 +20,59 @@ import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.Duration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Currency;
|
||||
import java.util.Date;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class MainController implements Initializable, INavigationController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(MainController.class);
|
||||
|
||||
private Settings settings;
|
||||
private OrderBookFilter orderBookFilter;
|
||||
private IWalletFacade walletFacade;
|
||||
private IChildController childController;
|
||||
private ToggleGroup toggleGroup;
|
||||
private ToggleButton prevToggleButton;
|
||||
private Image prevToggleButtonIcon;
|
||||
public ProgressBar networkSyncProgressBar;
|
||||
public Label networkSyncInfoLabel;
|
||||
|
||||
@FXML
|
||||
public Pane contentPane;
|
||||
public HBox leftNavPane, rightNavPane;
|
||||
public HBox leftNavPane, rightNavPane, footerContainer;
|
||||
|
||||
@Inject
|
||||
public MainController(Settings settings, OrderBookFilter orderBookFilter)
|
||||
public MainController(Settings settings, OrderBookFilter orderBookFilter, IWalletFacade walletFacade)
|
||||
{
|
||||
this.settings = settings;
|
||||
this.orderBookFilter = orderBookFilter;
|
||||
this.walletFacade = walletFacade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
toggleGroup = new ToggleGroup();
|
||||
buildNavigation();
|
||||
|
||||
ToggleButton homeButton = addNavButton(leftNavPane, "Overview", Icons.HOME, Icons.HOME, INavigationController.HOME);
|
||||
ToggleButton buyButton = addNavButton(leftNavPane, "Buy BTC", Icons.NAV_BUY, Icons.NAV_BUY_ACTIVE, INavigationController.TRADE, Direction.BUY);
|
||||
ToggleButton sellButton = addNavButton(leftNavPane, "Sell BTC", Icons.NAV_SELL, Icons.NAV_SELL_ACTIVE, INavigationController.TRADE, Direction.SELL);
|
||||
addNavButton(leftNavPane, "Orders", Icons.ORDERS, Icons.ORDERS, INavigationController.ORDERS);
|
||||
addNavButton(leftNavPane, "History", Icons.HISTORY, Icons.HISTORY, INavigationController.HISTORY);
|
||||
addNavButton(leftNavPane, "Funds", Icons.FUNDS, Icons.FUNDS, INavigationController.FUNDS);
|
||||
addNavButton(leftNavPane, "Message", Icons.MSG, Icons.MSG, INavigationController.MSG);
|
||||
addCurrencyComboBox();
|
||||
addNavButton(rightNavPane, "Settings", Icons.SETTINGS, Icons.SETTINGS, INavigationController.SETTINGS);
|
||||
buildFooter();
|
||||
|
||||
|
||||
sellButton.fire();
|
||||
//homeButton.fire();
|
||||
walletFacade.initWallet(new ProgressBarUpdater());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IChildController navigateToView(String fxmlView, String title)
|
||||
{
|
||||
@ -99,6 +102,34 @@ public class MainController implements Initializable, INavigationController
|
||||
return childController;
|
||||
}
|
||||
|
||||
private void buildNavigation()
|
||||
{
|
||||
toggleGroup = new ToggleGroup();
|
||||
|
||||
ToggleButton homeButton = addNavButton(leftNavPane, "Overview", Icons.HOME, Icons.HOME, INavigationController.HOME);
|
||||
ToggleButton buyButton = addNavButton(leftNavPane, "Buy BTC", Icons.NAV_BUY, Icons.NAV_BUY_ACTIVE, INavigationController.TRADE, Direction.BUY);
|
||||
ToggleButton sellButton = addNavButton(leftNavPane, "Sell BTC", Icons.NAV_SELL, Icons.NAV_SELL_ACTIVE, INavigationController.TRADE, Direction.SELL);
|
||||
addNavButton(leftNavPane, "Orders", Icons.ORDERS, Icons.ORDERS, INavigationController.ORDERS);
|
||||
addNavButton(leftNavPane, "History", Icons.HISTORY, Icons.HISTORY, INavigationController.HISTORY);
|
||||
addNavButton(leftNavPane, "Funds", Icons.FUNDS, Icons.FUNDS, INavigationController.FUNDS);
|
||||
addNavButton(leftNavPane, "Message", Icons.MSG, Icons.MSG, INavigationController.MSG);
|
||||
addCurrencyComboBox();
|
||||
addNavButton(rightNavPane, "Settings", Icons.SETTINGS, Icons.SETTINGS, INavigationController.SETTINGS);
|
||||
|
||||
sellButton.fire();
|
||||
//homeButton.fire();
|
||||
}
|
||||
|
||||
private void buildFooter()
|
||||
{
|
||||
networkSyncInfoLabel = new Label();
|
||||
networkSyncInfoLabel.setText("Synchronize with network...");
|
||||
networkSyncProgressBar = new ProgressBar();
|
||||
networkSyncProgressBar.setPrefWidth(200);
|
||||
networkSyncProgressBar.setProgress(-1);
|
||||
footerContainer.getChildren().addAll(networkSyncProgressBar, networkSyncInfoLabel);
|
||||
}
|
||||
|
||||
private ToggleButton addNavButton(Pane parent, String title, String iconId, String iconIdActivated, String navTarget)
|
||||
{
|
||||
return addNavButton(parent, title, iconId, iconIdActivated, navTarget, null);
|
||||
@ -162,4 +193,40 @@ public class MainController implements Initializable, INavigationController
|
||||
holder.getChildren().add(currencyComboBox);
|
||||
rightNavPane.getChildren().add(holder);
|
||||
}
|
||||
|
||||
private void setProgress(double percent)
|
||||
{
|
||||
networkSyncProgressBar.setProgress(percent / 100.0);
|
||||
networkSyncInfoLabel.setText("Synchronize with network: " + (int) percent + "%");
|
||||
}
|
||||
|
||||
private void doneDownload()
|
||||
{
|
||||
networkSyncInfoLabel.setText("Sync with network: Done");
|
||||
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(700), footerContainer);
|
||||
fade.setToValue(0.0);
|
||||
fade.setCycleCount(1);
|
||||
fade.setInterpolator(Interpolator.EASE_BOTH);
|
||||
fade.play();
|
||||
fade.setOnFinished(e -> footerContainer.getChildren().clear());
|
||||
}
|
||||
|
||||
private class ProgressBarUpdater extends DownloadListener
|
||||
{
|
||||
@Override
|
||||
protected void progress(double percent, int blocksSoFar, Date date)
|
||||
{
|
||||
super.progress(percent, blocksSoFar, date);
|
||||
Platform.runLater(() -> MainController.this.setProgress(percent));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doneDownload()
|
||||
{
|
||||
super.doneDownload();
|
||||
Platform.runLater(MainController.this::doneDownload);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -8,7 +8,9 @@
|
||||
<children>
|
||||
<HBox fx:id="leftNavPane" spacing="20" AnchorPane.leftAnchor="10" AnchorPane.topAnchor="5"/>
|
||||
<HBox fx:id="rightNavPane" spacing="10" AnchorPane.rightAnchor="10" AnchorPane.topAnchor="5"/>
|
||||
<AnchorPane id="content-pane" fx:id="contentPane" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
||||
<AnchorPane id="content-pane" fx:id="contentPane" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="0"
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="60"/>
|
||||
<HBox fx:id="footerContainer" prefHeight="20" spacing="10" AnchorPane.leftAnchor="10"
|
||||
AnchorPane.bottomAnchor="0"/>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
@ -2,19 +2,25 @@ package io.bitsquare.gui.funds;
|
||||
|
||||
import io.bitsquare.gui.IChildController;
|
||||
import io.bitsquare.gui.INavigationController;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
||||
public class FundsController implements Initializable, IChildController
|
||||
{
|
||||
|
||||
private INavigationController navigationController;
|
||||
|
||||
@FXML
|
||||
public Pane rootContainer;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -22,5 +28,6 @@ public class FundsController implements Initializable, IChildController
|
||||
{
|
||||
this.navigationController = navigationController;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<Pane fx:controller="io.bitsquare.gui.funds.FundsController"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
xmlns:fx="http://javafx.com/fxml" fx:id="rootContainer">
|
||||
<Label text="Wallet"/>
|
||||
</Pane>
|
@ -199,7 +199,7 @@ public class TradeProcessController implements Initializable, IChildController
|
||||
private void onBankTransferInited()
|
||||
{
|
||||
infoLabel.setText("Bank transfer has been inited.\nCheck your bank account and continue when you have received the money.\n");
|
||||
nextButton.setText("Money received on Bank account");
|
||||
nextButton.setText("I have received the bank transfer");
|
||||
nextButton.setOnAction(e -> releaseBTC());
|
||||
vBox.getChildren().add(nextButton);
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package io.bitsquare.trade;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.IWalletFacade;
|
||||
import io.bitsquare.btc.KeyPair;
|
||||
import io.bitsquare.btc.MockWalletFacade;
|
||||
import io.bitsquare.crypto.ICryptoFacade;
|
||||
import io.bitsquare.msg.IMessageFacade;
|
||||
import io.bitsquare.msg.Message;
|
||||
@ -29,7 +29,7 @@ public class TradingFacade
|
||||
private User user;
|
||||
private IMessageFacade messageFacade;
|
||||
private BlockChainFacade blockChainFacade;
|
||||
private MockWalletFacade walletFacade;
|
||||
private IWalletFacade walletFacade;
|
||||
private ICryptoFacade cryptoFacade;
|
||||
private Settings settings;
|
||||
|
||||
@ -38,7 +38,7 @@ public class TradingFacade
|
||||
Settings settings,
|
||||
IMessageFacade messageFacade,
|
||||
BlockChainFacade blockChainFacade,
|
||||
MockWalletFacade walletFacade,
|
||||
IWalletFacade walletFacade,
|
||||
ICryptoFacade cryptoFacade)
|
||||
{
|
||||
this.user = user;
|
||||
|
@ -2,7 +2,7 @@ package io.bitsquare.trade.payment.process;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.MockWalletFacade;
|
||||
import io.bitsquare.btc.IWalletFacade;
|
||||
import io.bitsquare.msg.IMessageFacade;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -26,7 +26,7 @@ public class PaymentProcess
|
||||
protected String takerOutputPayment;
|
||||
|
||||
protected String multiSigAddress;
|
||||
private MockWalletFacade wallet;
|
||||
private IWalletFacade wallet;
|
||||
|
||||
public PaymentProcess()
|
||||
{
|
||||
@ -39,7 +39,7 @@ public class PaymentProcess
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setWallet(MockWalletFacade wallet)
|
||||
public void setWallet(IWalletFacade wallet)
|
||||
{
|
||||
this.wallet = wallet;
|
||||
}
|
||||
|
BIN
src/main/resources/wallet/checkpoints
Normal file
BIN
src/main/resources/wallet/checkpoints
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user