mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
Support Ledger 2FA Security Card and prepare for new encoding format
This commit is contained in:
parent
db68dcbc14
commit
eed37e82d2
1 changed files with 29 additions and 6 deletions
|
@ -353,6 +353,7 @@ class BTChipWallet(BIP32_HD_Wallet):
|
||||||
outputAmount = None
|
outputAmount = None
|
||||||
use2FA = False
|
use2FA = False
|
||||||
pin = ""
|
pin = ""
|
||||||
|
rawTx = tx.serialize()
|
||||||
# Fetch inputs of the transaction to sign
|
# Fetch inputs of the transaction to sign
|
||||||
for txinput in tx.inputs:
|
for txinput in tx.inputs:
|
||||||
if ('is_coinbase' in txinput and txinput['is_coinbase']):
|
if ('is_coinbase' in txinput and txinput['is_coinbase']):
|
||||||
|
@ -396,13 +397,35 @@ class BTChipWallet(BIP32_HD_Wallet):
|
||||||
self.get_client().startUntrustedTransaction(firstTransaction, inputIndex,
|
self.get_client().startUntrustedTransaction(firstTransaction, inputIndex,
|
||||||
trustedInputs, redeemScripts[inputIndex])
|
trustedInputs, redeemScripts[inputIndex])
|
||||||
outputData = self.get_client().finalizeInput(output, format_satoshis(outputAmount),
|
outputData = self.get_client().finalizeInput(output, format_satoshis(outputAmount),
|
||||||
format_satoshis(self.get_tx_fee(tx)), changePath)
|
format_satoshis(self.get_tx_fee(tx)), changePath, bytearray(rawTx.decode('hex')))
|
||||||
if firstTransaction:
|
if firstTransaction:
|
||||||
transactionOutput = outputData['outputData']
|
transactionOutput = outputData['outputData']
|
||||||
if outputData['confirmationNeeded']:
|
if outputData['confirmationNeeded']:
|
||||||
use2FA = True
|
use2FA = True
|
||||||
# TODO : handle different confirmation types. For the time being only supports keyboard 2FA
|
# TODO : handle different confirmation types. For the time being only supports keyboard 2FA
|
||||||
waitDialog.emit(SIGNAL('dongle_done'))
|
waitDialog.emit(SIGNAL('dongle_done'))
|
||||||
|
if 'keycardData' in outputData:
|
||||||
|
pin2 = ""
|
||||||
|
for keycardIndex in range(len(outputData['keycardData'])):
|
||||||
|
msg = "Do not enter your device PIN here !\r\n\r\n" + \
|
||||||
|
"Your BTChip wants to talk to you and tell you a unique second factor code.\r\n" + \
|
||||||
|
"For this to work, please match the character between stars of the output address using your security card\r\n\r\n" + \
|
||||||
|
"Output address : "
|
||||||
|
for index in range(len(output)):
|
||||||
|
if index == outputData['keycardData'][keycardIndex]:
|
||||||
|
msg = msg + "*" + output[index] + "*"
|
||||||
|
else:
|
||||||
|
msg = msg + output[index]
|
||||||
|
msg = msg + "\r\n"
|
||||||
|
confirmed, p, pin = self.password_dialog(msg)
|
||||||
|
if not confirmed:
|
||||||
|
raise Exception('Aborted by user')
|
||||||
|
try:
|
||||||
|
pin2 = pin2 + chr(int(pin[0], 16))
|
||||||
|
except:
|
||||||
|
raise Exception('Invalid PIN character')
|
||||||
|
pin = pin2
|
||||||
|
else:
|
||||||
confirmed, p, pin = self.password_dialog()
|
confirmed, p, pin = self.password_dialog()
|
||||||
if not confirmed:
|
if not confirmed:
|
||||||
raise Exception('Aborted by user')
|
raise Exception('Aborted by user')
|
||||||
|
|
Loading…
Add table
Reference in a new issue