mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 01:35:20 +00:00
transaction: clean-up multisig_script
This commit is contained in:
parent
e04e8d2365
commit
e1b85327be
2 changed files with 6 additions and 9 deletions
|
@ -636,7 +636,7 @@ class Network(PrintError):
|
||||||
await asyncio.wait_for(interface.ready, timeout)
|
await asyncio.wait_for(interface.ready, timeout)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
#traceback.print_exc()
|
#traceback.print_exc()
|
||||||
self.print_error(server, "couldn't launch because", str(e), str(type(e)))
|
self.print_error(f"couldn't launch iface {server} -- {repr(e)}")
|
||||||
await interface.close()
|
await interface.close()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -38,7 +38,7 @@ from .util import print_error, profiler, to_bytes, bh2u, bfh
|
||||||
from .bitcoin import (TYPE_ADDRESS, TYPE_PUBKEY, TYPE_SCRIPT, hash_160,
|
from .bitcoin import (TYPE_ADDRESS, TYPE_PUBKEY, TYPE_SCRIPT, hash_160,
|
||||||
hash160_to_p2sh, hash160_to_p2pkh, hash_to_segwit_addr,
|
hash160_to_p2sh, hash160_to_p2pkh, hash_to_segwit_addr,
|
||||||
hash_encode, var_int, TOTAL_COIN_SUPPLY_LIMIT_IN_BTC, COIN,
|
hash_encode, var_int, TOTAL_COIN_SUPPLY_LIMIT_IN_BTC, COIN,
|
||||||
op_push, int_to_hex, push_script, b58_address_to_hash160)
|
push_script, int_to_hex, push_script, b58_address_to_hash160)
|
||||||
from .crypto import sha256d
|
from .crypto import sha256d
|
||||||
from .keystore import xpubkey_to_address, xpubkey_to_pubkey
|
from .keystore import xpubkey_to_address, xpubkey_to_pubkey
|
||||||
|
|
||||||
|
@ -649,15 +649,12 @@ def deserialize(raw: str, force_full_parse=False) -> dict:
|
||||||
|
|
||||||
# pay & redeem scripts
|
# pay & redeem scripts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def multisig_script(public_keys: Sequence[str], m: int) -> str:
|
def multisig_script(public_keys: Sequence[str], m: int) -> str:
|
||||||
n = len(public_keys)
|
n = len(public_keys)
|
||||||
assert n <= 15
|
assert 1 <= m <= n <= 15, f'm {m}, n {n}'
|
||||||
assert m <= n
|
op_m = bh2u(bytes([opcodes.OP_1 - 1 + m]))
|
||||||
op_m = format(opcodes.OP_1 + m - 1, 'x')
|
op_n = bh2u(bytes([opcodes.OP_1 - 1 + n]))
|
||||||
op_n = format(opcodes.OP_1 + n - 1, 'x')
|
keylist = [push_script(k) for k in public_keys]
|
||||||
keylist = [op_push(len(k)//2) + k for k in public_keys]
|
|
||||||
return op_m + ''.join(keylist) + op_n + 'ae'
|
return op_m + ''.join(keylist) + op_n + 'ae'
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue