Skip to content

Commit 728c79e

Browse files
committed
staticaddr: return error if address already exists
1 parent 38d7401 commit 728c79e

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

staticaddr/address/interface.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package address
22

33
import (
44
"context"
5-
"fmt"
65

76
"github.com/btcsuite/btcd/btcec/v2"
87
"github.com/lightninglabs/loop/staticaddr/version"
98
"github.com/lightningnetwork/lnd/keychain"
9+
"google.golang.org/grpc/codes"
10+
"google.golang.org/grpc/status"
1011
)
1112

1213
var (
13-
ErrAddressAlreadyExists = fmt.Errorf("address already exists")
14+
ErrAddressAlreadyExists = status.Error(codes.AlreadyExists,
15+
"address already exists")
1416
)
1517

1618
// Store is the database interface that is used to store and retrieve

staticaddr/address/manager.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,9 @@ func (m *Manager) NewAddress(ctx context.Context) (*btcutil.AddressTaproot,
104104
return nil, err
105105
}
106106
if len(addresses) > 0 {
107-
clientPubKey := addresses[0].ClientPubkey
108-
serverPubKey := addresses[0].ServerPubkey
109-
expiry := int64(addresses[0].Expiry)
110-
111107
m.Unlock()
112108

113-
return m.GetTaprootAddress(clientPubKey, serverPubKey, expiry)
109+
return nil, ErrAddressAlreadyExists
114110
}
115111
m.Unlock()
116112

0 commit comments

Comments
 (0)