From 429000e360d24c78fcf972a8432b59ff1ff26350 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Mon, 21 Apr 2025 17:09:17 -0300 Subject: [PATCH] lnwallet: fix InternalKeyForAddr for imported addr An address imported using ImportTapscript doesn't provide a private key so it can't satisfy waddrmgr.ManagedPubKeyAddress interface. So we don't return an error for imported addresses. Fix https://github.com/lightninglabs/loop/issues/923 --- lnwallet/interface.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lnwallet/interface.go b/lnwallet/interface.go index 767550ec1..9255c513e 100644 --- a/lnwallet/interface.go +++ b/lnwallet/interface.go @@ -660,6 +660,12 @@ func InternalKeyForAddr(wallet WalletController, netParams *chaincfg.Params, return none, nil } + // Imported addresses do not provide private keys, so they do not + // implement waddrmgr.ManagedPubKeyAddress. See RPC ImportTapscript. + if walletAddr.Imported() { + return none, nil + } + pubKeyAddr, ok := walletAddr.(waddrmgr.ManagedPubKeyAddress) if !ok { return none, fmt.Errorf("expected pubkey addr, got %T",