Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.
Open
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
19 changes: 14 additions & 5 deletions btchip/btchip.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,24 @@ def getTrustedInput(self, transaction, index):
self.dongle.exchange(bytearray(apdu))
# Each input
for trinput in transaction.inputs:
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_GET_TRUSTED_INPUT, 0x80, 0x00 ]
params = bytearray(trinput.prevOut)
writeVarint(len(trinput.script), params)
# TODO : in the unlikely case the script is longer, cut here
params.extend(trinput.script)
params.extend(trinput.sequence)
apdu.append(len(params))
apdu.extend(params)
self.dongle.exchange(bytearray(apdu))
offset = 0

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

# Number of outputs
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_GET_TRUSTED_INPUT, 0x80, 0x00 ]
params = []
Expand Down