@@ -391,9 +391,7 @@ type PoolRegistrationCertificate struct {
391391}
392392
393393func (p * PoolRegistrationCertificate ) UnmarshalJSON (data []byte ) error {
394- type Alias PoolRegistrationCertificate
395-
396- aux := & struct {
394+ type tempPool struct {
397395 Operator string `json:"operator"`
398396 VrfKeyHash string `json:"vrfKeyHash"`
399397 Pledge uint64 `json:"pledge"`
@@ -403,24 +401,22 @@ func (p *PoolRegistrationCertificate) UnmarshalJSON(data []byte) error {
403401 PoolOwners []string `json:"poolOwners"`
404402 Relays []PoolRelay `json:"relays"`
405403 PoolMetadata * PoolMetadata `json:"poolMetadata,omitempty"`
406- * Alias
407- }{
408- Alias : (* Alias )(p ),
409404 }
410405
411- if err := json .Unmarshal (data , aux ); err != nil {
406+ var tmp tempPool
407+ if err := json .Unmarshal (data , & tmp ); err != nil {
412408 return fmt .Errorf ("failed to unmarshal pool registration: %w" , err )
413409 }
414410
415- p .Pledge = aux .Pledge
416- p .Cost = aux .Cost
417- p .Relays = aux .Relays
418- p .PoolMetadata = aux .PoolMetadata
411+ p .Pledge = tmp .Pledge
412+ p .Cost = tmp .Cost
413+ p .Relays = tmp .Relays
414+ p .PoolMetadata = tmp .PoolMetadata
419415
420416 // Handle margin field
421- if len (aux .Margin ) > 0 {
417+ if len (tmp .Margin ) > 0 {
422418 var marginValue interface {}
423- if err := json .Unmarshal (aux .Margin , & marginValue ); err != nil {
419+ if err := json .Unmarshal (tmp .Margin , & marginValue ); err != nil {
424420 return fmt .Errorf ("failed to unmarshal margin: %w" , err )
425421 }
426422
@@ -439,17 +435,16 @@ func (p *PoolRegistrationCertificate) UnmarshalJSON(data []byte) error {
439435 }
440436
441437 // Handle reward account
442- if len (aux .RewardAccount ) > 0 {
438+ if len (tmp .RewardAccount ) > 0 {
443439 type credential struct {
444440 KeyHash string `json:"key hash"`
445441 }
446442 type rewardAccount struct {
447443 Credential credential `json:"credential"`
448- Network string `json:"network,omitempty"`
449444 }
450445
451446 var ra rewardAccount
452- if err := json .Unmarshal (aux .RewardAccount , & ra ); err != nil {
447+ if err := json .Unmarshal (tmp .RewardAccount , & ra ); err != nil {
453448 return fmt .Errorf ("failed to unmarshal reward account: %w" , err )
454449 }
455450
@@ -468,26 +463,26 @@ func (p *PoolRegistrationCertificate) UnmarshalJSON(data []byte) error {
468463 }
469464
470465 // Convert string fields to binary types
471- if aux .Operator != "" {
472- opBytes , err := hex .DecodeString (aux .Operator )
466+ if tmp .Operator != "" {
467+ opBytes , err := hex .DecodeString (tmp .Operator )
473468 if err != nil {
474469 return fmt .Errorf ("invalid operator key: %w" , err )
475470 }
476471 p .Operator = PoolKeyHash (Blake2b224 (opBytes ))
477472 }
478473
479- if aux .VrfKeyHash != "" {
480- vrfBytes , err := hex .DecodeString (aux .VrfKeyHash )
474+ if tmp .VrfKeyHash != "" {
475+ vrfBytes , err := hex .DecodeString (tmp .VrfKeyHash )
481476 if err != nil {
482477 return fmt .Errorf ("invalid VRF key hash: %w" , err )
483478 }
484479 p .VrfKeyHash = VrfKeyHash (Blake2b256 (vrfBytes ))
485480 }
486481
487482 // Convert pool owners
488- if len (aux .PoolOwners ) > 0 {
489- owners := make ([]AddrKeyHash , len (aux .PoolOwners ))
490- for i , owner := range aux .PoolOwners {
483+ if len (tmp .PoolOwners ) > 0 {
484+ owners := make ([]AddrKeyHash , len (tmp .PoolOwners ))
485+ for i , owner := range tmp .PoolOwners {
491486 ownerBytes , err := hex .DecodeString (owner )
492487 if err != nil {
493488 return fmt .Errorf ("invalid pool owner key: %w" , err )
0 commit comments