<p>Have a look at libbtc (<a href="https://github.com/libbtc/libbtc" rel="nofollow noreferrer">https://github.com/libbtc/libbtc</a>). </p>

<p>There is a function <code>btc_script_classify()</code> which will return what script type it is (P2PK, P2PKH, P2SH, P2WPKH, P2WSH) and it will return data elements (usually the RIPEMD160 of the pubkey).</p>

CC BY-SA 3.0
2018-04-29T17:55:23.527Z
2018-04-29T17:55:23.527Z
Jonas Schnelli
<p>I want to parse a script with <code>c++</code> to gain an output address from it.
can anybody introduce a suitable library or a sample code which extract addresses from scripts ?</p>

CC BY-SA 3.0
2018-04-29T12:07:35.330Z
You can look at the code for decodescript in the Bitcoin source. That outputs addresses (if they exist), so should do what you want
Raghav Sood
<script><c++>
Parse scripts to extract address
Saeed
# Parse scripts to extract address

(Asked by: username_0 on 2018-04-29)

I want to parse a script with `c++` to gain an output address from it.
can anybody introduce a suitable library or a sample code which extract addresses from scripts ?

**Tags:** script, c++

> **Comments:**
> **username_1**: You can look at the code for decodescript in the Bitcoin source. That outputs addresses (if they exist), so should do what you want  

---

## 1 answers

### Answer by username_2 on 2018-04-29. Score: 1

Have a look at libbtc (<https://github.com/libbtc/libbtc>).

There is a function `btc_script_classify()` which will return what script type it is (P2PK, P2PKH, P2SH, P2WPKH, P2WSH) and it will return data elements (usually the RIPEMD160 of the pubkey).


---

