<p>In bitcoinj, there is a check that indicates an error if the private key is 0 or 1. The above private key is 1, so it is an error.</p>
<p><a href="https://github.com/bitcoinj/bitcoinj/blob/04378aa6389deb5143f66cf2ab0abec52dc9d394/core/src/main/java/org/bitcoinj/core/ECKey.java#L190-L194" rel="nofollow noreferrer">https://github.com/bitcoinj/bitcoinj/blob/04378aa6389deb5143f66cf2ab0abec52dc9d394/core/src/main/java/org/bitcoinj/core/ECKey.java#L190-L194</a></p>

CC BY-SA 4.0
2021-11-29T07:04:00.853Z
Thanks a lot.  My task turned out to be very successful Undecided

I am trying to generate these keys
https://keys.lol/bitcoin/407532363493837873358792558699156305516644599981797776434520630335882679096

and get the corresponding addresses. They all knock out a bug.

Maybe there is some way to hardcode and get these addresses without libraries?
Samanta Fox
CC BY-SA 4.0
2021-11-30T13:27:48.323Z
It's not impossible if you implement what the library does on your own, but it's easy to use.
Shigeyuki Azuchi
CC BY-SA 4.0
2021-11-29T03:19:26.480Z
2021-11-29T03:19:26.480Z
Shigeyuki Azuchi
<p>I use Java and bitcoinj. I have a private key</p>
<pre><code>String str=&quot;5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf&quot;;
</code></pre>
<p>I try to get compress and decompress 2 adresses in this format:</p>
<pre><code>1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm  1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
</code></pre>
<p>I do the first step, try get ECKey:</p>
<pre><code>NetworkParameters params = MainNetParams.get();
      ECKey key;

      if (str.length() == 51 || str.length() == 52) {
          DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, str);
          key = dumpedPrivateKey.getKey();            //ERROR
      } else {
          BigInteger privKey = Base58.decodeToBigInteger(str);
          key = ECKey.fromPrivate(privKey);
      }
.
.
.
</code></pre>
<p>and I get an exception:</p>
<pre><code>Exception in thread &quot;main&quot; java.lang.IllegalArgumentException
   at com.google.common.base.Preconditions.checkArgument(Preconditions.java:128)
   at org.bitcoinj.core.ECKey.&lt;init&gt;(ECKey.java:195)
   at org.bitcoinj.core.ECKey.fromPrivate(ECKey.java:243)
   at org.bitcoinj.core.ECKey.fromPrivate(ECKey.java:259)
   at org.bitcoinj.core.DumpedPrivateKey.getKey(DumpedPrivateKey.java:101)
   at com.example.demo2.controllers.AdressFromKey.main(AdressFromKey.java:35)
</code></pre>
<p>What am I doing wrong?</p>

<java>
How I can get all adresses from WIF private key?
Samanta Fox
# How I can get all adresses from WIF private key?

(Asked by: username_0 on 2021-11-28)

I use Java and bitcoinj. I have a private key

```
String str="5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf";

```

I try to get compress and decompress 2 adresses in this format:

```
1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm  1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH

```

I do the first step, try get ECKey:

```
NetworkParameters params = MainNetParams.get();
      ECKey key;

      if (str.length() == 51 || str.length() == 52) {
          DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, str);
          key = dumpedPrivateKey.getKey();            //ERROR
      } else {
          BigInteger privKey = Base58.decodeToBigInteger(str);
          key = ECKey.fromPrivate(privKey);
      }
.
.
.

```

and I get an exception:

```
Exception in thread "main" java.lang.IllegalArgumentException
   at com.google.common.base.Preconditions.checkArgument(Preconditions.java:128)
   at org.bitcoinj.core.ECKey.<init>(ECKey.java:195)
   at org.bitcoinj.core.ECKey.fromPrivate(ECKey.java:243)
   at org.bitcoinj.core.ECKey.fromPrivate(ECKey.java:259)
   at org.bitcoinj.core.DumpedPrivateKey.getKey(DumpedPrivateKey.java:101)
   at com.example.demo2.controllers.AdressFromKey.main(AdressFromKey.java:35)

```

What am I doing wrong?

**Tags:** java


---

## 1 answers

### Answer by username_1 on 2021-11-29. Score: 1

In bitcoinj, there is a check that indicates an error if the private key is 0 or 1. The above private key is 1, so it is an error.

<https://github.com/bitcoinj/bitcoinj/blob/04378aa6389deb5143f66cf2ab0abec52dc9d394/core/src/main/java/org/bitcoinj/core/ECKey.java#L190-L194>

> **Comments:**
> **username_0**: Thanks a lot.  My task turned out to be very successful Undecided  I am trying to generate these keys https://keys.lol/bitcoin/407532363493837873358792558699156305516644599981797776434520630335882679096  and get the corresponding addresses. They all knock out a bug.  Maybe there is some way to hardcode and get these addresses without libraries?  
> **username_1**: It's not impossible if you implement what the library does on your own, but it's easy to use.  

---

