Skip to content

Commit 235f727

Browse files
authored
fix: return empty key hash for empty address keys (#688)
1 parent b44cbe1 commit 235f727

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ledger/address.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ func (a Address) PaymentAddress() *Address {
195195

196196
// PaymentKeyHash returns a new Blake2b224 hash of the payment key
197197
func (a *Address) PaymentKeyHash() Blake2b224 {
198+
if len(a.paymentAddress) != AddressHashSize {
199+
// Return empty hash
200+
return Blake2b224([AddressHashSize]byte{})
201+
}
198202
return Blake2b224(a.paymentAddress[:])
199203
}
200204

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

222226
// StakeKeyHash returns a new Blake2b224 hash of the stake key
223227
func (a *Address) StakeKeyHash() Blake2b224 {
228+
if len(a.stakingAddress) != AddressHashSize {
229+
// Return empty hash
230+
return Blake2b224([AddressHashSize]byte{})
231+
}
224232
return Blake2b224(a.stakingAddress[:])
225233
}
226234

0 commit comments

Comments
 (0)