electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit e1b85327bed94f99fb239c6cb6bff672e392b6aa
parent e04e8d236573d5ad5cd40bcca8c6d613b6ee31a4
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed, 14 Nov 2018 00:37:03 +0100

transaction: clean-up multisig_script

Diffstat:
Melectrum/network.py | 2+-
Melectrum/transaction.py | 13+++++--------
2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/electrum/network.py b/electrum/network.py @@ -636,7 +636,7 @@ class Network(PrintError): await asyncio.wait_for(interface.ready, timeout) except BaseException as e: #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() return else: diff --git a/electrum/transaction.py b/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, hash160_to_p2sh, hash160_to_p2pkh, hash_to_segwit_addr, 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 .keystore import xpubkey_to_address, xpubkey_to_pubkey @@ -649,15 +649,12 @@ def deserialize(raw: str, force_full_parse=False) -> dict: # pay & redeem scripts - - def multisig_script(public_keys: Sequence[str], m: int) -> str: n = len(public_keys) - assert n <= 15 - assert m <= n - op_m = format(opcodes.OP_1 + m - 1, 'x') - op_n = format(opcodes.OP_1 + n - 1, 'x') - keylist = [op_push(len(k)//2) + k for k in public_keys] + assert 1 <= m <= n <= 15, f'm {m}, n {n}' + op_m = bh2u(bytes([opcodes.OP_1 - 1 + m])) + op_n = bh2u(bytes([opcodes.OP_1 - 1 + n])) + keylist = [push_script(k) for k in public_keys] return op_m + ''.join(keylist) + op_n + 'ae'