Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ports/stm32/boards/Passport/modules/chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def render_value(cls, val, unpad=False):
txt = '%d.%08d' % (val // 1E8, val % 1E8)
else:
label = cls.ctype_sats
txt = ('%d' % (val))
txt = ('{:,}'.format(val))
return txt, label

@classmethod
Expand Down
10 changes: 9 additions & 1 deletion ports/stm32/boards/Passport/modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ports/stm32/boards/Passport/modules/wallets/casa.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def create_casa_export(sw_wallet=None, addr_type=None, acct_num=0, multisig=Fals
],
'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 changes: 2 additions & 2 deletions ports/stm32/boards/Passport/modules/wallets/sw_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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
Expand All @@ -25,7 +25,7 @@
BlueWallet,
BtcPayWallet,
# CaravanWallet,
# CasaWallet,
CasaWallet,
# DuxReserveWallet,
ElectrumWallet,
# FullyNodedWallet,
Expand Down
7 changes: 4 additions & 3 deletions ports/stm32/boards/Passport/modules/wallets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down