From 821fdb47cab64c91f956ad1ca6d5489961459e69 Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 21 Apr 2014 22:15:36 -0400 Subject: top level signatures for CryptoCoins --- CryptoCoins.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'CryptoCoins.hs') diff --git a/CryptoCoins.hs b/CryptoCoins.hs index 8ae092d..f417036 100644 --- a/CryptoCoins.hs +++ b/CryptoCoins.hs @@ -16,6 +16,7 @@ data CoinNetwork = CoinNetwork -- For forks of bitcoin, grep sources for PUBKEY_ADDRESS -- That value + 0x80 will be the private_byte_id. -- information source: https://raw.github.com/zamgo/PHPCoinAddress/master/README.md +coin_networks :: [CoinNetwork] coin_networks = [ CoinNetwork "bitcoin" 0x00 0x80 "https://github.com/bitcoin/bitcoin" , CoinNetwork "litecoin" 0x30 0xB0 "https://github.com/litecoin-project/litecoin" @@ -43,6 +44,7 @@ coin_networks = -- ixcoin - - https://github.com/ixcoin/ixcoin -- royalcoin - - http://sourceforge.net/projects/royalcoin/ +lookupNetwork :: Eq a => (CoinNetwork -> a) -> a -> Maybe CoinNetwork lookupNetwork f b = listToMaybe $ filter (\n->f n==b) coin_networks nameFromSecretByte :: Word8 -> String @@ -54,11 +56,13 @@ nameFromSecretByte b = maybe (defaultName b) network_name (lookupNetwork private where pad0 [c] = '0':c:[] pad0 cs = take 2 cs +publicByteFromName :: String -> Word8 publicByteFromName n = maybe (secretByteFromName n - 0x80) -- exceptions to the above: bbqcoin, bytecoin public_byte_id (lookupNetwork network_name n) +secretByteFromName :: String -> Word8 secretByteFromName n = maybe (defaultID n) private_byte_id (lookupNetwork network_name n) where defaultID ('?':'c':'o':'i':'n':'?':(readHex->((x,_):_))) -- cgit v1.2.3