Browse Source

lnsweep: use chan.logger instead of module _logger

to log the chan id for free
master
SomberNight 3 years ago
parent
commit
f6dc72899a
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/lnchannel.py
  2. 9
      electrum/lnsweep.py

4
electrum/lnchannel.py

@ -268,10 +268,10 @@ class AbstractChannel(Logger, ABC):
their_sweep_info = self.create_sweeptxs_for_their_ctx(ctx) their_sweep_info = self.create_sweeptxs_for_their_ctx(ctx)
if our_sweep_info is not None: if our_sweep_info is not None:
self._sweep_info[txid] = our_sweep_info self._sweep_info[txid] = our_sweep_info
self.logger.info(f'we force closed') self.logger.info(f'we (local) force closed')
elif their_sweep_info is not None: elif their_sweep_info is not None:
self._sweep_info[txid] = their_sweep_info self._sweep_info[txid] = their_sweep_info
self.logger.info(f'they force closed.') self.logger.info(f'they (remote) force closed.')
else: else:
self._sweep_info[txid] = {} self._sweep_info[txid] = {}
self.logger.info(f'not sure who closed.') self.logger.info(f'not sure who closed.')

9
electrum/lnsweep.py

@ -26,6 +26,7 @@ if TYPE_CHECKING:
_logger = get_logger(__name__) _logger = get_logger(__name__)
# note: better to use chan.logger instead, when applicable
class SweepInfo(NamedTuple): class SweepInfo(NamedTuple):
@ -215,7 +216,7 @@ def create_sweeptxs_for_our_ctx(
found_to_remote = False found_to_remote = False
if not found_to_local and not found_to_remote: if not found_to_local and not found_to_remote:
return return
_logger.debug(f'found our ctx: {to_local_address} {to_remote_address}') chan.logger.debug(f'(lnsweep) found our ctx: {to_local_address} {to_remote_address}')
# other outputs are htlcs # other outputs are htlcs
# if they are spent, we need to generate the script # if they are spent, we need to generate the script
# so, second-stage htlc sweep should not be returned here # so, second-stage htlc sweep should not be returned here
@ -241,7 +242,7 @@ def create_sweeptxs_for_our_ctx(
gen_tx=sweep_tx) gen_tx=sweep_tx)
we_breached = ctn < chan.get_oldest_unrevoked_ctn(LOCAL) we_breached = ctn < chan.get_oldest_unrevoked_ctn(LOCAL)
if we_breached: if we_breached:
_logger.info("we breached.") chan.logger.info(f"(lnsweep) we breached. txid: {ctx.txid()}")
# return only our_ctx_to_local, because we don't keep htlc_signatures for old states # return only our_ctx_to_local, because we don't keep htlc_signatures for old states
return txs return txs
@ -328,7 +329,7 @@ def analyze_ctx(chan: 'Channel', ctx: Transaction):
return return
their_pcp = ecc.ECPrivkey(per_commitment_secret).get_public_key_bytes(compressed=True) their_pcp = ecc.ECPrivkey(per_commitment_secret).get_public_key_bytes(compressed=True)
is_revocation = True is_revocation = True
#_logger.info(f'tx for revoked: {list(txs.keys())}') #chan.logger.debug(f'(lnsweep) tx for revoked: {list(txs.keys())}')
elif chan.get_data_loss_protect_remote_pcp(ctn): elif chan.get_data_loss_protect_remote_pcp(ctn):
their_pcp = chan.get_data_loss_protect_remote_pcp(ctn) their_pcp = chan.get_data_loss_protect_remote_pcp(ctn)
is_revocation = False is_revocation = False
@ -368,7 +369,7 @@ def create_sweeptxs_for_their_ctx(
found_to_remote = False found_to_remote = False
if not found_to_local and not found_to_remote: if not found_to_local and not found_to_remote:
return return
_logger.debug(f'found their ctx: {to_local_address} {to_remote_address}') chan.logger.debug(f'(lnsweep) found their ctx: {to_local_address} {to_remote_address}')
if is_revocation: if is_revocation:
our_revocation_privkey = derive_blinded_privkey(our_conf.revocation_basepoint.privkey, per_commitment_secret) our_revocation_privkey = derive_blinded_privkey(our_conf.revocation_basepoint.privkey, per_commitment_secret)
gen_tx = create_sweeptx_for_their_revoked_ctx(chan, ctx, per_commitment_secret, chan.sweep_address) gen_tx = create_sweeptx_for_their_revoked_ctx(chan, ctx, per_commitment_secret, chan.sweep_address)

Loading…
Cancel
Save