Skip to content

Commit e9f6e15

Browse files
authored
feat: address hash function (#651)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 20eaad0 commit e9f6e15

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ledger/address.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ const (
4343
AddressTypeNoneScript = 0b1111
4444
)
4545

46+
type AddrKeyHash Blake2b224
47+
4648
type Address struct {
4749
addressType uint8
4850
networkId uint8
@@ -191,6 +193,11 @@ func (a Address) PaymentAddress() *Address {
191193
return newAddr
192194
}
193195

196+
// PaymentKeyHash returns a new Blake2b224 hash of the payment key
197+
func (a *Address) PaymentKeyHash() Blake2b224 {
198+
return Blake2b224(a.paymentAddress[:])
199+
}
200+
194201
// StakeAddress returns a new Address with only the stake key portion. This will return nil if the address is not a payment/staking key pair
195202
func (a Address) StakeAddress() *Address {
196203
var addrType uint8
@@ -212,6 +219,11 @@ func (a Address) StakeAddress() *Address {
212219
return newAddr
213220
}
214221

222+
// StakeKeyHash returns a new Blake2b224 hash of the stake key
223+
func (a *Address) StakeKeyHash() Blake2b224 {
224+
return Blake2b224(a.stakingAddress[:])
225+
}
226+
215227
func (a Address) generateHRP() string {
216228
var ret string
217229
if a.addressType == AddressTypeNoneKey ||

ledger/certs.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ func (c *StakeDelegationCertificate) Utxorpc() *utxorpc.Certificate {
221221
}
222222
}
223223

224-
type AddrKeyHash Blake2b224
225224
type PoolKeyHash Blake2b224
226225
type PoolMetadataHash Blake2b256
227226
type VrfKeyHash Blake2b256

0 commit comments

Comments
 (0)