1

currently i am using bitcoinj library to create wallet for both Main-net and Test-net using Mnemonic code(Mnemonic Code is different for both), my question is can i create both Wallets(Test-net and Main-net) using one Mnemonic Code, if yes, then how?

1 Answer 1

1

Yes. You can create Mainnet and Testnet wallets using one Mnemonic Code.
Here is an example to switch networks.

> java HelloWorld testnet
> mrbZfHK4MuJYEH98w7gENLsrfnY1e4Lq8B

> java HelloWorld mainnet
> 1C5cNEE5YssHTAfXDYhrYRfXonwJe2u1Wf

.

public class HelloWorld {

    public static void main(String[] args){

        String seedCode = "yard impulse luxury drive today throw farm pepper survey wreck glass federal";
        long creationtime = 1409478661L;
        DeterministicSeed seed = null;
        try {
            seed = new DeterministicSeed(seedCode,null,"",creationtime);
        } catch (UnreadableWalletException e) {
            e.printStackTrace();
        }

        NetworkParameters params;
        if (args[0].equals("testnet")) {
            params = TestNet3Params.get();
        } else {
            params = MainNetParams.get();
        }
        Wallet wallet = Wallet.fromSeed(params, seed);
        Address address = wallet.currentReceiveAddress();
        System.out.println(address);

    }
}

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.