add comments about xpub encryption

This commit is contained in:
ThomasV
2026-04-02 12:09:01 +02:00
parent 2ea4874600
commit 7a6a39d1aa
3 changed files with 21 additions and 0 deletions
+14
View File
@@ -3610,6 +3610,20 @@ class LNWallet(Logger):
)
def export_channel_backup(self, channel_id):
"""Historically, we allowed watching-only wallets and hardware wallets
to have lightning channels. Since these wallets do not have
private keys, we use their master public key to encrypt
channel backups. This allows users to import channel backups
in these wallets. Note that these are static backups: they
only allow to request a force close (and, in some scenarios,
to sweep funds after a channel has been force closed).
The creation of lightning channels in watching-only wallets
has been disabled for anchor channels. Note that it is still
possible to create non-anchor channels, see
config.ENABLE_ANCHOR_CHANNELS.
"""
xpub = self.wallet.get_fingerprint()
backup_bytes = self.create_channel_backup(channel_id).to_bytes()
assert backup_bytes == ImportedChannelBackupStorage.from_bytes(backup_bytes).to_bytes(), "roundtrip failed"
+4
View File
@@ -212,6 +212,10 @@ class LabelsPlugin(BasePlugin):
return asyncio.run_coroutine_threadsafe(self.push_thread(wallet), wallet.network.asyncio_loop).result()
def start_wallet(self, wallet: 'Abstract_Wallet'):
"""Labels have the same level of privacy as the wallet transaction
history. Since the wallet master public key(s) give access to
the transaction history, we also use it to encrypt labels.
"""
if not wallet.network:
return # 'offline' mode
mpk = wallet.get_fingerprint()
+3
View File
@@ -548,6 +548,9 @@ class Abstract_Wallet(ABC, Logger, EventListener):
ln_xprv = self.keystore.get_lightning_xprv(password)
self.db.put('lightning_xprv', ln_xprv)
else:
# bip39 seeds and imported zprv.
# also, watching-only and hw wallets, if the user disables anchors.
# todo: we should kill that branch, it is a footgun.
seed = os.urandom(32)
node = BIP32Node.from_rootseed(seed, xtype='standard')
ln_xprv = node.to_xprv()