Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PoolRewardAccount ¶
func PoolRewardAccount( cert *lcommon.PoolRegistrationCertificate, ) (credentialTag uint8, hash []byte, err error)
PoolRewardAccount extracts the credential tag and pure 28-byte hash from a pool registration certificate's reward account.
Background: PoolRegistrationCertificate.RewardAccount is AddrKeyHash ([28]byte), but the on-chain CBOR encodes the reward_account field as a 29-byte reward address (1 header byte + 28 hash bytes). fxamacker/cbor decodes a 29-byte bytestring into [28]byte by taking the first 28 bytes, so the struct field contains [header, hash_0..hash_26] — the last hash byte is lost and the header byte pollutes the stored value.
This function decodes the raw cert CBOR (available via cert.Cbor()) to recover the full 29-byte reward address and returns both the credential type (0 = key hash, 1 = script hash) and the pure 28-byte stake credential hash.
Fallback when raw CBOR is unavailable (e.g. genesis/JSON-sourced certs): the cert was parsed via UnmarshalJSON which correctly stores the pure 28-byte hash in RewardAccount, and only key-hash reward accounts appear in genesis, so tag=0 and cert.RewardAccount[:] are returned.
Returns an error if rawCbor is non-empty but cannot be decoded correctly, to prevent storing a corrupted reward account hash.
Types ¶
This section is empty.