Skip to content

Commit

Permalink
sweep: rename sweep creation functions and reorder
Browse files Browse the repository at this point in the history
naming scheme:
tx(s)_our/their_ctx/htlctx_output-description

* functinon names are shortened to whether a single (tx) or several sweep
  transactions (txs) are generated
* functions are ordered by their purpose (our/their ctx related)
  • Loading branch information
bitromortac committed Nov 18, 2021
1 parent 3f9c530 commit f9210b4
Show file tree
Hide file tree
Showing 2 changed files with 416 additions and 416 deletions.
20 changes: 10 additions & 10 deletions electrum/lnchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
fee_for_htlc_output, offered_htlc_trim_threshold_sat,
received_htlc_trim_threshold_sat, make_commitment_output_to_remote_address, FIXED_ANCHOR_SAT,
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
Expand Down Expand Up @@ -223,10 +223,10 @@ def delete_closing_height(self):
self.storage.pop('closing_height', None)

def create_sweeptxs_for_our_ctx(self, ctx):
return create_sweeptxs_for_our_ctx(chan=self, ctx=ctx, sweep_address=self.sweep_address)
return txs_our_ctx(chan=self, ctx=ctx, sweep_address=self.sweep_address)

def create_sweeptxs_for_their_ctx(self, ctx):
return create_sweeptxs_for_their_ctx(chan=self, ctx=ctx, sweep_address=self.sweep_address)
return txs_their_ctx(chan=self, ctx=ctx, sweep_address=self.sweep_address)

def is_backup(self):
return False
Expand Down Expand Up @@ -494,11 +494,11 @@ def is_backup(self):
return True

def create_sweeptxs_for_their_ctx(self, ctx):
return create_sweeptx_their_backup_ctx(chan=self, ctx=ctx, sweep_address=self.sweep_address)
return tx_their_ctx_to_remote_backup(chan=self, ctx=ctx, sweep_address=self.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.sweep_address)
return txs_our_ctx(chan=self, ctx=ctx, sweep_address=self.sweep_address)
else:
return

Expand Down Expand Up @@ -1316,9 +1316,9 @@ def get_oldest_unrevoked_commitment(self, subject: HTLCOwner) -> PartialTransact
return self.get_commitment(subject, ctn=ctn)

def create_sweeptxs(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.sweep_address)
return txs_their_ctx_watchtower(self, ctx, secret, self.sweep_address)

def get_oldest_unrevoked_ctn(self, subject: HTLCOwner) -> int:
return self.hm.ctn_oldest_unrevoked(subject)
Expand Down Expand Up @@ -1543,7 +1543,7 @@ def force_close_tx(self) -> PartialTransaction:

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.sweep_address)
return tx_their_htlctx_justice(self, ctx, htlc_tx, self.sweep_address)

def has_pending_changes(self, subject: HTLCOwner) -> bool:
next_htlcs = self.hm.get_htlcs_in_next_ctx(subject)
Expand Down
Loading

0 comments on commit f9210b4

Please sign in to comment.