1

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
  • 1
    What is your question? – Pieter Wuille Jun 29 at 2:26
  • i edited my question – Mamu Jun 29 at 5:49
  • It seems you already have it? – Pieter Wuille Jun 29 at 5:59
  • first result ms-dos command-line tool "input pubkey", i want to python console, make address form pubkey. – Mamu Jun 29 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.