lnwallet: fix closechannel for P2TR external addr

If the delivery address is P2TR, function InternalKeyForAddr checks its
existance in the wallet to return internal key for it in case it is a custom
taproot channel. It used to return the error returned by wallet.AddressInfo.
The error is now ignored if it is ErrAddressNotFound error. This fixes
"lncli closechannel --delivery_addr <external p2tr address" case.
This commit is contained in:
Boris Nagaev 2024-10-25 20:28:17 -03:00
parent c37baa68d8
commit 9fec11eeb5
No known key found for this signature in database

View File

@ -636,6 +636,19 @@ func InternalKeyForAddr(wallet WalletController, netParams *chaincfg.Params,
walletAddr, err := wallet.AddressInfo(addr)
if err != nil {
// If the error is that the address can't be found, it is not
// an error. This happens when any channel which is not a custom
// taproot channel is cooperatively closed to an external P2TR
// address. In this case there is no internal key associated
// with the address. Callers can use the .Option() method to get
// an option value.
var managerErr waddrmgr.ManagerError
if errors.As(err, &managerErr) &&
managerErr.ErrorCode == waddrmgr.ErrAddressNotFound {
return none, nil
}
return none, err
}