From fd35b4c5c9a7aebb403c7ff712891eadc2d9551b Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Thu, 21 Jun 2018 13:58:57 +0200 Subject: [PATCH] coins: add slip44 --- src/apps/common/coininfo.py | 17 +++++++++++++++++ src/apps/common/coins.py | 7 +++++++ tools/codegen/gen_coins.py | 1 + 3 files changed, 25 insertions(+) diff --git a/src/apps/common/coininfo.py b/src/apps/common/coininfo.py index d6ed2bcf8..ad4d3a49f 100644 --- a/src/apps/common/coininfo.py +++ b/src/apps/common/coininfo.py @@ -11,6 +11,7 @@ class CoinInfo: xpub_magic: int, bech32_prefix: str, cashaddr_prefix: str, + slip44: int, segwit: bool, fork_id: int, force_bip143: bool, @@ -25,6 +26,7 @@ class CoinInfo: self.xpub_magic = xpub_magic self.bech32_prefix = bech32_prefix self.cashaddr_prefix = cashaddr_prefix + self.slip44 = slip44 self.segwit = segwit self.fork_id = fork_id self.force_bip143 = force_bip143 @@ -44,6 +46,7 @@ COINS = [ xpub_magic=0x0488b21e, bech32_prefix='bc', cashaddr_prefix=None, + slip44=0, segwit=True, fork_id=None, force_bip143=False, @@ -59,6 +62,7 @@ COINS = [ xpub_magic=0x043587cf, bech32_prefix='tb', cashaddr_prefix=None, + slip44=1, segwit=True, fork_id=None, force_bip143=False, @@ -74,6 +78,7 @@ COINS = [ xpub_magic=0x0488b21e, bech32_prefix=None, cashaddr_prefix='bitcoincash', + slip44=145, segwit=False, fork_id=0, force_bip143=True, @@ -89,6 +94,7 @@ COINS = [ xpub_magic=0x043587cf, bech32_prefix=None, cashaddr_prefix='bchtest', + slip44=1, segwit=False, fork_id=0, force_bip143=True, @@ -104,6 +110,7 @@ COINS = [ xpub_magic=0x019da462, bech32_prefix=None, cashaddr_prefix=None, + slip44=7, segwit=False, fork_id=None, force_bip143=False, @@ -119,6 +126,7 @@ COINS = [ xpub_magic=0x019da462, bech32_prefix='ltc', cashaddr_prefix=None, + slip44=2, segwit=True, fork_id=None, force_bip143=False, @@ -134,6 +142,7 @@ COINS = [ xpub_magic=0x02facafd, bech32_prefix=None, cashaddr_prefix=None, + slip44=3, segwit=False, fork_id=None, force_bip143=False, @@ -149,6 +158,7 @@ COINS = [ xpub_magic=0x02fe52cc, bech32_prefix=None, cashaddr_prefix=None, + slip44=5, segwit=False, fork_id=None, force_bip143=False, @@ -164,6 +174,7 @@ COINS = [ xpub_magic=0x0488b21e, bech32_prefix=None, cashaddr_prefix=None, + slip44=133, segwit=False, fork_id=None, force_bip143=False, @@ -179,6 +190,7 @@ COINS = [ xpub_magic=0x043587cf, bech32_prefix=None, cashaddr_prefix=None, + slip44=1, segwit=False, fork_id=None, force_bip143=False, @@ -194,6 +206,7 @@ COINS = [ xpub_magic=0x0488b21e, bech32_prefix='btg', cashaddr_prefix=None, + slip44=156, segwit=True, fork_id=79, force_bip143=True, @@ -209,6 +222,7 @@ COINS = [ xpub_magic=0x0488b21e, bech32_prefix='dgb', cashaddr_prefix=None, + slip44=20, segwit=True, fork_id=None, force_bip143=False, @@ -224,6 +238,7 @@ COINS = [ xpub_magic=0x0488b21e, bech32_prefix='mona', cashaddr_prefix=None, + slip44=22, segwit=True, fork_id=None, force_bip143=False, @@ -239,6 +254,7 @@ COINS = [ xpub_magic=0x0488b21e, bech32_prefix='fc', cashaddr_prefix=None, + slip44=75, segwit=True, fork_id=None, force_bip143=False, @@ -254,6 +270,7 @@ COINS = [ xpub_magic=0x0488b21e, bech32_prefix='vtc', cashaddr_prefix=None, + slip44=28, segwit=True, fork_id=None, force_bip143=False, diff --git a/src/apps/common/coins.py b/src/apps/common/coins.py index 82bd0c910..7810cf990 100644 --- a/src/apps/common/coins.py +++ b/src/apps/common/coins.py @@ -20,3 +20,10 @@ def by_address_type(address_type): if c.address_type == address_type: return c raise ValueError('Unknown coin address type %d' % address_type) + + +def by_slip44(slip44): + for c in COINS: + if c.slip44 == slip44: + return c + raise ValueError('Unknown coin slip44 index %d' % slip44) diff --git a/tools/codegen/gen_coins.py b/tools/codegen/gen_coins.py index e757ac2f6..035d3240e 100755 --- a/tools/codegen/gen_coins.py +++ b/tools/codegen/gen_coins.py @@ -11,6 +11,7 @@ fields = [ 'xpub_magic', 'bech32_prefix', 'cashaddr_prefix', + 'slip44', 'segwit', 'fork_id', 'force_bip143',