1
0

lnsweep: use chan.logger instead of module _logger

to log the chan id for free
This commit is contained in:
SomberNight
2023-03-01 15:27:13 +00:00
parent 3c5774a189
commit f6dc72899a
2 changed files with 7 additions and 6 deletions

View File

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

View File

@@ -26,6 +26,7 @@ if TYPE_CHECKING:
_logger = get_logger(__name__)
# note: better to use chan.logger instead, when applicable
class SweepInfo(NamedTuple):
@@ -215,7 +216,7 @@ def create_sweeptxs_for_our_ctx(
found_to_remote = False
if not found_to_local and not found_to_remote:
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
# if they are spent, we need to generate the script
# so, second-stage htlc sweep should not be returned here
@@ -241,7 +242,7 @@ def create_sweeptxs_for_our_ctx(
gen_tx=sweep_tx)
we_breached = ctn < chan.get_oldest_unrevoked_ctn(LOCAL)
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 txs
@@ -328,7 +329,7 @@ def analyze_ctx(chan: 'Channel', ctx: Transaction):
return
their_pcp = ecc.ECPrivkey(per_commitment_secret).get_public_key_bytes(compressed=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):
their_pcp = chan.get_data_loss_protect_remote_pcp(ctn)
is_revocation = False
@@ -368,7 +369,7 @@ def create_sweeptxs_for_their_ctx(
found_to_remote = False
if not found_to_local and not found_to_remote:
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:
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)