Skip to content

Commit 703d482

Browse files
committed
[HW] Sign P2CS inputs on Ledger (and trigger warning on Trezor)
1 parent 41c473a commit 703d482

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/ledgerClient.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ def append_inputs_to_TX(self, utxo, bip32_path):
148148
'pubkey': curr_pubkey,
149149
'bip32_path': bip32_path,
150150
'outputIndex': utxo['vout'],
151-
'txid': utxo['txid']
151+
'txid': utxo['txid'],
152+
'p2cs': (utxo['staker'] != "")
152153
})
153154

154155

@@ -370,7 +371,10 @@ def signTxSign(self, ctrl):
370371
inputTx.prevOut = bytearray.fromhex(new_input['txid'])[::-1] + int.to_bytes(new_input['outputIndex'], 4,
371372
byteorder='little')
372373

373-
inputTx.script = bytearray([len(sig)]) + sig + bytearray([0x21]) + new_input['pubkey']
374+
inputTx.script = bytearray([len(sig)]) + sig
375+
if new_input['p2cs']:
376+
inputTx.script += bytearray([0x00])
377+
inputTx.script += bytearray([0x21]) + new_input['pubkey']
374378

375379
inputTx.sequence = bytearray([0xFF, 0xFF, 0xFF, 0xFF])
376380

src/trezorClient.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def __init__(self, model, main_wnd, *args, **kwargs):
8484

8585
@process_trezor_exceptions
8686
def append_inputs_to_TX(self, utxo, bip32_path, inputs):
87+
if utxo['staker'] != "":
88+
printException(getCallerName(), getFunctionName(), "Unable to sing P2CS on Trezor", "")
89+
return
8790
# Update amount
8891
self.amount += int(utxo['satoshis'])
8992
# Add input

0 commit comments

Comments
 (0)