1
0

sweep: rename sweep creation functions

naming scheme: tx(s)_our/their_ctx/htlctx_output-description

function names are shortened to whether a single (tx) or several sweep
transactions (txs) are generated
This commit is contained in:
bitromortac
2021-11-12 10:34:50 +01:00
committed by ThomasV
parent de9fee706d
commit 9c277802e9
2 changed files with 56 additions and 47 deletions

View File

@@ -57,9 +57,9 @@ from .lnutil import (Outpoint, LocalConfig, RemoteConfig, Keypair, OnlyPubkeyKey
fee_for_htlc_output, offered_htlc_trim_threshold_sat,
received_htlc_trim_threshold_sat, make_commitment_output_to_remote_address, FIXED_ANCHOR_SAT,
ChannelType, LNProtocolWarning, ctx_has_anchors)
from .lnsweep import create_sweeptxs_for_our_ctx, create_sweeptxs_for_their_ctx
from .lnsweep import create_sweeptx_for_their_revoked_htlc, SweepInfo
from .lnsweep import create_sweeptx_their_backup_ctx
from .lnsweep import txs_our_ctx, txs_their_ctx
from .lnsweep import tx_their_htlctx_justice, SweepInfo
from .lnsweep import tx_their_ctx_to_remote_backup
from .lnhtlc import HTLCManager
from .lnmsg import encode_msg, decode_msg
from .address_synchronizer import TX_HEIGHT_LOCAL
@@ -284,11 +284,11 @@ class AbstractChannel(Logger, ABC):
def delete_closing_height(self):
self.storage.pop('closing_height', None)
def create_sweeptxs_for_our_ctx(self, ctx: Transaction) -> Optional[Dict[str, SweepInfo]]:
return create_sweeptxs_for_our_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
def create_sweeptxs_for_our_ctx(self, ctx):
return txs_our_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
def create_sweeptxs_for_their_ctx(self, ctx: Transaction) -> Optional[Dict[str, SweepInfo]]:
return create_sweeptxs_for_their_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
def create_sweeptxs_for_their_ctx(self, ctx):
return txs_their_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
def is_backup(self) -> bool:
return False
@@ -595,11 +595,11 @@ class ChannelBackup(AbstractChannel):
return True
def create_sweeptxs_for_their_ctx(self, ctx):
return create_sweeptx_their_backup_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
return tx_their_ctx_to_remote_backup(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
def create_sweeptxs_for_our_ctx(self, ctx):
if self.is_imported:
return create_sweeptxs_for_our_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
return txs_our_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
else:
return
@@ -1491,9 +1491,9 @@ class Channel(AbstractChannel):
return self.get_commitment(subject, ctn=ctn)
def create_sweeptxs_for_watchtower(self, ctn: int) -> List[Transaction]:
from .lnsweep import create_sweeptxs_for_watchtower
from .lnsweep import txs_their_ctx_watchtower
secret, ctx = self.get_secret_and_commitment(REMOTE, ctn=ctn)
return create_sweeptxs_for_watchtower(self, ctx, secret, self.get_sweep_address())
return txs_their_ctx_watchtower(self, ctx, secret, self.get_sweep_address())
def get_oldest_unrevoked_ctn(self, subject: HTLCOwner) -> int:
return self.hm.ctn_oldest_unrevoked(subject)
@@ -1728,7 +1728,7 @@ class Channel(AbstractChannel):
def maybe_sweep_revoked_htlc(self, ctx: Transaction, htlc_tx: Transaction) -> Optional[SweepInfo]:
# look at the output address, check if it matches
return create_sweeptx_for_their_revoked_htlc(self, ctx, htlc_tx, self.get_sweep_address())
return tx_their_htlctx_justice(self, ctx, htlc_tx, self.get_sweep_address())
def has_pending_changes(self, subject: HTLCOwner) -> bool:
next_htlcs = self.hm.get_htlcs_in_next_ctx(subject)