mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Merge branch 'gradle'
This commit is contained in:
commit
fb7397eb48
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
/docs
|
||||
/log
|
||||
/target
|
||||
/bin
|
||||
/out
|
||||
.idea
|
||||
@ -14,3 +13,5 @@ bitsquare.iml
|
||||
*.log
|
||||
*.sw[op]
|
||||
.DS_Store
|
||||
.gradle
|
||||
build
|
||||
|
49
build.gradle
Normal file
49
build.gradle
Normal file
@ -0,0 +1,49 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.github.rholder:gradle-one-jar:1.0.4'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'application'
|
||||
apply plugin: 'gradle-one-jar'
|
||||
|
||||
version = '0.1.0-SNAPSHOT'
|
||||
sourceCompatibility = 1.8
|
||||
mainClassName = 'io.bitsquare.BitSquare'
|
||||
|
||||
sourceSets.main.resources.srcDirs += 'src/main/java'
|
||||
|
||||
task executableJar(type: OneJar) {
|
||||
mainClass = project.mainClassName
|
||||
archiveName = 'bitsquare.jar'
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.google:bitcoinj:0.12-SNAPSHOT'
|
||||
compile 'net.tomp2p:tomp2p-all:5.0-Alpha24-SNAPSHOT'
|
||||
compile 'org.slf4j:slf4j-api:1.7.7'
|
||||
compile 'ch.qos.logback:logback-core:1.1.2'
|
||||
compile 'ch.qos.logback:logback-classic:1.1.2'
|
||||
compile 'com.google.inject:guice:3.0'
|
||||
compile 'com.google.guava:guava:16.0.1'
|
||||
compile 'com.google.code.gson:gson:2.2.4'
|
||||
compile 'org.controlsfx:controlsfx:8.0.5'
|
||||
compile 'de.jensd:fontawesomefx:8.0.0'
|
||||
compile 'net.glxn:qrgen:1.3'
|
||||
compile 'com.google.code.findbugs:jsr305:2.0.3'
|
||||
compile 'net.jcip:jcip-annotations:1.0'
|
||||
compile 'org.jetbrains:annotations:13.0'
|
||||
testCompile 'junit:junit:4.11'
|
||||
testCompile 'org.mockito:mockito-all:1.9.5'
|
||||
}
|
||||
|
||||
wrapper.gradleVersion = '2.0'
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Tue Aug 26 08:24:12 CEST 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
|
164
gradlew
vendored
Executable file
164
gradlew
vendored
Executable file
@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
gradlew.bat
vendored
Normal file
90
gradlew.bat
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
253
pom.xml
253
pom.xml
@ -1,253 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>io.bitsquare</groupId>
|
||||
<artifactId>bitsquare</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<name>BitSquare</name>
|
||||
<description>The P2P Fiat-Bitcoin Exchange</description>
|
||||
<url>http://www.bitsquare.io</url>
|
||||
|
||||
<organization>
|
||||
<name>bitsquare.io</name>
|
||||
</organization>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU AFFERO GENERAL PUBLIC LICENSE</name>
|
||||
<url>http://www.gnu.org/licenses/agpl-3.0.html</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/bitsquare/bitsquare/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<scm>
|
||||
<!-- Public read-only source -->
|
||||
<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>
|
||||
<repository>
|
||||
<id>bitcoinj-release</id>
|
||||
<releases/>
|
||||
<url>http://distribution.bitcoinj.googlecode.com/git/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mvn-adamgent</id>
|
||||
<url>http://mvn-adamgent.googlecode.com/svn/maven/release</url>
|
||||
<name>Adam Gent Maven Repository</name>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>tomp2p.net</id>
|
||||
<url>http://tomp2p.net/dev/mvn/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<finalName>bitsquare</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>**/*.fxml</include>
|
||||
<include>**/*.css</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.zenjava</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>2.0</version>
|
||||
<configuration>
|
||||
<mainClass>io.bitsquare.BitSquare</mainClass>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.twdata.maven</groupId>
|
||||
<artifactId>mojo-executor</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>io.bitsquare.BitSquare</mainClass>
|
||||
<classpathPrefix>dependency-jars/</classpathPrefix>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includeGroupIds>log4j</includeGroupIds>
|
||||
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>bitcoinj</artifactId>
|
||||
<version>0.12-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.tomp2p</groupId>
|
||||
<artifactId>tomp2p-all</artifactId>
|
||||
<version>5.0-Alpha24-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
<version>3.0</version>
|
||||
<classifier>no_aop</classifier>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>16.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.2.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.controlsfx</groupId>
|
||||
<artifactId>controlsfx</artifactId>
|
||||
<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>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>2.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.jcip</groupId>
|
||||
<artifactId>jcip-annotations</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>13.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
@ -122,7 +122,7 @@ public class BalanceTextField extends AnchorPane {
|
||||
}
|
||||
|
||||
private void updateBalance(Coin balance) {
|
||||
balanceTextField.setText(BSFormatter.formatBtc(balance));
|
||||
balanceTextField.setText(BSFormatter.formatCoin(balance));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class WithdrawalController extends CachedViewController {
|
||||
amountTextField, withdrawFromTextField, withdrawToTextField, changeAddressTextField);
|
||||
BitSquareValidator.textFieldsHasDoubleValueWithReset(amountTextField);
|
||||
|
||||
Coin amount = BSFormatter.parseToBtc(amountTextField.getText());
|
||||
Coin amount = BSFormatter.parseToCoin(amountTextField.getText());
|
||||
if (Restrictions.isMinSpendableAmount(amount)) {
|
||||
FutureCallback<Transaction> callback = new FutureCallback<Transaction>() {
|
||||
@Override
|
||||
|
@ -105,7 +105,7 @@ class CreateOfferPresenter {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void onViewInitialized() {
|
||||
totalFees.set(BSFormatter.formatBtc(model.totalFeesAsCoin));
|
||||
totalFees.set(BSFormatter.formatCoin(model.totalFeesAsCoin));
|
||||
paymentLabel.set("Bitsquare trade (" + model.getOfferId() + ")");
|
||||
|
||||
if (model.addressEntry != null) {
|
||||
@ -166,8 +166,8 @@ class CreateOfferPresenter {
|
||||
model.priceAsFiat = parseToFiatWith2Decimals(String.valueOf(orderBookFilter.getPrice()));
|
||||
|
||||
directionLabel.set(model.getDirection() == Direction.BUY ? "Buy:" : "Sell:");
|
||||
amount.set(formatBtc(model.amountAsCoin));
|
||||
minAmount.set(formatBtc(model.minAmountAsCoin));
|
||||
amount.set(formatCoin(model.amountAsCoin));
|
||||
minAmount.set(formatCoin(model.minAmountAsCoin));
|
||||
price.set(formatFiat(model.priceAsFiat));
|
||||
}
|
||||
|
||||
@ -177,10 +177,10 @@ class CreateOfferPresenter {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void placeOffer() {
|
||||
model.amountAsCoin = parseToBtcWith4Decimals(amount.get());
|
||||
model.minAmountAsCoin = parseToBtcWith4Decimals(minAmount.get());
|
||||
model.amountAsCoin = parseToCoinWith4Decimals(amount.get());
|
||||
model.minAmountAsCoin = parseToCoinWith4Decimals(minAmount.get());
|
||||
model.priceAsFiat = parseToFiatWith2Decimals(price.get());
|
||||
model.minAmountAsCoin = parseToBtcWith4Decimals(minAmount.get());
|
||||
model.minAmountAsCoin = parseToCoinWith4Decimals(minAmount.get());
|
||||
|
||||
needsInputValidation.set(true);
|
||||
|
||||
@ -202,19 +202,23 @@ class CreateOfferPresenter {
|
||||
|
||||
// bindBidirectional for amount, price, volume and minAmount
|
||||
amount.addListener(ov -> {
|
||||
model.amountAsCoin = parseToBtcWith4Decimals(amount.get());
|
||||
model.amountAsCoin = parseToCoinWith4Decimals(amount.get());
|
||||
calculateVolume();
|
||||
calculateTotalToPay();
|
||||
calculateCollateral();
|
||||
|
||||
});
|
||||
|
||||
price.addListener(ov -> {
|
||||
model.priceAsFiat = parseToFiatWith2Decimals(price.get());
|
||||
calculateVolume();
|
||||
calculateTotalToPay();
|
||||
calculateCollateral();
|
||||
});
|
||||
|
||||
volume.addListener(ov -> {
|
||||
model.volumeAsFiat = parseToFiatWith2Decimals(volume.get());
|
||||
calculateAmount();
|
||||
calculateTotalToPay();
|
||||
calculateCollateral();
|
||||
});
|
||||
@ -224,8 +228,8 @@ class CreateOfferPresenter {
|
||||
|
||||
if (oldValue && !newValue) {
|
||||
showWarningInvalidBtcDecimalPlaces.set(!hasBtcValidDecimals(amount.get()));
|
||||
model.amountAsCoin = parseToBtcWith4Decimals(amount.get());
|
||||
amount.set(formatBtc(model.amountAsCoin));
|
||||
model.amountAsCoin = parseToCoinWith4Decimals(amount.get());
|
||||
amount.set(formatCoin(model.amountAsCoin));
|
||||
calculateVolume();
|
||||
}
|
||||
}
|
||||
@ -234,8 +238,8 @@ class CreateOfferPresenter {
|
||||
|
||||
if (oldValue && !newValue) {
|
||||
showWarningInvalidBtcDecimalPlaces.set(!hasBtcValidDecimals(minAmount.get()));
|
||||
model.minAmountAsCoin = parseToBtcWith4Decimals(minAmount.get());
|
||||
minAmount.set(formatBtc(model.minAmountAsCoin));
|
||||
model.minAmountAsCoin = parseToCoinWith4Decimals(minAmount.get());
|
||||
minAmount.set(formatCoin(model.minAmountAsCoin));
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,7 +284,7 @@ class CreateOfferPresenter {
|
||||
}
|
||||
|
||||
private void calculateVolume() {
|
||||
model.amountAsCoin = parseToBtcWith4Decimals(amount.get());
|
||||
model.amountAsCoin = parseToCoinWith4Decimals(amount.get());
|
||||
model.priceAsFiat = parseToFiatWith2Decimals(price.get());
|
||||
|
||||
if (model.priceAsFiat != null && model.amountAsCoin != null && !model.amountAsCoin.isZero()) {
|
||||
@ -298,7 +302,7 @@ class CreateOfferPresenter {
|
||||
|
||||
// If we got a btc value with more then 4 decimals we convert it to max 4 decimals
|
||||
model.amountAsCoin = reduceto4Dezimals(model.amountAsCoin);
|
||||
amount.set(formatBtc(model.amountAsCoin));
|
||||
amount.set(formatCoin(model.amountAsCoin));
|
||||
calculateTotalToPay();
|
||||
calculateCollateral();
|
||||
}
|
||||
@ -309,7 +313,7 @@ class CreateOfferPresenter {
|
||||
|
||||
if (model.collateralAsCoin != null) {
|
||||
model.totalToPayAsCoin.set(model.collateralAsCoin.add(model.totalFeesAsCoin));
|
||||
totalToPay.bind(createStringBinding(() -> formatBtcWithCode(model.totalToPayAsCoin.get()),
|
||||
totalToPay.bind(createStringBinding(() -> formatCoinWithCode(model.totalToPayAsCoin.get()),
|
||||
model.totalToPayAsCoin));
|
||||
}
|
||||
}
|
||||
@ -317,7 +321,7 @@ class CreateOfferPresenter {
|
||||
private void calculateCollateral() {
|
||||
if (model.amountAsCoin != null) {
|
||||
model.collateralAsCoin = model.amountAsCoin.multiply(model.collateralAsLong.get()).divide(1000);
|
||||
collateral.set(BSFormatter.formatBtcWithCode(model.collateralAsCoin));
|
||||
collateral.set(BSFormatter.formatCoinWithCode(model.collateralAsCoin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class OrderBookController extends CachedViewController {
|
||||
|
||||
// handlers
|
||||
amount.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
orderBookFilter.setAmount(BSFormatter.parseToBtc(newValue));
|
||||
orderBookFilter.setAmount(BSFormatter.parseToCoin(newValue));
|
||||
updateVolume();
|
||||
});
|
||||
|
||||
@ -348,7 +348,7 @@ public class OrderBookController extends CachedViewController {
|
||||
|
||||
Coin requestedAmount;
|
||||
if (!"".equals(amount.getText())) {
|
||||
requestedAmount = BSFormatter.parseToBtc(amount.getText());
|
||||
requestedAmount = BSFormatter.parseToCoin(amount.getText());
|
||||
}
|
||||
else {
|
||||
requestedAmount = offer.getAmount();
|
||||
|
@ -153,7 +153,7 @@ public class TakeOfferController extends CachedViewController {
|
||||
@FXML
|
||||
public void onTakeOffer() {
|
||||
AddressEntry addressEntry = walletFacade.getAddressInfoByTradeID(offer.getId());
|
||||
Coin amount = BSFormatter.parseToBtc(getAmountString());
|
||||
Coin amount = BSFormatter.parseToCoin(getAmountString());
|
||||
// TODO more validation (fee payment, blacklist,...)
|
||||
if (amountTextField.isInvalid()) {
|
||||
Popups.openErrorPopup("Invalid input", "The requested amount you entered is not a valid amount.");
|
||||
@ -279,7 +279,7 @@ public class TakeOfferController extends CachedViewController {
|
||||
}
|
||||
|
||||
private Coin getAmountInSatoshis() {
|
||||
return BSFormatter.parseToBtc(getAmountString());
|
||||
return BSFormatter.parseToCoin(getAmountString());
|
||||
}
|
||||
|
||||
private String getAmountString() {
|
||||
@ -304,12 +304,12 @@ public class TakeOfferController extends CachedViewController {
|
||||
}
|
||||
|
||||
private Coin getCollateralAsCoin() {
|
||||
Coin amountAsCoin = BSFormatter.parseToBtc(getAmountString());
|
||||
Coin amountAsCoin = BSFormatter.parseToCoin(getAmountString());
|
||||
return amountAsCoin.divide((long) (1d / offer.getCollateral()));
|
||||
}
|
||||
|
||||
private String getFormattedCollateralAsBtc() {
|
||||
Coin amountAsCoin = BSFormatter.parseToBtc(getAmountString());
|
||||
Coin amountAsCoin = BSFormatter.parseToCoin(getAmountString());
|
||||
Coin collateralAsCoin = amountAsCoin.divide((long) (1d / getCollateral()));
|
||||
return BSFormatter.formatCoin(collateralAsCoin);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import io.bitsquare.locale.Localisation;
|
||||
import io.bitsquare.trade.Direction;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
import com.google.bitcoin.utils.BtcFormat;
|
||||
import com.google.bitcoin.utils.CoinFormat;
|
||||
import com.google.bitcoin.utils.Fiat;
|
||||
|
||||
@ -42,9 +43,21 @@ import org.slf4j.LoggerFactory;
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
||||
//TODO a lot of old trash... need to cleanup...
|
||||
|
||||
/**
|
||||
* Central point for formatting and input parsing.
|
||||
* <p>
|
||||
* Note that we never use for text input values any coin or currency symbol or code.
|
||||
* BtcFormat does not support
|
||||
*/
|
||||
public class BSFormatter {
|
||||
private static final Logger log = LoggerFactory.getLogger(BSFormatter.class);
|
||||
|
||||
private static Locale locale = Locale.getDefault();
|
||||
private static boolean useMilliBit;
|
||||
private static String code = "BTC";
|
||||
private static int scale = 3;
|
||||
|
||||
// format is like: 1,00 or 1,0010 never more then 4 decimals
|
||||
private static CoinFormat coinFormat = CoinFormat.BTC.repeatOptionalDecimals(2, 1);
|
||||
|
||||
@ -52,28 +65,40 @@ public class BSFormatter {
|
||||
private static CoinFormat fiatFormat = CoinFormat.FIAT.repeatOptionalDecimals(0, 0);
|
||||
|
||||
private static String currencyCode = Currency.getInstance(Locale.getDefault()).getCurrencyCode();
|
||||
private static Locale locale = Locale.getDefault();
|
||||
|
||||
private static BtcFormat btcFormat = getBtcFormat();
|
||||
|
||||
static {
|
||||
//useMilliBitFormat(true);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Config
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static void useMilliBitFormat() {
|
||||
coinFormat = CoinFormat.MBTC.repeatOptionalDecimals(2, 1);
|
||||
}
|
||||
|
||||
public static void setFiatCurrencyCode(String currencyCode) {
|
||||
BSFormatter.currencyCode = currencyCode;
|
||||
public static void useMilliBitFormat(boolean useMilliBit) {
|
||||
BSFormatter.useMilliBit = useMilliBit;
|
||||
code = useMilliBit ? "mBTC" : "BTC";
|
||||
btcFormat = getBtcFormat();
|
||||
scale = useMilliBit ? 0 : 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that setting the locale does not set the currency as it might be independent.
|
||||
*
|
||||
* @param locale
|
||||
*/
|
||||
public static void setLocale(Locale locale) {
|
||||
BSFormatter.locale = locale;
|
||||
btcFormat = getBtcFormat();
|
||||
}
|
||||
|
||||
private static BtcFormat getBtcFormat() {
|
||||
return BtcFormat.getInstance(useMilliBit ? BtcFormat.MILLICOIN_SCALE : BtcFormat.COIN_SCALE, locale, 2, 2);
|
||||
}
|
||||
|
||||
public static void setFiatCurrencyCode(String currencyCode) {
|
||||
BSFormatter.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
|
||||
@ -81,31 +106,31 @@ public class BSFormatter {
|
||||
// BTC
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static String formatBtc(Coin coin) {
|
||||
public static String formatCoin(Coin coin) {
|
||||
try {
|
||||
return coinFormat.noCode().format(coin).toString();
|
||||
return btcFormat.format(coin);
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at formatBtc: " + t.toString());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatBtcWithCode(Coin coin) {
|
||||
public static String formatCoinWithCode(Coin coin) {
|
||||
try {
|
||||
return coinFormat.postfixCode().format(coin).toString();
|
||||
// we don't use the code feature from btcFormat as it does automatic switching between mBTC and BTC and
|
||||
// pre and post fixing
|
||||
return btcFormat.format(coin) + " " + code;
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at formatBtcWithCode: " + t.toString());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static Coin parseToBtc(String input) {
|
||||
public static Coin parseToCoin(String input) {
|
||||
try {
|
||||
input = input.replace(",", ".");
|
||||
Double.parseDouble(input); // test if valid double
|
||||
return Coin.parseCoin(input);
|
||||
return btcFormat.parse(input);
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at parseToCoin: " + t.toString());
|
||||
log.warn("Exception at parseToBtc: " + t.toString());
|
||||
return Coin.ZERO;
|
||||
}
|
||||
}
|
||||
@ -118,20 +143,18 @@ public class BSFormatter {
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static Coin parseToBtcWith4Decimals(String input) {
|
||||
public static Coin parseToCoinWith4Decimals(String input) {
|
||||
try {
|
||||
input = input.replace(",", ".");
|
||||
Double.parseDouble(input); // test if valid double
|
||||
return parseToBtc(new BigDecimal(input).setScale(4, BigDecimal.ROUND_HALF_UP).toString());
|
||||
return Coin.valueOf(new BigDecimal(parseToCoin(input).value).setScale(-scale - 1,
|
||||
BigDecimal.ROUND_HALF_UP).setScale(scale + 1).toBigInteger().longValue());
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at parseCoinTo4Decimals: " + t.toString());
|
||||
log.warn("Exception at parseToCoinWith4Decimals: " + t.toString());
|
||||
return Coin.ZERO;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasBtcValidDecimals(String input) {
|
||||
return parseToBtc(input).equals(parseToBtcWith4Decimals(input));
|
||||
return parseToCoin(input).equals(parseToCoinWith4Decimals(input));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,7 +164,7 @@ public class BSFormatter {
|
||||
* @return The transformed coin
|
||||
*/
|
||||
public static Coin reduceto4Dezimals(Coin coin) {
|
||||
return parseToBtc(formatBtc(coin));
|
||||
return parseToCoin(formatCoin(coin));
|
||||
}
|
||||
|
||||
|
||||
@ -323,7 +346,7 @@ public class BSFormatter {
|
||||
public static String formatVolumeWithMinVolume(double volume, double minVolume) {
|
||||
return formatDouble(volume) + " (" + formatDouble(minVolume) + ")";
|
||||
}
|
||||
|
||||
/*
|
||||
@Deprecated
|
||||
public static String formatCoin(Coin coin) {
|
||||
return coin != null ? coin.toPlainString() : "";
|
||||
@ -333,5 +356,5 @@ public class BSFormatter {
|
||||
@Deprecated
|
||||
public static String formatCoinWithCode(Coin coin) {
|
||||
return coin != null ? coin.toFriendlyString() : "";
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import io.bitsquare.trade.handlers.TransactionResultHandler;
|
||||
import io.bitsquare.trade.protocol.createoffer.tasks.BroadCastOfferFeeTx;
|
||||
import io.bitsquare.trade.protocol.createoffer.tasks.CreateOfferFeeTx;
|
||||
import io.bitsquare.trade.protocol.createoffer.tasks.PublishOfferToDHT;
|
||||
import io.bitsquare.trade.protocol.createoffer.tasks.ValidateOffer;
|
||||
import io.bitsquare.trade.protocol.createoffer.tasks.VerifyOffer;
|
||||
|
||||
import com.google.bitcoin.core.Transaction;
|
||||
|
||||
@ -112,7 +112,7 @@ public class CreateOfferCoordinator {
|
||||
|
||||
public void start() {
|
||||
model.setState(State.STARTED);
|
||||
ValidateOffer.run(this::onOfferValidated, this::onFailed, offer);
|
||||
VerifyOffer.run(this::onOfferValidated, this::onFailed, offer);
|
||||
}
|
||||
|
||||
private void onOfferValidated() {
|
||||
|
@ -30,33 +30,35 @@ import org.slf4j.LoggerFactory;
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
||||
@Immutable
|
||||
public class ValidateOffer {
|
||||
private static final Logger log = LoggerFactory.getLogger(ValidateOffer.class);
|
||||
public class VerifyOffer {
|
||||
private static final Logger log = LoggerFactory.getLogger(VerifyOffer.class);
|
||||
|
||||
public static void run(ResultHandler resultHandler, FaultHandler faultHandler, Offer offer) {
|
||||
try {
|
||||
checkNotNull(offer.getAcceptedCountries());
|
||||
checkNotNull(offer.getAcceptedLanguageLocales());
|
||||
checkNotNull(offer.getAmount());
|
||||
checkNotNull(offer.getArbitrator());
|
||||
checkNotNull(offer.getBankAccountCountry());
|
||||
checkNotNull(offer.getBankAccountId());
|
||||
checkNotNull(offer.getCollateral());
|
||||
checkNotNull(offer.getCreationDate());
|
||||
checkNotNull(offer.getCurrency());
|
||||
checkNotNull(offer.getDirection());
|
||||
checkNotNull(offer.getId());
|
||||
checkNotNull(offer.getMessagePublicKey());
|
||||
checkNotNull(offer.getMinAmount());
|
||||
checkNotNull(offer.getPrice());
|
||||
checkNotNull(offer.getAcceptedCountries(), "AcceptedCountries is null");
|
||||
checkNotNull(offer.getAcceptedLanguageLocales(), "AcceptedLanguageLocales is null");
|
||||
checkNotNull(offer.getAmount(), "Amount is null");
|
||||
checkNotNull(offer.getArbitrator(), "Arbitrator is null");
|
||||
checkNotNull(offer.getBankAccountCountry(), "BankAccountCountry is null");
|
||||
checkNotNull(offer.getBankAccountId(), "BankAccountId is null");
|
||||
checkNotNull(offer.getCollateral(), "Collateral is null");
|
||||
checkNotNull(offer.getCreationDate(), "CreationDate is null");
|
||||
checkNotNull(offer.getCurrency(), "Currency is null");
|
||||
checkNotNull(offer.getDirection(), "Direction is null");
|
||||
checkNotNull(offer.getId(), "Id is null");
|
||||
checkNotNull(offer.getMessagePublicKey(), "MessagePublicKey is null");
|
||||
checkNotNull(offer.getMinAmount(), "MinAmount is null");
|
||||
checkNotNull(offer.getPrice(), "Price is null");
|
||||
|
||||
checkArgument(offer.getAcceptedCountries().size() > 0);
|
||||
checkArgument(offer.getAcceptedLanguageLocales().size() > 0);
|
||||
checkArgument(offer.getMinAmount().compareTo(Restrictions.MIN_TRADE_AMOUNT) >= 0);
|
||||
checkArgument(offer.getAmount().compareTo(Restrictions.MIN_TRADE_AMOUNT) >= 0);
|
||||
checkArgument(offer.getAmount().compareTo(offer.getMinAmount()) >= 0);
|
||||
checkArgument(offer.getCollateral() > 0);
|
||||
checkArgument(offer.getPrice() > 0);
|
||||
checkArgument(!offer.getAcceptedCountries().isEmpty(), "AcceptedCountries is empty");
|
||||
checkArgument(!offer.getAcceptedLanguageLocales().isEmpty(), "AcceptedLanguageLocales is empty");
|
||||
checkArgument(offer.getMinAmount().compareTo(Restrictions.MIN_TRADE_AMOUNT) >= 0,
|
||||
"MinAmount is less then " + Restrictions.MIN_TRADE_AMOUNT);
|
||||
checkArgument(offer.getAmount().compareTo(Restrictions.MIN_TRADE_AMOUNT) >= 0,
|
||||
"Amount is less then " + Restrictions.MIN_TRADE_AMOUNT);
|
||||
checkArgument(offer.getAmount().compareTo(offer.getMinAmount()) >= 0, "MinAmount is larger then Amount");
|
||||
checkArgument(offer.getCollateral() > 0, "Collateral is 0");
|
||||
checkArgument(offer.getPrice() > 0, "Price is 0");
|
||||
|
||||
// TODO check balance
|
||||
// Coin collateralAsCoin = offer.getAmount().divide((long) (1d / offer.getCollateral()));
|
@ -17,6 +17,10 @@
|
||||
|
||||
package io.bitsquare.gui.util;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -29,18 +33,115 @@ public class BSFormatterTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(BSFormatterTest.class);
|
||||
|
||||
@Test
|
||||
public void testParseToBtcWith4Decimals() {
|
||||
public void testParseToBtc() {
|
||||
useMilliBitFormat(false);
|
||||
setLocale(Locale.GERMAN);
|
||||
assertEquals(Coin.ZERO, parseToCoin("0"));
|
||||
assertEquals(Coin.COIN, parseToCoin("1"));
|
||||
assertEquals(Coin.SATOSHI, parseToCoin("0,00000001"));
|
||||
|
||||
assertEquals("0", parseToBtcWith4Decimals("0").toPlainString());
|
||||
assertEquals("0", parseToBtcWith4Decimals(null).toPlainString());
|
||||
assertEquals("0", parseToBtcWith4Decimals("s").toPlainString());
|
||||
assertEquals("0.0012", parseToBtcWith4Decimals("0.00123").toPlainString());
|
||||
assertEquals("0.0013", parseToBtcWith4Decimals("0.00125").toPlainString());
|
||||
assertEquals("0.0013", parseToBtcWith4Decimals("0,00125").toPlainString());
|
||||
assertEquals(Coin.parseCoin("-1"), parseToCoin("-1"));
|
||||
assertEquals(Coin.parseCoin("1.1"), parseToCoin("1,1"));
|
||||
assertEquals(Coin.parseCoin("11"), parseToCoin("1.1"));
|
||||
assertEquals(Coin.parseCoin("1123.45"), parseToCoin("1.123,45"));
|
||||
assertEquals(Coin.parseCoin("1.123"), parseToCoin("1,123.45"));
|
||||
|
||||
assertEquals(Coin.parseCoin("1.1234"), parseToCoinWith4Decimals("1,12342"));
|
||||
assertEquals(Coin.parseCoin("1.1235"), parseToCoinWith4Decimals("1,12345"));
|
||||
assertEquals(Coin.parseCoin("1.1230"), parseToCoinWith4Decimals("1,123"));
|
||||
|
||||
|
||||
// change locale
|
||||
setLocale(Locale.US);
|
||||
assertEquals(Coin.parseCoin("1.1"), parseToCoin("1.1"));
|
||||
assertEquals(Coin.parseCoin("11"), parseToCoin("1,1"));
|
||||
assertEquals(Coin.parseCoin("1.123"), parseToCoin("1.123,45"));
|
||||
assertEquals(Coin.parseCoin("1123.45"), parseToCoin("1,123.45"));
|
||||
|
||||
// change to mBTC
|
||||
useMilliBitFormat(true);
|
||||
assertEquals(Coin.parseCoin("1"), parseToCoin("1000"));
|
||||
assertEquals(Coin.parseCoin("0.123"), parseToCoin("123"));
|
||||
assertEquals(Coin.parseCoin("0.1234"), parseToCoin("123.4"));
|
||||
assertEquals(Coin.parseCoin("0.12345"), parseToCoin("123.45"));
|
||||
assertEquals(Coin.parseCoin("0.123456"), parseToCoin("123.456"));
|
||||
assertEquals(Coin.parseCoin("123.4567"), parseToCoin("123,456.7"));
|
||||
|
||||
assertEquals(Coin.parseCoin("0.001123"), parseToCoinWith4Decimals("1.123"));
|
||||
assertEquals(Coin.parseCoin("0.0011234"), parseToCoinWith4Decimals("1.1234"));
|
||||
assertEquals(Coin.parseCoin("0.0011234"), parseToCoinWith4Decimals("1.12342"));
|
||||
assertEquals(Coin.parseCoin("0.0011235"), parseToCoinWith4Decimals("1.12345"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatCoin() {
|
||||
useMilliBitFormat(false);
|
||||
setLocale(Locale.GERMAN);
|
||||
assertEquals("1,00", formatCoin(Coin.COIN));
|
||||
assertEquals("1,0120", formatCoin(Coin.parseCoin("1.012")));
|
||||
assertEquals("1.012,30", formatCoin(Coin.parseCoin("1012.3")));
|
||||
assertEquals("1,0120", formatCoin(Coin.parseCoin("1.01200")));
|
||||
assertEquals("1,0123", formatCoin(Coin.parseCoin("1.01234")));
|
||||
|
||||
assertEquals("1,2345", formatCoin(Coin.parseCoin("1.2345")));
|
||||
assertEquals("1,2346", formatCoin(Coin.parseCoin("1.23456")));
|
||||
assertEquals("1,2346", formatCoin(Coin.parseCoin("1.234567")));
|
||||
assertEquals("1,2345", formatCoin(Coin.parseCoin("1.23448")));
|
||||
|
||||
setLocale(Locale.US);
|
||||
assertEquals("1.00", formatCoin(Coin.COIN));
|
||||
assertEquals("1,012.30", formatCoin(Coin.parseCoin("1012.3")));
|
||||
|
||||
// change to mBTC
|
||||
useMilliBitFormat(true);
|
||||
assertEquals("1,000.00", formatCoin(Coin.COIN));
|
||||
assertEquals("1.00", formatCoin(Coin.MILLICOIN));
|
||||
assertEquals("0.0010", formatCoin(Coin.MICROCOIN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatCoinWithCode() {
|
||||
useMilliBitFormat(false);
|
||||
setLocale(Locale.GERMAN);
|
||||
assertEquals("1,00 BTC", formatCoinWithCode(Coin.COIN));
|
||||
assertEquals("1,01 BTC", formatCoinWithCode(Coin.parseCoin("1.01")));
|
||||
assertEquals("1,0120 BTC", formatCoinWithCode(Coin.parseCoin("1.012")));
|
||||
assertEquals("1.012,30 BTC", formatCoinWithCode(Coin.parseCoin("1012.3")));
|
||||
assertEquals("1,0120 BTC", formatCoinWithCode(Coin.parseCoin("1.01200")));
|
||||
assertEquals("1,0123 BTC", formatCoinWithCode(Coin.parseCoin("1.01234")));
|
||||
|
||||
assertEquals("1,2345 BTC", formatCoinWithCode(Coin.parseCoin("1.2345")));
|
||||
assertEquals("1,2346 BTC", formatCoinWithCode(Coin.parseCoin("1.23456")));
|
||||
assertEquals("1,2346 BTC", formatCoinWithCode(Coin.parseCoin("1.234567")));
|
||||
assertEquals("1,2345 BTC", formatCoinWithCode(Coin.parseCoin("1.23448")));
|
||||
|
||||
setLocale(Locale.US);
|
||||
assertEquals("1.00 BTC", formatCoinWithCode(Coin.COIN));
|
||||
assertEquals("1,012.30 BTC", formatCoinWithCode(Coin.parseCoin("1012.3")));
|
||||
|
||||
// change to mBTC
|
||||
useMilliBitFormat(true);
|
||||
assertEquals("1,000.00 mBTC", formatCoinWithCode(Coin.COIN));
|
||||
assertEquals("1.00 mBTC", formatCoinWithCode(Coin.MILLICOIN));
|
||||
assertEquals("0.0010 mBTC", formatCoinWithCode(Coin.MICROCOIN));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseToBtcWith4Decimals() {
|
||||
useMilliBitFormat(false);
|
||||
setLocale(Locale.GERMAN);
|
||||
assertEquals(Coin.parseCoin("0"), parseToCoinWith4Decimals("0"));
|
||||
assertEquals(Coin.parseCoin("0"), parseToCoinWith4Decimals(null));
|
||||
assertEquals(Coin.parseCoin("0"), parseToCoinWith4Decimals("s"));
|
||||
assertEquals(Coin.parseCoin("0.0012"), parseToCoinWith4Decimals("0,00123"));
|
||||
assertEquals(Coin.parseCoin("0.0013"), parseToCoinWith4Decimals("0,00125"));
|
||||
}
|
||||
/*
|
||||
@Test
|
||||
public void testHasBtcValidDecimals() {
|
||||
useMilliBitFormat(false);
|
||||
setLocale(Locale.GERMAN);
|
||||
assertTrue(hasBtcValidDecimals(null));
|
||||
assertTrue(hasBtcValidDecimals("0"));
|
||||
assertTrue(hasBtcValidDecimals("0,0001"));
|
||||
@ -52,19 +153,22 @@ public class BSFormatterTest {
|
||||
assertFalse(hasBtcValidDecimals("0.0001222312312312313"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testParseToFiatWith2Decimals() {
|
||||
|
||||
assertEquals("0", parseToFiatWith2Decimals("0").toPlainString());
|
||||
assertEquals("0", parseToFiatWith2Decimals(null).toPlainString());
|
||||
assertEquals("0", parseToFiatWith2Decimals("s").toPlainString());
|
||||
assertEquals("0.12", parseToFiatWith2Decimals("0.123").toPlainString());
|
||||
assertEquals("0.13", parseToFiatWith2Decimals("0.125").toPlainString());
|
||||
assertEquals("0.13", parseToFiatWith2Decimals("0,125").toPlainString());
|
||||
useMilliBitFormat(false);
|
||||
setLocale(Locale.GERMAN);
|
||||
assertEquals("0", parseToFiatWith2Decimals("0"));
|
||||
assertEquals("0", parseToFiatWith2Decimals(null));
|
||||
assertEquals("0", parseToFiatWith2Decimals("s"));
|
||||
assertEquals("0.12", parseToFiatWith2Decimals("0.123"));
|
||||
assertEquals("0.13", parseToFiatWith2Decimals("0.125"));
|
||||
assertEquals("0.13", parseToFiatWith2Decimals("0,125"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasFiatValidDecimals() {
|
||||
useMilliBitFormat(false);
|
||||
setLocale(Locale.GERMAN);
|
||||
assertTrue(hasFiatValidDecimals(null));
|
||||
assertTrue(hasFiatValidDecimals("0"));
|
||||
assertTrue(hasFiatValidDecimals("0,01"));
|
||||
@ -74,6 +178,6 @@ public class BSFormatterTest {
|
||||
assertFalse(hasFiatValidDecimals("20000000.0123"));
|
||||
assertFalse(hasFiatValidDecimals("0.012"));
|
||||
assertFalse(hasFiatValidDecimals("0.01222312312312313"));
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user