Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit fe29221

Browse files
committed
Fix parsing, bump version
1 parent 8b0476d commit fe29221

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

btchip/btchip.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,19 @@ def finalizeInput(self, outputAddress, amount, fees, changePath, rawTx=None):
272272
if result['confirmationType'] == 0x02:
273273
result['keycardData'] = response[1 + response[0] + 1:]
274274
if result['confirmationType'] == 0x03:
275-
offset = 1 + response[0]
276-
result['keycardData'] = response[offset + 1 : offset + 1 + response[offset]]
275+
offset = 1 + response[0] + 1
276+
keycardDataLength = response[offset]
277277
offset = offset + 1
278+
result['keycardData'] = response[offset : offset + keycardDataLength]
279+
offset = offset + keycardDataLength
278280
result['secureScreenData'] = response[offset:]
279281
result['outputData'] = response[1 : 1 + response[0]]
280282
return result
281283

282284
def finalizeInputFull(self, outputData):
283285
result = {}
284286
offset = 0
287+
encryptedOutputData = ""
285288
while (offset < len(outputData)):
286289
blockLength = 255
287290
if ((offset + blockLength) < len(outputData)):
@@ -294,13 +297,22 @@ def finalizeInputFull(self, outputData):
294297
p1, 0x00, dataLength ]
295298
apdu.extend(outputData[offset : offset + dataLength])
296299
response = self.dongle.exchange(bytearray(apdu))
300+
encryptedOutputData = encryptedOutputData + response[1 : 1 + response[0]]
297301
offset += dataLength
298-
result['confirmationNeeded'] = response[0] <> 0x00
299-
result['confirmationType'] = response[0]
300-
if result['confirmationType'] == 0x02:
301-
result['keycardData'] = response[1:]
302-
if result['confirmationType'] == 0x03:
303-
result['secureScreenData'] = response[1:]
302+
result['confirmationNeeded'] = response[1 + response[0]] <> 0x00
303+
result['confirmationType'] = response[1 + response[0]]
304+
if result['confirmationType'] == 0x02:
305+
offset = 1 + response[0] + 1
306+
keycardDataLength = response[offset]
307+
result['keycardData'] = response[offset : offset + keycardDataLength]
308+
if result['confirmationType'] == 0x03:
309+
offset = 1 + response[0] + 1
310+
keycardDataLength = response[offset]
311+
offset = offset + 1
312+
result['keycardData'] = response[offset : offset + keycardDataLength]
313+
offset = offset + keycardDataLength
314+
result['secureScreenData'] = response[offset:]
315+
result['encryptedOutputData'] = encryptedOutputData
304316
return result
305317

306318
def untrustedHashSign(self, path, pin="", lockTime=0, sighashType=0x01):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
here = dirname(__file__)
88
setup(
99
name='btchip-python',
10-
version='0.1.15',
10+
version='0.1.16',
1111
author='BTChip',
1212
author_email='[email protected]',
1313
description='Python library to communicate with Ledger Nano dongle',

0 commit comments

Comments
 (0)