Skip to content

Commit

Permalink
fix: return empty key hash for empty address keys (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
agaffney authored Aug 20, 2024
1 parent b44cbe1 commit 235f727
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ledger/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ func (a Address) PaymentAddress() *Address {

// PaymentKeyHash returns a new Blake2b224 hash of the payment key
func (a *Address) PaymentKeyHash() Blake2b224 {
if len(a.paymentAddress) != AddressHashSize {
// Return empty hash
return Blake2b224([AddressHashSize]byte{})
}
return Blake2b224(a.paymentAddress[:])
}

Expand All @@ -221,6 +225,10 @@ func (a Address) StakeAddress() *Address {

// StakeKeyHash returns a new Blake2b224 hash of the stake key
func (a *Address) StakeKeyHash() Blake2b224 {
if len(a.stakingAddress) != AddressHashSize {
// Return empty hash
return Blake2b224([AddressHashSize]byte{})
}
return Blake2b224(a.stakingAddress[:])
}

Expand Down

0 comments on commit 235f727

Please sign in to comment.