0

I've created a crypto-currency wallet for Bitcoin using BitcoinJ. Now I want to add Litecoin in this wallet. How to implement BitcoinJ dependency for Litecoin? While using BitcoinJ for both Litecoin and Bitcoin, I was getting blockchain of Bitcoin for both the addresses. What should I do so that I can get Bicoin blockchain for Bitcoin address and Litecoin blockchain for Litecoin address?

here is dependency which is I used>>>

  implementation 'org.bitcoinj:bitcoinj-core:0.14.7'

here is my code for bitcoin blockchain download initialisation>>>

  public void initWallet() {
    ECKey key;
    String btcpri = 
     "cxxxxxre75ENAnpGjUr8EEdP2kxtvk1r65nTydnM954n4WxxxxxM";
    if (btcpri.length() == 51 || btcpri.length() == 52) {
        DumpedPrivateKey dumpedPrivateKey = 
        DumpedPrivateKey.fromBase58(params, btcpri);
        key = dumpedPrivateKey.getKey();
    } else {
        BigInteger privKey = Base58.decodeToBigInteger(btcpri);
        key = ECKey.fromPrivate(privKey);
    }
    Log.e("key ", String.valueOf(key));
    setBtcSDKThread();
    BriefLogFormatter.init();

    kit = new WalletAppKit(params, file, "btc_justbitcoin") {
        @Override
        protected void onSetupCompleted() {
            wallet().importKey(key);
            setupWalletListeners(wallet());
            Log.e("Address ", 
            String.valueOf(wallet().freshReceiveAddress()));
        }
    };
    kit.setBlockingStartup(false);
    kit.startAsync();
    kit.awaitRunning();
 }
6
  • Can you show the definition of params variable? You will need to make a Litecoin version of the params so it has all of the Litecoin parameters. Then create another WalletAppKit using those new params.
    – JBaczuk
    Commented Aug 25, 2018 at 14:39
  • See github.com/litecoin-project/litecoinj/blob/master/src/main/java/… for an example.
    – JBaczuk
    Commented Aug 25, 2018 at 14:45
  • here is my variable params is NetworkParameters params = TestNet3Params.get();
    – Sid009
    Commented Aug 26, 2018 at 13:14
  • @JBaczuk how to use this in android studio [github.com/litecoin-project/litecoinj/blob/master/pom.xml]
    – Sid009
    Commented Aug 27, 2018 at 5:43
  • I was trying to use this dependancy but it didn't implement in my project implementation 'org.bitcoinj:bitcoinj-core:0.13-alice-SNAPSHOT'
    – Sid009
    Commented Aug 27, 2018 at 5:45

1 Answer 1

0

use an alternative library to me I like this gives you more flexibility and uses bitcoinj

https://github.com/dogecoin/libdohj

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.