How to generate litecoin using pycoin?

0 votes

I have generate the address of bitcoin using python script. How to generate the address of Litecoin.

Here is my code to generate bitcoin address

import hashlib
from pycoin import ecdsa, encoding
import os
import codecs
for i in range(10):
    rand = codecs.encode(os.urandom(32), 'hex').decode()
    secret_exponent= int('0x'+rand, 0)
    print ('WIF: ' + encoding.secret_exponent_to_wif(secret_exponent, compressed=False))
    public_pair = ecdsa.public_pair_for_secret_exponent(ecdsa.secp256k1.generator_secp256k1, secret_exponent)
    hash160 = encoding.public_pair_to_hash160_sec(public_pair, compressed=True)
    print('Bitcoin address: %s' % encoding.hash160_sec_to_bitcoin_address(hash160))
Aug 29, 2018 in Blockchain by slayer
• 29,040 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

In the secret_exponent_to_wif function

def secret_exponent_to_wif(se, compressed):
    blob = to_bytes_32(se)
    if compressed:
        blob += b'\01'
    return BitcoinMainnet.ui.wif_for_blob(blob)

Here it uses BitcoinMainnet to generate Bitcoin address.You just use LitecoinMannet to generate Litecoin address. It is already there in pycoin.coins.litecoin library. By changing the corresponding network values you can generate address of any crypto key. 

answered Aug 29, 2018 by digger
• 27,620 points

Related Questions In Blockchain

0 votes
1 answer

How to generate coin address using bitcoin-ruby?

The only difference between the addresses is ...READ MORE

answered Aug 29, 2018 in Blockchain by slayer
• 29,040 points
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points
+1 vote
1 answer
+1 vote
1 answer

How can I connect to the specified nodes using IPFS?

You can actually connect to the specific ...READ MORE

answered Apr 25, 2018 in Blockchain by Christine
• 15,790 points
0 votes
1 answer

Python request module for bitcoin json rpc

This should work: #!/usr/bin/env python import getpass import json import requests ...READ MORE

answered Aug 28, 2018 in Blockchain by digger
• 27,620 points
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 27,620 points
0 votes
1 answer

How to transact custom token instead of ethers using JSON rpc?

First create your custom token. Then develop ...READ MORE

answered Jul 10, 2018 in Blockchain by digger
• 27,620 points
0 votes
1 answer

How to interact with blockchain using Java web app?

You can interact with the blockchain using ...READ MORE

answered Jul 16, 2018 in Blockchain by digger
• 27,620 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.