|
1 | 1 | //! Txs App submit_tx module |
2 | 2 | #![forbid(unsafe_code)] |
3 | | -use crate::config::AppCfg; |
| 3 | + |
| 4 | +use std::io; |
| 5 | +use std::path::PathBuf; |
| 6 | + |
4 | 7 | use anyhow::Error; |
| 8 | +use reqwest::Url; |
5 | 9 |
|
6 | 10 | use diem_crypto::{ |
7 | 11 | ed25519::{Ed25519PrivateKey, Ed25519PublicKey}, |
8 | 12 | test_utils::KeyPair, |
9 | 13 | }; |
10 | 14 | use diem_global_constants::OPERATOR_KEY; |
11 | | - |
12 | 15 | use diem_secure_storage::{CryptoStorage, Namespaced, OnDiskStorage, Storage}; |
13 | 16 | use diem_types::{account_address::AccountAddress, chain_id::NamedChain, waypoint::Waypoint}; |
14 | 17 | use diem_types::{chain_id::ChainId, transaction::authenticator::AuthenticationKey}; |
| 18 | +use diem_wallet::WalletLibrary; |
15 | 19 | use ol::node::client::find_a_remote_jsonrpc; |
16 | 20 | use ol_keys::{scheme::KeyScheme, wallet}; |
17 | | - |
18 | | -use diem_wallet::WalletLibrary; |
19 | 21 | use ol_types::{ |
20 | 22 | self, |
21 | 23 | config::{TxCost, TxType}, |
22 | 24 | fixtures, |
23 | 25 | }; |
24 | | -use reqwest::Url; |
25 | | -use std::path::PathBuf; |
| 26 | + |
| 27 | +use crate::config::AppCfg; |
26 | 28 |
|
27 | 29 | /// All the parameters needed for a client transaction. |
28 | 30 | #[derive(Debug)] |
@@ -109,6 +111,39 @@ impl TxParams { |
109 | 111 | } |
110 | 112 | }; |
111 | 113 |
|
| 114 | + println!("OPTIONAL: If you have changed your account's authkey \ |
| 115 | + then input the old address below, enter to skip."); |
| 116 | + let mut account_address: Option<AccountAddress> = None; |
| 117 | + let mut input = String::new(); |
| 118 | + loop { |
| 119 | + match io::stdin().read_line(&mut input) { |
| 120 | + Ok(_) => { |
| 121 | + if let Some('\n') = input.chars().next_back() { |
| 122 | + input.pop(); |
| 123 | + } |
| 124 | + if let Some('\r') = input.chars().next_back() { |
| 125 | + input.pop(); |
| 126 | + } |
| 127 | + if input.len() == 0 { |
| 128 | + break; |
| 129 | + } |
| 130 | + if let Ok(address) = AccountAddress::from_hex_literal(&format!("0x{}", input)) { |
| 131 | + account_address = Some(address); |
| 132 | + break; |
| 133 | + }; |
| 134 | + println!("Invalid address. Try again!"); |
| 135 | + input.clear(); |
| 136 | + } |
| 137 | + Err(error) => println!("{}", error) |
| 138 | + } |
| 139 | + } |
| 140 | + if let Some(address) = account_address { |
| 141 | + tx_params.signer_address = address; |
| 142 | + if !is_operator { |
| 143 | + tx_params.owner_address = address; |
| 144 | + } |
| 145 | + } |
| 146 | + |
112 | 147 | if let Some(w) = waypoint { |
113 | 148 | tx_params.waypoint = w |
114 | 149 | } |
|
0 commit comments