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

pull/25/head
Pavol Rusnak 6 years ago
parent 038e76071c
commit 6433862a11
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -12,7 +12,7 @@ class CoinInfo:
bech32_prefix: str,
cashaddr_prefix: str,
segwit: bool,
forkid: int,
fork_id: int,
force_bip143: bool
):
self.coin_name = coin_name
@ -25,7 +25,7 @@ class CoinInfo:
self.bech32_prefix = bech32_prefix
self.cashaddr_prefix = cashaddr_prefix
self.segwit = segwit
self.forkid = forkid
self.fork_id = fork_id
self.force_bip143 = force_bip143
@ -43,7 +43,7 @@ COINS = [
bech32_prefix='bc',
cashaddr_prefix=None,
segwit=True,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -57,7 +57,7 @@ COINS = [
bech32_prefix='tb',
cashaddr_prefix=None,
segwit=True,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -71,7 +71,7 @@ COINS = [
bech32_prefix=None,
cashaddr_prefix='bitcoincash',
segwit=False,
forkid=0,
fork_id=0,
force_bip143=True,
),
CoinInfo(
@ -85,7 +85,7 @@ COINS = [
bech32_prefix=None,
cashaddr_prefix='bchtest',
segwit=False,
forkid=0,
fork_id=0,
force_bip143=True,
),
CoinInfo(
@ -99,7 +99,7 @@ COINS = [
bech32_prefix=None,
cashaddr_prefix=None,
segwit=False,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -113,7 +113,7 @@ COINS = [
bech32_prefix='ltc',
cashaddr_prefix=None,
segwit=True,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -127,7 +127,7 @@ COINS = [
bech32_prefix=None,
cashaddr_prefix=None,
segwit=False,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -141,7 +141,7 @@ COINS = [
bech32_prefix=None,
cashaddr_prefix=None,
segwit=False,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -155,7 +155,7 @@ COINS = [
bech32_prefix=None,
cashaddr_prefix=None,
segwit=False,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -169,11 +169,11 @@ COINS = [
bech32_prefix=None,
cashaddr_prefix=None,
segwit=False,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
coin_name='Bitcoin Gold',
coin_name='Bgold',
coin_shortcut='BTG',
address_type=38,
address_type_p2sh=23,
@ -183,7 +183,7 @@ COINS = [
bech32_prefix='btg',
cashaddr_prefix=None,
segwit=True,
forkid=79,
fork_id=79,
force_bip143=True,
),
CoinInfo(
@ -197,7 +197,7 @@ COINS = [
bech32_prefix='dgb',
cashaddr_prefix=None,
segwit=True,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -211,7 +211,7 @@ COINS = [
bech32_prefix='mona',
cashaddr_prefix=None,
segwit=True,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -225,7 +225,7 @@ COINS = [
bech32_prefix='fc',
cashaddr_prefix=None,
segwit=True,
forkid=None,
fork_id=None,
force_bip143=False,
),
CoinInfo(
@ -239,21 +239,7 @@ COINS = [
bech32_prefix='vtc',
cashaddr_prefix=None,
segwit=True,
forkid=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,
fork_id=None,
force_bip143=False,
),
]

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

@ -12,19 +12,26 @@ fields = [
'bech32_prefix',
'cashaddr_prefix',
'segwit',
'forkid',
'fork_id',
'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 = [')
for c in coins:
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:
if n == 'xpub_magic':
print(' %s=0x%s,' % (n, c[n]))
print(' %s=0x%08x,' % (n, data[n]))
else:
print(' %s=%s,' % (n, repr(c[n])))
print(' %s=%s,' % (n, repr(data[n])))
print(' ),')
print(']')

@ -1 +1 @@
Subproject commit 0c9d67954c871553a7d44575a7a9198cba83df88
Subproject commit a0d37a0371aba597d3e0f3f1055adf1a9683a5e4
Loading…
Cancel
Save