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

Commit 5988ca2

Browse files
committed
Non default sequence support when signing a transaction
1 parent 84578ea commit 5988ca2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

btchip/btchip.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
219219
# Loop for each input
220220
currentIndex = 0
221221
for passedOutput in outputList:
222+
if ('sequence' in passedOutput) and passedOutput['sequence']:
223+
sequence = bytearray(passedOutput['sequence'].decode('hex'))
224+
else:
225+
sequence = bytearray([0xFF, 0xFF, 0xFF, 0xFF]) # default sequence
222226
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_HASH_INPUT_START, 0x80, 0x00 ]
223227
params = []
224228
script = redeemScript
@@ -235,7 +239,7 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
235239
script = bytearray()
236240
writeVarint(len(script), params)
237241
if len(script) == 0:
238-
params.extend(bytearray([0xFF, 0xFF, 0xFF, 0xFF])) # default sequence
242+
params.extend(sequence)
239243
apdu.append(len(params))
240244
apdu.extend(params)
241245
self.dongle.exchange(bytearray(apdu))
@@ -248,7 +252,7 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
248252
dataLength = len(script) - offset
249253
params = script[offset : offset + dataLength]
250254
if ((offset + dataLength) == len(script)):
251-
params.extend(bytearray([0xFF, 0xFF, 0xFF, 0xFF])) # default sequence
255+
params.extend(sequence)
252256
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_HASH_INPUT_START, 0x80, 0x00, len(params) ]
253257
apdu.extend(params)
254258
self.dongle.exchange(bytearray(apdu))

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.19',
10+
version='0.1.20',
1111
author='BTChip',
1212
author_email='[email protected]',
1313
description='Python library to communicate with Ledger Nano dongle',

0 commit comments

Comments
 (0)