Minor style changes
This commit is contained in:
@@ -97,7 +97,7 @@ class CKCCClient(HardwareClientBase):
|
||||
if expected_xpub is None:
|
||||
expected_xpub = self.dev.master_xpub
|
||||
|
||||
if ( (self._expected_device is not None)
|
||||
if ((self._expected_device is not None)
|
||||
or (self.dev.master_fingerprint != expected_xfp)
|
||||
or (self.dev.master_xpub != expected_xpub)):
|
||||
# probably indicating programing error, not hacking
|
||||
@@ -569,14 +569,14 @@ class ColdcardPlugin(HW_PluginBase):
|
||||
print('# Exported from Electrum', file=fp)
|
||||
print(f'Name: {name:.20s}', file=fp)
|
||||
print(f'Policy: {wallet.m} of {wallet.n}', file=fp)
|
||||
print(f'Format: {wallet.txin_type.upper()}' , file=fp)
|
||||
print(f'Format: {wallet.txin_type.upper()}', file=fp)
|
||||
|
||||
xpubs = []
|
||||
for xpub, ks in zip(wallet.get_master_public_keys(), wallet.get_keystores()): # type: str, KeyStoreWithMPK
|
||||
fp_bytes, der_full = ks.get_fp_and_derivation_to_be_used_in_partial_tx(der_suffix=[], only_der_suffix=False)
|
||||
fp_hex = fp_bytes.hex().upper()
|
||||
der_prefix_str = bip32.convert_bip32_intpath_to_strpath(der_full)
|
||||
xpubs.append( (fp_hex, xpub, der_prefix_str) )
|
||||
xpubs.append((fp_hex, xpub, der_prefix_str))
|
||||
|
||||
# Before v3.2.1 derivation didn't matter too much to the Coldcard, since it
|
||||
# could use key path data from PSBT or USB request as needed. However,
|
||||
|
||||
@@ -136,7 +136,7 @@ class CKCCSettingsDialog(WindowModalDialog):
|
||||
<br><a href="https://coldcardwallet.com">coldcardwallet.com</a>''')
|
||||
title.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
|
||||
|
||||
grid.addWidget(title , 0,0, 1,2, Qt.AlignHCenter)
|
||||
grid.addWidget(title, 0,0, 1,2, Qt.AlignHCenter)
|
||||
y = 3
|
||||
|
||||
rows = [
|
||||
|
||||
@@ -15,7 +15,7 @@ class CmdLineHandler(HardwareHandlerBase):
|
||||
return getpass.getpass('')
|
||||
|
||||
def get_pin(self, msg, *, show_strength=True):
|
||||
t = { 'a':'7', 'b':'8', 'c':'9', 'd':'4', 'e':'5', 'f':'6', 'g':'1', 'h':'2', 'i':'3'}
|
||||
t = {'a':'7', 'b':'8', 'c':'9', 'd':'4', 'e':'5', 'f':'6', 'g':'1', 'h':'2', 'i':'3'}
|
||||
print_stderr(msg)
|
||||
print_stderr("a b c\nd e f\ng h i\n-----")
|
||||
o = raw_input()
|
||||
|
||||
@@ -48,8 +48,8 @@ class HW_PluginBase(BasePlugin):
|
||||
libraries_available: bool
|
||||
|
||||
# define supported library versions: minimum_library <= x < maximum_library
|
||||
minimum_library = (0, )
|
||||
maximum_library = (float('inf'), )
|
||||
minimum_library = (0,)
|
||||
maximum_library = (float('inf'),)
|
||||
|
||||
DEVICE_IDS: Iterable[Any]
|
||||
|
||||
|
||||
@@ -308,9 +308,9 @@ class KeepKeyPlugin(HW_PluginBase):
|
||||
return self.types.SPENDWITNESS
|
||||
if electrum_txin_type in ('p2wpkh-p2sh', 'p2wsh-p2sh'):
|
||||
return self.types.SPENDP2SHWITNESS
|
||||
if electrum_txin_type in ('p2pkh', ):
|
||||
if electrum_txin_type in ('p2pkh',):
|
||||
return self.types.SPENDADDRESS
|
||||
if electrum_txin_type in ('p2sh', ):
|
||||
if electrum_txin_type in ('p2sh',):
|
||||
return self.types.SPENDMULTISIG
|
||||
raise ValueError('unexpected txin type: {}'.format(electrum_txin_type))
|
||||
|
||||
@@ -319,9 +319,9 @@ class KeepKeyPlugin(HW_PluginBase):
|
||||
return self.types.PAYTOWITNESS
|
||||
if electrum_txin_type in ('p2wpkh-p2sh', 'p2wsh-p2sh'):
|
||||
return self.types.PAYTOP2SHWITNESS
|
||||
if electrum_txin_type in ('p2pkh', ):
|
||||
if electrum_txin_type in ('p2pkh',):
|
||||
return self.types.PAYTOADDRESS
|
||||
if electrum_txin_type in ('p2sh', ):
|
||||
if electrum_txin_type in ('p2sh',):
|
||||
return self.types.PAYTOMULTISIG
|
||||
raise ValueError('unexpected txin type: {}'.format(electrum_txin_type))
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ helpTxt = [_("Your Ledger Wallet wants to tell you a one-time PIN code.<br><br>"
|
||||
"put your cursor into it, and plug your device into that computer. " \
|
||||
"It will output a summary of the transaction being signed and a one-time PIN.<br><br>" \
|
||||
"Verify the transaction summary and type the PIN code here.<br><br>" \
|
||||
"Before pressing enter, plug the device back into this computer.<br>" ),
|
||||
"Before pressing enter, plug the device back into this computer.<br>"),
|
||||
_("Verify the address below.<br>Type the character from your security card corresponding to the <u><b>BOLD</b></u> character."),
|
||||
]
|
||||
|
||||
@@ -161,7 +161,7 @@ class LedgerAuthDialog(QDialog):
|
||||
def getDevice2FAMode(self):
|
||||
apdu = [0xe0, 0x24, 0x01, 0x00, 0x00, 0x01] # get 2fa mode
|
||||
try:
|
||||
mode = self.dongle.exchange( bytearray(apdu) )
|
||||
mode = self.dongle.exchange(bytearray(apdu))
|
||||
return mode
|
||||
except BTChipException as e:
|
||||
_logger.debug('Device getMode Failed')
|
||||
|
||||
@@ -193,7 +193,7 @@ class Ledger_Client(HardwareClientBase):
|
||||
except BTChipException as e:
|
||||
if (e.sw == 0x6985):
|
||||
self.close()
|
||||
self.handler.get_setup( )
|
||||
self.handler.get_setup()
|
||||
# Acquire the new client on the next run
|
||||
else:
|
||||
raise e
|
||||
@@ -493,7 +493,7 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
||||
raise UserWarning()
|
||||
self.handler.show_message(_("Confirmed. Signing Transaction..."))
|
||||
while inputIndex < len(inputs):
|
||||
singleInput = [ chipInputs[inputIndex] ]
|
||||
singleInput = [chipInputs[inputIndex]]
|
||||
client_ledger.startUntrustedTransaction(False, 0,
|
||||
singleInput, redeemScripts[inputIndex], version=tx.version)
|
||||
inputSignature = client_ledger.untrustedHashSign(inputsPaths[inputIndex], pin, lockTime=tx.locktime)
|
||||
@@ -595,7 +595,7 @@ class LedgerPlugin(HW_PluginBase):
|
||||
(0x2c97, 0x0009), # RFU
|
||||
(0x2c97, 0x000a) # RFU
|
||||
]
|
||||
VENDOR_IDS = (0x2c97, )
|
||||
VENDOR_IDS = (0x2c97,)
|
||||
LEDGER_MODEL_IDS = {
|
||||
0x10: "Ledger Nano S",
|
||||
0x40: "Ledger Nano X",
|
||||
|
||||
@@ -299,7 +299,7 @@ class Plugin(RevealerPlugin):
|
||||
bitmap.fill(Qt.white)
|
||||
painter = QPainter()
|
||||
painter.begin(bitmap)
|
||||
QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'SourceSansPro-Bold.otf') )
|
||||
QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'SourceSansPro-Bold.otf'))
|
||||
if len(txt) < 102 :
|
||||
fontsize = 15
|
||||
linespace = 15
|
||||
@@ -325,7 +325,7 @@ class Plugin(RevealerPlugin):
|
||||
while len(' '.join(map(str, temp_seed))) > max_letters:
|
||||
nwords = nwords - 1
|
||||
temp_seed = seed_array[:nwords]
|
||||
painter.drawText(QRect(0, linespace*n , self.SIZE[0], self.SIZE[1]), Qt.AlignHCenter, ' '.join(map(str, temp_seed)))
|
||||
painter.drawText(QRect(0, linespace*n, self.SIZE[0], self.SIZE[1]), Qt.AlignHCenter, ' '.join(map(str, temp_seed)))
|
||||
del seed_array[:nwords]
|
||||
|
||||
painter.end()
|
||||
@@ -463,7 +463,7 @@ class Plugin(RevealerPlugin):
|
||||
painter.end()
|
||||
|
||||
def pixelcode_2x2(self, img):
|
||||
result = QImage(img.width()*2, img.height()*2, QImage.Format_ARGB32 )
|
||||
result = QImage(img.width()*2, img.height()*2, QImage.Format_ARGB32)
|
||||
white = qRgba(255,255,255,0)
|
||||
black = qRgba(0,0,0,255)
|
||||
|
||||
@@ -625,7 +625,7 @@ class Plugin(RevealerPlugin):
|
||||
+ self.versioned_seed.checksum)
|
||||
target = QRectF(base_img.width()-65-qr_size,
|
||||
base_img.height()-65-qr_size,
|
||||
qr_size, qr_size )
|
||||
qr_size, qr_size)
|
||||
painter.drawImage(target, qr_qt)
|
||||
painter.setPen(QPen(Qt.black, 4))
|
||||
painter.drawLine(base_img.width()-65-qr_size,
|
||||
|
||||
@@ -278,9 +278,9 @@ class SafeTPlugin(HW_PluginBase):
|
||||
return self.types.InputScriptType.SPENDWITNESS
|
||||
if electrum_txin_type in ('p2wpkh-p2sh', 'p2wsh-p2sh'):
|
||||
return self.types.InputScriptType.SPENDP2SHWITNESS
|
||||
if electrum_txin_type in ('p2pkh', ):
|
||||
if electrum_txin_type in ('p2pkh',):
|
||||
return self.types.InputScriptType.SPENDADDRESS
|
||||
if electrum_txin_type in ('p2sh', ):
|
||||
if electrum_txin_type in ('p2sh',):
|
||||
return self.types.InputScriptType.SPENDMULTISIG
|
||||
raise ValueError('unexpected txin type: {}'.format(electrum_txin_type))
|
||||
|
||||
@@ -289,9 +289,9 @@ class SafeTPlugin(HW_PluginBase):
|
||||
return self.types.OutputScriptType.PAYTOWITNESS
|
||||
if electrum_txin_type in ('p2wpkh-p2sh', 'p2wsh-p2sh'):
|
||||
return self.types.OutputScriptType.PAYTOP2SHWITNESS
|
||||
if electrum_txin_type in ('p2pkh', ):
|
||||
if electrum_txin_type in ('p2pkh',):
|
||||
return self.types.OutputScriptType.PAYTOADDRESS
|
||||
if electrum_txin_type in ('p2sh', ):
|
||||
if electrum_txin_type in ('p2sh',):
|
||||
return self.types.OutputScriptType.PAYTOMULTISIG
|
||||
raise ValueError('unexpected txin type: {}'.format(electrum_txin_type))
|
||||
|
||||
|
||||
@@ -322,9 +322,9 @@ class TrezorPlugin(HW_PluginBase):
|
||||
return InputScriptType.SPENDWITNESS
|
||||
if electrum_txin_type in ('p2wpkh-p2sh', 'p2wsh-p2sh'):
|
||||
return InputScriptType.SPENDP2SHWITNESS
|
||||
if electrum_txin_type in ('p2pkh', ):
|
||||
if electrum_txin_type in ('p2pkh',):
|
||||
return InputScriptType.SPENDADDRESS
|
||||
if electrum_txin_type in ('p2sh', ):
|
||||
if electrum_txin_type in ('p2sh',):
|
||||
return InputScriptType.SPENDMULTISIG
|
||||
raise ValueError('unexpected txin type: {}'.format(electrum_txin_type))
|
||||
|
||||
@@ -333,15 +333,15 @@ class TrezorPlugin(HW_PluginBase):
|
||||
return OutputScriptType.PAYTOWITNESS
|
||||
if electrum_txin_type in ('p2wpkh-p2sh', 'p2wsh-p2sh'):
|
||||
return OutputScriptType.PAYTOP2SHWITNESS
|
||||
if electrum_txin_type in ('p2pkh', ):
|
||||
if electrum_txin_type in ('p2pkh',):
|
||||
return OutputScriptType.PAYTOADDRESS
|
||||
if electrum_txin_type in ('p2sh', ):
|
||||
if electrum_txin_type in ('p2sh',):
|
||||
return OutputScriptType.PAYTOMULTISIG
|
||||
raise ValueError('unexpected txin type: {}'.format(electrum_txin_type))
|
||||
|
||||
@runs_in_hwd_thread
|
||||
def sign_transaction(self, keystore, tx: PartialTransaction, prev_tx):
|
||||
prev_tx = { bfh(txhash): self.electrum_tx_to_txtype(tx) for txhash, tx in prev_tx.items() }
|
||||
prev_tx = {bfh(txhash): self.electrum_tx_to_txtype(tx) for txhash, tx in prev_tx.items()}
|
||||
client = self.get_client(keystore)
|
||||
inputs = self.tx_inputs(tx, for_sig=True, keystore=keystore)
|
||||
outputs = self.tx_outputs(tx, keystore=keystore)
|
||||
|
||||
Reference in New Issue
Block a user