diff --git a/rusk-wallet/src/bin/command.rs b/rusk-wallet/src/bin/command.rs index d807fa7c16..fa50c3756c 100644 --- a/rusk-wallet/src/bin/command.rs +++ b/rusk-wallet/src/bin/command.rs @@ -217,11 +217,12 @@ pub(crate) enum Command { contract_id: Vec, /// Function name to call - #[clap(short, long)] + + #[clap(short = 'n', long)] fn_name: String, /// Function arguments for this call - #[clap(short, long)] + #[clap(short = 'f', long)] fn_args: Vec, /// Max amount of gas for this transaction @@ -337,10 +338,6 @@ pub(crate) enum Command { #[clap(short, long)] addr: Option
, - /// Amount of DUSK to withdraw - #[clap(short, long)] - amt: Dusk, - /// Max amount of gas for this transaction #[clap(short = 'l', long, default_value_t = DEFAULT_STAKE_GAS_LIMIT)] gas_limit: u64, @@ -385,11 +382,11 @@ pub(crate) enum Command { contract_id: Vec, /// Function name to call - #[clap(short, long)] + #[clap(short = 'n', long)] fn_name: String, /// Function arguments for this call - #[clap(short, long)] + #[clap(short = 'f', long)] fn_args: Vec, /// Max amount of gas for this transaction @@ -405,7 +402,7 @@ pub(crate) enum Command { /// Convert Phoenix DUSK to Moonlight for the same owned address PhoenixToMoonlight { /// Moonlight or Phoenix address from which to convert DUSK to - #[clap(short, long)] + #[clap(short = 's', long)] addr: Option
, /// Amount of DUSK to transfer to your Moonlight account @@ -424,7 +421,7 @@ pub(crate) enum Command { /// Convert Moonlight DUSK to Phoenix for the same owned address MoonlightToPhoenix { /// Moonlight or Phoenix Address from which to convert DUSK to - #[clap(short, long)] + #[clap(short = 's', long)] addr: Option
, /// Amount of DUSK to transfer to your phoenix account @@ -746,7 +743,6 @@ impl Command { } Command::MoonlightWithdraw { addr, - amt, gas_limit, gas_price, } => { @@ -757,8 +753,7 @@ impl Command { let gas = Gas::new(gas_limit).with_price(gas_price); - let tx = - wallet.moonlight_stake_withdraw(addr, amt, gas).await?; + let tx = wallet.moonlight_stake_withdraw(addr, gas).await?; Ok(RunResult::Tx(tx.hash())) } diff --git a/rusk-wallet/src/bin/interactive.rs b/rusk-wallet/src/bin/interactive.rs index 10951c8cee..f33fd833f1 100644 --- a/rusk-wallet/src/bin/interactive.rs +++ b/rusk-wallet/src/bin/interactive.rs @@ -259,7 +259,6 @@ fn transaction_op_menu_moonlight( })), Withdraw => AddrOp::Run(Box::new(Command::MoonlightWithdraw { addr: Some(addr), - amt: prompt::request_token_amt("withdraw", moonlight_bal)?, gas_limit: prompt::request_gas_limit(DEFAULT_STAKE_GAS_LIMIT)?, gas_price: prompt::request_gas_price()?, })), diff --git a/rusk-wallet/src/wallet.rs b/rusk-wallet/src/wallet.rs index f42addc4cf..28cb7be548 100644 --- a/rusk-wallet/src/wallet.rs +++ b/rusk-wallet/src/wallet.rs @@ -993,20 +993,22 @@ impl Wallet { pub async fn moonlight_stake_withdraw( &self, sender: &Address, - amt: Dusk, gas: Gas, ) -> Result { let mut rng = StdRng::from_entropy(); let state = self.state()?; let sender_index = sender.index()?; - let pk = sender.apk()?; - let nonce = state.fetch_account(pk).await?.nonce + 1; + let pk = self.bls_public_key(sender_index); + let nonce = state.fetch_account(&pk).await?.nonce + 1; let chain_id = state.fetch_chain_id().await?; + let stake_info = state.fetch_stake(&pk).await?; + let reward = stake_info.map(|s| s.reward).ok_or(Error::NoReward)?; + let reward = Dusk::from(reward); let mut sender_sk = self.bls_secret_key(sender_index); let withdraw = moonlight_stake_reward( - &mut rng, &sender_sk, &sender_sk, *amt, gas.limit, gas.price, + &mut rng, &sender_sk, &sender_sk, *reward, gas.limit, gas.price, nonce, chain_id, )?;