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

Commit 7c6d107

Browse files
committed
CashAddr support
1 parent 6e985b5 commit 7c6d107

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

btchip/btchip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ def getVerifyPinRemainingAttempts(self):
114114
return e.sw - 0x63c0
115115
raise e
116116

117-
def getWalletPublicKey(self, path, showOnScreen=False, segwit=False, segwitNative=False):
117+
def getWalletPublicKey(self, path, showOnScreen=False, segwit=False, segwitNative=False, cashAddr=False):
118118
result = {}
119119
donglePath = parse_bip32_path(path)
120120
if self.needKeyCache:
121121
self.resolvePublicKeysInPath(path)
122-
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_GET_WALLET_PUBLIC_KEY, 0x01 if showOnScreen else 0x00, 0x02 if segwitNative else 0x01 if segwit else 0x00, len(donglePath) ]
122+
apdu = [ self.BTCHIP_CLA, self.BTCHIP_INS_GET_WALLET_PUBLIC_KEY, 0x01 if showOnScreen else 0x00, 0x03 if cashAddr else 0x02 if segwitNative else 0x01 if segwit else 0x00, len(donglePath) ]
123123
apdu.extend(donglePath)
124124
response = self.dongle.exchange(bytearray(apdu))
125125
offset = 0
@@ -199,7 +199,7 @@ def getTrustedInput(self, transaction, index):
199199
result['value'] = response
200200
return result
201201

202-
def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, redeemScript, version=0x01):
202+
def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, redeemScript, version=0x01, cashAddr=False):
203203
# Start building a fake transaction with the passed inputs
204204
segwit = False
205205
if newTransaction:
@@ -209,7 +209,7 @@ def startUntrustedTransaction(self, newTransaction, inputIndex, outputList, rede
209209
break
210210
if newTransaction:
211211
if segwit:
212-
p2 = 0x02
212+
p2 = 0x03 if cashAddr else 0x02
213213
else:
214214
p2 = 0x00
215215
else:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
here = dirname(__file__)
88
setup(
99
name='btchip-python',
10-
version='0.1.26',
10+
version='0.1.27',
1111
author='BTChip',
1212
author_email='[email protected]',
1313
description='Python library to communicate with Ledger Nano dongle',

0 commit comments

Comments
 (0)