From ca6a2e12e07a541ca730e189a51d35330cc2903b Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 22 Aug 2022 16:11:22 +0200 Subject: [PATCH] rpcserver+docs: add default case to addr type switch This commit adds a default case to the address type switch statement in the NewAddress rpc server function. This catches any invalid address types and returns an error. --- docs/release-notes/release-notes-0.15.1.md | 3 +++ rpcserver.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/release-notes/release-notes-0.15.1.md b/docs/release-notes/release-notes-0.15.1.md index 320b6cf41..951634f1b 100644 --- a/docs/release-notes/release-notes-0.15.1.md +++ b/docs/release-notes/release-notes-0.15.1.md @@ -164,6 +164,9 @@ default](https://github.com/lightningnetwork/lnd/pull/6810) in most cases. * [Remove `ScidAliasOptional` dependency on `ExplicitChannelTypeOptional`](https://github.com/lightningnetwork/lnd/pull/6809) +* [Add a default case](https://github.com/lightningnetwork/lnd/pull/6847) to the + Address Type switch statement in the `NewAddress` rpc server method. + ## Code Health ### Code cleanup, refactor, typo fixes diff --git a/rpcserver.go b/rpcserver.go index 95d0b136d..a2befc0e4 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1542,6 +1542,9 @@ func (r *rpcServer) NewAddress(ctx context.Context, if err != nil { return nil, err } + + default: + return nil, fmt.Errorf("unknown address type: %v", in.Type) } rpcsLog.Debugf("[newaddress] account=%v type=%v addr=%v", account,