@@ -391,9 +391,7 @@ type PoolRegistrationCertificate struct {
391
391
}
392
392
393
393
func (p * PoolRegistrationCertificate ) UnmarshalJSON (data []byte ) error {
394
- type Alias PoolRegistrationCertificate
395
-
396
- aux := & struct {
394
+ type tempPool struct {
397
395
Operator string `json:"operator"`
398
396
VrfKeyHash string `json:"vrfKeyHash"`
399
397
Pledge uint64 `json:"pledge"`
@@ -403,24 +401,22 @@ func (p *PoolRegistrationCertificate) UnmarshalJSON(data []byte) error {
403
401
PoolOwners []string `json:"poolOwners"`
404
402
Relays []PoolRelay `json:"relays"`
405
403
PoolMetadata * PoolMetadata `json:"poolMetadata,omitempty"`
406
- * Alias
407
- }{
408
- Alias : (* Alias )(p ),
409
404
}
410
405
411
- if err := json .Unmarshal (data , aux ); err != nil {
406
+ var tmp tempPool
407
+ if err := json .Unmarshal (data , & tmp ); err != nil {
412
408
return fmt .Errorf ("failed to unmarshal pool registration: %w" , err )
413
409
}
414
410
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
419
415
420
416
// Handle margin field
421
- if len (aux .Margin ) > 0 {
417
+ if len (tmp .Margin ) > 0 {
422
418
var marginValue interface {}
423
- if err := json .Unmarshal (aux .Margin , & marginValue ); err != nil {
419
+ if err := json .Unmarshal (tmp .Margin , & marginValue ); err != nil {
424
420
return fmt .Errorf ("failed to unmarshal margin: %w" , err )
425
421
}
426
422
@@ -439,17 +435,16 @@ func (p *PoolRegistrationCertificate) UnmarshalJSON(data []byte) error {
439
435
}
440
436
441
437
// Handle reward account
442
- if len (aux .RewardAccount ) > 0 {
438
+ if len (tmp .RewardAccount ) > 0 {
443
439
type credential struct {
444
440
KeyHash string `json:"key hash"`
445
441
}
446
442
type rewardAccount struct {
447
443
Credential credential `json:"credential"`
448
- Network string `json:"network,omitempty"`
449
444
}
450
445
451
446
var ra rewardAccount
452
- if err := json .Unmarshal (aux .RewardAccount , & ra ); err != nil {
447
+ if err := json .Unmarshal (tmp .RewardAccount , & ra ); err != nil {
453
448
return fmt .Errorf ("failed to unmarshal reward account: %w" , err )
454
449
}
455
450
@@ -468,26 +463,26 @@ func (p *PoolRegistrationCertificate) UnmarshalJSON(data []byte) error {
468
463
}
469
464
470
465
// 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 )
473
468
if err != nil {
474
469
return fmt .Errorf ("invalid operator key: %w" , err )
475
470
}
476
471
p .Operator = PoolKeyHash (Blake2b224 (opBytes ))
477
472
}
478
473
479
- if aux .VrfKeyHash != "" {
480
- vrfBytes , err := hex .DecodeString (aux .VrfKeyHash )
474
+ if tmp .VrfKeyHash != "" {
475
+ vrfBytes , err := hex .DecodeString (tmp .VrfKeyHash )
481
476
if err != nil {
482
477
return fmt .Errorf ("invalid VRF key hash: %w" , err )
483
478
}
484
479
p .VrfKeyHash = VrfKeyHash (Blake2b256 (vrfBytes ))
485
480
}
486
481
487
482
// 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 {
491
486
ownerBytes , err := hex .DecodeString (owner )
492
487
if err != nil {
493
488
return fmt .Errorf ("invalid pool owner key: %w" , err )
0 commit comments