pycoin icon indicating copy to clipboard operation
pycoin copied to clipboard

How to use pycoin for an altcoin

Open lephleg opened this issue 6 years ago • 9 comments

I've tried to add a new entry in BUILT_IN_NETWORKS with the network details, however I do not know how can I enable this instead of the default Bitcoin network.

I'm trying to achieve a simple operation like generating an address from an extended public key, like I do for Bitcoin with the following code:

from pycoin.key import Key
# Pull BTC Address from given xpub
key = Key.from_text(xpub).subkey(0). \
         subkey(0)
address = key.address(use_uncompressed=False)

lephleg avatar Nov 12 '17 18:11 lephleg

You need to set the ._netcode attribute

i.e key = Key.from_text(xpub).subkey(0).
subkey(0) key._netcode="LTC"

will generate the address for Litecoin

skoroneos avatar Dec 09 '17 20:12 skoroneos

What coins are supported? It's there a list available

LabtronicsDesign avatar Dec 23 '17 11:12 LabtronicsDesign

@SPWC, check networks/all.py and networks/legacy_networks.py.

metamarcdw avatar Dec 23 '17 22:12 metamarcdw

Ah sucks that it doesn't support bip 44 coin list

LabtronicsDesign avatar Dec 23 '17 23:12 LabtronicsDesign

You need to set the ._netcode attribute

i.e key = Key.from_text(xpub).subkey(0). subkey(0) key._netcode="LTC"

will generate the address for Litecoin

hi can you explain more i have

def secret_to_address(secret_exponent):
    k = Key(secret_exponent=secret_exponent)
    addr = k.address(use_uncompressed=True)
    caddr = k.address()
    wif = k.wif(use_uncompressed=True)
    return secret_exponent, wif, addr, caddr

how to change it for example doge?

arshiay avatar Jan 21 '19 09:01 arshiay

I'm changing how all this works... take a look at the "develop" branch and start with pycoin.symbols.*. You will find a bunch of symbols in there with patches for each network. The patches are of various levels of quality, but generally support at least keys and addresses, if not transactions.

richardkiss avatar Jan 21 '19 20:01 richardkiss

from pycoin.symbols.doge import network

secret_exponent = 1
k = network.keys.private(secret_exponent)
print(k.wif())
print(k.address())

richardkiss avatar Jan 21 '19 20:01 richardkiss

I'd be happy to support the BIP44 coin list. Is there an authoritative list somewhere?

richardkiss avatar Jan 21 '19 20:01 richardkiss

@richardkiss BIP44 spec: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki BIP44 coins list: https://github.com/satoshilabs/slips/blob/master/slip-0044.md

lorien avatar Jun 15 '19 14:06 lorien