Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transaction sign with Ledger #62

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions electrum_dash/gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def __init__(self, gui_object: 'ElectrumGui', wallet: Abstract_Wallet):
tabs.addTab(self.create_history_tab(), read_QIcon("tab_history.png"), _('History'))
tabs.addTab(self.send_tab, read_QIcon("tab_send.png"), _('Send'))
tabs.addTab(self.receive_tab, read_QIcon("tab_receive.png"), _('Receive'))
tabs.addTab(self.utxo_tab, read_QIcon("tab_coins.png"), _("Co&ins"))
self.update_available_amount()

def add_optional_tab(tabs, tab, icon, description, name):
Expand Down
37 changes: 28 additions & 9 deletions electrum_dash/plugins/ledger/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,39 @@ def getTrustedInput(self, transaction, index):
self.dongle.exchange(bytearray(apdu))
offset += dataLength

params = []
#Sending the lockTime and the extraPayload
blockLength = 255
buffer = []
levonpetrosyan93 marked this conversation as resolved.
Show resolved Hide resolved
if transaction.extra_data:
if len(transaction.extra_data) > 255 - len(transaction.lockTime):
# for now the size should be sufficient
raise Exception('The size of the DIP2 extra data block has exceeded the limit.')
writeVarint(len(transaction.extra_data), buffer)
offset = blockLength - len(transaction.lockTime) - len(buffer)
levonpetrosyan93 marked this conversation as resolved.
Show resolved Hide resolved

writeVarint(len(transaction.extra_data), params)
params.extend(transaction.extra_data)
if transaction.extra_data:
apdu = [self.BTCHIP_CLA, self.BTCHIP_INS_GET_TRUSTED_INPUT, 0x80, 0x00, blockLength]
else:
apdu = [self.BTCHIP_CLA, self.BTCHIP_INS_GET_TRUSTED_INPUT, 0x80, 0x00, len(transaction.lockTime) + len(buffer)]
levonpetrosyan93 marked this conversation as resolved.
Show resolved Hide resolved

apdu = [self.BTCHIP_CLA, self.BTCHIP_INS_GET_TRUSTED_INPUT, 0x80, 0x00, len(transaction.lockTime) + len(params)]
# Locktime
apdu.extend(transaction.lockTime)
apdu.extend(params)
apdu.extend(buffer)
if offset > len(transaction.extra_data):
offset = len(transaction.extra_data)

if transaction.extra_data:
apdu.extend(transaction.extra_data[0: offset])
response = self.dongle.exchange(bytearray(apdu))

if transaction.extra_data:
while (offset < len(transaction.extra_data)):
blockLength = 255
if ((offset + blockLength) < len(transaction.extra_data)):
dataLength = blockLength
else:
dataLength = len(transaction.extra_data) - offset
apdu = [self.BTCHIP_CLA, self.BTCHIP_INS_GET_TRUSTED_INPUT, 0x80, 0x00, dataLength]
apdu.extend(transaction.extra_data[offset: offset + dataLength])
response = self.dongle.exchange(bytearray(apdu))
offset += dataLength

levonpetrosyan93 marked this conversation as resolved.
Show resolved Hide resolved
result['trustedInput'] = True
result['value'] = response
return result
Expand Down
Loading