Browse Source

PASS1-148: Fix missing address prefixes for testnet (#53)

* PASS1-148: Fix missing address prefixes for testnet

* Add comma separations to sats values

* Casa support added

* Added testnet prefix check to Verify Address process
dev-v1.0.7
Corey Lakey 3 years ago
committed by GitHub
parent
commit
c298adfb61
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ports/stm32/boards/Passport/modules/chains.py
  2. 10
      ports/stm32/boards/Passport/modules/utils.py
  3. 2
      ports/stm32/boards/Passport/modules/wallets/casa.py
  4. 4
      ports/stm32/boards/Passport/modules/wallets/sw_wallets.py
  5. 7
      ports/stm32/boards/Passport/modules/wallets/utils.py

2
ports/stm32/boards/Passport/modules/chains.py

@ -172,7 +172,7 @@ class ChainsBase:
txt = '%d.%08d' % (val // 1E8, val % 1E8)
else:
label = cls.ctype_sats
txt = ('%d' % (val))
txt = ('{:,}'.format(val))
return txt, label
@classmethod

10
ports/stm32/boards/Passport/modules/utils.py

@ -446,7 +446,15 @@ async def show_top_menu():
# TODO: For now this just checks the front bytes, but it could ensure the whole thing is valid
def is_valid_address(address):
return (len(address) > 3) and (address[0] == '1' or address[0] == '3' or (address[0] == 'b' and address[1] == 'c' and address[2] == '1'))
# Valid addresses: 1 , 3 , bc1, tb1, m, n, 2
return (len(address) > 3) and \
((address[0] == '1') or \
(address[0] == '2') or \
(address[0] == '3') or \
(address[0] == 'm') or \
(address[0] == 'n') or \
(address[0] == 'b' and address[1] == 'c' and address[2] == '1') or \
(address[0] == 't' and address[1] == 'b' and address[2] == '1'))
# Return array of bytewords where each byte in buf maps to a word

2
ports/stm32/boards/Passport/modules/wallets/casa.py

@ -55,6 +55,6 @@ CasaWallet = {
],
'export_modes': [
{'id': 'microsd', 'label': 'microSD', 'filename_pattern': '{sd}/{xfp}-casa.txt', 'ext': '.txt',
'filename_pattern_multisig': '{sd}/{xfp}-casa-multisig.json', 'ext_multisig': '.txt'}
'filename_pattern_multisig': '{sd}/{xfp}-casa-multisig.txt', 'ext_multisig': '.txt'}
]
}

4
ports/stm32/boards/Passport/modules/wallets/sw_wallets.py

@ -8,7 +8,7 @@ from data_codecs.qr_type import QRType
from .bitcoin_core import BitcoinCoreWallet
from .bluewallet import BlueWallet
from .btcpay import BtcPayWallet
# from .casa import CasaWallet
from .casa import CasaWallet
# from .caravan import CaravanWallet
# from .dux_reserve import DuxReserveWallet
from .electrum import ElectrumWallet
@ -25,7 +25,7 @@ supported_software_wallets = [
BlueWallet,
BtcPayWallet,
# CaravanWallet,
# CasaWallet,
CasaWallet,
# DuxReserveWallet,
ElectrumWallet,
# FullyNodedWallet,

7
ports/stm32/boards/Passport/modules/wallets/utils.py

@ -44,11 +44,12 @@ def get_addr_type_from_address(address, is_multisig):
if len(address) < 26:
return None
if address[0] == '1':
if address[0] == '1' or address[0] == 'm' or address[0] == 'n' :
return AF_P2SH if is_multisig else AF_CLASSIC
elif address[0] == '3':
elif address[0] == '3' or address[0] == '2' :
return AF_P2WSH_P2SH if is_multisig else AF_P2WPKH_P2SH
elif address[0] == 'b' and address[1] == 'c' and address[2] == '1':
elif (address[0] == 'b' and address[1] == 'c' and address[2] == '1') or \
(address[0] == 't' and address[1] == 'b' and address[2] == '1'):
return AF_P2WSH if is_multisig else AF_P2WPKH
return None

Loading…
Cancel
Save