Files
zeekay 579f53c3cc chore: remove local replace directives and update dependencies
- Update github.com/luxfi/netrunner v1.15.3 → v1.15.4
- Update github.com/luxfi/node v1.22.77 → v1.22.80
- Remove local replace directive for netrunner
- Use published package versions for reproducible builds
2026-01-03 07:09:01 -08:00

63 lines
1.9 KiB
Go

// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package blockchain
import (
"github.com/luxfi/cli/pkg/application"
"github.com/luxfi/cli/pkg/ux"
"github.com/luxfi/sdk/models"
"github.com/luxfi/sdk/prompts"
)
// PromptValidatorBalance prompts the user to enter a validator balance amount.
func PromptValidatorBalance(app *application.Lux, availableBalance float64, prompt string) (float64, error) {
ux.Logger.PrintToUser("Validator's balance is used to pay for continuous fee to the P-Chain")
ux.Logger.PrintToUser("When this Balance reaches 0, the validator will be considered inactive and will no longer participate in validating the L1")
return app.Prompt.CaptureValidatorBalance(prompt, availableBalance, 0)
}
// GetKeyForChangeOwner prompts for and returns a key address for change ownership.
func GetKeyForChangeOwner(app *application.Lux, network models.Network) (string, error) {
changeAddrPrompt := "Which key would you like to set as change owner for leftover LUX if the node is removed from validator set?"
const (
getFromStored = "Get address from an existing stored key (created from lux key create or lux key import)"
custom = "Custom"
)
listOptions := []string{getFromStored, custom}
listDecision, err := app.Prompt.CaptureList(changeAddrPrompt, listOptions)
if err != nil {
return "", err
}
var key string
switch listDecision {
case getFromStored:
key, err = prompts.CaptureKeyAddress(
app.Prompt,
"be set as a change owner for leftover LUX",
app.GetKeyDir(),
app.GetKey,
network,
prompts.PChainFormat,
)
if err != nil {
return "", err
}
case custom:
addrPrompt := "Enter change address (P-chain format)"
changeAddr, err := app.Prompt.CaptureAddress(addrPrompt)
if err != nil {
return "", err
}
key = changeAddr.String()
}
if err != nil {
return "", err
}
return key, nil
}