<p>i am new on python,
i know it</p>
<p>how to create Bitcoin address , p2sh segwit and Bitcoin segwit address on python console ?</p>
<p>i  use <a href="https://github.com/richardkiss/pycoin" rel="nofollow noreferrer">https://github.com/richardkiss/pycoin</a></p>
<p>and command-line</p>
<p><code>(base) C:\Users\MM&gt;ku 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a</code></p>
<pre><code> input                        : &gt;04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\
                                  1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a
 network                      : Bitcoin mainnet
 symbol                       : BTC
 public pair x                : 89565891926547004231252920425935692360644145829622209833684329913297188986597
 public pair y                : 12158399299693830322967808612713398636155367887041628176798871954788371653930
  x as hex                    : c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5
  y as hex                    : 1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a
 y parity                     : even
 key pair as sec              : 02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5
  uncompressed                : 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\
                                  1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a
 hash160                      : 06afd46bcdfd22ef94ac122aa11f241244a37ecc
  uncompressed                : d6c8e828c1eca1bba065e1b83e1dc2a36e387a42
 Bitcoin address              : 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP
 Bitcoin address uncompressed : 1LagHJk2FyCV2VzrNHVqg3gYG4TSYwDV4m
 Bitcoin segwit address       : bc1qq6hag67dl53wl99vzg42z8eyzfz2xlkvxechjp
 p2sh segwit                  : 3FWHHE3RVgyv5vYmMrcoRdA25uugWvQbso
  corresponding p2sh script   : 001406afd46bcdfd22ef94ac122aa11f241244a37ecc
</code></pre>
<p>python console</p>
<p><code>(base) C:\Users\MM&gt;python</code></p>
<pre><code>Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.

&gt;&gt;&gt; from pycoin.encoding.hexbytes import h2b
&gt;&gt;&gt; from pycoin.symbols.btc import network
&gt;&gt;&gt; pub = '04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a'
&gt;&gt;&gt; hpub = h2b(pub)
&gt;&gt;&gt; key = network.keys.public(hpub)
&gt;&gt;&gt; key
&lt;BTCSEC:04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a&gt; 
&gt;&gt;&gt; key.address()
'1LagHJk2FyCV2VzrNHVqg3gYG4TSYwDV4m'
</code></pre>
<p>I want generate these address on python console, but how ?</p>
<pre><code> Bitcoin address              : 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP

 Bitcoin segwit address       : bc1qq6hag67dl53wl99vzg42z8eyzfz2xlkvxechjp

 p2sh segwit                  : 3FWHHE3RVgyv5vYmMrcoRdA25uugWvQbso
</code></pre>

CC BY-SA 4.0
2020-06-29T05:59:50.250Z
It seems you already have it?
Pieter Wuille
CC BY-SA 4.0
2020-06-29T06:05:41.310Z
first result  ms-dos command-line tool  "input pubkey", i want to python console, make address form pubkey.
Mamu
<address-generation>
how to create Bitcoin address , p2sh segwit and Bitcoin segwit address on python console from pubkey?
Mamu
# how to create Bitcoin address , p2sh segwit and Bitcoin segwit address on python console from pubkey?

(Asked by: username_0 on 2020-06-29)

i am new on python,
i know it

how to create Bitcoin address , p2sh segwit and Bitcoin segwit address on python console ?

i use <https://github.com/richardkiss/pycoin>

and command-line

`(base) C:\Users\MM>ku 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a`

```
 input                        : >04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\
                                  1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a
 network                      : Bitcoin mainnet
 symbol                       : BTC
 public pair x                : 89565891926547004231252920425935692360644145829622209833684329913297188986597
 public pair y                : 12158399299693830322967808612713398636155367887041628176798871954788371653930
  x as hex                    : c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5
  y as hex                    : 1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a
 y parity                     : even
 key pair as sec              : 02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5
  uncompressed                : 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\
                                  1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a
 hash160                      : 06afd46bcdfd22ef94ac122aa11f241244a37ecc
  uncompressed                : d6c8e828c1eca1bba065e1b83e1dc2a36e387a42
 Bitcoin address              : 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP
 Bitcoin address uncompressed : 1LagHJk2FyCV2VzrNHVqg3gYG4TSYwDV4m
 Bitcoin segwit address       : bc1qq6hag67dl53wl99vzg42z8eyzfz2xlkvxechjp
 p2sh segwit                  : 3FWHHE3RVgyv5vYmMrcoRdA25uugWvQbso
  corresponding p2sh script   : 001406afd46bcdfd22ef94ac122aa11f241244a37ecc

```

python console

`(base) C:\Users\MM>python`

```
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information.

>>> from pycoin.encoding.hexbytes import h2b
>>> from pycoin.symbols.btc import network
>>> pub = '04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a'
>>> hpub = h2b(pub)
>>> key = network.keys.public(hpub)
>>> key
<BTCSEC:04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a> 
>>> key.address()
'1LagHJk2FyCV2VzrNHVqg3gYG4TSYwDV4m'

```

I want generate these address on python console, but how ?

```
 Bitcoin address              : 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP

 Bitcoin segwit address       : bc1qq6hag67dl53wl99vzg42z8eyzfz2xlkvxechjp

 p2sh segwit                  : 3FWHHE3RVgyv5vYmMrcoRdA25uugWvQbso

```

**Tags:** address-generation

> **Comments:**
> **username_1**: It seems you already have it?  
> **username_0**: first result  ms-dos command-line tool  "input pubkey", i want to python console, make address form pubkey.  

---

## 0 answers

