【问题标题】:how to create the address of litecoin using pycoin library?如何使用 pycoin 库创建莱特币的地址?
【发布时间】:2018-04-19 05:59:44
【问题描述】:

我已经使用 python 脚本生成了比特币的地址。如何生成莱特币的地址。

这是我生成比特币地址的代码

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))

【问题讨论】:

    标签: python blockchain bitcoin


    【解决方案1】:

    在这个函数中,secret_exponent_to_wif

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

    这里使用BitcoinMainnet生成比特币地址。你只需使用LitecoinMannet生成Litecoin地址。它已经存在于 pycoin.coins.litecoin 库中。通过更改相应的网络值,您可以生成任何加密密钥的地址

    【讨论】:

      猜你喜欢
      • 2020-04-14
      • 2018-11-30
      • 1970-01-01
      • 2013-11-29
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 2018-06-18
      • 2014-04-22
      相关资源
      最近更新 更多