diff --git a/keychain/keychain.go b/keychain/keychain.go index 0401172..6ed361f 100644 --- a/keychain/keychain.go +++ b/keychain/keychain.go @@ -125,7 +125,7 @@ func (kc *Keychain) AddLedgerFunds(amount uint64) error { return fmt.Errorf("keychain is not ledger enabled") } -func (kc *Keychain) PChainFormattedStrAddresses() ([]string, error) { +func (kc *Keychain) GetPChainAddresses() ([]string, error) { addrs := kc.Addresses().List() if len(addrs) == 0 { return nil, fmt.Errorf("no addresses in keychain") diff --git a/subnet/add_validator_subnet.go b/subnet/add_validator_subnet.go index 0f5542b..1f3e72a 100644 --- a/subnet/add_validator_subnet.go +++ b/subnet/add_validator_subnet.go @@ -27,15 +27,25 @@ type ValidatorParams struct { Duration time.Duration Weight uint64 + + Network avalanche.Network } // AddValidator adds validator to subnet func (c *Subnet) AddValidator(wallet wallet.Wallet, validatorInput ValidatorParams) (*multisig.Multisig, error) { - controlKeys, threshold, err := GetOwners(network, c.SubnetID, c.DeployInfo.TransferSubnetOwnershipTxID) + controlKeys, threshold, err := GetOwners(validatorInput.Network, c.SubnetID, c.DeployInfo.TransferSubnetOwnershipTxID) + if err != nil { + return nil, err + } + pChainAddr, err := wallet.Keychain.GetPChainAddresses() if err != nil { - return err + return nil, err + } + var subnetAuthKeysStr []string + for _, subnetAuthKey := range subnetAuthKeysStr { + subnetAuthKeysStr = append(subnetAuthKeysStr, subnetAuthKey) } - if err := checkSubnetAuthKeys(wallet.Keychain, c.DeployInfo.SubnetAuthKeys, controlKeys, threshold); err != nil { + if err := checkSubnetAuthKeys(pChainAddr, subnetAuthKeysStr, controlKeys, threshold); err != nil { return nil, err } validator := &txs.SubnetValidator{