I need to add a vanity address to a local wallet that I maintain using bitcoinj APIs. I'm not able to search for the vanity using bitcoinj APIs directly, on my local PC, because my vanity is too fancy. However, I'm able to generate the pair online easily. What is the API I should use to add this key pair to my local wallet ?

I tried the following,

Say the required vanity is 1meowvYmB7ughhsRvUWfsac9LKDonh4cn (private key: 5JXFsJEAiqtTv95rSmw3KSJeAZ97SsmKWTQq5yqBzioSJ1guUHK). I generated this at bitcoinvanitygen, I converted this to hex at, Base58 Encode, Decode, and Validate. I tried the following.

Address vanity = new Address(networkParameters, networkParameters.getAddressHeader(), Hex.decode("000871DD31D517D15D7352139A44B07EBE97B1772C7F291357"));

I need to construct an Address from this string. I get the following error:

exception decoding Hex string: String index out of range: 47
  • Note: generating private keys online is very risky! Doing so may leave your funds at risk.
    – chytrik
    Oct 8, 2018 at 20:56

2 Answers 2


After searching for a while I found this type that takes a private key (in base58), required network parameters, and constructs the public address. Please refer: DumpedPrivateKey. This was enough for me at least. I construct an address from the key so formed using the toAddress method exported from the type key.

DumpedPrivateKey vanityKey = DumpedPrivateKey.fromBase58(networkParameters, "5JXFsJEAiqtTv95rSmw3KSJeAZ97SsmKWTQq5yqBzioSJ1guUHK");
ECKey ECVanityKey = vanityKey.getKey();
Address vanityAddress = ECVanityKey.toAddress(networkParameters);

At first the 'Service' you used is a common scam their are not providing splitkey generation this means, the private key you got is saved by them! Dont use this address. Use only vanity address Services with splitkeys by give it your Public key, then you got a vanity address and a partial private key, if you merge the splitkeys (privatekey of the given pubkey and partial privkey) to get the final private key! Import the private key just by open your wallet for example Bluewallet or electrum and import the final priv key! Ps: please delete the backlink to this scam read in bitcointalk about this!

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.