Skip to content

Commit

Permalink
dev-v1.1.0 (#92)
Browse files Browse the repository at this point in the history
* PASS1-420: Add Envoy pairing support

Until the new FE firmware with the new UI is released, you can now pair FE with the Envoy app

* PASS1-434: Change "Pair Wallet" menu to "Connect Wallet"

And similar terms/wording in a few other places

* PASS1-472: Fix Verify Address for uppercase bech32 addresses

Also, don't say testnet address is valid in mainnet mode or vice versa
  • Loading branch information
FoundationKen authored Aug 3, 2022
1 parent 5bdad21 commit e985d0a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions ports/stm32/boards/Passport/modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,16 +450,14 @@ 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):
# Valid addresses: 1 , 3 , bc1, tb1, m, n, 2
address = address.lower()
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'))
import chains
chain = chains.current_chain()
if chain.ctype == 'BTC':
return (len(address) > 3) and (address[0] == '1' or address[0] == '3' or
(address[0] == 'b' and address[1] == 'c' and address[2] == '1'))
else:
return (len(address) > 3) and (address[0] == 'm' or address[0] == 'n' or address[0] == '2' 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 Expand Up @@ -715,6 +713,11 @@ async def is_valid_btc_address(address):
if address[0:8].lower() == 'bitcoin:':
address = address[8:]

# We need to lowercase BECH32 addresses, but not legacy
lower_address = address.lower()
if lower_address.startswith('bc1') or lower_address.startswith('tb1'):
address = lower_address

if not is_valid_address(address):
await ux_show_story('That is not a valid Bitcoin address.', title='Error', left_btn='BACK',
right_btn='SCAN', center=True, center_vertically=True)
Expand Down

0 comments on commit e985d0a

Please sign in to comment.