Skip to content

Commit

Permalink
wip: fix reveal pk
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Jul 19, 2023
1 parent 108d941 commit f60341c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 106 deletions.
1 change: 0 additions & 1 deletion apps/src/lib/client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod rpc;
pub mod signing;
pub mod tx;
pub mod utils;
79 changes: 0 additions & 79 deletions apps/src/lib/client/signing.rs

This file was deleted.

9 changes: 5 additions & 4 deletions apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use masp_proofs::prover::LocalTxProver;
use namada::core::types::account::AccountPublicKeysMap;
use namada::ledger::governance::storage as gov_storage;
use namada::ledger::rpc::{TxBroadcastData, TxResponse};
use namada::ledger::signing::TxSigningKey;
use namada::ledger::signing::{find_pk, TxSigningKey};
use namada::ledger::wallet::{Wallet, WalletUtils};
use namada::ledger::{masp, pos, signing, tx};
use namada::proof_of_stake::parameters::PosParams;
Expand All @@ -33,7 +33,6 @@ use super::rpc;
use crate::cli::context::WalletAddress;
use crate::cli::{args, safe_exit, Context};
use crate::client::rpc::query_wasm_code_hash;
use crate::client::signing::find_pk;
use crate::client::tx::tx::ProcessTxResponse;
use crate::config::TendermintMode;
use crate::facade::tendermint_rpc::endpoint::broadcast::tx_sync::Response;
Expand Down Expand Up @@ -171,6 +170,7 @@ where
{
let (mut tx, addr, public_keys) =
tx::build_init_account(client, &mut ctx.wallet, args.clone()).await?;

submit_reveal_aux(
client,
ctx,
Expand Down Expand Up @@ -778,7 +778,7 @@ where

if args.offline {
let signer = ctx.get(&signer);
let key = find_pk(client, &mut ctx.wallet, &signer).await?;
let key = find_pk(client, &mut ctx.wallet, &signer, None).await?;
let signing_key =
signing::find_key_by_pk(&mut ctx.wallet, &args.tx, &key)?;
let offline_proposal =
Expand Down Expand Up @@ -994,7 +994,8 @@ where
safe_exit(1)
}

let key = find_pk(client, &mut ctx.wallet, &args.voter_address).await?;
let key =
find_pk(client, &mut ctx.wallet, &args.voter_address, None).await?;
let signing_key =
signing::find_key_by_pk(&mut ctx.wallet, &args.tx, &key)?;
let offline_vote = OfflineVote::new(
Expand Down
25 changes: 9 additions & 16 deletions shared/src/ledger/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,13 @@ pub async fn tx_signer<
wallet: &mut Wallet<U>,
args: &args::Tx,
default: TxSigningKey,
) -> Result<(Option<Address>, Vec<common::PublicKey>), Error> {
let signer = if args.dry_run {
// We cannot override the signer if we're doing a dry run
default
} else if !&args.signing_keys.is_empty() {
) -> Result<Vec<common::PublicKey>, Error> {
let signer = if !&args.signing_keys.is_empty() {
let public_keys =
args.signing_keys.iter().map(|key| key.ref_to()).collect();

return Ok((None, public_keys));
return Ok(public_keys);
} else if let Some(verification_key) = &args.verification_key {
return Ok((None, vec![verification_key.clone()]));
return Ok(vec![verification_key.clone()]);
} else {
// Otherwise use the signer determined by the caller
default
Expand All @@ -173,15 +169,12 @@ pub async fn tx_signer<
// Now actually fetch the signing key and apply it
match signer {
TxSigningKey::WalletAddress(signer) if signer == masp() => {
Ok((None, vec![masp_tx_key().ref_to()]))
Ok(vec![masp_tx_key().ref_to()])
}
TxSigningKey::WalletAddress(signer) => Ok((
Some(signer.clone()),
vec![
find_pk::<C, U>(client, wallet, &signer, args.password.clone())
.await?,
],
)),
TxSigningKey::WalletAddress(signer) => Ok(vec![
find_pk::<C, U>(client, wallet, &signer, args.password.clone())
.await?,
]),
TxSigningKey::None => other_err(
"All transactions must be signed; please either specify the key \
or the address from which to look up the signing key."
Expand Down
8 changes: 4 additions & 4 deletions shared/src/ledger/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ pub async fn prepare_tx<
wallet: &mut Wallet<U>,
args: &args::Tx,
tx: Tx,
_owner: Option<Address>,
owner: Option<Address>,
default_signer: TxSigningKey,
#[cfg(not(feature = "mainnet"))] requires_pow: bool,
) -> Result<(Tx, Option<Address>, Vec<common::PublicKey>), Error> {
let (signer_address, signer_public_keys) =
let signer_public_keys =
tx_signer::<C, U>(client, wallet, args, default_signer.clone()).await?;

let fee_payer = match &args.fee_payer {
Expand All @@ -275,7 +275,7 @@ pub async fn prepare_tx<
};

if args.dry_run {
Ok((tx, signer_address, signer_public_keys))
Ok((tx, owner, signer_public_keys))
} else {
let epoch = rpc::query_epoch(client).await;
Ok((
Expand All @@ -290,7 +290,7 @@ pub async fn prepare_tx<
requires_pow,
)
.await,
signer_address,
owner,
signer_public_keys,
))
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ fn ledger_txs_and_queries() -> Result<()> {
"--node",
&validator_one_rpc,
],
// 6. Submit a tx to withdraw from faucet account (requires PoW challenge
// solution)
// 6. Submit a tx to withdraw from faucet account (requires PoW challenge
// solution)
vec![
"transfer",
"--source",
Expand Down

0 comments on commit f60341c

Please sign in to comment.