Browse Source

transaction: clean-up multisig_script

3.3.3.1
SomberNight 6 years ago
parent
commit
e1b85327be
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/network.py
  2. 13
      electrum/transaction.py

2
electrum/network.py

@ -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:

13
electrum/transaction.py

@ -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…
Cancel
Save