Skip to content

Commit

Permalink
RPC create_validator uses the client configuration as input
Browse files Browse the repository at this point in the history
  • Loading branch information
ii-cruz committed Jan 7, 2025
1 parent db0c1e5 commit 4feeaeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
1 change: 1 addition & 0 deletions rpc-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum Command {

/// Shows and modifies validator information.
/// Create, signs and send transactions referring to the local validator.
/// These operations only work if the current client is configured as a validator.
#[clap(flatten)]
Validator(ValidatorCommand),

Expand Down
21 changes: 7 additions & 14 deletions rpc-client/src/subcommands/validator_subcommands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ pub enum ValidatorCommand {
/// Returns the voting key of the local validator.
ValidatorVotingKey {},

/// Sends a `new_validator` transaction to the network. You need to provide the address of a basic
/// Sends a transaction to the network to create this validator. You need to provide the address of a basic
/// account (the sender wallet) to pay the transaction fee and the validator deposit. The sender wallet must be unlocked
/// prior to this command.
/// The sender_wallet must be unlocked prior to this command.
/// Since JSON doesn't have a primitive for Option (it just has the null primitive), we can't
/// have a double Option. This becomes an issue when creating an update_validator transaction.
/// Instead we use the following work-around. We define the empty String to be None. So, in
Expand All @@ -42,12 +41,6 @@ pub enum ValidatorCommand {
/// The fee will be paid from this address. This address must be already unlocked.
sender_wallet: Address,

/// The new validator address. This wallet must be already unlocked.
validator_wallet: Address,

/// The Schnorr signing key used by the validator.
signing_secret_key: String,

/// The BLS key used by the validator.
voting_secret_key: String,

Expand Down Expand Up @@ -154,20 +147,20 @@ impl HandleSubcommand for ValidatorCommand {

ValidatorCommand::CreateNewValidator {
sender_wallet,
validator_wallet,
signing_secret_key,
voting_secret_key,
reward_address,
signal_data,
tx_commons,
} => {
let validator_address = client.validator.get_address().await?.data;
let key_data = client.validator.get_signing_key().await?.data;
if tx_commons.dry {
let tx = client
.consensus
.create_new_validator_transaction(
sender_wallet,
validator_wallet,
signing_secret_key,
validator_address,
key_data,
voting_secret_key,
reward_address,
signal_data,
Expand All @@ -181,8 +174,8 @@ impl HandleSubcommand for ValidatorCommand {
.consensus
.send_new_validator_transaction(
sender_wallet,
validator_wallet,
signing_secret_key,
validator_address,
key_data,
voting_secret_key,
reward_address,
signal_data,
Expand Down

0 comments on commit 4feeaeb

Please sign in to comment.