pycoin
pycoin copied to clipboard
How to use pycoin for an altcoin
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)
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
What coins are supported? It's there a list available
@SPWC, check networks/all.py and networks/legacy_networks.py.
Ah sucks that it doesn't support bip 44 coin list
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?
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.
from pycoin.symbols.doge import network
secret_exponent = 1
k = network.keys.private(secret_exponent)
print(k.wif())
print(k.address())
I'd be happy to support the BIP44 coin list. Is there an authoritative list somewhere?
@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