trezor plugin: support external pre-signed inputs
closes https://github.com/spesmilo/electrum/issues/8324
This commit is contained in:
@@ -371,7 +371,7 @@ class TrezorPlugin(HW_PluginBase):
|
|||||||
serialize=False,
|
serialize=False,
|
||||||
prev_txes=prev_tx)
|
prev_txes=prev_tx)
|
||||||
sighash = Sighash.to_sigbytes(Sighash.ALL).hex()
|
sighash = Sighash.to_sigbytes(Sighash.ALL).hex()
|
||||||
signatures = [(x.hex() + sighash) for x in signatures]
|
signatures = [((x.hex() + sighash) if x else None) for x in signatures]
|
||||||
tx.update_signatures(signatures)
|
tx.update_signatures(signatures)
|
||||||
|
|
||||||
@runs_in_hwd_thread
|
@runs_in_hwd_thread
|
||||||
@@ -412,17 +412,23 @@ class TrezorPlugin(HW_PluginBase):
|
|||||||
assert isinstance(tx, PartialTransaction)
|
assert isinstance(tx, PartialTransaction)
|
||||||
assert isinstance(txin, PartialTxInput)
|
assert isinstance(txin, PartialTxInput)
|
||||||
assert keystore
|
assert keystore
|
||||||
desc = txin.script_descriptor
|
if txin.is_complete():
|
||||||
assert desc
|
txinputtype.script_type = InputScriptType.EXTERNAL
|
||||||
if multi := desc.get_simple_multisig():
|
assert txin.scriptpubkey
|
||||||
txinputtype.multisig = self._make_multisig(multi)
|
txinputtype.script_pubkey = txin.scriptpubkey
|
||||||
txinputtype.script_type = self.get_trezor_input_script_type(desc.to_legacy_electrum_script_type())
|
else:
|
||||||
my_pubkey, full_path = keystore.find_my_pubkey_in_txinout(txin)
|
desc = txin.script_descriptor
|
||||||
if full_path:
|
assert desc
|
||||||
txinputtype.address_n = full_path
|
if multi := desc.get_simple_multisig():
|
||||||
|
txinputtype.multisig = self._make_multisig(multi)
|
||||||
|
txinputtype.script_type = self.get_trezor_input_script_type(desc.to_legacy_electrum_script_type())
|
||||||
|
my_pubkey, full_path = keystore.find_my_pubkey_in_txinout(txin)
|
||||||
|
if full_path:
|
||||||
|
txinputtype.address_n = full_path
|
||||||
|
|
||||||
txinputtype.amount = txin.value_sats()
|
txinputtype.amount = txin.value_sats()
|
||||||
txinputtype.script_sig = txin.script_sig
|
txinputtype.script_sig = txin.script_sig
|
||||||
|
txinputtype.witness = txin.witness
|
||||||
txinputtype.sequence = txin.nsequence
|
txinputtype.sequence = txin.nsequence
|
||||||
|
|
||||||
inputs.append(txinputtype)
|
inputs.append(txinputtype)
|
||||||
|
|||||||
@@ -2145,7 +2145,7 @@ class PartialTransaction(Transaction):
|
|||||||
raw_bytes = self.serialize_as_bytes()
|
raw_bytes = self.serialize_as_bytes()
|
||||||
return base64.b64encode(raw_bytes).decode('ascii')
|
return base64.b64encode(raw_bytes).decode('ascii')
|
||||||
|
|
||||||
def update_signatures(self, signatures: Sequence[str]):
|
def update_signatures(self, signatures: Sequence[Union[str, None]]):
|
||||||
"""Add new signatures to a transaction
|
"""Add new signatures to a transaction
|
||||||
|
|
||||||
`signatures` is expected to be a list of sigs with signatures[i]
|
`signatures` is expected to be a list of sigs with signatures[i]
|
||||||
@@ -2159,6 +2159,8 @@ class PartialTransaction(Transaction):
|
|||||||
for i, txin in enumerate(self.inputs()):
|
for i, txin in enumerate(self.inputs()):
|
||||||
pubkeys = [pk.hex() for pk in txin.pubkeys]
|
pubkeys = [pk.hex() for pk in txin.pubkeys]
|
||||||
sig = signatures[i]
|
sig = signatures[i]
|
||||||
|
if sig is None:
|
||||||
|
continue
|
||||||
if bfh(sig) in list(txin.part_sigs.values()):
|
if bfh(sig) in list(txin.part_sigs.values()):
|
||||||
continue
|
continue
|
||||||
pre_hash = sha256d(bfh(self.serialize_preimage(i)))
|
pre_hash = sha256d(bfh(self.serialize_preimage(i)))
|
||||||
|
|||||||
Reference in New Issue
Block a user