Bitcoin Forum
June 29, 2024, 05:35:18 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Android Wallet / Bitcoin-j Question regarding "Fatal Exception"  (Read 750 times)
theh1982 (OP)
Full Member
***
Offline Offline

Activity: 138
Merit: 100

Gaelcoin - Ireland's first Crypto Currency


View Profile WWW
April 26, 2014, 09:06:37 PM
 #1

Hi all,

I'm trying to build an alt client for android and although I believe I have most parameters up and running , i'm getting the following error:

The parameters i'm using

Code:



package org.litecoin;

import com.google.bitcoin.core.*;
import com.google.bitcoin.script.Script;
import com.google.bitcoin.script.ScriptOpCodes;
import com.lambdaworks.crypto.SCrypt;
import org.spongycastle.util.encoders.Hex;

import java.io.ByteArrayOutputStream;
import java.math.BigInteger;
import java.security.GeneralSecurityException;

import static com.google.common.base.Preconditions.checkState;

/**
 * Parameters for the testnet, a separate public instance of Bitcoin that has relaxed rules suitable for development
 * and testing of applications and new Bitcoin versions.
 */
public class LitecoinParams extends NetworkParameters {
    public LitecoinParams() {
        super();
        id = "org.litecoin.production";
        proofOfWorkLimit = Utils.decodeCompactBits(0x1e0fffffL);
        addressHeader = 15;
        acceptableAddressCodes = new int[] { 48 };
        port = 12622;
        packetMagic = 0xfbc0b6dbL;
        dumpedPrivateKeyHeader = 128 + addressHeader;

        targetTimespan = (int)(6 * 8 * 60);
        interval = targetTimespan/((int)(2 * 60));

        genesisBlock.setDifficultyTarget(0x1e0ffff0L);
        genesisBlock.setTime(1394208197L);
        genesisBlock.setNonce(2085670015);
        genesisBlock.removeTransaction(0);
        Transaction t = new Transaction(this);
        try {
            // A script containing the difficulty bits and the following message:
            //
            //   "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
            byte[] bytes = Hex.decode
                    ("0497269736820756e69766572736974696573206661696c20746f206d616b65206c697374206f6620746f702031303020696e737469747574696f6e73");
            t.addInput(new TransactionInput(this, t, bytes));
            ByteArrayOutputStream scriptPubKeyBytes = new ByteArrayOutputStream();
            Script.writeBytes(scriptPubKeyBytes, Hex.decode
                    ("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9"));
            scriptPubKeyBytes.write(ScriptOpCodes.OP_CHECKSIG);
            t.addOutput(new TransactionOutput(this, t, Utils.toNanoCoins(50, 0), scriptPubKeyBytes.toByteArray()));
        } catch (Exception e) {
            // Cannot happen.
            throw new RuntimeException(e);
        }
        genesisBlock.addTransaction(t);
        String genesisHash = genesisBlock.getHashAsString();
        checkState(genesisHash.equals("3831a2c571523657ea6886293559c8751a9e8bc195a9f437febbb3df56bc55a1"),
                genesisBlock);

        subsidyDecreaseBlockCount = 450000;

        dnsSeeds = new String[] {
                "seed.gaelcoin.org",
                "pool.gaelcoin.org",

        };
    }

    private static BigInteger MAX_MONEY = Utils.COIN.multiply(BigInteger.valueOf(640000000));
    @Override
    public BigInteger getMaxMoney() { return MAX_MONEY; }

    private static LitecoinParams instance;
    public static synchronized LitecoinParams get() {
        if (instance == null) {
            instance = new LitecoinParams();
        }
        return instance;
    }

    /** The number of previous blocks to look at when calculating the next Block's difficulty */
    @Override
    public int getRetargetBlockCount(StoredBlock cursor) {
        if (cursor.getHeight() + 1 != getInterval()) {
            //Logger.getLogger("wallet_ltc").info("Normal LTC retarget");
            return getInterval();
        } else {
            //Logger.getLogger("wallet_ltc").info("Genesis LTC retarget");
            return getInterval() - 1;
        }
    }

    @Override public String getURIScheme() { return "litecoin:"; }

    /** Gets the hash of the given block for the purpose of checking its PoW */
    public Sha256Hash calculateBlockPoWHash(Block b) {
        byte[] blockHeader = b.cloneAsHeader().bitcoinSerialize();
        try {
            return new Sha256Hash(Utils.reverseBytes(SCrypt.scrypt(blockHeader, blockHeader, 1024, 1, 1, 32)));
        } catch (GeneralSecurityException e) {
            throw new RuntimeException(e);
        }
    }

    static {
        NetworkParameters.registerParams(get());
        NetworkParameters.PROTOCOL_VERSION = 70002;
    }
}


The error


Code:
04-26 21:41:03.930  25015-25015/de.schildbach.wallet_ltc E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: de.schildbach.wallet_ltc, PID: 25015
    java.lang.ExceptionInInitializerError
            at de.schildbach.wallet.Constants.<clinit>(Constants.java:42)
            at de.schildbach.wallet.WalletApplication.initLogging(WalletApplication.java:174)
            at de.schildbach.wallet.WalletApplication.onCreate(WalletApplication.java:109)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java)
            at android.app.ActivityThread.access$1500(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
            at android.os.Handler.dispatchMessage(Handler.java)
            at android.os.Looper.loop(Looper.java)
            at android.app.ActivityThread.main(ActivityThread.java)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalStateException: v1 block:
    previous block: 0000000000000000000000000000000000000000000000000000000000000000
    merkle root: 97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9
    time: [1394208197] Fri Mar 07 16:03:17 GMT+00:00 2014
    difficulty target (nBits): 504365040
    nonce: 2085670015
    with 1 transaction(s):
    97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9: Unknown confidence level.
    == COINBASE TXN (scriptSig [ffff001d] [04] [4e592054696d65732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997320566973696f6e6172792c2044696573206174203536])  (scriptPubKey [040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9] CHECKSIG)
            at com.google.common.base.Preconditions.checkState(Preconditions.java:149)
            at org.litecoin.LitecoinParams.<init>(LitecoinParams.java:72)
            at org.litecoin.LitecoinParams.get(LitecoinParams.java:91)
            at org.litecoin.LitecoinParams.<clinit>(LitecoinParams.java:121)
            ... 15 more

Any idea what i'm missing here?

Visit Gaelcoin.org - Ireland's 1st CryptoCurrency
Mike Hearn
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
April 26, 2014, 09:24:16 PM
 #2

Litecoin requires more changes than just new NetworkParameters. You should look for litecoinj.
theh1982 (OP)
Full Member
***
Offline Offline

Activity: 138
Merit: 100

Gaelcoin - Ireland's first Crypto Currency


View Profile WWW
April 26, 2014, 09:32:34 PM
 #3

Litecoin requires more changes than just new NetworkParameters. You should look for litecoinj.

Yep I know and I did do those other changes as well I believe however the error I see is referencing this particle file so wanted to know if there is something obvious that i'm missing


Visit Gaelcoin.org - Ireland's 1st CryptoCurrency
theh1982 (OP)
Full Member
***
Offline Offline

Activity: 138
Merit: 100

Gaelcoin - Ireland's first Crypto Currency


View Profile WWW
April 26, 2014, 10:02:39 PM
 #4

I figured it out, I didn't convert the original ASCII String correctly

Visit Gaelcoin.org - Ireland's 1st CryptoCurrency
HashEngineering
Sr. Member
****
Offline Offline

Activity: 350
Merit: 250

Independent Cryptoveloper


View Profile WWW
April 28, 2014, 01:20:20 AM
 #5

This issue was resolved by specifying the correct parameters for the Genesis Block.

GRS:  FrFpTbfEAni5Ruf8mNdwVQazJVJaQyEM2Y
BTC:  128Ptecsv4j6NoxdBxdvGzBtipfaAarZMJ
https://bitcointalk.org/index.php?topic=336215 - Android Wallet Creation Service
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!