lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.65k stars 2.07k forks source link

LND Crashes When An Unknown AddressType Is Used #6846

Closed cryptosharks131 closed 2 years ago

cryptosharks131 commented 2 years ago

Background

When requesting a new address via the gRPC endpoint with an AddressType that is unknown to the current LND wallet, it crashes immediately after the request is made with an exit status of 2/INVALIDARGUMENT.

Your environment

Steps to reproduce

Use the NewAddress gRPC endpoint to request an address with an AddressType that the current LND version is unaware of. https://api.lightning.community/#newaddress

Expected behaviour

The gRPC should return an error to the user instead of crashing.

Actual behaviour

LND will immediately crash with an exit status of 2/INVALIDARGUMENT.

ellemouton commented 2 years ago

Hi @cryptosharks131! Thanks for opening an issue! Looks like it is a switch statement without a default case: https://github.com/lightningnetwork/lnd/blob/master/rpcserver.go#L1497

Thanks for reporting this! we will fix it asap :)

alexbosworth commented 2 years ago

A workaround for p2tr address generation is to look to see if p2tr is known in the ListAccounts call