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

Commit 49495ec

Browse files
authored
Merge pull request #20 from instagibbs/keepdetails
take version and sequence numbers in help functions
2 parents 5988ca2 + c14731d commit 49495ec

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

btchip/btchip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def getTrustedInput(self, transaction, index):
195195
result['value'] = response
196196
return result
197197

198-
def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, redeemScript):
198+
def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, redeemScript, version=0x01):
199199
# Start building a fake transaction with the passed inputs
200200
segwit = False
201201
if newTransaction:
@@ -211,7 +211,7 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
211211
else:
212212
p2 = 0x80
213213
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_HASH_INPUT_START, 0x00, p2 ]
214-
params = bytearray([0x01, 0x00, 0x00, 0x00]) # default version
214+
params = bytearray([version, 0x00, 0x00, 0x00])
215215
writeVarint(len(outputList), params)
216216
apdu.append(len(params))
217217
apdu.extend(params)

btchip/btchipUtils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ def format_transaction(dongleOutputData, trustedInputsAndInputScripts, version=0
4343
newInput = bitcoinInput()
4444
newInput.prevOut = item[0][4:4+36]
4545
newInput.script = item[1]
46-
newInput.sequence = bytearray([0xff, 0xff, 0xff, 0xff])
46+
if len(item > 2):
47+
newInput.sequence = bytearray(item[2].decode('hex'))
48+
else:
49+
newInput.sequence = bytearray([0xff, 0xff, 0xff, 0xff])
4750
transaction.inputs.append(newInput)
4851
result = transaction.serialize(True)
4952
result.extend(dongleOutputData)

0 commit comments

Comments
 (0)