Skip to content

Commit

Permalink
Update btchip library
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Jul 2, 2020
1 parent 4c08a59 commit bd60b74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hwilib/devices/btchip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
* limitations under the License.
********************************************************************************
"""

__version__ = "0.1.30"
10 changes: 6 additions & 4 deletions hwilib/devices/btchip/btchip.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def getTrustedInput(self, transaction, index):
result['value'] = response
return result

def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, redeemScript, version=0x01, cashAddr=False):
def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, redeemScript, version=0x01, cashAddr=False, continueSegwit=False):
# Start building a fake transaction with the passed inputs
segwit = False
if newTransaction:
Expand All @@ -186,7 +186,7 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
else:
p2 = 0x00
else:
p2 = 0x80
p2 = 0x10 if continueSegwit else 0x80
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_HASH_INPUT_START, 0x00, p2 ]
params = bytearray([version, 0x00, 0x00, 0x00])
writeVarint(len(outputList), params)
Expand Down Expand Up @@ -215,8 +215,6 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
if currentIndex != inputIndex:
script = bytearray()
writeVarint(len(script), params)
if len(script) == 0:
params.extend(sequence)
apdu.append(len(params))
apdu.extend(params)
self.dongle.exchange(bytearray(apdu))
Expand All @@ -234,6 +232,10 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
apdu.extend(params)
self.dongle.exchange(bytearray(apdu))
offset += blockLength
if len(script) == 0:
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_HASH_INPUT_START, 0x80, 0x00, len(sequence) ]
apdu.extend(sequence)
self.dongle.exchange(bytearray(apdu))
currentIndex += 1

def finalizeInput(self, outputAddress, amount, fees, changePath, rawTx=None):
Expand Down

0 comments on commit bd60b74

Please sign in to comment.