electrum

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

commit 7b18c91b74bbebfe56ba547080ab29775e42feb2
parent 707b74d22b28d942c445754311736f158e505990
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:
Melectrum/lnpeer.py | 6+++---
Melectrum/lnutil.py | 22++++++++++++++--------
2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -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 @@ -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) diff --git a/electrum/lnutil.py b/electrum/lnutil.py @@ -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 @@ -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]