mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-11 13:09:52 +00:00
parent
7ebff5616e
commit
8f7a4cf876
1 changed files with 28 additions and 17 deletions
|
@ -652,12 +652,19 @@ class Transaction:
|
||||||
return pubkeys, x_pubkeys
|
return pubkeys, x_pubkeys
|
||||||
|
|
||||||
def update_signatures(self, signatures: Sequence[str]):
|
def update_signatures(self, signatures: Sequence[str]):
|
||||||
"""Add new signatures to a transaction"""
|
"""Add new signatures to a transaction
|
||||||
|
|
||||||
|
`signatures` is expected to be a list of sigs with signatures[i]
|
||||||
|
intended for self._inputs[i].
|
||||||
|
This is used by the Trezor and KeepKey plugins.
|
||||||
|
"""
|
||||||
if self.is_complete():
|
if self.is_complete():
|
||||||
return
|
return
|
||||||
|
if len(self.inputs()) != len(signatures):
|
||||||
|
raise Exception('expected {} signatures; got {}'.format(len(self.inputs()), len(signatures)))
|
||||||
for i, txin in enumerate(self.inputs()):
|
for i, txin in enumerate(self.inputs()):
|
||||||
pubkeys, x_pubkeys = self.get_sorted_pubkeys(txin)
|
pubkeys, x_pubkeys = self.get_sorted_pubkeys(txin)
|
||||||
for sig in signatures:
|
sig = signatures[i]
|
||||||
if sig in txin.get('signatures'):
|
if sig in txin.get('signatures'):
|
||||||
continue
|
continue
|
||||||
pre_hash = Hash(bfh(self.serialize_preimage(i)))
|
pre_hash = Hash(bfh(self.serialize_preimage(i)))
|
||||||
|
@ -670,7 +677,11 @@ class Transaction:
|
||||||
continue
|
continue
|
||||||
pubkey_hex = public_key.get_public_key_hex(compressed=True)
|
pubkey_hex = public_key.get_public_key_hex(compressed=True)
|
||||||
if pubkey_hex in pubkeys:
|
if pubkey_hex in pubkeys:
|
||||||
|
try:
|
||||||
public_key.verify_message_hash(sig_string, pre_hash)
|
public_key.verify_message_hash(sig_string, pre_hash)
|
||||||
|
except Exception:
|
||||||
|
traceback.print_exc(file=sys.stderr)
|
||||||
|
continue
|
||||||
j = pubkeys.index(pubkey_hex)
|
j = pubkeys.index(pubkey_hex)
|
||||||
print_error("adding sig", i, j, pubkey_hex, sig)
|
print_error("adding sig", i, j, pubkey_hex, sig)
|
||||||
self.add_signature_to_txin(self._inputs[i], j, sig)
|
self.add_signature_to_txin(self._inputs[i], j, sig)
|
||||||
|
|
Loading…
Add table
Reference in a new issue