Skip to content

Commit

Permalink
Non default sequence support when signing a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
BTChip github committed Apr 12, 2017
1 parent 84578ea commit 5988ca2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions btchip/btchip.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
# Loop for each input
currentIndex = 0
for passedOutput in outputList:
if ('sequence' in passedOutput) and passedOutput['sequence']:
sequence = bytearray(passedOutput['sequence'].decode('hex'))
else:
sequence = bytearray([0xFF, 0xFF, 0xFF, 0xFF]) # default sequence
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_HASH_INPUT_START, 0x80, 0x00 ]
params = []
script = redeemScript
Expand All @@ -235,7 +239,7 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
script = bytearray()
writeVarint(len(script), params)
if len(script) == 0:
params.extend(bytearray([0xFF, 0xFF, 0xFF, 0xFF])) # default sequence
params.extend(sequence)
apdu.append(len(params))
apdu.extend(params)
self.dongle.exchange(bytearray(apdu))
Expand All @@ -248,7 +252,7 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
dataLength = len(script) - offset
params = script[offset : offset + dataLength]
if ((offset + dataLength) == len(script)):
params.extend(bytearray([0xFF, 0xFF, 0xFF, 0xFF])) # default sequence
params.extend(sequence)
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_HASH_INPUT_START, 0x80, 0x00, len(params) ]
apdu.extend(params)
self.dongle.exchange(bytearray(apdu))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
here = dirname(__file__)
setup(
name='btchip-python',
version='0.1.19',
version='0.1.20',
author='BTChip',
author_email='[email protected]',
description='Python library to communicate with Ledger Nano dongle',
Expand Down

0 comments on commit 5988ca2

Please sign in to comment.