From c1b28fbef25732bc0e5614374965a10d14b1fe1f Mon Sep 17 00:00:00 2001 From: b00lean Date: Tue, 16 Feb 2016 09:06:19 +0100 Subject: [PATCH] BATM: Added support for plugable watchlists --- .../batm/server/extensions/IExtension.java | 17 ++++++ .../extensions/watchlist/IWatchList.java | 59 ++++++++++++++++++ .../extensions/watchlist/WatchListMatch.java | 56 +++++++++++++++++ .../extensions/watchlist/WatchListQuery.java | 60 +++++++++++++++++++ .../extensions/watchlist/WatchListResult.java | 57 ++++++++++++++++++ .../extra/bitcoin/BitcoinExtension.java | 10 ++++ .../extra/dogecoin/DogecoinExtension.java | 10 ++++ .../groestlcoin/GroestlcoinExtension.java | 10 ++++ .../extra/guldencoin/GuldencoinExtension.java | 10 ++++ .../incognitocoin/IncognitocoinExtension.java | 10 ++++ .../extra/leocoin/LeocoinExtension.java | 10 ++++ .../extra/litecoin/LitecoinExtension.java | 10 ++++ .../extra/maxcoin/MaxcoinExtension.java | 10 ++++ .../extra/nubits/NubitsExtension.java | 11 ++++ .../extensions/extra/nxt/NXTExtension.java | 11 ++++ 15 files changed, 351 insertions(+) create mode 100644 server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/IWatchList.java create mode 100644 server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListMatch.java create mode 100644 server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListQuery.java create mode 100644 server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListResult.java diff --git a/server_extensions_api/src/com/generalbytes/batm/server/extensions/IExtension.java b/server_extensions_api/src/com/generalbytes/batm/server/extensions/IExtension.java index dba39f9..4b166fd 100644 --- a/server_extensions_api/src/com/generalbytes/batm/server/extensions/IExtension.java +++ b/server_extensions_api/src/com/generalbytes/batm/server/extensions/IExtension.java @@ -18,6 +18,8 @@ package com.generalbytes.batm.server.extensions; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; + import java.util.Set; /** @@ -92,4 +94,19 @@ public interface IExtension { */ public IPaperWalletGenerator createPaperWalletGenerator(String cryptoCurrency); + /** + * Returns the list of watchlists that extenstion contains + * @return + */ + public Set getSupportedWatchLists(); + + + /** + * Returns watchlist by name + * @param name + * @return + */ + public IWatchList getWatchList(String name); + + } diff --git a/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/IWatchList.java b/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/IWatchList.java new file mode 100644 index 0000000..d614bf0 --- /dev/null +++ b/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/IWatchList.java @@ -0,0 +1,59 @@ +/************************************************************************************* + * Copyright (C) 2014-2016 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.watchlist; + +/** + * This class defines basic interface which every watchlist sould conform to + */ +public interface IWatchList { + public static final int LIST_NOT_CHANGED = 0; + public static final int LIST_CHANGED = 1; + public static final int LIST_REFRESH_FAILED = 2; + + /** + * Unique name of the watchlist + * @return + */ + public String getName(); + + /** + * Short description of the watchlist. For instance link to a website containing more information about the watchlist data + * @return + */ + public String getDescription(); + + /** + * Performs the re-download of the watchlist from the remote side @see LIST_NOT_CHANGED or LIST_CHANGED or LIST_REFRESH_FAILED if download fails. + * @return + */ + public int refresh(); + + /** + * This method returns number of recommended minutes for which the watchlist is considered valid. After this period method refresh() should be called again. + * @return + */ + public int recommendedRefreshPeriodInMins(); + + /** + * This method is used to query the watchlist for results + * @param query + * @return + */ + public WatchListResult search(WatchListQuery query); + +} diff --git a/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListMatch.java b/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListMatch.java new file mode 100644 index 0000000..b44b083 --- /dev/null +++ b/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListMatch.java @@ -0,0 +1,56 @@ +/************************************************************************************* + * Copyright (C) 2014-2016 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.watchlist; + +import java.io.Serializable; + + +public class WatchListMatch implements Serializable{ + private int score; + private String details; + private String matchedWatchListName; + + + public WatchListMatch(int score, String details, String matchedWatchListName) { + this.score = score; + this.details = details; + this.matchedWatchListName = matchedWatchListName; + } + + public int getScore() { + return score; + } + + public String getDetails() { + return details; + } + + public String getMatchedWatchListName() { + return matchedWatchListName; + } + + @Override + public String toString() { + return "WatchlistMatch{" + + "score=" + score + + ", details='" + details + '\'' + + ", matchedWatchListName=" + matchedWatchListName + + '}'; + } +} diff --git a/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListQuery.java b/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListQuery.java new file mode 100644 index 0000000..b533212 --- /dev/null +++ b/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListQuery.java @@ -0,0 +1,60 @@ +/************************************************************************************* + * Copyright (C) 2014-2016 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.watchlist; + +import java.io.Serializable; + + +public class WatchListQuery implements Serializable{ + public static final int TYPE_INDIVIDUAL = 0; + public static final int TYPE_ENTITY = 1; + + private int type = TYPE_INDIVIDUAL; + private String name; + private String firstName; + private String lastName; + + + public WatchListQuery(String name) { + this.type = TYPE_ENTITY; + this.name = name; + } + + public WatchListQuery(String firstName, String lastName) { + this.type = TYPE_INDIVIDUAL; + this.firstName = firstName; + this.lastName = lastName; + } + + public int getType() { + return type; + } + + public String getName() { + return name; + } + + public String getLastName() { + return lastName; + } + + public String getFirstName() { + return firstName; + } +} diff --git a/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListResult.java b/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListResult.java new file mode 100644 index 0000000..a7cc230 --- /dev/null +++ b/server_extensions_api/src/com/generalbytes/batm/server/extensions/watchlist/WatchListResult.java @@ -0,0 +1,57 @@ +/************************************************************************************* + * Copyright (C) 2014-2016 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.watchlist; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class WatchListResult implements Serializable{ + public static final int RESULT_TYPE_WATCHLIST_SEARCHED = 0; + public static final int RESULT_TYPE_WATCHLIST_NOT_READY = 1; + + private int resultType = RESULT_TYPE_WATCHLIST_NOT_READY; + private List matches = new ArrayList(); + + + public WatchListResult(int resultType) { + this.resultType = resultType; + } + + public WatchListResult(List matches) { + this.matches = matches; + this.resultType=RESULT_TYPE_WATCHLIST_SEARCHED; + } + + public List getMatches() { + return matches; + } + + public int getResultType() { + return resultType; + } + + @Override + public String toString() { + return "WatchListResult{" + + "resultType=" + resultType + + ", matches=" + matches + + '}'; + } +} diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java index b3affae..88cb9b1 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java @@ -27,6 +27,7 @@ import com.generalbytes.batm.server.extensions.extra.bitcoin.sources.FixPriceRat import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitcoind.BATMBitcoindRPCWallet; import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitcore.BitcoreWallet; import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.coinkite.CoinkiteWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.*; @@ -180,4 +181,13 @@ public class BitcoinExtension implements IExtension{ return result; } + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/dogecoin/DogecoinExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/dogecoin/DogecoinExtension.java index 119965f..1b42f05 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/dogecoin/DogecoinExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/dogecoin/DogecoinExtension.java @@ -22,6 +22,7 @@ import com.generalbytes.batm.server.extensions.extra.dogecoin.sources.FixPriceRa import com.generalbytes.batm.server.extensions.extra.dogecoin.sources.chainso.ChainSoRateSource; import com.generalbytes.batm.server.extensions.extra.dogecoin.wallets.blockio.BlockIOWallet; import com.generalbytes.batm.server.extensions.extra.dogecoin.wallets.dogecoind.DogecoindRPCWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.*; @@ -122,4 +123,13 @@ public class DogecoinExtension implements IExtension{ return result; } + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/groestlcoin/GroestlcoinExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/groestlcoin/GroestlcoinExtension.java index 4f58e57..fefaaf8 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/groestlcoin/GroestlcoinExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/groestlcoin/GroestlcoinExtension.java @@ -21,6 +21,7 @@ import com.generalbytes.batm.server.extensions.*; import com.generalbytes.batm.server.extensions.extra.groestlcoin.sources.FixPriceRateSource; import com.generalbytes.batm.server.extensions.extra.groestlcoin.sources.GroestlcoinTickerRateSource; import com.generalbytes.batm.server.extensions.extra.groestlcoin.wallets.groestlcoind.GroestlcoindRPCWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.HashSet; @@ -122,4 +123,13 @@ public class GroestlcoinExtension implements IExtension{ return result; } + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/guldencoin/GuldencoinExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/guldencoin/GuldencoinExtension.java index 1152c8d..7a5145d 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/guldencoin/GuldencoinExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/guldencoin/GuldencoinExtension.java @@ -21,6 +21,7 @@ import com.generalbytes.batm.server.extensions.*; import com.generalbytes.batm.server.extensions.extra.guldencoin.sources.FixPriceRateSource; import com.generalbytes.batm.server.extensions.extra.guldencoin.sources.GuldencoinTickerRateSource; import com.generalbytes.batm.server.extensions.extra.guldencoin.wallets.guldencoind.GuldencoindRPCWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.HashSet; @@ -122,4 +123,13 @@ public class GuldencoinExtension implements IExtension{ return result; } + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/incognitocoin/IncognitocoinExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/incognitocoin/IncognitocoinExtension.java index 7f6c1ad..b97a035 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/incognitocoin/IncognitocoinExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/incognitocoin/IncognitocoinExtension.java @@ -20,6 +20,7 @@ package com.generalbytes.batm.server.extensions.extra.incognitocoin; import com.generalbytes.batm.server.extensions.*; import com.generalbytes.batm.server.extensions.extra.incognitocoin.sources.FixPriceRateSource; import com.generalbytes.batm.server.extensions.extra.incognitocoin.wallets.incognitocoind.IncognitocoindRPCWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.HashSet; @@ -116,4 +117,13 @@ public class IncognitocoinExtension implements IExtension{ return result; } + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/leocoin/LeocoinExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/leocoin/LeocoinExtension.java index 33b4580..9a2163f 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/leocoin/LeocoinExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/leocoin/LeocoinExtension.java @@ -20,6 +20,7 @@ package com.generalbytes.batm.server.extensions.extra.leocoin; import com.generalbytes.batm.server.extensions.*; import com.generalbytes.batm.server.extensions.extra.leocoin.sources.FixPriceRateSource; import com.generalbytes.batm.server.extensions.extra.leocoin.wallets.leocoind.LeocoindRPCWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.HashSet; @@ -117,4 +118,13 @@ public class LeocoinExtension implements IExtension{ return result; } + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/litecoin/LitecoinExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/litecoin/LitecoinExtension.java index 3e92223..a9a29be 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/litecoin/LitecoinExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/litecoin/LitecoinExtension.java @@ -22,6 +22,7 @@ import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.coinkite.Co import com.generalbytes.batm.server.extensions.extra.litecoin.sources.FixPriceRateSource; import com.generalbytes.batm.server.extensions.extra.litecoin.sources.btce.BTCeRateSource; import com.generalbytes.batm.server.extensions.extra.litecoin.wallets.litecoind.LitecoindRPCWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.*; @@ -128,4 +129,13 @@ public class LitecoinExtension implements IExtension{ return result; } + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/maxcoin/MaxcoinExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/maxcoin/MaxcoinExtension.java index 9264e9f..190f85d 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/maxcoin/MaxcoinExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/maxcoin/MaxcoinExtension.java @@ -21,6 +21,7 @@ import com.generalbytes.batm.server.extensions.*; import com.generalbytes.batm.server.extensions.extra.maxcoin.sources.FixPriceRateSource; import com.generalbytes.batm.server.extensions.extra.maxcoin.sources.MaxcoinTickerRateSource; import com.generalbytes.batm.server.extensions.extra.maxcoin.wallets.maxcoind.MaxcoindRPCWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.HashSet; @@ -119,4 +120,13 @@ public class MaxcoinExtension implements IExtension{ return result; } + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/nubits/NubitsExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/nubits/NubitsExtension.java index d3dc8ba..6e3386d 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/nubits/NubitsExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/nubits/NubitsExtension.java @@ -4,6 +4,7 @@ import com.generalbytes.batm.server.extensions.*; import com.generalbytes.batm.server.extensions.extra.nubits.NubitsAddressValidator; import com.generalbytes.batm.server.extensions.extra.nubits.sources.FixPriceRateSource; import com.generalbytes.batm.server.extensions.extra.nubits.wallets.nud.NubitsRPCWallet; +import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.HashSet; @@ -98,4 +99,14 @@ public class NubitsExtension implements IExtension{ result.add(ICurrencies.NBT); return result; } + + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } } diff --git a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/nxt/NXTExtension.java b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/nxt/NXTExtension.java index 13871c0..c9c7451 100644 --- a/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/nxt/NXTExtension.java +++ b/server_extensions_extra/src/com/generalbytes/batm/server/extensions/extra/nxt/NXTExtension.java @@ -22,6 +22,7 @@ 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 com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.math.BigDecimal; import java.util.HashSet; @@ -116,4 +117,14 @@ public class NXTExtension implements IExtension{ result.add(ICurrencies.NXT); return result; } + + @Override + public Set getSupportedWatchLists() { + return null; + } + + @Override + public IWatchList getWatchList(String name) { + return null; + } }