@@ -26,7 +26,6 @@ import (
2626 "strconv"
2727
2828 "github.com/blinklabs-io/gouroboros/cbor"
29- "github.com/cosmos/cosmos-sdk/types/bech32"
3029 "golang.org/x/crypto/blake2b"
3130)
3231
@@ -244,16 +243,11 @@ func GetBlockOutput(
244243 // We will only focus on:
245244 // pool_registration = (3, pool_params)
246245 // pool_retirement = (4, pool_keyhash, epoch)
247- for certIndex , cert := range tx .Certificates () {
246+ for _ , cert := range tx .Certificates () {
248247 switch v := cert .(type ) {
249248 case * PoolRegistrationCertificate :
250- poolIdBytes := v .Operator [:]
251- vrfKeyHashBytes := v .VrfKeyHash [:]
252- vrfKeyHashHex := hex .EncodeToString (vrfKeyHashBytes )
253- poolId , poolIdError := PoolIdToBech32 (poolIdBytes )
254- if poolIdError != nil {
255- return nil , nil , nil , fmt .Errorf ("GetBlockOutput: RegisSPO => PoolIdToBech32 , tx index %v, cert index %v, error, %v" , txIndex , certIndex , poolIdError .Error ())
256- }
249+ poolId := NewBlake2b224 (v .Operator [:]).String ()
250+ vrfKeyHashHex := hex .EncodeToString (v .VrfKeyHash [:])
257251 regisCerts = append (regisCerts , RegisCert {
258252 RegisPoolId : poolId ,
259253 RegisPoolVrf : vrfKeyHashHex ,
@@ -262,11 +256,7 @@ func GetBlockOutput(
262256
263257 case * PoolRetirementCertificate :
264258 // pool_retirement
265- poolIdBytes := v .PoolKeyHash [:]
266- poolId , poolIdError := PoolIdToBech32 (poolIdBytes )
267- if poolIdError != nil {
268- return nil , nil , nil , fmt .Errorf ("GetBlockOutput: RetireSPO => PoolIdToBech32, tx index %v, cert index %v, error, %v" , txIndex , certIndex , poolIdError .Error ())
269- }
259+ poolId := NewBlake2b224 (v .PoolKeyHash [:]).String ()
270260 retireEpoch := v .Epoch
271261 deRegisCerts = append (deRegisCerts , DeRegisCert {
272262 DeRegisPoolId : poolId ,
@@ -281,17 +271,6 @@ func GetBlockOutput(
281271 return outputs , regisCerts , deRegisCerts , nil
282272}
283273
284- func PoolIdToBech32 (data []byte ) (string , error ) {
285- pool , err := bech32 .ConvertAndEncode ("pool" , data )
286- if err != nil {
287- return "" , fmt .Errorf (
288- "PoolIdToBech32: ConvertAndEncode error, %v" ,
289- err .Error (),
290- )
291- }
292- return pool , nil
293- }
294-
295274func ExtractTokens (output TransactionOutput ) ([]UTXOOutputToken , error ) {
296275 var outputTokens []UTXOOutputToken
297276 // append lovelace first
0 commit comments