diff --git a/src/main/java/io/cloudchains/app/net/CoinInstance.java b/src/main/java/io/cloudchains/app/net/CoinInstance.java index 54063b4..0ff322e 100644 --- a/src/main/java/io/cloudchains/app/net/CoinInstance.java +++ b/src/main/java/io/cloudchains/app/net/CoinInstance.java @@ -24,6 +24,7 @@ //import io.cloudchains.app.net.protocols.poliscoin.PoliscoinNetworkParameters; //import io.cloudchains.app.net.protocols.ravencoin.RavencoinNetworkParameters; import io.cloudchains.app.net.protocols.syscoin.SyscoinNetworkParameters; +import io.cloudchains.app.net.protocols.unobtanium.UnobtaniumNetworkParameters; //import io.cloudchains.app.net.protocols.trezarcoin.TrezarcoinNetworkParameters; import io.cloudchains.app.net.xrouter.XRouterMessage; import io.cloudchains.app.net.xrouter.XRouterMessageSerializer; @@ -426,6 +427,12 @@ public CoinError init(String pw, String userMnemonic, boolean isMnemonic, boolea // rpcPort = 8766; // break; // } + case UNOBTANIUM: { + LOGGER.log(Level.FINER, "[coin] Initializing for Unobtanium main network."); + networkParameters = new UnobtaniumNetworkParameters(); + rpcPort = 65535; + break; + } default: { LOGGER.log(Level.FINER, "[coin] ERROR: Invalid/unsupported network: " + ticker.toString()); return new CoinError("Unsupported coin", CoinError.CoinErrorCode.UNSUPPORTEDCOIN); diff --git a/src/main/java/io/cloudchains/app/net/CoinTicker.java b/src/main/java/io/cloudchains/app/net/CoinTicker.java index 0767012..391cc84 100644 --- a/src/main/java/io/cloudchains/app/net/CoinTicker.java +++ b/src/main/java/io/cloudchains/app/net/CoinTicker.java @@ -20,7 +20,8 @@ public enum CoinTicker { POLISCOIN, PHORECOIN, RAVENCOIN, - BITBAY + BITBAY, + UNOBTANIUM ; /** @@ -39,7 +40,8 @@ public static List coins() { DOGECOIN, // TREZARCOIN, - not support on backend SYSCOIN, - PIVX + PIVX, + UNOBTANIUM // ALQOCOIN, - not support on backend // POLISCOIN, - not support on backend // PHORECOIN, - not support on backend diff --git a/src/main/java/io/cloudchains/app/net/CoinTickerUtils.java b/src/main/java/io/cloudchains/app/net/CoinTickerUtils.java index 72fe53f..e5a9aa7 100644 --- a/src/main/java/io/cloudchains/app/net/CoinTickerUtils.java +++ b/src/main/java/io/cloudchains/app/net/CoinTickerUtils.java @@ -32,6 +32,7 @@ public class CoinTickerUtils { // tickers.put(CoinTicker.PHORECOIN, "PHR"); tickers.put(CoinTicker.TREZARCOIN, "TZC"); tickers.put(CoinTicker.BITBAY, "BAY"); + tickers.put(CoinTicker.UNOBTANIUM, "UNO"); } public static String tickerToString(CoinTicker ticker) { diff --git a/src/main/java/io/cloudchains/app/net/api/http/server/HTTPServerHandler.java b/src/main/java/io/cloudchains/app/net/api/http/server/HTTPServerHandler.java index a563efe..3abf1a1 100644 --- a/src/main/java/io/cloudchains/app/net/api/http/server/HTTPServerHandler.java +++ b/src/main/java/io/cloudchains/app/net/api/http/server/HTTPServerHandler.java @@ -1506,6 +1506,10 @@ private byte[] formatMessageForSigning(String message) { case SYSCOIN: header = "Syscoin Signed Message:\n"; break; + case UNOBTANIUM: + header = "Unobtanium Signed Message:\n"; + break; + default: LOGGER.log(Level.FINER, "[http-server-handler] ERROR: Unsupported coin. This should never happen."); break; diff --git a/src/main/java/io/cloudchains/app/net/protocols/unobtanium/UnobtaniumNetworkParameters.java b/src/main/java/io/cloudchains/app/net/protocols/unobtanium/UnobtaniumNetworkParameters.java new file mode 100644 index 0000000..2cb71b8 --- /dev/null +++ b/src/main/java/io/cloudchains/app/net/protocols/unobtanium/UnobtaniumNetworkParameters.java @@ -0,0 +1,103 @@ +package io.cloudchains.app.net.protocols.unobtanium; + +import org.bitcoinj.core.*; +import org.bitcoinj.store.BlockStore; +import org.bitcoinj.store.BlockStoreException; +import org.bitcoinj.utils.MonetaryFormat; + +public class UnobtaniumNetworkParameters extends NetworkParameters { + + public UnobtaniumNetworkParameters() { + super(); + } + + @Override + public String getPaymentProtocolId() { + return PAYMENT_PROTOCOL_ID_MAINNET; + } + + @Override + public void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException { + // Adapt this method if needed for UNO + } + + @Override + public Coin getMaxMoney() { + return MAX_MONEY; + } + + @Override + public Coin getMinNonDustOutput() { + return Transaction.MIN_NONDUST_OUTPUT; + } + + @Override + public MonetaryFormat getMonetaryFormat() { + return new MonetaryFormat().code(0, "UNO"); + } + + @Override + public String getUriScheme() { + return "unobtanium:"; + } + + @Override + public boolean hasMaxMoney() { + return true; + } + + @Override + public BitcoinSerializer getSerializer(boolean parseRetain) { + return new BitcoinSerializer(this, parseRetain); + } + + @Override + public int getProtocolVersionNum(final ProtocolVersion version) { + return version.getBitcoinProtocolVersion(); + } + + @Override + public int getAddressHeader() { + return 130; + } + + @Override + public int getP2SHHeader() { + return 30; + } + + @Override + public int getDumpedPrivateKeyHeader() { + return 224; + } + + @Override + public int[] getAcceptableAddressCodes() { + return new int[]{getAddressHeader(), getP2SHHeader()}; + } + + @Override + public int getBip32HeaderPriv() { + return 0x0488ADE4; + } + + @Override + public int getBip32HeaderPub() { + return 0x0488B21E; + } + + @Override + public int getSubsidyDecreaseBlockCount() { + return 100000; // Adjusted for UNO + } + + @Override + public int getInterval() { + return INTERVAL; + } + + @Override + public String getId() { + return "UNO"; + } +}