Skip to content

Commit

Permalink
fix: adapt GetAppWalletKey to use DeriveKey with path 1'
Browse files Browse the repository at this point in the history
  • Loading branch information
frnandu committed Nov 1, 2024
1 parent 339d420 commit 606c33b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions service/keys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package keys

import (
"encoding/hex"

"github.com/btcsuite/btcd/btcec/v2"
"errors"
"github.com/btcsuite/btcd/btcec/v2"

"github.com/getAlby/hub/config"
"github.com/getAlby/hub/logger"
Expand Down Expand Up @@ -87,10 +86,14 @@ func (keys *keys) GetNostrSecretKey() string {
return keys.nostrSecretKey
}

func (keys *keys) GetAppWalletKey(childIndex uint) (string, error) {
// Derive child key
// TODO
return "", nil
func (keys *keys) GetAppWalletKey(appID uint) (string, error) {
path := []uint32{bip32.FirstHardenedChild + 1, uint32(appID)}
key, err := keys.DeriveKey(path)
if err != nil {
return "", err
}
childPrivKey, _ := btcec.PrivKeyFromBytes(key.Key)
return hex.EncodeToString(childPrivKey.Serialize()), nil
}

func (keys *keys) DeriveKey(path []uint32) (*bip32.Key, error) {
Expand Down

0 comments on commit 606c33b

Please sign in to comment.