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,350 points
1,687 views

1 answer to this question.

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
• 26,740 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,350 points
553 views
+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
948 views
+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
1,797 views
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
• 26,740 points
2,172 views
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,663 views
+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
• 26,740 points
43,813 views
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
• 26,740 points
868 views
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
• 26,740 points
907 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP