Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring UNO #21

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/java/io/cloudchains/app/net/CoinInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/cloudchains/app/net/CoinTicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public enum CoinTicker {
POLISCOIN,
PHORECOIN,
RAVENCOIN,
BITBAY
BITBAY,
UNOBTANIUM
;

/**
Expand All @@ -39,7 +40,8 @@ public static List<CoinTicker> 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
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/cloudchains/app/net/CoinTickerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}
}
Loading