summaryrefslogtreecommitdiff
path: root/CryptoCoins.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-21 22:15:36 -0400
committerjoe <joe@jerkface.net>2014-04-21 22:15:36 -0400
commit821fdb47cab64c91f956ad1ca6d5489961459e69 (patch)
tree68cfc9ad2dd760e2e02d7b826ff99f56a1e8d375 /CryptoCoins.hs
parentbbb38d5e54664ced895a6e4dcfcc289f2a9afef4 (diff)
top level signatures for CryptoCoins
Diffstat (limited to 'CryptoCoins.hs')
-rw-r--r--CryptoCoins.hs4
1 files changed, 4 insertions, 0 deletions
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
16-- For forks of bitcoin, grep sources for PUBKEY_ADDRESS 16-- For forks of bitcoin, grep sources for PUBKEY_ADDRESS
17-- That value + 0x80 will be the private_byte_id. 17-- That value + 0x80 will be the private_byte_id.
18-- information source: https://raw.github.com/zamgo/PHPCoinAddress/master/README.md 18-- information source: https://raw.github.com/zamgo/PHPCoinAddress/master/README.md
19coin_networks :: [CoinNetwork]
19coin_networks = 20coin_networks =
20 [ CoinNetwork "bitcoin" 0x00 0x80 "https://github.com/bitcoin/bitcoin" 21 [ CoinNetwork "bitcoin" 0x00 0x80 "https://github.com/bitcoin/bitcoin"
21 , CoinNetwork "litecoin" 0x30 0xB0 "https://github.com/litecoin-project/litecoin" 22 , CoinNetwork "litecoin" 0x30 0xB0 "https://github.com/litecoin-project/litecoin"
@@ -43,6 +44,7 @@ coin_networks =
43 -- ixcoin - - https://github.com/ixcoin/ixcoin 44 -- ixcoin - - https://github.com/ixcoin/ixcoin
44 -- royalcoin - - http://sourceforge.net/projects/royalcoin/ 45 -- royalcoin - - http://sourceforge.net/projects/royalcoin/
45 46
47lookupNetwork :: Eq a => (CoinNetwork -> a) -> a -> Maybe CoinNetwork
46lookupNetwork f b = listToMaybe $ filter (\n->f n==b) coin_networks 48lookupNetwork f b = listToMaybe $ filter (\n->f n==b) coin_networks
47 49
48nameFromSecretByte :: Word8 -> String 50nameFromSecretByte :: Word8 -> String
@@ -54,11 +56,13 @@ nameFromSecretByte b = maybe (defaultName b) network_name (lookupNetwork private
54 where pad0 [c] = '0':c:[] 56 where pad0 [c] = '0':c:[]
55 pad0 cs = take 2 cs 57 pad0 cs = take 2 cs
56 58
59publicByteFromName :: String -> Word8
57publicByteFromName n = maybe (secretByteFromName n - 0x80) 60publicByteFromName n = maybe (secretByteFromName n - 0x80)
58 -- exceptions to the above: bbqcoin, bytecoin 61 -- exceptions to the above: bbqcoin, bytecoin
59 public_byte_id 62 public_byte_id
60 (lookupNetwork network_name n) 63 (lookupNetwork network_name n)
61 64
65secretByteFromName :: String -> Word8
62secretByteFromName n = maybe (defaultID n) private_byte_id (lookupNetwork network_name n) 66secretByteFromName n = maybe (defaultID n) private_byte_id (lookupNetwork network_name n)
63 where 67 where
64 defaultID ('?':'c':'o':'i':'n':'?':(readHex->((x,_):_))) 68 defaultID ('?':'c':'o':'i':'n':'?':(readHex->((x,_):_)))