<p>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: <a href="https://github.com/bitcoinj/bitcoinj/blob/b9adef271957eaeaeb69b6bf08f111569b22df50/core/src/main/java/org/bitcoinj/core/DumpedPrivateKey.java#L46" rel="nofollow noreferrer">DumpedPrivateKey</a>. This was enough for me at least. I construct an address from the <code>key</code> so formed using the <code>toAddress</code> method exported from the type <code>key</code>.</p>

<pre><code>DumpedPrivateKey vanityKey = DumpedPrivateKey.fromBase58(networkParameters, "5JXFsJEAiqtTv95rSmw3KSJeAZ97SsmKWTQq5yqBzioSJ1guUHK");
ECKey ECVanityKey = vanityKey.getKey();
Address vanityAddress = ECVanityKey.toAddress(networkParameters);
</code></pre>

CC BY-SA 4.0
2018-10-09T13:45:36.960Z
2018-10-09T13:51:29.183Z
2018-10-09T13:51:29.183Z
rranjik
<p>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!</p>

CC BY-SA 4.0
2020-09-18T11:15:08.357Z
2020-09-18T11:15:08.357Z
Ƀ-Uni
<p>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 ?</p>

<p>I tried the following,</p>

<p>Say the required vanity is <code>1meowvYmB7ughhsRvUWfsac9LKDonh4cn</code> (private key: <code>5JXFsJEAiqtTv95rSmw3KSJeAZ97SsmKWTQq5yqBzioSJ1guUHK</code>). I generated this at <a href="https://bitcoinvanitygen.com" rel="nofollow noreferrer">bitcoinvanitygen</a>, I converted this to hex at, <a href="http://lenschulwitz.com/base58" rel="nofollow noreferrer">Base58 Encode, Decode, and Validate</a>. I tried the following. </p>

<pre><code>Address vanity = new Address(networkParameters, networkParameters.getAddressHeader(), Hex.decode("000871DD31D517D15D7352139A44B07EBE97B1772C7F291357"));
</code></pre>

<p>I need to construct an <code>Address</code> from this string. I get the following error:</p>

<pre><code>exception decoding Hex string: String index out of range: 47
</code></pre>

CC BY-SA 4.0
2018-10-08T20:56:10.887Z
Note: generating private keys online is *very* risky! Doing so may leave your funds at risk.
chytrik
<bitcoinj><address-generation><vanity-address>
Adding an external key pair to a local bitcoinj wallet
rranjik
# Adding an external key pair to a local bitcoinj wallet

(Asked by: username_0 on 2018-10-08)

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](https://bitcoinvanitygen.com), I converted this to hex at, [Base58 Encode, Decode, and Validate](http://lenschulwitz.com/base58). 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

```

**Tags:** bitcoinj, address-generation, vanity-address

> **Comments:**
> **username_1**: Note: generating private keys online is *very* risky! Doing so may leave your funds at risk.  

---

## 2 answers

### Answer by username_0 on 2018-10-09. Score: 1

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](https://github.com/bitcoinj/bitcoinj/blob/b9adef271957eaeaeb69b6bf08f111569b22df50/core/src/main/java/org/bitcoinj/core/DumpedPrivateKey.java#L46). 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);

```


---

### Answer by username_2 on 2020-09-18. Score: 0

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!


---

