tpsbt follow-up: fix ln cooperative close, and minor type clean up - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 7b18c91b74bbebfe56ba547080ab29775e42feb2 DIR parent 707b74d22b28d942c445754311736f158e505990 HTML Author: SomberNight <somber.night@protonmail.com> Date: Thu, 7 Nov 2019 18:28:27 +0100 psbt follow-up: fix ln cooperative close, and minor type clean up Diffstat: M electrum/lnpeer.py | 6 +++--- M electrum/lnutil.py | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) --- DIR diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py t@@ -474,7 +474,7 @@ class Peer(Logger): funding_locked_received=False, was_announced=False, current_commitment_signature=None, - current_htlc_signatures=[], + current_htlc_signatures=b'', ) return local_config t@@ -1487,10 +1487,10 @@ class Peer(Logger): our_fee = their_fee # add signatures closing_tx.add_signature_to_txin(txin_idx=0, - signing_pubkey=chan.config[LOCAL].multisig_key.pubkey, + signing_pubkey=chan.config[LOCAL].multisig_key.pubkey.hex(), sig=bh2u(der_sig_from_sig_string(our_sig) + b'\x01')) closing_tx.add_signature_to_txin(txin_idx=0, - signing_pubkey=chan.config[REMOTE].multisig_key.pubkey, + signing_pubkey=chan.config[REMOTE].multisig_key.pubkey.hex(), sig=bh2u(der_sig_from_sig_string(their_sig) + b'\x01')) # broadcast await self.network.broadcast_transaction(closing_tx) DIR diff --git a/electrum/lnutil.py b/electrum/lnutil.py t@@ -27,8 +27,14 @@ if TYPE_CHECKING: HTLC_TIMEOUT_WEIGHT = 663 HTLC_SUCCESS_WEIGHT = 703 -Keypair = namedtuple("Keypair", ["pubkey", "privkey"]) -OnlyPubkeyKeypair = namedtuple("OnlyPubkeyKeypair", ["pubkey"]) + +class Keypair(NamedTuple): + pubkey: bytes + privkey: bytes + + +class OnlyPubkeyKeypair(NamedTuple): + pubkey: bytes # NamedTuples cannot subclass NamedTuples :'( https://github.com/python/typing/issues/427 t@@ -55,19 +61,19 @@ class LocalConfig(NamedTuple): class RemoteConfig(NamedTuple): # shared channel config fields (DUPLICATED code!!) - payment_basepoint: 'Keypair' - multisig_key: 'Keypair' - htlc_basepoint: 'Keypair' - delayed_basepoint: 'Keypair' - revocation_basepoint: 'Keypair' + payment_basepoint: Union['Keypair', 'OnlyPubkeyKeypair'] + multisig_key: Union['Keypair', 'OnlyPubkeyKeypair'] + htlc_basepoint: Union['Keypair', 'OnlyPubkeyKeypair'] + delayed_basepoint: Union['Keypair', 'OnlyPubkeyKeypair'] + revocation_basepoint: Union['Keypair', 'OnlyPubkeyKeypair'] to_self_delay: int dust_limit_sat: int max_htlc_value_in_flight_msat: int max_accepted_htlcs: int initial_msat: int reserve_sat: int - htlc_minimum_msat: int # specific to "REMOTE" config + htlc_minimum_msat: int next_per_commitment_point: bytes revocation_store: 'RevocationStore' current_per_commitment_point: Optional[bytes]