Skip to content

Commit d2d3c12

Browse files
Feature: QR message signing for SeedSigner (#1938)
* supports_qr_message_signing added * cypress test adapted Co-authored-by: moneymanolis <[email protected]>
1 parent cdd09fc commit d2d3c12

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

cypress/integration/spec_qr_signing.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,14 @@ describe('Test QR code signing flow', () => {
2525
cy.get('#page_overlay_popup_cancel_button').click()
2626
})
2727

28-
it('QR code signing (currently) only available for DIYs', () => {
28+
it('No QR message signing button for a Trezor', () => {
2929
// Changing the device type to simulate a different device
3030
cy.changeDeviceType("DIY ghost", "Trezor")
31+
cy.reload()
3132
cy.contains("Sign message").click()
3233
// Only USB signing available for a Trezor device
33-
cy.get('#diy_ghost_qr_sign_msg_btn').should('not.exist')
34-
cy.get('#diy_ghost_usb_sign_msg_btn').should('exist')
35-
cy.get('#page_overlay_popup_cancel_button').click()
36-
cy.contains("Ghost wallet").click()
37-
cy.get('main').contains('Addresses').click()
38-
cy.contains('td', '#0').siblings().contains('bcrt').click()
39-
cy.get('#msg-signing-btn').should('exist')
40-
cy.get('#page_overlay_popup_cancel_button').click()
41-
// Reload fixes issues with sometimes persisting overlays
42-
cy.reload()
34+
cy.contains('Sign message via USB').should('be.visible')
35+
cy.contains('Sign message via QR code').should('not.exist')
4336
// Change device type back to DIY
4437
cy.changeDeviceType("DIY ghost", "specter")
4538
})

src/cryptoadvance/specter/device.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Device:
2424
# - "on": animate psbt by default
2525
# - "off": don't animate psbt even if it is huge
2626
qr_code_animate = "auto"
27+
supports_qr_message_signing = False
2728
hwi_support = False
2829
supports_hwi_toggle_passphrase = False
2930
supports_hwi_multisig_display_address = False

src/cryptoadvance/specter/devices/seedsigner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ class SeedSignerDevice(Device):
99

1010
sd_card_support = False
1111
qr_code_support = True
12+
qr_code_support_verify = True
1213
qr_code_frame_rate = 2 # 500 ms per frame
1314
qr_code_animate = "on"
15+
supports_qr_message_signing = True
16+
taproot_support = True
1417

1518
def create_psbts(self, base64_psbt, wallet):
1619
# in QR codes keep only xpubs

src/cryptoadvance/specter/devices/specter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Specter(SDCardDevice):
6969
qr_code_support = True
7070
qr_code_support_verify = True
7171
wallet_export_type = "qr"
72+
supports_qr_message_signing = True
7273
supports_hwi_multisig_display_address = True
7374
liquid_support = True
7475
taproot_support = True

src/cryptoadvance/specter/templates/device/device.jinja

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
<button id="add_keys" type="submit" name="action" value="add_keys" class="btn centered">{{ _("Convert to hot wallet") }}</button>
9393
{% endif %}
9494
</form>
95-
{% if device.hwi_support or device.device_type == "specter" %}
95+
96+
{% if device.hwi_support or device.supports_qr_message_signing %}
9697
<button type="button" class="btn centered" onclick="showPageOverlay('message-signing')">{{ _("Sign message") }}</button>
9798
<div id="message-signing" class="hidden" style="text-align: left; max-width: 350px;">
9899
{% if origin %}
@@ -107,7 +108,7 @@
107108
{% if device.hwi_support %}
108109
<button id="{{ device.alias }}_usb_sign_msg_btn" type="button" class="btn centered" onclick="signMessageOnDevice();">{{ _("Sign message via USB") }}</button>
109110
{% endif %}
110-
{% if device.device_type == "specter" %}
111+
{% if device.supports_qr_message_signing %}
111112
{% include "includes/overlay/qr_code_sign_message.jinja" %}
112113
<button id="{{ device.alias }}_qr_sign_msg_btn" class="btn centered" style="margin-top: 10px;">{{ _("Sign message via QR code") }}</button>
113114
{% endif %}
@@ -204,7 +205,7 @@
204205
}
205206
206207
// Event listener for sign message via QR code-button
207-
{% if device.device_type == "specter" %}
208+
{% if device.supports_qr_message_signing %}
208209
document.getElementById("{{ device.alias }}_qr_sign_msg_btn").addEventListener("click", e => {
209210
e.preventDefault();
210211
hidePageOverlay();

src/cryptoadvance/specter/templates/includes/address-data.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ <h1>{{ _("Address details") }}</h1><br>
132132

133133
// Message signing feature restricted to singlesig wallets using a Specter DIY
134134
{% set device = wallet.devices[0] %}
135-
{% if wallet.is_singlesig and device.hwi_support or wallet.is_singlesig and device.device_type == "specter" %}
135+
{% if wallet.is_singlesig and device.hwi_support or wallet.is_singlesig and device.supports_qr_message_signing %}
136136
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);
137137
addressInfoHTML += `<tr><td>{{ _("Message signing") }}:</td><td>
138138
<button type="button" id="msg-signing-btn" class="signing-btn" onclick="location.href='${redirectUrl}';">

0 commit comments

Comments
 (0)