1
0

Merge pull request #9265 from SomberNight/202410_ln_address_reuse_2

lnworker: reserve wallet addresses also for chan backups
This commit is contained in:
ThomasV
2024-11-13 10:59:03 +01:00
committed by GitHub
3 changed files with 39 additions and 7 deletions

View File

@@ -488,6 +488,14 @@ class AbstractChannel(Logger, ABC):
def can_be_deleted(self) -> bool:
pass
@abstractmethod
def get_wallet_addresses_channel_might_want_reserved(self) -> Sequence[str]:
"""Returns a list of addrs that the wallet should not use, to avoid address-reuse.
Typically, these addresses are wallet.is_mine, but that is not guaranteed,
in which case the wallet can just ignore those.
"""
pass
class ChannelBackup(AbstractChannel):
"""
@@ -639,6 +647,19 @@ class ChannelBackup(AbstractChannel):
ret.append(ChanCloseOption.REQUEST_REMOTE_FCLOSE)
return ret
def get_wallet_addresses_channel_might_want_reserved(self) -> Sequence[str]:
if self.is_imported:
# For v1 imported cbs, we have the local_payment_pubkey, which is
# directly used as p2wpkh() of static_remotekey channels.
# (for v0 imported cbs, the correct local_payment_pubkey is missing, and so
# we might calculate a different address here, which might not be wallet.is_mine,
# but that should be harmless)
our_payment_pubkey = self.config[LOCAL].payment_basepoint.pubkey
to_remote_address = make_commitment_output_to_remote_address(our_payment_pubkey)
return [to_remote_address]
else: # on-chain backup
return []
class Channel(AbstractChannel):
# note: try to avoid naming ctns/ctxs/etc as "current" and "pending".