Added support for NXT
This commit is contained in:
parent
3d0ee25abd
commit
b7ca47b9e9
|
@ -28,6 +28,7 @@ public interface ICurrencies {
|
||||||
public static final String GRS = "GRS";
|
public static final String GRS = "GRS";
|
||||||
public static final String ICG = "ICG";
|
public static final String ICG = "ICG";
|
||||||
public static final String NBT = "NBT";
|
public static final String NBT = "NBT";
|
||||||
|
public static final String NXT = "NXT";
|
||||||
|
|
||||||
public static final String CAD = "CAD";
|
public static final String CAD = "CAD";
|
||||||
public static final String CNY = "CNY";
|
public static final String CNY = "CNY";
|
||||||
|
|
|
@ -190,4 +190,22 @@
|
||||||
</ratesource>
|
</ratesource>
|
||||||
<cryptologo cryptocurrency="NBT" file="nbt.png"/>
|
<cryptologo cryptocurrency="NBT" file="nbt.png"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension class="com.generalbytes.batm.server.extensions.extra.nxt.NXTExtension" >
|
||||||
|
<wallet prefix="mynxt" name="MyNXT.info">
|
||||||
|
<param name="email" />
|
||||||
|
<param name="password" />
|
||||||
|
<param name="masterPassword" />
|
||||||
|
<param name="accountId" />
|
||||||
|
<cryptocurrency>NXT</cryptocurrency>
|
||||||
|
</wallet>
|
||||||
|
<ratesource prefix="ntxfix" name ="Fix Price" >
|
||||||
|
<param name="price" />
|
||||||
|
<cryptocurrency>NXT</cryptocurrency>
|
||||||
|
</ratesource>
|
||||||
|
<ratesource prefix="poloniexrs" name ="Poloniex.com vs bitcoinaverage.com" >
|
||||||
|
<param name="fiatcurrency" />
|
||||||
|
<cryptocurrency>NXT</cryptocurrency>
|
||||||
|
</ratesource>
|
||||||
|
<cryptologo cryptocurrency="NXT" file="nxt.png"/>
|
||||||
|
</extension>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
|
@ -0,0 +1,87 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt;
|
||||||
|
|
||||||
|
import com.generalbytes.batm.server.extensions.ExtensionsUtil;
|
||||||
|
import com.generalbytes.batm.server.extensions.ICryptoAddressValidator;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
public class NXTAddressValidator implements ICryptoAddressValidator {
|
||||||
|
@Override
|
||||||
|
public boolean isAddressValid(String address) {
|
||||||
|
boolean result = isNXTAddressValid(address);
|
||||||
|
if (!result) {
|
||||||
|
result = isPaperWalletSupported() && ExtensionsUtil.isValidEmailAddress(address);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BigInteger getAccountIdFromRS(String address) {
|
||||||
|
if (address.startsWith("NXT")) {
|
||||||
|
try {
|
||||||
|
String[] pieces = address.split("-");
|
||||||
|
if (pieces.length != 5) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (pieces[0].length() != 3 ||
|
||||||
|
pieces[1].length() != 4 ||
|
||||||
|
pieces[2].length() != 4 ||
|
||||||
|
pieces[3].length() != 4 ||
|
||||||
|
pieces[4].length() != 5 ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigInteger l = rsDecode(pieces[1] + "-" + pieces[2] + "-" + pieces[3] + "-" + pieces[4]);
|
||||||
|
return l;
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isNXTAddressValid(String address) {
|
||||||
|
return getAccountIdFromRS(address) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPaperWalletSupported() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mustBeBase58Address() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BigInteger rsDecode(String rsString) {
|
||||||
|
rsString = rsString.toUpperCase();
|
||||||
|
try {
|
||||||
|
BigInteger id = ReedSolomon.decode(rsString);
|
||||||
|
if (! rsString.equals(ReedSolomon.encode(id))) {
|
||||||
|
throw new RuntimeException("ERROR: Reed-Solomon decoding of " + rsString + " not reversible, decoded to " + id);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
} catch (ReedSolomon.DecodeException e) {
|
||||||
|
throw new RuntimeException(e.toString(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt;
|
||||||
|
|
||||||
|
import com.generalbytes.batm.server.extensions.*;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.sources.FixPriceRateSource;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.sources.poloniex.PoloniexRateSource;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.MynxtWallet;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
public class NXTExtension implements IExtension{
|
||||||
|
@Override
|
||||||
|
public String getName() { return "BATM NXT extension"; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IExchange createExchange(String exchangeLogin) { return null; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWallet createWallet(String walletLogin) {
|
||||||
|
if (walletLogin != null && !walletLogin.trim().isEmpty()) {
|
||||||
|
StringTokenizer st = new StringTokenizer(walletLogin,":");
|
||||||
|
String walletType = st.nextToken();
|
||||||
|
|
||||||
|
if ("mynxt".equalsIgnoreCase(walletType)) {
|
||||||
|
//"nud:protocol:user:password:ip:port:accountname"
|
||||||
|
|
||||||
|
String email = st.nextToken();
|
||||||
|
String password = st.nextToken();
|
||||||
|
String masterPassword = st.nextToken();
|
||||||
|
String accountId =null;
|
||||||
|
if (st.hasMoreTokens()) {
|
||||||
|
accountId = st.nextToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (email != null && password != null && masterPassword !=null) {
|
||||||
|
return new MynxtWallet(email,password,masterPassword,accountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICryptoAddressValidator createAddressValidator(String cryptoCurrency) {
|
||||||
|
if (ICurrencies.NXT.equalsIgnoreCase(cryptoCurrency)) {
|
||||||
|
return new NXTAddressValidator();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPaperWalletGenerator createPaperWalletGenerator(String cryptoCurrency) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IRateSource createRateSource(String sourceLogin) {
|
||||||
|
if (sourceLogin != null && !sourceLogin.trim().isEmpty()) {
|
||||||
|
StringTokenizer st = new StringTokenizer(sourceLogin,":");
|
||||||
|
String rsType = st.nextToken();
|
||||||
|
|
||||||
|
if ("nxtfix".equalsIgnoreCase(rsType)) {
|
||||||
|
BigDecimal rate = BigDecimal.ZERO;
|
||||||
|
if (st.hasMoreTokens()) {
|
||||||
|
try {
|
||||||
|
rate = new BigDecimal(st.nextToken());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String preferedFiatCurrency = ICurrencies.USD;
|
||||||
|
if (st.hasMoreTokens()) {
|
||||||
|
preferedFiatCurrency = st.nextToken();
|
||||||
|
}
|
||||||
|
return new FixPriceRateSource(rate,preferedFiatCurrency);
|
||||||
|
}else if ("poloniexrs".equalsIgnoreCase(rsType)) {
|
||||||
|
String preferredFiatCurrency = ICurrencies.USD;
|
||||||
|
if (st.hasMoreTokens()) {
|
||||||
|
preferredFiatCurrency = st.nextToken();
|
||||||
|
}
|
||||||
|
return new PoloniexRateSource(preferredFiatCurrency);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPaymentProcessor createPaymentProcessor(String paymentProcessorLogin) {
|
||||||
|
return null; //no payment processors available
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getSupportedCryptoCurrencies() {
|
||||||
|
Set<String> result = new HashSet<String>();
|
||||||
|
result.add(ICurrencies.NXT);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Reed Solomon Encoding and Decoding for Nxt
|
||||||
|
|
||||||
|
Version: 1.0, license: Public Domain, coder: NxtChg (admin@nxtchg.com)
|
||||||
|
Java Version: ChuckOne (ChuckOne@mail.de).
|
||||||
|
*/
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
final class ReedSolomon {
|
||||||
|
public static final BigInteger two64 = new BigInteger("18446744073709551616");
|
||||||
|
private static final int[] initial_codeword = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
private static final int[] gexp = {1, 2, 4, 8, 16, 5, 10, 20, 13, 26, 17, 7, 14, 28, 29, 31, 27, 19, 3, 6, 12, 24, 21, 15, 30, 25, 23, 11, 22, 9, 18, 1};
|
||||||
|
private static final int[] glog = {0, 0, 1, 18, 2, 5, 19, 11, 3, 29, 6, 27, 20, 8, 12, 23, 4, 10, 30, 17, 7, 22, 28, 26, 21, 25, 9, 16, 13, 14, 24, 15};
|
||||||
|
private static final int[] codeword_map = {3, 2, 1, 0, 7, 6, 5, 4, 13, 14, 15, 16, 12, 8, 9, 10, 11};
|
||||||
|
private static final String alphabet = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
||||||
|
|
||||||
|
private static final int base_32_length = 13;
|
||||||
|
private static final int base_10_length = 20;
|
||||||
|
|
||||||
|
public static String toUnsignedLong(long objectId) {
|
||||||
|
if (objectId >= 0) {
|
||||||
|
return String.valueOf(objectId);
|
||||||
|
}
|
||||||
|
BigInteger id = BigInteger.valueOf(objectId).add(two64);
|
||||||
|
return id.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String encode(BigInteger plain) {
|
||||||
|
String plain_string = plain.toString();
|
||||||
|
int length = plain_string.length();
|
||||||
|
int[] plain_string_10 = new int[ReedSolomon.base_10_length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
plain_string_10[i] = (int)plain_string.charAt(i) - (int)'0';
|
||||||
|
}
|
||||||
|
|
||||||
|
int codeword_length = 0;
|
||||||
|
int[] codeword = new int[ReedSolomon.initial_codeword.length];
|
||||||
|
|
||||||
|
do { // base 10 to base 32 conversion
|
||||||
|
int new_length = 0;
|
||||||
|
int digit_32 = 0;
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
digit_32 = digit_32 * 10 + plain_string_10[i];
|
||||||
|
if (digit_32 >= 32) {
|
||||||
|
plain_string_10[new_length] = digit_32 >> 5;
|
||||||
|
digit_32 &= 31;
|
||||||
|
new_length += 1;
|
||||||
|
} else if (new_length > 0) {
|
||||||
|
plain_string_10[new_length] = 0;
|
||||||
|
new_length += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
length = new_length;
|
||||||
|
codeword[codeword_length] = digit_32;
|
||||||
|
codeword_length += 1;
|
||||||
|
} while(length > 0);
|
||||||
|
|
||||||
|
int[] p = {0, 0, 0, 0};
|
||||||
|
for (int i = ReedSolomon.base_32_length - 1; i >= 0; i--) {
|
||||||
|
final int fb = codeword[i] ^ p[3];
|
||||||
|
p[3] = p[2] ^ ReedSolomon.gmult(30, fb);
|
||||||
|
p[2] = p[1] ^ ReedSolomon.gmult(6, fb);
|
||||||
|
p[1] = p[0] ^ ReedSolomon.gmult(9, fb);
|
||||||
|
p[0] = ReedSolomon.gmult(17, fb);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.arraycopy(p, 0, codeword, ReedSolomon.base_32_length, ReedSolomon.initial_codeword.length - ReedSolomon.base_32_length);
|
||||||
|
|
||||||
|
StringBuilder cypher_string_builder = new StringBuilder();
|
||||||
|
for (int i = 0; i < 17; i++) {
|
||||||
|
final int codework_index = ReedSolomon.codeword_map[i];
|
||||||
|
final int alphabet_index = codeword[codework_index];
|
||||||
|
cypher_string_builder.append(ReedSolomon.alphabet.charAt(alphabet_index));
|
||||||
|
|
||||||
|
if ((i & 3) == 3 && i < 13) {
|
||||||
|
cypher_string_builder.append('-');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cypher_string_builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static BigInteger decode(String cypher_string) throws DecodeException {
|
||||||
|
|
||||||
|
int[] codeword = new int[ReedSolomon.initial_codeword.length];
|
||||||
|
System.arraycopy(ReedSolomon.initial_codeword, 0, codeword, 0, ReedSolomon.initial_codeword.length);
|
||||||
|
|
||||||
|
int codeword_length = 0;
|
||||||
|
for (int i = 0; i < cypher_string.length(); i++) {
|
||||||
|
int position_in_alphabet = ReedSolomon.alphabet.indexOf(cypher_string.charAt(i));
|
||||||
|
|
||||||
|
if (position_in_alphabet <= -1 || position_in_alphabet > ReedSolomon.alphabet.length()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (codeword_length > 16) {
|
||||||
|
throw new CodewordTooLongException();
|
||||||
|
}
|
||||||
|
|
||||||
|
int codework_index = ReedSolomon.codeword_map[codeword_length];
|
||||||
|
codeword[codework_index] = position_in_alphabet;
|
||||||
|
codeword_length += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (codeword_length == 17 && !ReedSolomon.is_codeword_valid(codeword) || codeword_length != 17) {
|
||||||
|
throw new CodewordInvalidException();
|
||||||
|
}
|
||||||
|
|
||||||
|
int length = ReedSolomon.base_32_length;
|
||||||
|
int[] cypher_string_32 = new int[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
cypher_string_32[i] = codeword[length - i - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder plain_string_builder = new StringBuilder();
|
||||||
|
do { // base 32 to base 10 conversion
|
||||||
|
int new_length = 0;
|
||||||
|
int digit_10 = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
digit_10 = digit_10 * 32 + cypher_string_32[i];
|
||||||
|
|
||||||
|
if (digit_10 >= 10) {
|
||||||
|
cypher_string_32[new_length] = digit_10 / 10;
|
||||||
|
digit_10 %= 10;
|
||||||
|
new_length += 1;
|
||||||
|
} else if (new_length > 0) {
|
||||||
|
cypher_string_32[new_length] = 0;
|
||||||
|
new_length += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
length = new_length;
|
||||||
|
plain_string_builder.append((char)(digit_10 + (int)'0'));
|
||||||
|
} while (length > 0);
|
||||||
|
|
||||||
|
return new BigInteger(plain_string_builder.reverse().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int gmult(int a, int b) {
|
||||||
|
if (a == 0 || b == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int idx = (ReedSolomon.glog[a] + ReedSolomon.glog[b]) % 31;
|
||||||
|
|
||||||
|
return ReedSolomon.gexp[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean is_codeword_valid(int[] codeword) {
|
||||||
|
int sum = 0;
|
||||||
|
|
||||||
|
for (int i = 1; i < 5; i++) {
|
||||||
|
int t = 0;
|
||||||
|
|
||||||
|
for (int j = 0; j < 31; j++) {
|
||||||
|
if (j > 12 && j < 27) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos = j;
|
||||||
|
if (j > 26) {
|
||||||
|
pos -= 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
t ^= ReedSolomon.gmult(codeword[pos], ReedSolomon.gexp[(i * j) % 31]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sum |= t;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract static class DecodeException extends Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
static final class CodewordTooLongException extends DecodeException {
|
||||||
|
}
|
||||||
|
|
||||||
|
static final class CodewordInvalidException extends DecodeException {
|
||||||
|
}
|
||||||
|
|
||||||
|
private ReedSolomon() {} // never
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.sources;
|
||||||
|
|
||||||
|
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||||
|
import com.generalbytes.batm.server.extensions.IRateSource;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class FixPriceRateSource implements IRateSource {
|
||||||
|
private BigDecimal rate = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
private String preferedFiatCurrency = ICurrencies.USD;
|
||||||
|
|
||||||
|
public FixPriceRateSource(BigDecimal rate, String preferedFiatCurrency) {
|
||||||
|
this.rate = rate;
|
||||||
|
if (ICurrencies.EUR.equalsIgnoreCase(preferedFiatCurrency)) {
|
||||||
|
this.preferedFiatCurrency = ICurrencies.EUR;
|
||||||
|
}
|
||||||
|
if (ICurrencies.USD.equalsIgnoreCase(preferedFiatCurrency)) {
|
||||||
|
this.preferedFiatCurrency = ICurrencies.USD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getCryptoCurrencies() {
|
||||||
|
Set<String> result = new HashSet<String>();
|
||||||
|
result.add(ICurrencies.NXT);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getExchangeRateLast(String cryptoCurrency, String fiatCurrency) {
|
||||||
|
if (ICurrencies.NXT.equalsIgnoreCase(cryptoCurrency)) {
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getFiatCurrencies() {
|
||||||
|
Set<String> result = new HashSet<String>();
|
||||||
|
result.add(ICurrencies.USD);
|
||||||
|
result.add(ICurrencies.EUR);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getPreferredFiatCurrency() {
|
||||||
|
return preferedFiatCurrency;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.sources.poloniex;
|
||||||
|
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
@Path("/")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public interface IPoloniexAPI {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/public")
|
||||||
|
public OrderBookResponse returnOrderBook(@QueryParam("command") String command, @QueryParam("currencyPair") String currencyPair, @QueryParam("depth") long depth);
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.sources.poloniex;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by b00lean on 3/8/15.
|
||||||
|
*/
|
||||||
|
public class OrderBookResponse {
|
||||||
|
private BigDecimal[][] asks;
|
||||||
|
private BigDecimal[][] bids;
|
||||||
|
private String isFrozen;
|
||||||
|
|
||||||
|
|
||||||
|
public BigDecimal[][] getAsks() {
|
||||||
|
return asks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAsks(BigDecimal[][] asks) {
|
||||||
|
this.asks = asks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal[][] getBids() {
|
||||||
|
return bids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBids(BigDecimal[][] bids) {
|
||||||
|
this.bids = bids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsFrozen() {
|
||||||
|
return isFrozen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsFrozen(String isFrozen) {
|
||||||
|
this.isFrozen = isFrozen;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.sources.poloniex;
|
||||||
|
|
||||||
|
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||||
|
import com.generalbytes.batm.server.extensions.IRateSource;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.bitcoin.sources.BitcoinAverageRateSource;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import si.mazi.rescu.RestProxyFactory;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class PoloniexRateSource implements IRateSource{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(PoloniexRateSource.class);
|
||||||
|
|
||||||
|
private BitcoinAverageRateSource btcRs;
|
||||||
|
private String preferedFiatCurrency;
|
||||||
|
private IPoloniexAPI api;
|
||||||
|
|
||||||
|
private static HashMap<String,BigDecimal> rateAmounts = new HashMap<String, BigDecimal>();
|
||||||
|
private static HashMap<String,Long> rateTimes = new HashMap<String, Long>();
|
||||||
|
private static final long MAXIMUM_ALLOWED_TIME_OFFSET = 30 * 1000; //30sec
|
||||||
|
|
||||||
|
public PoloniexRateSource(String preferedFiatCurrency) {
|
||||||
|
if (preferedFiatCurrency == null) {
|
||||||
|
preferedFiatCurrency = ICurrencies.USD;
|
||||||
|
}
|
||||||
|
this.preferedFiatCurrency = preferedFiatCurrency;
|
||||||
|
btcRs = new BitcoinAverageRateSource(preferedFiatCurrency);
|
||||||
|
api = RestProxyFactory.createProxy(IPoloniexAPI.class, "https://poloniex.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getFiatCurrencies() {
|
||||||
|
return btcRs.getFiatCurrencies();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferredFiatCurrency() {
|
||||||
|
return btcRs.getPreferredFiatCurrency();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getCryptoCurrencies() {
|
||||||
|
Set<String> result = new HashSet<String>();
|
||||||
|
result.add(ICurrencies.NXT);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getExchangeRateLast(String cryptoCurrency, String fiatCurrency) {
|
||||||
|
if (!ICurrencies.NXT.equalsIgnoreCase(cryptoCurrency)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String key = cryptoCurrency +"_" + fiatCurrency;
|
||||||
|
synchronized (rateAmounts) {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
BigDecimal amount = rateAmounts.get(key);
|
||||||
|
if (amount == null) {
|
||||||
|
BigDecimal result = getExchangeRateLastSync(cryptoCurrency, fiatCurrency);
|
||||||
|
log.debug("Called bitcoinaverage exchange for rate: " + key + " = " + result);
|
||||||
|
rateAmounts.put(key,result);
|
||||||
|
rateTimes.put(key,now+MAXIMUM_ALLOWED_TIME_OFFSET);
|
||||||
|
return result;
|
||||||
|
}else {
|
||||||
|
Long expirationTime = rateTimes.get(key);
|
||||||
|
if (expirationTime > now) {
|
||||||
|
return rateAmounts.get(key);
|
||||||
|
}else{
|
||||||
|
//do the job;
|
||||||
|
BigDecimal result = getExchangeRateLastSync(cryptoCurrency, fiatCurrency);
|
||||||
|
log.debug("Called bitcoinaverage exchange for rate: " + key + " = " + result);
|
||||||
|
rateAmounts.put(key,result);
|
||||||
|
rateTimes.put(key,now+MAXIMUM_ALLOWED_TIME_OFFSET);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal getExchangeRateLastSync(String cryptoCurrency, String fiatCurrency) {
|
||||||
|
if (!ICurrencies.NXT.equalsIgnoreCase(cryptoCurrency)) {
|
||||||
|
return null; //unsupported currency
|
||||||
|
}
|
||||||
|
OrderBookResponse orderBookResponse = api.returnOrderBook("returnOrderBook", "BTC_NXT", 10000);
|
||||||
|
if (orderBookResponse != null) {
|
||||||
|
BigDecimal[][] asks = orderBookResponse.getAsks();
|
||||||
|
BigDecimal asksTotal = BigDecimal.ZERO;
|
||||||
|
BigDecimal targetAmount = new BigDecimal(100000); //calculate price based on this amount of NXT
|
||||||
|
BigDecimal tradableLimit = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
for (int i = 0; i < asks.length; i++) {
|
||||||
|
BigDecimal[] ask = asks[i];
|
||||||
|
log.debug("ask = " + ask);
|
||||||
|
asksTotal = asksTotal.add(ask[1]);
|
||||||
|
if (targetAmount.compareTo(asksTotal) <= 0) {
|
||||||
|
tradableLimit = ask[0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("tradableLimit = " + tradableLimit);;
|
||||||
|
if (tradableLimit != null) {
|
||||||
|
BigDecimal btcRate = btcRs.getExchangeRateLast(ICurrencies.BTC, fiatCurrency);
|
||||||
|
if (btcRate != null) {
|
||||||
|
return btcRate.multiply(tradableLimit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt;
|
||||||
|
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto.AccountResponse;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto.MynxtAccountsResponse;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto.MynxtSendResponse;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto.SendResponse;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Path("/api/0.1")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public interface IMynxtWalletAPI {
|
||||||
|
@GET
|
||||||
|
@Path("/user/account")
|
||||||
|
public MynxtAccountsResponse getAllAccounts(@QueryParam("email") String email, @QueryParam("password") String password);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/nxt")
|
||||||
|
public AccountResponse getAccount(@QueryParam("email") String email, @QueryParam("password") String password, @QueryParam("account") String accountId, @DefaultValue("getAccount") @QueryParam("requestType") String requestType);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/send")
|
||||||
|
public MynxtSendResponse send(@FormParam("email") String email, @FormParam("password") String password, @FormParam("masterPassword") String masterPassword, @FormParam("accountId") String accountId, @FormParam("recipient") String recipient, @FormParam("amountNQT") BigDecimal amountNQT, @FormParam("message") String message);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/nxt")
|
||||||
|
public SendResponse send2(@QueryParam("email") String email, @QueryParam("password") String password, @QueryParam("masterPassword") String masterPassword, @QueryParam("accountId") String accountId, @QueryParam("recipient") String recipient, @QueryParam("amountNQT") BigDecimal amountNQT,@QueryParam("feeNQT") BigDecimal feeNQT, @QueryParam("deadline") long deadline, @QueryParam("requestType") String requestType);
|
||||||
|
}
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt;
|
||||||
|
|
||||||
|
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||||
|
import com.generalbytes.batm.server.extensions.IWallet;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.NXTAddressValidator;
|
||||||
|
import com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import si.mazi.rescu.RestProxyFactory;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class MynxtWallet implements IWallet{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger("batm.master.MynxtWallet");
|
||||||
|
private static final BigDecimal NQT = new BigDecimal("100000000");
|
||||||
|
private static final BigDecimal DEFAULT_FEE_IN_NXT = new BigDecimal(1);
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
private String password;
|
||||||
|
private String masterPassword;
|
||||||
|
private String accountId;
|
||||||
|
|
||||||
|
private IMynxtWalletAPI api;
|
||||||
|
|
||||||
|
public MynxtWallet(String email, String password, String masterPassword, String accountId) {
|
||||||
|
this.email = email;
|
||||||
|
this.password = password;
|
||||||
|
this.masterPassword = masterPassword;
|
||||||
|
this.accountId = accountId;
|
||||||
|
api = RestProxyFactory.createProxy(IMynxtWalletAPI.class, "https://wallet.mynxt.info");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferredCryptoCurrency() {
|
||||||
|
return ICurrencies.NXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getCryptoCurrencies() {
|
||||||
|
Set<String> result = new HashSet<String>();
|
||||||
|
result.add(ICurrencies.NXT);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCryptoAddress(String cryptoCurrency) {
|
||||||
|
if (!getCryptoCurrencies().contains(cryptoCurrency)) {
|
||||||
|
log.error("Cryptocurrency " + cryptoCurrency + " not supported.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (accountId != null) {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
MynxtAccountsResponse res = api.getAllAccounts(email, password);
|
||||||
|
if (res != null) {
|
||||||
|
if (res.getStatus().equalsIgnoreCase("success")) {
|
||||||
|
Account[] accounts = res.getData().getAccounts();
|
||||||
|
Account selectedAccount = accounts[0];
|
||||||
|
accountId = selectedAccount.getTx_account_rs();
|
||||||
|
return accountId;
|
||||||
|
}else{
|
||||||
|
log.debug("No success received: " + res.getStatus() + " " + res.getMessage());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
log.debug("No response received.");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getCryptoBalance(String cryptoCurrency) {
|
||||||
|
if (!getCryptoCurrencies().contains(cryptoCurrency)) {
|
||||||
|
log.error("Cryptocurrency " + cryptoCurrency + " not supported.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (accountId == null) {
|
||||||
|
getCryptoAddress(cryptoCurrency); //to load account_id
|
||||||
|
}
|
||||||
|
if (accountId != null) {
|
||||||
|
AccountResponse account = api.getAccount(email, password, accountId,"getAccount");
|
||||||
|
if (account != null) {
|
||||||
|
String balanceNQT = account.getBalanceNQT();
|
||||||
|
if (balanceNQT == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}else{
|
||||||
|
return new BigDecimal(balanceNQT).divide(NQT);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
log.debug("No response received.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String sendCoins(String destinationAddress, BigDecimal amount, String cryptoCurrency, String description) {
|
||||||
|
if (!getCryptoCurrencies().contains(cryptoCurrency)) {
|
||||||
|
log.error("Cryptocurrency " + cryptoCurrency + " not supported.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (accountId == null) {
|
||||||
|
getCryptoAddress(cryptoCurrency); //to load account_id
|
||||||
|
}
|
||||||
|
String accId = NXTAddressValidator.getAccountIdFromRS(accountId) +"";
|
||||||
|
String recipient = destinationAddress;
|
||||||
|
|
||||||
|
BigInteger recipientInt = NXTAddressValidator.getAccountIdFromRS(destinationAddress);
|
||||||
|
if (recipientInt != null) {
|
||||||
|
recipient = recipientInt.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
SendResponse res = api.send2(email, password, masterPassword, accId, recipient, amount.multiply(NQT), DEFAULT_FEE_IN_NXT.multiply(NQT), 1440, "sendMoney");
|
||||||
|
if (res != null) {
|
||||||
|
log.debug("Transaction " + res.getTransaction() + " sent.");
|
||||||
|
return res.getTransaction();
|
||||||
|
}else{
|
||||||
|
log.debug("No response received.");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto;
|
||||||
|
|
||||||
|
public class Account {
|
||||||
|
private String id_account;
|
||||||
|
private String tx_account_id;
|
||||||
|
private String tx_public_key;
|
||||||
|
private String bl_selected;
|
||||||
|
private String tx_label;
|
||||||
|
private String bl_active;
|
||||||
|
private String tx_account_rs;
|
||||||
|
|
||||||
|
public String getId_account() {
|
||||||
|
return id_account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId_account(String id_account) {
|
||||||
|
this.id_account = id_account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTx_account_id() {
|
||||||
|
return tx_account_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTx_account_id(String tx_account_id) {
|
||||||
|
this.tx_account_id = tx_account_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTx_label() {
|
||||||
|
return tx_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTx_label(String tx_label) {
|
||||||
|
this.tx_label = tx_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBl_active() {
|
||||||
|
return bl_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBl_active(String bl_active) {
|
||||||
|
this.bl_active = bl_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBl_selected() {
|
||||||
|
return bl_selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBl_selected(String bl_selected) {
|
||||||
|
this.bl_selected = bl_selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTx_public_key() {
|
||||||
|
return tx_public_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTx_public_key(String tx_public_key) {
|
||||||
|
this.tx_public_key = tx_public_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTx_account_rs() {
|
||||||
|
return tx_account_rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTx_account_rs(String tx_account_rs) {
|
||||||
|
this.tx_account_rs = tx_account_rs;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public class AccountResponse {
|
||||||
|
private String publicKey;
|
||||||
|
private long requestProcessingTime;
|
||||||
|
private String guaranteedBalanceNQT;
|
||||||
|
private String unconfirmedBalanceNQT;
|
||||||
|
private String forgedBalanceNQT;
|
||||||
|
private String balanceNQT;
|
||||||
|
private String accountRS;
|
||||||
|
private String account;
|
||||||
|
private BigDecimal effectiveBalanceNXT;
|
||||||
|
|
||||||
|
public String getPublicKey() {
|
||||||
|
return publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicKey(String publicKey) {
|
||||||
|
this.publicKey = publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getRequestProcessingTime() {
|
||||||
|
return requestProcessingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestProcessingTime(long requestProcessingTime) {
|
||||||
|
this.requestProcessingTime = requestProcessingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGuaranteedBalanceNQT() {
|
||||||
|
return guaranteedBalanceNQT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuaranteedBalanceNQT(String guaranteedBalanceNQT) {
|
||||||
|
this.guaranteedBalanceNQT = guaranteedBalanceNQT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnconfirmedBalanceNQT() {
|
||||||
|
return unconfirmedBalanceNQT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnconfirmedBalanceNQT(String unconfirmedBalanceNQT) {
|
||||||
|
this.unconfirmedBalanceNQT = unconfirmedBalanceNQT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getForgedBalanceNQT() {
|
||||||
|
return forgedBalanceNQT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForgedBalanceNQT(String forgedBalanceNQT) {
|
||||||
|
this.forgedBalanceNQT = forgedBalanceNQT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBalanceNQT() {
|
||||||
|
return balanceNQT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBalanceNQT(String balanceNQT) {
|
||||||
|
this.balanceNQT = balanceNQT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountRS() {
|
||||||
|
return accountRS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountRS(String accountRS) {
|
||||||
|
this.accountRS = accountRS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccount(String account) {
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getEffectiveBalanceNXT() {
|
||||||
|
return effectiveBalanceNXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEffectiveBalanceNXT(BigDecimal effectiveBalanceNXT) {
|
||||||
|
this.effectiveBalanceNXT = effectiveBalanceNXT;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto;
|
||||||
|
|
||||||
|
public class MynxtAccountsResponse extends MynxtResponse {
|
||||||
|
private Data data;
|
||||||
|
|
||||||
|
public Data getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(Data data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Data {
|
||||||
|
private Account[] accounts;
|
||||||
|
|
||||||
|
public Account[] getAccounts() {
|
||||||
|
return accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccounts(Account[] accounts) {
|
||||||
|
this.accounts = accounts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto;
|
||||||
|
|
||||||
|
public abstract class MynxtResponse {
|
||||||
|
private String status;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto;
|
||||||
|
|
||||||
|
public class MynxtSendResponse extends MynxtResponse{
|
||||||
|
private Data data;
|
||||||
|
|
||||||
|
public Data getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(Data data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Data {
|
||||||
|
private String fullHash;
|
||||||
|
private String signatureHash;
|
||||||
|
private String transactionBytes;
|
||||||
|
private String transaction;
|
||||||
|
private boolean broadcasted;
|
||||||
|
|
||||||
|
public String getFullHash() {
|
||||||
|
return fullHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFullHash(String fullHash) {
|
||||||
|
this.fullHash = fullHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignatureHash() {
|
||||||
|
return signatureHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignatureHash(String signatureHash) {
|
||||||
|
this.signatureHash = signatureHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTransactionBytes() {
|
||||||
|
return transactionBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransactionBytes(String transactionBytes) {
|
||||||
|
this.transactionBytes = transactionBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTransaction() {
|
||||||
|
return transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransaction(String transaction) {
|
||||||
|
this.transaction = transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBroadcasted() {
|
||||||
|
return broadcasted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBroadcasted(boolean broadcasted) {
|
||||||
|
this.broadcasted = broadcasted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*************************************************************************************
|
||||||
|
* Copyright (C) 2015 GENERAL BYTES s.r.o. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software may be distributed and modified under the terms of the GNU
|
||||||
|
* General Public License version 2 (GPL2) as published by the Free Software
|
||||||
|
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||||
|
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||||
|
* on this software must also be made publicly available under the terms of
|
||||||
|
* the GPL2 ("Copyleft").
|
||||||
|
*
|
||||||
|
* Contact information
|
||||||
|
* -------------------
|
||||||
|
*
|
||||||
|
* GENERAL BYTES s.r.o
|
||||||
|
* Web : http://www.generalbytes.com
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
package com.generalbytes.batm.server.extensions.extra.nxt.wallets.mynxt.dto;
|
||||||
|
|
||||||
|
public class SendResponse {
|
||||||
|
private String transaction;
|
||||||
|
|
||||||
|
public String getTransaction() {
|
||||||
|
return transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransaction(String transaction) {
|
||||||
|
this.transaction = transaction;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue