Skip to content

Commit

Permalink
Update pkg/crypto/utils.go
Browse files Browse the repository at this point in the history
remove PubKeyBech32Address and add support for Bech32 to PubKeyAddress

Co-authored-by: Matt Ketmo <[email protected]>
  • Loading branch information
qwertzlbert and MattKetmo authored Nov 12, 2024
1 parent 1ef6585 commit 1722a03
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions pkg/crypto/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,10 @@ func PubKeyAddress(consensusPubkey *types1.Any) string {
}

func PubKeyBech32Address(consensusPubkey *types1.Any, prefix string) string {
switch consensusPubkey.TypeUrl {
case "/cosmos.crypto.ed25519.PubKey":
key := ed25519.PubKey{Key: consensusPubkey.Value[2:]}
address, _ := bech32.ConvertAndEncode(prefix, key.Address())
return address

case "/cosmos.crypto.secp256k1.PubKey":
key := secp256k1.PubKey{Key: consensusPubkey.Value[2:]}
address, _ := bech32.ConvertAndEncode(prefix, key.Address())
return address
}

panic("unknown pubkey type: " + consensusPubkey.TypeUrl)
key := PubKeyAddress(consensusPubkey)
address, _ := bech32.ConvertAndEncode(prefix, key.Address())

return address
}

// GetHrpPrefix returns the human-readable prefix for a given address.
Expand Down

0 comments on commit 1722a03

Please sign in to comment.