@@ -79,6 +79,15 @@ def __init__(self, dongle):
7979 self .dongle = dongle
8080 self .needKeyCache = False
8181 try :
82+ firmware = self .getFirmwareVersion ()['version' ].split ("." )
83+ self .multiOutputSupported = int (firmware [0 ]) >= 1 and int (firmware [1 ]) >= 1 and int (firmware [2 ]) >= 4
84+ if self .multiOutputSupported :
85+ self .scriptBlockLength = 50
86+ else :
87+ self .scriptBlockLength = 255
88+ except :
89+ pass
90+ try :
8291 result = self .getJCExtendedFeatures ()
8392 self .needKeyCache = (result ['proprietaryApi' ] == False )
8493 except :
@@ -264,12 +273,20 @@ def finalizeInput(self, outputAddress, amount, fees, changePath, rawTx=None):
264273 apdu .append (len (params ))
265274 apdu .extend (params )
266275 response = self .dongle .exchange (bytearray (apdu ))
267- apdu = [ self .BTCHIP_CLA , self .BTCHIP_INS_HASH_INPUT_FINALIZE_FULL , 0x80 , 0x00 ]
268- params = []
269- params .extend (outputs )
270- apdu .append (len (params ))
271- apdu .extend (params )
272- response = self .dongle .exchange (bytearray (apdu ))
276+ offset = 0
277+ while (offset < len (outputs )):
278+ blockLength = self .scriptBlockLength
279+ if ((offset + blockLength ) < len (outputs )):
280+ dataLength = blockLength
281+ p1 = 0x00
282+ else :
283+ dataLength = len (outputs ) - offset
284+ p1 = 0x80
285+ apdu = [ self .BTCHIP_CLA , self .BTCHIP_INS_HASH_INPUT_FINALIZE_FULL , \
286+ p1 , 0x00 , dataLength ]
287+ apdu .extend (outputs [offset : offset + dataLength ])
288+ response = self .dongle .exchange (bytearray (apdu ))
289+ offset += dataLength
273290 alternateEncoding = True
274291 except :
275292 pass
@@ -310,7 +327,7 @@ def finalizeInputFull(self, outputData):
310327 offset = 0
311328 encryptedOutputData = ""
312329 while (offset < len (outputData )):
313- blockLength = 255
330+ blockLength = self . scriptBlockLength
314331 if ((offset + blockLength ) < len (outputData )):
315332 dataLength = blockLength
316333 p1 = 0x00
0 commit comments