Skip to content

Commit

Permalink
Merge #593: jade: Pass utxo satoshi value to Jade on signing
Browse files Browse the repository at this point in the history
90a12a4 jade: Pass utxo satoshi value to Jade on signing (Jamie C. Driver)

Pull request description:

  Pass the utxo value, along with the prior tx (non-witness-utxo) when it
  is available.  Most of the time Jade requires the prior tx but there are
  cases when it can be omitted if the sats value is passed.
  Pass both whenever possible - the precise logic of which is required can
  remain contained in the Jade fw.
  (Improves compatibility with PSBT which does not always contain
  'non-witness-utxo' for segwit inputs.)

ACKs for top commit:
  achow101:
    ACK 90a12a4

Tree-SHA512: 3c5bd8e7817492146d0a5b33d9cd514156342770003b5d8eb3c73efd88f342c565305c8221caf5d4d620099385c2643451713eee04789f893c9fab130dd527a3
  • Loading branch information
achow101 committed May 6, 2022
2 parents 8ab80eb + 90a12a4 commit 01c1f55
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hwilib/devices/jade.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def _split_at_last_hardened_element(path: Sequence[int]) -> Tuple[Sequence[int],
input_txn_bytes = psbtin.non_witness_utxo.serialize_without_witness()
if utxo is None:
raise Exception('PSBT is missing input utxo information, cannot sign')
sats_value = utxo.nValue
scriptcode = utxo.scriptPubKey

if is_p2sh(scriptcode):
Expand Down Expand Up @@ -267,8 +268,8 @@ def _split_at_last_hardened_element(path: Sequence[int]) -> Tuple[Sequence[int],
signing_multisigs[multisig_name] = (script_variant, threshold, signers)

# Build the input and add to the list - include some host entropy for AE sigs (although we won't verify)
jade_inputs.append({'is_witness': witness_input, 'input_tx': input_txn_bytes, 'script': scriptcode, 'path': path,
'ae_host_entropy': os.urandom(32), 'ae_host_commitment': os.urandom(32)})
jade_inputs.append({'is_witness': witness_input, 'satoshi': sats_value, 'script': scriptcode, 'path': path,
'input_tx': input_txn_bytes, 'ae_host_entropy': os.urandom(32), 'ae_host_commitment': os.urandom(32)})

# Change output details
# This is optional, in that if we send it Jade validates the change output script
Expand Down

0 comments on commit 01c1f55

Please sign in to comment.