Skip to content

Commit

Permalink
test-wallet: Adapt to new wallet-core
Browse files Browse the repository at this point in the history
Co-authored-by: Daksh <[email protected]>
  • Loading branch information
Daksh14 and Daksh14 committed Sep 10, 2024
1 parent 4cd7860 commit e11c701
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
5 changes: 2 additions & 3 deletions rusk-wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ use execution_core::{
signatures::bls::PublicKey as AccountPublicKey,
stake::StakeData,
transfer::phoenix::{
ArchivedNoteLeaf, Note, NoteLeaf, NoteOpening,
PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey,
ViewKey as PhoenixViewKey,
ArchivedNoteLeaf, Note, NoteOpening, PublicKey as PhoenixPublicKey,
SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey,
},
BlsScalar,
};
Expand Down
17 changes: 9 additions & 8 deletions rusk-wallet/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use wallet_core::{

use execution_core::{
signatures::bls::{PublicKey as BlsPublicKey, SecretKey as BlsSecretKey},
transfer::{data::TransactionData, Transaction},
transfer::{data::ContractCall, data::TransactionData, Transaction},
};

use zeroize::Zeroize;
Expand Down Expand Up @@ -539,7 +539,7 @@ impl<F: SecureWalletFile + Debug> Wallet<F> {
gas.limit,
gas.price,
chain_id,
data,
Some(data),
&Prover,
)?;

Expand Down Expand Up @@ -730,7 +730,6 @@ impl<F: SecureWalletFile + Debug> Wallet<F> {
}

let state = self.state()?;

let amt = *amt;
let sender_index = addr.index()?;
let mut stake_sk = self.bls_secret_key(sender_index);
Expand All @@ -741,13 +740,14 @@ impl<F: SecureWalletFile + Debug> Wallet<F> {
let nonce = state.fetch_stake(&pk)?.map(|s| s.nonce).unwrap_or(0);

let stake = moonlight_stake(
&stake_sk,
&stake_sk,
amt,
chain_id,
nonce,
account.nonce,
gas.limit,
gas.price,
account.nonce,
nonce,
chain_id,
)?;

stake_sk.zeroize();
Expand Down Expand Up @@ -842,11 +842,12 @@ impl<F: SecureWalletFile + Debug> Wallet<F> {
let unstake = moonlight_unstake(
&mut rng,
&stake_sk,
&stake_sk,
unstake_value,
chain_id,
account.nonce + 1,
gas.price,
gas.limit,
account.nonce + 1,
chain_id,
)?;

stake_sk.zeroize();
Expand Down
15 changes: 11 additions & 4 deletions wallet-core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

//! Implementations of basic wallet functionalities to create phoenix
//! transactions.
//! Implementations of basic wallet functionalities to create transactions.
use alloc::vec::Vec;

Expand All @@ -30,7 +29,16 @@ use execution_core::{
BlsScalar, ContractId, Error, JubJubScalar,
};

/// Generate a phoenix-transaction with a given prover.
/// An unproven-transaction is nearly identical to a [`PhoenixTransaction`] with
/// the only difference being that it carries a serialized [`TxCircuitVec`]
/// instead of the proof bytes.
/// This way it is possible to delegate the proof generation of the
/// [`TxCircuitVec`] after the unproven transaction was created while at the
/// same time ensuring non-malleability of the transaction, as the transaction's
/// payload-hash is part of the public inputs of the circuit.
/// Once the proof is generated from the [`TxCircuitVec`] bytes, it can
/// replace the serialized circuit in the transaction by calling
/// [`Transaction::replace_proof`].
///
/// # Errors
/// The creation of a transaction is not possible and will error if:
Expand All @@ -40,7 +48,6 @@ use execution_core::{
/// - the `inputs` vector contains duplicate `Note`s
/// - the `Prove` trait is implemented incorrectly
/// - the Memo provided with `data` is too large
/// - the transaction-data is incorrect
#[allow(clippy::too_many_arguments)]
pub fn phoenix<R: RngCore + CryptoRng, P: Prove>(
rng: &mut R,
Expand Down

0 comments on commit e11c701

Please sign in to comment.