Skip to content

Commit bbb69bf

Browse files
committed
went ahead and removed comments on self-explanatory code
1 parent 4d9bbd2 commit bbb69bf

3 files changed

Lines changed: 0 additions & 59 deletions

File tree

electrum/gui/qml/components/wizard/WCHaveMasterKey.qml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ WizardComponent {
2727
wizard_data['multisig_cosigner_data'][cosigner.toString()]['master_key'] = key
2828
} else {
2929
wizard_data['master_key'] = key
30-
// Pass key-origin fields through to create_storage() so the
31-
// keystore is stored with the correct derivation prefix and master
32-
// fingerprint. Both fields are optional; empty strings are ignored.
3330
wizard_data['key_origin_derivation'] = derivation_tf.text.trim()
3431
wizard_data['key_origin_fingerprint'] = fingerprint_tf.text.trim().toLowerCase()
3532
}
@@ -65,12 +62,9 @@ WizardComponent {
6562
return valid = true
6663
}
6764

68-
// Validate the key-origin fields and update the inline error label.
69-
// Returns true when everything is OK (or when the section is not shown).
7065
function validateKeyOrigin() {
7166
if (cosigner || wizard_data['wallet_type'] === 'multisig')
7267
return true
73-
// Section is hidden for depth <= 1: no validation needed.
7468
if (bitcoin.masterKeyDepth(masterkey_ta.text.trim()) <= 1)
7569
return true
7670
var msg = bitcoin.verifyKeyOriginInfo(
@@ -82,8 +76,6 @@ WizardComponent {
8276
return msg === ''
8377
}
8478

85-
// Revalidate both the master key and the key-origin fields together,
86-
// then commit the current values to wizard_data.
8779
function revalidate() {
8880
var keyOk = verifyMasterKey(masterkey_ta.text)
8981
var originOk = validateKeyOrigin()
@@ -222,30 +214,8 @@ WizardComponent {
222214
}
223215
}
224216

225-
// ── Key-origin section ─────────────────────────────────────────────
226-
// Only shown for standard single-sig imports (not multisig/cosigner)
227-
// where the key depth is > 1.
228-
//
229-
// Both fields are optional.
230-
//
231-
// Hardware wallets export xpubs at derivation depth > 1 (e.g.
232-
// Coldcard exports a zpub at m/84'/0'/0', depth=3). Electrum
233-
// cannot infer the master fingerprint or the full derivation path
234-
// from such an xpub alone, so without these values the generated
235-
// PSBTs will be missing key-origin metadata and hardware signers
236-
// that verify it will refuse to sign the transaction.
237-
//
238-
// At depth 0 the node IS the root -> fingerprint is computed locally.
239-
// At depth 1 the node encodes the master fingerprint directly in its
240-
// parent_fingerprint bytes, so Electrum can infer it automatically.
241-
// At depth > 1 the xpub only carries the *immediate parent's*
242-
// fingerprint (e.g. Coldcard zpub at m/84'/0'/0' has depth 3), so
243-
// Electrum cannot recover the master fingerprint or full path on its
244-
// own -> the user must supply them.
245217
ColumnLayout {
246218
id: keyOriginSection
247-
// masterKeyDepth returns -1 for invalid/empty input, so the
248-
// section stays hidden until a valid key of depth > 1 is entered.
249219
visible: !cosigner
250220
&& wizard_data['wallet_type'] !== 'multisig'
251221
&& bitcoin.masterKeyDepth(masterkey_ta.text.trim()) > 1

electrum/gui/qml/qebitcoin.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,6 @@ def verifyDerivationPath(self, path):
100100

101101
@pyqtSlot(str, str, str, result=str)
102102
def verifyKeyOriginInfo(self, xpub: str, derivation: str, fingerprint: str) -> str:
103-
"""Validate optional key-origin fields against the given xpub.
104-
105-
Both fields are optional, passing empty strings is valid. When
106-
non-empty each field is checked for format, and if the xpub is also
107-
provided the combination is checked for internal consistency
108-
(derivation path depth must match the xpub depth, last child number
109-
must match, etc.).
110-
111-
Returns an empty string if everything is valid, or a translated
112-
human-readable error message describing the problem.
113-
"""
114103
derivation = derivation.strip()
115104
fingerprint = fingerprint.strip().lower()
116105
if not derivation and not fingerprint:
@@ -136,17 +125,6 @@ def verifyKeyOriginInfo(self, xpub: str, derivation: str, fingerprint: str) -> s
136125

137126
@pyqtSlot(str, result=int)
138127
def masterKeyDepth(self, key: str) -> int:
139-
"""Return the BIP32 depth of *key* (xpub or xprv), or -1 if invalid.
140-
141-
Depth 0: key is the root; fingerprint computed locally.
142-
Depth 1: parent_fingerprint in the xpub IS the master fingerprint;
143-
Electrum can recover it automatically.
144-
Depth > 1: only the immediate parent fingerprint is encoded (e.g.
145-
a Coldcard zpub at m/84'/0'/0' has depth 3); neither the
146-
master fingerprint nor the full path can be recovered,
147-
the user must supply them.
148-
Returns -1 for empty or invalid input.
149-
"""
150128
try:
151129
return BIP32Node.from_xkey(key.strip()).depth
152130
except Exception:

electrum/wizard.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -749,13 +749,6 @@ def create_storage(self, path: str, data: dict):
749749
else:
750750
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
751751
raise UserFacingException(_('Wrong key type {}').format(t1))
752-
# Apply optional key-origin metadata supplied by the user.
753-
# A raw xpub exported from a hardware wallet (e.g. Coldcard at
754-
# m/84'/0'/0', depth=3) cannot encode the master fingerprint or
755-
# the full derivation path by itself. Without these values the
756-
# keystore generates PSBTs whose bip32_derivations use only the
757-
# xpub's own intermediate fingerprint, which hardware signers
758-
# that verify key-origin (Coldcard fw >= 3.2.1) will reject.
759752
_der = data.get('key_origin_derivation', '').strip()
760753
_fp = data.get('key_origin_fingerprint', '').strip().lower()
761754
if _der or _fp:

0 commit comments

Comments
 (0)