Skip to content

Commit

Permalink
drop support for the BCH Cash Addr format in GUI
Browse files Browse the repository at this point in the history
This means users can no longer display addresses in the "bitcoincash:..." format, and we no longer open "bitcoincash:" URIs.

Users can still paste BCH addresses in the address converter, or convert eCash & legacy addresses to BCH addresses.

Test plan:
Modify config file to `"address_format": "CashAddr BCH"` and bump version in version.py. Check that the program starts successfully with ecash: addresses in the GUI  and updates the config file to  `"address_format": "CashAddr"`.
  • Loading branch information
PiRK committed Dec 13, 2022
1 parent 9d55fb9 commit 9880275
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 39 deletions.
6 changes: 0 additions & 6 deletions contrib/build-wine/electrum-abc.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ Section
WriteRegStr ${INSTDIR_REG_ROOT} "Software\Classes\ecash" "URL Protocol" ""
WriteRegStr ${INSTDIR_REG_ROOT} "Software\Classes\ecash" "DefaultIcon" "$\"$INSTDIR\electrumABC.ico, 0$\""
WriteRegStr ${INSTDIR_REG_ROOT} "Software\Classes\ecash\shell\open\command" "" "$\"$INSTDIR\${INTERNAL_NAME}.exe$\" $\"%1$\""
;Links bitcoincash: URI's to Electrum ABC
WriteRegStr ${INSTDIR_REG_ROOT} "Software\Classes\bitcoincash" "" "URL:bitcoincash Protocol"
WriteRegStr ${INSTDIR_REG_ROOT} "Software\Classes\bitcoincash" "URL Protocol" ""
WriteRegStr ${INSTDIR_REG_ROOT} "Software\Classes\bitcoincash" "DefaultIcon" "$\"$INSTDIR\electrumABC.ico, 0$\""
WriteRegStr ${INSTDIR_REG_ROOT} "Software\Classes\bitcoincash\shell\open\command" "" "$\"$INSTDIR\${INTERNAL_NAME}.exe$\" $\"%1$\""

;Adds an uninstaller possibilty to Windows Uninstall or change a program section
WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayName" "$(^Name)"
Expand Down Expand Up @@ -240,7 +235,6 @@ Section "Uninstall"
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"

DeleteRegKey ${INSTDIR_REG_ROOT} "Software\Classes\ecash"
DeleteRegKey ${INSTDIR_REG_ROOT} "Software\Classes\bitcoincash"
DeleteRegKey ${INSTDIR_REG_ROOT} "Software\${PRODUCT_NAME}"
DeleteRegKey ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
SectionEnd
Expand Down
8 changes: 1 addition & 7 deletions contrib/osx/make_osx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ python3 setup.py install --user > /dev/null || fail "Could not build $PACKAGE"
info "Building binary"
pyinstaller --clean --noconfirm --ascii --name $VERSION contrib/osx/osx.spec || fail "Could not build binary"

info "Adding ecash & bitcoincash URI types to Info.plist"
info "Adding ecash URI type to Info.plist"
# NB: Make sure there are no trailing spaces after the '\' characters here
plutil -insert 'CFBundleURLTypes' \
-xml \
Expand All @@ -249,12 +249,6 @@ plutil -insert 'CFBundleURLTypes' \
' <key>CFBundleURLSchemes</key> '\
' <array><string>ecash</string></array> '\
'</dict> '\
'<dict> '\
' <key>CFBundleURLName</key> '\
' <string>bitcoincash</string> '\
' <key>CFBundleURLSchemes</key> '\
' <array><string>bitcoincash</string></array> '\
'</dict> '\
'</array>' \
-- dist/$PACKAGE.app/Contents/Info.plist \
|| fail "Could not add keys to Info.plist. Make sure the program 'plutil' exists and is installed."
Expand Down
11 changes: 7 additions & 4 deletions electroncash/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,17 @@ class Address(namedtuple("AddressTuple", "hash160 kind")):

# Address formats
FMT_CASHADDR = "CashAddr"
FMT_CASHADDR_BCH = "CashAddr BCH"
FMT_LEGACY = "Legacy"

# We keep this for now for the address converter tool and hw wallets, but it
# can no longer be shown in the rest of the UI.
FMT_CASHADDR_BCH = "CashAddr BCH"

# Default to CashAddr
FMT_UI = FMT_CASHADDR
"""Current address format used in the UI"""

FMTS_UI = [FMT_CASHADDR, FMT_CASHADDR_BCH, FMT_LEGACY]
FMTS_UI = [FMT_CASHADDR, FMT_LEGACY]
"""All address formats that can be used in the UI"""

FMT_UI_IDX = FMTS_UI.index(FMT_UI)
Expand Down Expand Up @@ -432,8 +435,8 @@ def from_string(cls, string: str, *,
"""Construct from an address string.
This supports the following formats:
- legacy BTC addresses
- CashAddr with a "bitcoincash:" prefix
- CashAddr with a prefix omitted if this prefix is "bitcoincash:"
- CashAddr with a "ecash:" prefix
- CashAddr with a prefix omitted if this prefix is "ecash:"
- CashAddr with an arbitrary prefix, if support_arbitrary_prefix
is True
Expand Down
4 changes: 2 additions & 2 deletions electroncash/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,10 +1012,10 @@ def help(self):
'requests_dir': 'directory where a bip70 file will be written.',
'ssl_privkey': 'Path to your SSL private key, needed to sign the request.',
'ssl_chain': 'Chain of SSL certificates, needed for signed requests. Put your certificate at the top and the root CA at the end',
'url_rewrite': 'Parameters passed to str.replace(), in order to create the r= part of bitcoincash: URIs. Example: \"(\'file:///var/www/\',\'https://electron-cash.org/\')\"',
'url_rewrite': 'Parameters passed to str.replace(), in order to create the r= part of ecash: URIs. Example: \"(\'file:///var/www/\',\'https://electron-cash.org/\')\"',
},
'listrequests':{
'url_rewrite': 'Parameters passed to str.replace(), in order to create the r= part of bitcoincash: URIs. Example: \"(\'file:///var/www/\',\'https://electron-cash.org/\')\"',
'url_rewrite': 'Parameters passed to str.replace(), in order to create the r= part of ecash: URIs. Example: \"(\'file:///var/www/\',\'https://electron-cash.org/\')\"',
}
}

Expand Down
5 changes: 5 additions & 0 deletions electroncash/migrate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ def update_config():
_logger.info("Updating the block explorer to the new default explorer.e.cash")
config["block_explorer"] = "eCash"

# We no longer support the BCH Cash Address format in the GUI as of 5.1.7
if config.get('address_format') == "CashAddr BCH":
_logger.info("Updating the Cash Addr format from bitcoincash: to ecash:")
config["address_format"] = "CashAddr"

# update version number, to avoid doing this again for this version
config["latest_version_used"] = VERSION_TUPLE
save_user_config(config, get_user_dir())
5 changes: 1 addition & 4 deletions electroncash_gui/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def _check_and_warn_qt_version(self):


def eventFilter(self, obj, event):
''' This event filter allows us to open bitcoincash: URIs on macOS '''
''' This event filter allows us to open ecash: URIs on macOS '''
if event.type() == QtCore.QEvent.FileOpen:
if len(self.windows) >= 1:
self.windows[0].pay_to_URI(event.url().toString())
Expand Down Expand Up @@ -942,9 +942,6 @@ def notify(self, message):
def is_cashaddr(self) -> bool:
return bool(self.get_config_addr_format() == Address.FMT_CASHADDR)

def is_cashaddr_bch(self) -> bool:
return bool(self.get_config_addr_format() == Address.FMT_CASHADDR_BCH)

def get_config_addr_format(self) -> str:
return self.config.get('address_format', Address.FMT_CASHADDR)

Expand Down
16 changes: 4 additions & 12 deletions electroncash_gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,12 +1542,12 @@ def update_receive_qr(self):
if opret:
kwargs[arg] = opret

# Special case hack -- see #1473. Omit bitcoincash: prefix from
# Special case hack -- see #1473. Omit ecash: prefix from
# legacy address if no other params present in receive request.
if Address.FMT_UI == Address.FMT_LEGACY and not kwargs and not amount and not message:
uri = self.receive_address.to_ui_string_without_prefix()
else:
# Otherwise proceed as normal, prepending bitcoincash: to URI
# Otherwise proceed as normal, prepending ecash: to URI
uri = web.create_URI(self.receive_address, amount, message, **kwargs)

self.receive_qr.setData(uri)
Expand All @@ -1571,7 +1571,6 @@ def create_send_tab(self):
_("You may enter:"
"<ul>"
f"<li> {CURRENCY} <b>Address</b> <b>★</b>"
"<li> Bitcoin Cash <b>Address</b> <b>★</b>"
"<li> Bitcoin Legacy <b>Address</b> <b>★</b>"
"<li> <b>Contact name</b> <b>★</b> from the Contacts tab"
"<li> <b>OpenAlias</b> e.g. <i>satoshi@domain.com</i>"
Expand Down Expand Up @@ -2459,7 +2458,7 @@ def pay_to_URI(self, URI):
if address or URI.strip().lower().split(':', 1)[0] in web.parseable_schemes():
# if address, set the payto field to the address.
# if *not* address, then we set the payto field to the empty string
# only IFF it was bitcoincash:, see issue #1131.
# only IFF it was ecash:, see issue Electron-Cash#1131.
self.payto_e.setText(address or '')
if message:
self.message_e.setText(message)
Expand Down Expand Up @@ -3298,7 +3297,7 @@ def _on_qr_reader_finished(success: bool, error: str, result):
return
if not result:
return
# if the user scanned a bitcoincash URI
# if the user scanned an ecash URI
if result.lower().startswith(networks.net.CASHADDR_PREFIX + ':'):
self.pay_to_URI(result)
return
Expand Down Expand Up @@ -4010,16 +4009,12 @@ def update_fiat(self):
def cashaddr_icon(self):
if self.gui_object.is_cashaddr():
return QIcon(":icons/tab_converter.svg")
elif self.gui_object.is_cashaddr_bch():
return QIcon(":icons/tab_converter_red.svg")
else:
return QIcon(":icons/tab_converter_bw.svg")

def cashaddr_status_tip(self):
if self.gui_object.is_cashaddr():
return _('Address Format') + ' - ' + _('CashAddr')
elif self.gui_object.is_cashaddr_bch():
return _('Address Format') + ' - ' + _('CashAddr') + ' BCH'
else:
return _('Address Format') + ' - ' + _('Legacy')

Expand Down Expand Up @@ -4401,9 +4396,6 @@ def on_fontconfig_chk():
cashaddr_cbox.addItem(QIcon(':icons/tab_converter.svg'),
_("CashAddr"),
Address.FMT_CASHADDR)
cashaddr_cbox.addItem(QIcon(':icons/tab_converter_red.svg'),
_("CashAddr") + " BCH",
Address.FMT_CASHADDR_BCH)
cashaddr_cbox.addItem(QIcon(':icons/tab_converter_bw.svg'),
_("Legacy"),
Address.FMT_LEGACY)
Expand Down
6 changes: 4 additions & 2 deletions electroncash_plugins/ledger/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,9 @@ def sign_transaction(self, tx, password, *, use_cache=False):
# Sign all inputs
inputIndex = 0
client_ledger.enableAlternate2fa(False)
cashaddr = Address.FMT_UI == Address.FMT_CASHADDR_BCH
cashaddr = Address.FMT_UI == Address.FMT_CASHADDR
if cashaddr and client_electrum.supports_cashaddr():
# For now the Ledger will show a bitcoincash: CashAddr
client_ledger.startUntrustedTransaction(True, inputIndex, chipInputs,
redeemScripts[inputIndex], cashAddr=True)
else:
Expand Down Expand Up @@ -550,7 +551,8 @@ def show_address(self, sequence):
address_path = self.get_derivation()[2:] + "/{:d}/{:d}".format(*sequence)
self.handler.show_message(_('Showing address on {}...').format(self.device))
try:
if Address.FMT_UI == Address.FMT_CASHADDR_BCH and self.get_client_electrum().supports_cashaddr():
if Address.FMT_UI == Address.FMT_CASHADDR and self.get_client_electrum().supports_cashaddr():
# For now the Ledger will show a bitcoincash: CashAddr
client.getWalletPublicKey(address_path, showOnScreen=True, cashAddr=True)
else:
client.getWalletPublicKey(address_path, showOnScreen=True)
Expand Down
2 changes: 1 addition & 1 deletion electrum-abc.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ StartupNotify=true
StartupWMClass=Electrum ABC
Terminal=false
Type=Application
MimeType=x-scheme-handler/bitcoincash;
MimeType=x-scheme-handler/ecash;
Actions=Testnet;

[Desktop Action Testnet]
Expand Down
1 change: 0 additions & 1 deletion org.bitcoinabc.Electrum-ABC.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@
</provides>
<mimetypes>
<mimetype>x-scheme-handler/ecash</mimetype>
<mimetype>x-scheme-handler/bitcoincash</mimetype>
</mimetypes>
</component>

0 comments on commit 9880275

Please sign in to comment.