<p>Try <a href="https://github.com/bitcoinjs/bitcoinjs-lib" rel="nofollow noreferrer">bitcoinjs-lib</a></p>

<p>The following will generate a <code>P2SH(P2WPKH)</code> address</p>

<pre><code>const bitcoin = require('bitcoinjs-lib')

let ecpair = bitcoin.ECPair.fromWIF('L34XqVbrw1VSHsiavdpm4QGTRrFyH7RKAp7SFYf36gYcyLX2ieWi')
let address = bitcoin.payments.p2sh({redeem: bitcoin.payments.p2wpkh({ pubkey: ecpair.publicKey })}).address

&gt; '3F1JMjuxgNFuK4kBxv4JXMEdQ2yvjuz939'
</code></pre>

CC BY-SA 4.0
2019-02-08T21:52:08.960Z
2019-02-08T21:57:12.330Z
2019-02-08T21:57:12.330Z
JBaczuk
<p>I'm building an js related application that only stores my user's bitcoin private keys, but not the public key or bitcoin address to save space.</p>

<p>Is there a javascript library that can output the bitcoin address by only providing the bitcoin private key as an input?</p>

CC BY-SA 4.0
2019-02-08T21:23:51.147Z
You’re using javascript, but are concerned about storing tens of bytes?
Claris
CC BY-SA 4.0
2019-02-08T21:48:07.070Z
I need it to be as compact as possible due to storage constraint. If i can derive the bitcoin address from the private key, great. I'm using very low bandwidth communications, every byte saved is time saved.
Patoshi パトシ
CC BY-SA 4.0
2019-02-08T21:53:30.883Z
be careful sending private keys over the air.
JBaczuk
<address><private-key><javascript>
Using only Javascript and JS related Bitcoin Libraries. How do you extract the Bitcoin Address from a private key?
Patoshi パトシ
# Using only Javascript and JS related Bitcoin Libraries. How do you extract the Bitcoin Address from a private key?

(Asked by: username_0 on 2019-02-08)

I'm building an js related application that only stores my user's bitcoin private keys, but not the public key or bitcoin address to save space.

Is there a javascript library that can output the bitcoin address by only providing the bitcoin private key as an input?

**Tags:** address, private-key, javascript

> **Comments:**
> **username_1**: You’re using javascript, but are concerned about storing tens of bytes?  
> **username_0**: I need it to be as compact as possible due to storage constraint. If i can derive the bitcoin address from the private key, great. I'm using very low bandwidth communications, every byte saved is time saved.  
> **username_2**: be careful sending private keys over the air.  

---

## 1 answers

### Answer by username_2 on 2019-02-08. Score: 0 | Accepted answer

Try bitcoinjs-lib
The following will generate a P2SH(P2WPKH) address
const bitcoin = require('bitcoinjs-lib')

let ecpair = bitcoin.ECPair.fromWIF('L34XqVbrw1VSHsiavdpm4QGTRrFyH7RKAp7SFYf36gYcyLX2ieWi')
let address = bitcoin.payments.p2sh({redeem: bitcoin.payments.p2wpkh({ pubkey: ecpair.publicKey })}).address

> '3F1JMjuxgNFuK4kBxv4JXMEdQ2yvjuz939'


---

