lnchannel: convert sweep_address property to get_sweep_address() method
no functional changes
This commit is contained in:
@@ -191,7 +191,6 @@ class AbstractChannel(Logger, ABC):
|
||||
funding_outpoint: Outpoint
|
||||
node_id: bytes # note that it might not be the full 33 bytes; for OCB it is only the prefix
|
||||
_state: ChannelState
|
||||
sweep_address: str
|
||||
|
||||
def set_short_channel_id(self, short_id: ShortChannelID) -> None:
|
||||
self.short_channel_id = short_id
|
||||
@@ -284,10 +283,10 @@ class AbstractChannel(Logger, ABC):
|
||||
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 create_sweeptxs_for_our_ctx(chan=self, ctx=ctx, sweep_address=self.get_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 create_sweeptxs_for_their_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
|
||||
|
||||
def is_backup(self):
|
||||
return False
|
||||
@@ -416,6 +415,14 @@ class AbstractChannel(Logger, ABC):
|
||||
def get_funding_address(self) -> str:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_sweep_address(self) -> str:
|
||||
"""Returns a wallet address we can use to sweep coins to.
|
||||
It could be something static to the channel (fixed for its lifecycle),
|
||||
or it might just ask the wallet now for an unused address.
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_state_for_GUI(self) -> str:
|
||||
cs = self.get_state()
|
||||
if cs <= ChannelState.OPEN and self.unconfirmed_closing_txid:
|
||||
@@ -575,7 +582,7 @@ class ChannelBackup(AbstractChannel):
|
||||
|
||||
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 create_sweeptxs_for_our_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
|
||||
else:
|
||||
# backup from op_return
|
||||
return {}
|
||||
@@ -613,8 +620,7 @@ class ChannelBackup(AbstractChannel):
|
||||
def is_frozen_for_receiving(self) -> bool:
|
||||
return False
|
||||
|
||||
@property
|
||||
def sweep_address(self) -> str:
|
||||
def get_sweep_address(self) -> str:
|
||||
return self.lnworker.wallet.get_new_sweep_address_for_channel()
|
||||
|
||||
def get_local_pubkey(self) -> bytes:
|
||||
@@ -846,10 +852,8 @@ class Channel(AbstractChannel):
|
||||
channel_type = ChannelType(self.storage.get('channel_type'))
|
||||
return bool(channel_type & ChannelType.OPTION_ZEROCONF)
|
||||
|
||||
@property
|
||||
def sweep_address(self) -> str:
|
||||
def get_sweep_address(self) -> str:
|
||||
# TODO: in case of unilateral close with pending HTLCs, this address will be reused
|
||||
addr = None
|
||||
assert self.is_static_remotekey_enabled()
|
||||
our_payment_pubkey = self.config[LOCAL].payment_basepoint.pubkey
|
||||
addr = make_commitment_output_to_remote_address(our_payment_pubkey)
|
||||
@@ -1415,10 +1419,10 @@ class Channel(AbstractChannel):
|
||||
ctn = self.get_oldest_unrevoked_ctn(subject)
|
||||
return self.get_commitment(subject, ctn=ctn)
|
||||
|
||||
def create_sweeptxs(self, ctn: int) -> List[Transaction]:
|
||||
def create_sweeptxs_for_watchtower(self, ctn: int) -> List[Transaction]:
|
||||
from .lnsweep import create_sweeptxs_for_watchtower
|
||||
secret, ctx = self.get_secret_and_commitment(REMOTE, ctn=ctn)
|
||||
return create_sweeptxs_for_watchtower(self, ctx, secret, self.sweep_address)
|
||||
return create_sweeptxs_for_watchtower(self, ctx, secret, self.get_sweep_address())
|
||||
|
||||
def get_oldest_unrevoked_ctn(self, subject: HTLCOwner) -> int:
|
||||
return self.hm.ctn_oldest_unrevoked(subject)
|
||||
@@ -1645,7 +1649,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.sweep_address)
|
||||
return create_sweeptx_for_their_revoked_htlc(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)
|
||||
|
||||
Reference in New Issue
Block a user