Feature: QR message signing for SeedSigner (#1938)

* supports_qr_message_signing added
* cypress test adapted

Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
This commit is contained in:
kdmukai 2022-10-25 10:00:36 -05:00 committed by GitHub
parent cdd09fcd70
commit d2d3c1200c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 15 deletions

View file

@ -25,21 +25,14 @@ describe('Test QR code signing flow', () => {
cy.get('#page_overlay_popup_cancel_button').click()
})
it('QR code signing (currently) only available for DIYs', () => {
it('No QR message signing button for a Trezor', () => {
// Changing the device type to simulate a different device
cy.changeDeviceType("DIY ghost", "Trezor")
cy.reload()
cy.contains("Sign message").click()
// Only USB signing available for a Trezor device
cy.get('#diy_ghost_qr_sign_msg_btn').should('not.exist')
cy.get('#diy_ghost_usb_sign_msg_btn').should('exist')
cy.get('#page_overlay_popup_cancel_button').click()
cy.contains("Ghost wallet").click()
cy.get('main').contains('Addresses').click()
cy.contains('td', '#0').siblings().contains('bcrt').click()
cy.get('#msg-signing-btn').should('exist')
cy.get('#page_overlay_popup_cancel_button').click()
// Reload fixes issues with sometimes persisting overlays
cy.reload()
cy.contains('Sign message via USB').should('be.visible')
cy.contains('Sign message via QR code').should('not.exist')
// Change device type back to DIY
cy.changeDeviceType("DIY ghost", "specter")
})

View file

@ -24,6 +24,7 @@ class Device:
# - "on": animate psbt by default
# - "off": don't animate psbt even if it is huge
qr_code_animate = "auto"
supports_qr_message_signing = False
hwi_support = False
supports_hwi_toggle_passphrase = False
supports_hwi_multisig_display_address = False

View file

@ -9,8 +9,11 @@ class SeedSignerDevice(Device):
sd_card_support = False
qr_code_support = True
qr_code_support_verify = True
qr_code_frame_rate = 2 # 500 ms per frame
qr_code_animate = "on"
supports_qr_message_signing = True
taproot_support = True
def create_psbts(self, base64_psbt, wallet):
# in QR codes keep only xpubs

View file

@ -69,6 +69,7 @@ class Specter(SDCardDevice):
qr_code_support = True
qr_code_support_verify = True
wallet_export_type = "qr"
supports_qr_message_signing = True
supports_hwi_multisig_display_address = True
liquid_support = True
taproot_support = True

View file

@ -92,7 +92,8 @@
<button id="add_keys" type="submit" name="action" value="add_keys" class="btn centered">{{ _("Convert to hot wallet") }}</button>
{% endif %}
</form>
{% if device.hwi_support or device.device_type == "specter" %}
{% if device.hwi_support or device.supports_qr_message_signing %}
<button type="button" class="btn centered" onclick="showPageOverlay('message-signing')">{{ _("Sign message") }}</button>
<div id="message-signing" class="hidden" style="text-align: left; max-width: 350px;">
{% if origin %}
@ -107,7 +108,7 @@
{% if device.hwi_support %}
<button id="{{ device.alias }}_usb_sign_msg_btn" type="button" class="btn centered" onclick="signMessageOnDevice();">{{ _("Sign message via USB") }}</button>
{% endif %}
{% if device.device_type == "specter" %}
{% if device.supports_qr_message_signing %}
{% include "includes/overlay/qr_code_sign_message.jinja" %}
<button id="{{ device.alias }}_qr_sign_msg_btn" class="btn centered" style="margin-top: 10px;">{{ _("Sign message via QR code") }}</button>
{% endif %}
@ -204,7 +205,7 @@
}
// Event listener for sign message via QR code-button
{% if device.device_type == "specter" %}
{% if device.supports_qr_message_signing %}
document.getElementById("{{ device.alias }}_qr_sign_msg_btn").addEventListener("click", e => {
e.preventDefault();
hidePageOverlay();

View file

@ -132,7 +132,7 @@
// Message signing feature restricted to singlesig wallets using a Specter DIY
{% set device = wallet.devices[0] %}
{% if wallet.is_singlesig and device.hwi_support or wallet.is_singlesig and device.device_type == "specter" %}
{% if wallet.is_singlesig and device.hwi_support or wallet.is_singlesig and device.supports_qr_message_signing %}
let redirectUrl = `{{ url_for('devices_endpoint.device', device_alias=device.alias, origin='wallet', address='ADDRESS', derivation_path='DERIVATION_PATH') }}`.replace('ADDRESS', address).replace('DERIVATION_PATH', derivation_path);
addressInfoHTML += `<tr><td>{{ _("Message signing") }}:</td><td>
<button type="button" id="msg-signing-btn" class="signing-btn" onclick="location.href='${redirectUrl}';">