electrum

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

commit 15fb8c04158c563f0d010db1b5b83b39f4464b7f
parent 28452e2d4661715841aba7bea43c855dc6e9f9e1
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  6 Mar 2020 11:40:08 +0100

allow transition from FORCE_CLOSING to REDEEMED. define REDEEM_AFTER_DOUBLE_SPENT_DELAY

Diffstat:
Melectrum/lnchannel.py | 1+
Melectrum/lnutil.py | 1+
Melectrum/lnworker.py | 8+++++---
3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py @@ -99,6 +99,7 @@ state_transitions = [ (cs.CLOSING, cs.CLOSING), # if we reestablish (cs.CLOSING, cs.CLOSED), (cs.FORCE_CLOSING, cs.CLOSED), + (cs.FORCE_CLOSING, cs.REDEEMED), (cs.CLOSED, cs.REDEEMED), (cs.OPENING, cs.REDEEMED), # channel never funded (dropped from mempool) (cs.PREOPENING, cs.REDEEMED), # channel never funded diff --git a/electrum/lnutil.py b/electrum/lnutil.py @@ -135,6 +135,7 @@ class PaymentFailure(UserFacingException): pass # TODO make some of these values configurable? DEFAULT_TO_SELF_DELAY = 144 +REDEEM_AFTER_DOUBLE_SPENT_DELAY = 30 ##### CLTV-expiry-delta-related values # see https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#cltv_expiry_delta-selection diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -704,8 +704,11 @@ class LNWallet(LNWorker): return chan async def update_unfunded_channel(self, chan, funding_txid): - if chan.get_state() in [channel_states.PREOPENING, channel_states.OPENING]: + if chan.get_state() in [channel_states.PREOPENING, channel_states.OPENING, channel_states.FORCE_CLOSING]: if chan.constraints.is_initiator: + # set channel state to REDEEMED so that it can be removed manually + # to protect ourselves against a server lying by omission, + # we check that funding_inputs have been double spent and deeply mined inputs = chan.storage.get('funding_inputs', []) if not inputs: self.logger.info(f'channel funding inputs are not provided') @@ -716,9 +719,8 @@ class LNWallet(LNWorker): continue if spender_txid != funding_txid: tx_mined_height = self.wallet.get_tx_height(spender_txid) - if tx_mined_height.conf > 6: + if tx_mined_height.conf > lnutil.REDEEM_AFTER_DOUBLE_SPENT_DELAY: self.logger.info(f'channel is double spent {inputs}') - # set to REDEEMED so that it can be removed manually chan.set_state(channel_states.REDEEMED) break else: