1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

coins: update how coins are being generated from trezor-common

This commit is contained in:
Pavol Rusnak 2018-05-28 17:43:29 +02:00
parent 038e76071c
commit 6433862a11
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 32 additions and 39 deletions

View File

@ -12,7 +12,7 @@ class CoinInfo:
bech32_prefix: str, bech32_prefix: str,
cashaddr_prefix: str, cashaddr_prefix: str,
segwit: bool, segwit: bool,
forkid: int, fork_id: int,
force_bip143: bool force_bip143: bool
): ):
self.coin_name = coin_name self.coin_name = coin_name
@ -25,7 +25,7 @@ class CoinInfo:
self.bech32_prefix = bech32_prefix self.bech32_prefix = bech32_prefix
self.cashaddr_prefix = cashaddr_prefix self.cashaddr_prefix = cashaddr_prefix
self.segwit = segwit self.segwit = segwit
self.forkid = forkid self.fork_id = fork_id
self.force_bip143 = force_bip143 self.force_bip143 = force_bip143
@ -43,7 +43,7 @@ COINS = [
bech32_prefix='bc', bech32_prefix='bc',
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=True, segwit=True,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -57,7 +57,7 @@ COINS = [
bech32_prefix='tb', bech32_prefix='tb',
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=True, segwit=True,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -71,7 +71,7 @@ COINS = [
bech32_prefix=None, bech32_prefix=None,
cashaddr_prefix='bitcoincash', cashaddr_prefix='bitcoincash',
segwit=False, segwit=False,
forkid=0, fork_id=0,
force_bip143=True, force_bip143=True,
), ),
CoinInfo( CoinInfo(
@ -85,7 +85,7 @@ COINS = [
bech32_prefix=None, bech32_prefix=None,
cashaddr_prefix='bchtest', cashaddr_prefix='bchtest',
segwit=False, segwit=False,
forkid=0, fork_id=0,
force_bip143=True, force_bip143=True,
), ),
CoinInfo( CoinInfo(
@ -99,7 +99,7 @@ COINS = [
bech32_prefix=None, bech32_prefix=None,
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=False, segwit=False,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -113,7 +113,7 @@ COINS = [
bech32_prefix='ltc', bech32_prefix='ltc',
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=True, segwit=True,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -127,7 +127,7 @@ COINS = [
bech32_prefix=None, bech32_prefix=None,
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=False, segwit=False,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -141,7 +141,7 @@ COINS = [
bech32_prefix=None, bech32_prefix=None,
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=False, segwit=False,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -155,7 +155,7 @@ COINS = [
bech32_prefix=None, bech32_prefix=None,
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=False, segwit=False,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -169,11 +169,11 @@ COINS = [
bech32_prefix=None, bech32_prefix=None,
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=False, segwit=False,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
coin_name='Bitcoin Gold', coin_name='Bgold',
coin_shortcut='BTG', coin_shortcut='BTG',
address_type=38, address_type=38,
address_type_p2sh=23, address_type_p2sh=23,
@ -183,7 +183,7 @@ COINS = [
bech32_prefix='btg', bech32_prefix='btg',
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=True, segwit=True,
forkid=79, fork_id=79,
force_bip143=True, force_bip143=True,
), ),
CoinInfo( CoinInfo(
@ -197,7 +197,7 @@ COINS = [
bech32_prefix='dgb', bech32_prefix='dgb',
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=True, segwit=True,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -211,7 +211,7 @@ COINS = [
bech32_prefix='mona', bech32_prefix='mona',
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=True, segwit=True,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -225,7 +225,7 @@ COINS = [
bech32_prefix='fc', bech32_prefix='fc',
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=True, segwit=True,
forkid=None, fork_id=None,
force_bip143=False, force_bip143=False,
), ),
CoinInfo( CoinInfo(
@ -239,21 +239,7 @@ COINS = [
bech32_prefix='vtc', bech32_prefix='vtc',
cashaddr_prefix=None, cashaddr_prefix=None,
segwit=True, segwit=True,
forkid=None, fork_id=None,
force_bip143=False,
),
CoinInfo(
coin_name='Decred Testnet',
coin_shortcut='TDCR',
address_type=3873,
address_type_p2sh=3836,
maxfee_kb=10000000,
signed_message_header='Decred Signed Message:\n',
xpub_magic=0x043587d1,
bech32_prefix=None,
cashaddr_prefix=None,
segwit=False,
forkid=None,
force_bip143=False, force_bip143=False,
), ),
] ]

View File

@ -423,8 +423,8 @@ def get_hash_type(coin: CoinInfo) -> int:
SIGHASH_FORKID = const(0x40) SIGHASH_FORKID = const(0x40)
SIGHASH_ALL = const(0x01) SIGHASH_ALL = const(0x01)
hashtype = SIGHASH_ALL hashtype = SIGHASH_ALL
if coin.forkid is not None: if coin.fork_id is not None:
hashtype |= (coin.forkid << 8) | SIGHASH_FORKID hashtype |= (coin.fork_id << 8) | SIGHASH_FORKID
return hashtype return hashtype

View File

@ -12,19 +12,26 @@ fields = [
'bech32_prefix', 'bech32_prefix',
'cashaddr_prefix', 'cashaddr_prefix',
'segwit', 'segwit',
'forkid', 'fork_id',
'force_bip143', 'force_bip143',
] ]
coins = json.load(open('../../vendor/trezor-common/coins.json', 'r')) support = json.load(open('../../vendor/trezor-common/defs/support.json', 'r'))
coins = support['trezor2'].keys()
print('COINS = [') print('COINS = [')
for c in coins: for c in coins:
print(' CoinInfo(') print(' CoinInfo(')
name = c.replace(' ', '_').lower()
if name == 'testnet':
name = 'bitcoin_testnet'
data = json.load(open('../../vendor/trezor-common/defs/coins/%s.json' % name, 'r'))
for n in fields: for n in fields:
if n == 'xpub_magic': if n == 'xpub_magic':
print(' %s=0x%s,' % (n, c[n])) print(' %s=0x%08x,' % (n, data[n]))
else: else:
print(' %s=%s,' % (n, repr(c[n]))) print(' %s=%s,' % (n, repr(data[n])))
print(' ),') print(' ),')
print(']') print(']')

@ -1 +1 @@
Subproject commit 0c9d67954c871553a7d44575a7a9198cba83df88 Subproject commit a0d37a0371aba597d3e0f3f1055adf1a9683a5e4