mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 08:38:07 +00:00
core: ensure multisig (m,n) parameters are valid (#423)
This commit is contained in:
parent
1eb823be03
commit
5b3427a21d
@ -250,7 +250,7 @@ def input_script_multisig(
|
||||
|
||||
def output_script_multisig(pubkeys, m: int, w: bytearray = None) -> bytearray:
|
||||
n = len(pubkeys)
|
||||
if n < 1 or n > 15 or m < 1 or m > 15:
|
||||
if n < 1 or n > 15 or m < 1 or m > 15 or m > n:
|
||||
raise ScriptsError("Invalid multisig parameters")
|
||||
for pubkey in pubkeys:
|
||||
if len(pubkey) != 33:
|
||||
|
@ -110,6 +110,10 @@ class TestAddress(unittest.TestCase):
|
||||
address = address_multisig_p2sh(pubkeys, 2, coin)
|
||||
self.assertEqual(address, '39bgKC7RFbpoCRbtD5KEdkYKtNyhpsNa3Z')
|
||||
|
||||
for invalid_m in (-1, 0, len(pubkeys) + 1, 16):
|
||||
with self.assertRaises(scripts.ScriptsError):
|
||||
address_multisig_p2sh(pubkeys, invalid_m, coin)
|
||||
|
||||
def test_multisig_address_p2wsh_in_p2sh(self):
|
||||
# test data from
|
||||
# https://bitcoin.stackexchange.com/questions/62656/generate-a-p2sh-p2wsh-address-and-spend-output-sent-to-it
|
||||
|
Loading…
Reference in New Issue
Block a user