@@ -393,7 +393,6 @@ type PoolRegistrationCertificate struct {
393
393
func (p * PoolRegistrationCertificate ) UnmarshalJSON (data []byte ) error {
394
394
type Alias PoolRegistrationCertificate
395
395
396
- // Temporary struct for initial unmarshaling
397
396
aux := & struct {
398
397
Operator string `json:"operator"`
399
398
VrfKeyHash string `json:"vrfKeyHash"`
@@ -413,7 +412,10 @@ func (p *PoolRegistrationCertificate) UnmarshalJSON(data []byte) error {
413
412
return fmt .Errorf ("failed to unmarshal pool registration: %w" , err )
414
413
}
415
414
415
+ p .Pledge = aux .Pledge
416
416
p .Cost = aux .Cost
417
+ p .Relays = aux .Relays
418
+ p .PoolMetadata = aux .PoolMetadata
417
419
418
420
// Handle margin field
419
421
if len (aux .Margin ) > 0 {
@@ -438,20 +440,27 @@ func (p *PoolRegistrationCertificate) UnmarshalJSON(data []byte) error {
438
440
439
441
// Handle reward account
440
442
if len (aux .RewardAccount ) > 0 {
441
- var rewardAccount struct {
442
- Credential struct {
443
- KeyHash string `json:"key hash"`
444
- } `json:"credential"`
443
+ type credential struct {
444
+ KeyHash string `json:"key hash"`
445
445
}
446
- if err := json .Unmarshal (aux .RewardAccount , & rewardAccount ); err != nil {
446
+ type rewardAccount struct {
447
+ Credential credential `json:"credential"`
448
+ Network string `json:"network,omitempty"`
449
+ }
450
+
451
+ var ra rewardAccount
452
+ if err := json .Unmarshal (aux .RewardAccount , & ra ); err != nil {
447
453
return fmt .Errorf ("failed to unmarshal reward account: %w" , err )
448
454
}
449
455
450
- if rewardAccount .Credential .KeyHash != "" {
451
- hashBytes , err := hex .DecodeString (rewardAccount .Credential .KeyHash )
456
+ if ra .Credential .KeyHash != "" {
457
+ hashBytes , err := hex .DecodeString (ra .Credential .KeyHash )
452
458
if err != nil {
453
459
return fmt .Errorf ("failed to decode reward account key hash: %w" , err )
454
460
}
461
+ if len (hashBytes ) != 28 {
462
+ return fmt .Errorf ("invalid key hash length: expected 28, got %d" , len (hashBytes ))
463
+ }
455
464
var hash Blake2b224
456
465
copy (hash [:], hashBytes )
457
466
p .RewardAccount = AddrKeyHash (hash )
0 commit comments