mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 07:18:09 +00:00
core/bitcoin: Rename witness_p2wsh() to witness_multisig().
This commit is contained in:
parent
91b615c217
commit
37f4dcc7e5
@ -293,7 +293,7 @@ def parse_witness_p2wpkh(witness: bytes) -> Tuple[bytes, bytes, int]:
|
|||||||
return pubkey, signature, hash_type
|
return pubkey, signature, hash_type
|
||||||
|
|
||||||
|
|
||||||
def witness_p2wsh(
|
def witness_multisig(
|
||||||
multisig: MultisigRedeemScriptType,
|
multisig: MultisigRedeemScriptType,
|
||||||
signature: bytes,
|
signature: bytes,
|
||||||
signature_index: int,
|
signature_index: int,
|
||||||
@ -342,7 +342,7 @@ def witness_p2wsh(
|
|||||||
return w
|
return w
|
||||||
|
|
||||||
|
|
||||||
def parse_witness_p2wsh(witness: bytes) -> Tuple[bytes, List[Tuple[bytes, int]]]:
|
def parse_witness_multisig(witness: bytes) -> Tuple[bytes, List[Tuple[bytes, int]]]:
|
||||||
try:
|
try:
|
||||||
r = BytearrayReader(witness)
|
r = BytearrayReader(witness)
|
||||||
|
|
||||||
@ -535,7 +535,7 @@ def write_bip322_signature_proof(
|
|||||||
if multisig:
|
if multisig:
|
||||||
# find the place of our signature based on the public key
|
# find the place of our signature based on the public key
|
||||||
signature_index = multisig_pubkey_index(multisig, public_key)
|
signature_index = multisig_pubkey_index(multisig, public_key)
|
||||||
witness = witness_p2wsh(
|
witness = witness_multisig(
|
||||||
multisig, signature, signature_index, common.SIGHASH_ALL
|
multisig, signature, signature_index, common.SIGHASH_ALL
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -353,7 +353,7 @@ class Bitcoin:
|
|||||||
# find out place of our signature based on the pubkey
|
# find out place of our signature based on the pubkey
|
||||||
signature_index = multisig.multisig_pubkey_index(txi.multisig, public_key)
|
signature_index = multisig.multisig_pubkey_index(txi.multisig, public_key)
|
||||||
self.serialized_tx.extend(
|
self.serialized_tx.extend(
|
||||||
scripts.witness_p2wsh(
|
scripts.witness_multisig(
|
||||||
txi.multisig, signature, signature_index, self.get_hash_type(txi)
|
txi.multisig, signature, signature_index, self.get_hash_type(txi)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -13,8 +13,8 @@ from .scripts import (
|
|||||||
parse_input_script_multisig,
|
parse_input_script_multisig,
|
||||||
parse_input_script_p2pkh,
|
parse_input_script_p2pkh,
|
||||||
parse_output_script_multisig,
|
parse_output_script_multisig,
|
||||||
|
parse_witness_multisig,
|
||||||
parse_witness_p2wpkh,
|
parse_witness_p2wpkh,
|
||||||
parse_witness_p2wsh,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
@ -38,7 +38,7 @@ class SignatureVerifier:
|
|||||||
self.public_keys = [public_key]
|
self.public_keys = [public_key]
|
||||||
self.signatures = [(signature, hash_type)]
|
self.signatures = [(signature, hash_type)]
|
||||||
elif len(script_pubkey) == 34: # P2WSH
|
elif len(script_pubkey) == 34: # P2WSH
|
||||||
script, self.signatures = parse_witness_p2wsh(witness)
|
script, self.signatures = parse_witness_multisig(witness)
|
||||||
script_hash = sha256(script).digest()
|
script_hash = sha256(script).digest()
|
||||||
if output_script_native_p2wpkh_or_p2wsh(script_hash) != script_pubkey:
|
if output_script_native_p2wpkh_or_p2wsh(script_hash) != script_pubkey:
|
||||||
raise wire.DataError("Invalid script hash")
|
raise wire.DataError("Invalid script hash")
|
||||||
@ -57,7 +57,7 @@ class SignatureVerifier:
|
|||||||
self.public_keys = [public_key]
|
self.public_keys = [public_key]
|
||||||
self.signatures = [(signature, hash_type)]
|
self.signatures = [(signature, hash_type)]
|
||||||
elif len(script_sig) == 35: # P2WSH nested in BIP16 P2SH
|
elif len(script_sig) == 35: # P2WSH nested in BIP16 P2SH
|
||||||
script, self.signatures = parse_witness_p2wsh(witness)
|
script, self.signatures = parse_witness_multisig(witness)
|
||||||
script_hash = sha256(script).digest()
|
script_hash = sha256(script).digest()
|
||||||
if input_script_p2wsh_in_p2sh(script_hash) != script_sig:
|
if input_script_p2wsh_in_p2sh(script_hash) != script_sig:
|
||||||
raise wire.DataError("Invalid script hash")
|
raise wire.DataError("Invalid script hash")
|
||||||
|
Loading…
Reference in New Issue
Block a user