From 39aa8afd134ad1a96d647158e358d38474442124 Mon Sep 17 00:00:00 2001 From: kdmukai Date: Sun, 27 Mar 2022 18:01:16 -0500 Subject: [PATCH 1/2] Support for Nunchuk animated multisig wallet descriptors --- src/seedsigner/helpers/ur2/ur_decoder.py | 4 ++++ src/seedsigner/models/decode_qr.py | 5 +++-- src/seedsigner/views/scan_views.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/seedsigner/helpers/ur2/ur_decoder.py b/src/seedsigner/helpers/ur2/ur_decoder.py index c0baf21f8..d8fb4fde3 100644 --- a/src/seedsigner/helpers/ur2/ur_decoder.py +++ b/src/seedsigner/helpers/ur2/ur_decoder.py @@ -143,6 +143,10 @@ def expected_type(self): def expected_part_count(self): return self.fountain_decoder.expected_part_count() + + @property + def total_segments(self): + return self.expected_part_count() def received_part_indexes(self): return self.fountain_decoder.received_part_indexes diff --git a/src/seedsigner/models/decode_qr.py b/src/seedsigner/models/decode_qr.py index 0118e8fe8..db7ac61de 100644 --- a/src/seedsigner/models/decode_qr.py +++ b/src/seedsigner/models/decode_qr.py @@ -278,7 +278,8 @@ def is_wallet_descriptor(self): if self.qr_type in [QRType.BYTES__UR]: cbor = self.decoder.result_message().cbor raw = Bytes.from_cbor(cbor).data - check = 'multisig setup file' in raw.decode("utf-8").lower() + data = raw.decode("utf-8").lower() + check = 'policy:' in data and "format:" in data and "derivation:" in data return check @@ -572,7 +573,7 @@ def multisig_setup_file_to_descriptor(text) -> str: descriptor += ',[' + x['xfp'] + derivation + "]" + x['key'] + "/{0,1}/*" descriptor += script_close - + return descriptor class BaseQrDecoder: diff --git a/src/seedsigner/views/scan_views.py b/src/seedsigner/views/scan_views.py index 771aa10cd..1376cf1da 100644 --- a/src/seedsigner/views/scan_views.py +++ b/src/seedsigner/views/scan_views.py @@ -79,6 +79,7 @@ def run(self): if not descriptor.is_basic_multisig: # TODO: Handle single-sig descriptors? + print(f"Received single sig descriptor: {descriptor}") return Destination(NotYetImplementedView) self.controller.multisig_wallet_descriptor = descriptor From e8ed183ae791d5b4dd984b37cd9a9ac28cf7224c Mon Sep 17 00:00:00 2001 From: kdmukai Date: Sun, 27 Mar 2022 19:12:42 -0500 Subject: [PATCH 2/2] Improvement on DecodeQR bugfix --- src/seedsigner/helpers/ur2/ur_decoder.py | 4 ---- src/seedsigner/models/decode_qr.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/seedsigner/helpers/ur2/ur_decoder.py b/src/seedsigner/helpers/ur2/ur_decoder.py index d8fb4fde3..c0baf21f8 100644 --- a/src/seedsigner/helpers/ur2/ur_decoder.py +++ b/src/seedsigner/helpers/ur2/ur_decoder.py @@ -143,10 +143,6 @@ def expected_type(self): def expected_part_count(self): return self.fountain_decoder.expected_part_count() - - @property - def total_segments(self): - return self.expected_part_count() def received_part_indexes(self): return self.fountain_decoder.received_part_indexes diff --git a/src/seedsigner/models/decode_qr.py b/src/seedsigner/models/decode_qr.py index db7ac61de..7578ea9d5 100644 --- a/src/seedsigner/models/decode_qr.py +++ b/src/seedsigner/models/decode_qr.py @@ -212,7 +212,7 @@ def get_percent_complete(self) -> int: if not self.decoder: return 0 - if self.qr_type in [QRType.PSBT__UR2, QRType.OUTPUT__UR, QRType.ACCOUNT__UR]: + if self.qr_type in [QRType.PSBT__UR2, QRType.OUTPUT__UR, QRType.ACCOUNT__UR, QRType.BYTES__UR]: return int(self.decoder.estimated_percent_complete() * 100) elif self.qr_type in [QRType.PSBT__SPECTER]: