From 876a69a59c77d4cb073dd1aba31e5fc4418bf5e2 Mon Sep 17 00:00:00 2001 From: Martin Lechner Date: Thu, 18 Aug 2016 12:37:27 +0200 Subject: [PATCH] BPUB-71: Block.io wallet should have support for mining fee priority --- .../server_extensions_extra.iml | 121 ++++++++++++++++++ .../extra/dogecoin/DogecoinExtension.java | 7 +- .../wallets/blockio/BlockIOWallet.java | 22 +++- .../dogecoin/wallets/blockio/IBlockIO.java | 15 +-- .../src/main/resources/batm-extensions.xml | 1 + 5 files changed, 154 insertions(+), 12 deletions(-) create mode 100644 server_extensions_extra/server_extensions_extra.iml diff --git a/server_extensions_extra/server_extensions_extra.iml b/server_extensions_extra/server_extensions_extra.iml new file mode 100644 index 0000000..e2690cd --- /dev/null +++ b/server_extensions_extra/server_extensions_extra.iml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/DogecoinExtension.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/DogecoinExtension.java index 5f941b8..0785f4b 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/DogecoinExtension.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/DogecoinExtension.java @@ -52,7 +52,12 @@ public class DogecoinExtension implements IExtension{ if ("blockio".equalsIgnoreCase(walletType)) { String apikey = st.nextToken(); String pin = st.nextToken(); - return new BlockIOWallet(apikey,pin); + String priority = null; + if (st.hasMoreTokens()) { + priority = st.nextToken(); + } + return new BlockIOWallet(apikey,pin, priority); + }else if ("dogecoind".equalsIgnoreCase(walletType)) { //"dogecoind:protocol:user:password:ip:port:accountname" diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/wallets/blockio/BlockIOWallet.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/wallets/blockio/BlockIOWallet.java index 7bb3d88..93b1fc7 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/wallets/blockio/BlockIOWallet.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/wallets/blockio/BlockIOWallet.java @@ -8,18 +8,36 @@ import si.mazi.rescu.RestProxyFactory; import java.math.BigDecimal; import java.util.*; +import static com.generalbytes.batm.server.extensions.extra.dogecoin.wallets.blockio.IBlockIO.PRIORITY_HIGH; +import static com.generalbytes.batm.server.extensions.extra.dogecoin.wallets.blockio.IBlockIO.PRIORITY_LOW; +import static com.generalbytes.batm.server.extensions.extra.dogecoin.wallets.blockio.IBlockIO.PRIORITY_MEDIUM; + /** * Created by b00lean on 8/11/14. */ public class BlockIOWallet implements IWallet { private String apiKey; private String pin; + private String priority; private IBlockIO api; - public BlockIOWallet(String apiKey, String pin) { + public BlockIOWallet(String apiKey, String pin, String priority) { this.apiKey = apiKey; this.pin = pin; + if (priority == null) { + this.priority = PRIORITY_LOW; + } else if (PRIORITY_LOW.equalsIgnoreCase(priority.trim())) { + this.priority = PRIORITY_LOW; + } + else if (PRIORITY_MEDIUM.equalsIgnoreCase(priority.trim())) { + this.priority = PRIORITY_MEDIUM; + } + else if (PRIORITY_HIGH.equalsIgnoreCase(priority.trim())) { + this.priority = PRIORITY_HIGH; + } else { + this.priority = PRIORITY_LOW; + } api = RestProxyFactory.createProxy(IBlockIO.class, "https://block.io"); } @@ -78,7 +96,7 @@ public class BlockIOWallet implements IWallet { return null; } try { - BlockIOResponseWithdrawal response = api.withdraw(apiKey, pin, amount.toPlainString(), destinationAddress); + BlockIOResponseWithdrawal response = api.withdraw(apiKey, pin, amount.toPlainString(), destinationAddress, priority); if (response != null && response.getStatus() != null && "success".equalsIgnoreCase(response.getStatus()) && response.getData() != null && response.getData().getTxid() !=null) { return response.getData().getTxid(); } diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/wallets/blockio/IBlockIO.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/wallets/blockio/IBlockIO.java index 811d201..afef2fc 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/wallets/blockio/IBlockIO.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/dogecoin/wallets/blockio/IBlockIO.java @@ -6,15 +6,13 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -/** - * Created by b00lean on 8/11/14. - */ @Path("/api/v2/") @Produces(MediaType.APPLICATION_JSON) public interface IBlockIO { - public static final String PRIORITY_LOW = "low"; - public static final String PRIORITY_MEDIUM = "medium"; - public static final String PRIORITY_HIGH = "high"; + + String PRIORITY_LOW = "low"; + String PRIORITY_MEDIUM = "medium"; + String PRIORITY_HIGH = "high"; @GET @Path("get_my_addresses/?api_key={apikey}") @@ -25,7 +23,6 @@ public interface IBlockIO { BlockIOResponseBalance getBalance(@PathParam("apikey") String apikey); @GET - @Path("withdraw/?api_key={apikey}&amounts={amount}&to_addresses={payment_address}&pin={pin}") - BlockIOResponseWithdrawal withdraw(@PathParam("apikey") String apikey, @PathParam("pin") String pin, @PathParam("amount") String amount, @PathParam("payment_address") String payment_address); - + @Path("withdraw/?api_key={apikey}&amounts={amount}&to_addresses={payment_address}&pin={pin}&priority={priority}") + BlockIOResponseWithdrawal withdraw(@PathParam("apikey") String apikey, @PathParam("pin") String pin, @PathParam("amount") String amount, @PathParam("payment_address") String payment_address, @PathParam("priority") String priority); } diff --git a/server_extensions_extra/src/main/resources/batm-extensions.xml b/server_extensions_extra/src/main/resources/batm-extensions.xml index 94f28ee..7ef8779 100644 --- a/server_extensions_extra/src/main/resources/batm-extensions.xml +++ b/server_extensions_extra/src/main/resources/batm-extensions.xml @@ -68,6 +68,7 @@ + DOGE BTC LTC