From a13c20ceb22b8b3c74d27d2f87281c1fcd5a4b5d Mon Sep 17 00:00:00 2001 From: Quentin Le Sceller Date: Thu, 27 Sep 2018 15:45:48 -0400 Subject: [PATCH] Fix API wallets calls (#1597) * Add API Secret in wallet calls * File node api secret default to same api secret and directly in http parameter --- config/src/comments.rs | 7 ++- config/src/config.rs | 4 ++ servers/tests/framework/mod.rs | 6 +-- servers/tests/simulnet.rs | 4 +- src/bin/cmd/wallet.rs | 12 +++-- src/bin/tui/menu.rs | 6 +-- src/bin/tui/mining.rs | 57 ++++++++---------------- src/bin/tui/peers.rs | 9 ++-- src/bin/tui/status.rs | 21 +++------ wallet/src/client.rs | 15 ++++--- wallet/src/file_wallet.rs | 6 +-- wallet/src/libwallet/controller.rs | 3 +- wallet/src/libwallet/internal/updater.rs | 6 +-- wallet/src/libwallet/types.rs | 5 ++- wallet/src/lmdb_wallet.rs | 6 ++- wallet/src/types.rs | 3 ++ wallet/tests/common/testclient.rs | 9 ++-- wallet/tests/transaction.rs | 2 + 18 files changed, 91 insertions(+), 90 deletions(-) diff --git a/config/src/comments.rs b/config/src/comments.rs index 7b1460cfe..2158d98da 100644 --- a/config/src/comments.rs +++ b/config/src/comments.rs @@ -326,7 +326,12 @@ fn comments() -> HashMap { #where the wallet should find a running node ".to_string(), ); - + retval.insert( + "node_api_secret_path".to_string(), + " +#location of the node api secret for basic auth on the Grin API +".to_string(), + ); retval.insert( "data_file_dir".to_string(), " diff --git a/config/src/config.rs b/config/src/config.rs index 6ab4d99dd..90f04d2cc 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -371,6 +371,10 @@ impl GlobalWalletConfig { secret_path.push(API_SECRET_FILE_NAME); self.members.as_mut().unwrap().wallet.api_secret_path = Some(secret_path.to_str().unwrap().to_owned()); + let mut node_secret_path = wallet_home.clone(); + node_secret_path.push(API_SECRET_FILE_NAME); + self.members.as_mut().unwrap().wallet.node_api_secret_path = + Some(node_secret_path.to_str().unwrap().to_owned()); let mut log_path = wallet_home.clone(); log_path.push(WALLET_LOG_FILE_NAME); self.members diff --git a/servers/tests/framework/mod.rs b/servers/tests/framework/mod.rs index 190718063..f49040f30 100644 --- a/servers/tests/framework/mod.rs +++ b/servers/tests/framework/mod.rs @@ -263,7 +263,7 @@ impl LocalServerContainer { let _ = fs::create_dir_all(self.wallet_config.clone().data_file_dir); let r = wallet::WalletSeed::init_file(&self.wallet_config); - let client = HTTPWalletClient::new(&self.wallet_config.check_node_api_http_addr); + let client = HTTPWalletClient::new(&self.wallet_config.check_node_api_http_addr, None); if let Err(e) = r { //panic!("Error initializing wallet seed: {}", e); @@ -305,7 +305,7 @@ impl LocalServerContainer { let keychain: keychain::ExtKeychain = wallet_seed .derive_keychain("") .expect("Failed to derive keychain from seed file and passphrase."); - let client = HTTPWalletClient::new(&config.check_node_api_http_addr); + let client = HTTPWalletClient::new(&config.check_node_api_http_addr, None); let mut wallet = FileWallet::new(config.clone(), "", client) .unwrap_or_else(|e| panic!("Error creating wallet: {:?} Config: {:?}", e, config)); wallet.keychain = Some(keychain); @@ -331,7 +331,7 @@ impl LocalServerContainer { .derive_keychain("") .expect("Failed to derive keychain from seed file and passphrase."); - let client = HTTPWalletClient::new(&config.check_node_api_http_addr); + let client = HTTPWalletClient::new(&config.check_node_api_http_addr, None); let max_outputs = 500; let change_outputs = 1; diff --git a/servers/tests/simulnet.rs b/servers/tests/simulnet.rs index c1e61a705..03f2130ae 100644 --- a/servers/tests/simulnet.rs +++ b/servers/tests/simulnet.rs @@ -423,7 +423,7 @@ fn replicate_tx_fluff_failure() { // Create Wallet 1 (Mining Input) and start it listening // Wallet 1 post to another node, just for fun - let client1 = HTTPWalletClient::new("http://127.0.0.1:23003"); + let client1 = HTTPWalletClient::new("http://127.0.0.1:23003", None); let wallet1 = create_wallet("target/tmp/tx_fluff/wallet1", client1.clone()); let wallet1_handle = thread::spawn(move || { controller::foreign_listener(wallet1, "127.0.0.1:33000") @@ -431,7 +431,7 @@ fn replicate_tx_fluff_failure() { }); // Create Wallet 2 (Recipient) and launch - let client2 = HTTPWalletClient::new("http://127.0.0.1:23001"); + let client2 = HTTPWalletClient::new("http://127.0.0.1:23001", None); let wallet2 = create_wallet("target/tmp/tx_fluff/wallet2", client2.clone()); let wallet2_handle = thread::spawn(move || { controller::foreign_listener(wallet2, "127.0.0.1:33001") diff --git a/src/bin/cmd/wallet.rs b/src/bin/cmd/wallet.rs index 582fe9491..437706299 100644 --- a/src/bin/cmd/wallet.rs +++ b/src/bin/cmd/wallet.rs @@ -52,6 +52,7 @@ pub fn seed_exists(wallet_config: WalletConfig) -> bool { pub fn instantiate_wallet( wallet_config: WalletConfig, passphrase: &str, + node_api_secret: Option, ) -> Box> { if grin_wallet::needs_migrate(&wallet_config.data_file_dir) { // Migrate wallet automatically @@ -67,7 +68,7 @@ pub fn instantiate_wallet( warn!(LOGGER, "If anything went wrong, you can try again by deleting the `db` directory and running a wallet command"); warn!(LOGGER, "If all is okay, you can move/backup/delete all files in the wallet directory EXCEPT FOR wallet.seed"); } - let client = HTTPWalletClient::new(&wallet_config.check_node_api_http_addr); + let client = HTTPWalletClient::new(&wallet_config.check_node_api_http_addr, node_api_secret); let db_wallet = LMDBBackend::new(wallet_config.clone(), "", client).unwrap_or_else(|e| { panic!( "Error creating DB wallet: {} Config: {:?}", @@ -102,13 +103,15 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) { if wallet_args.is_present("show_spent") { show_spent = true; } + let node_api_secret = get_first_line(wallet_config.node_api_secret_path.clone()); // Derive the keychain based on seed from seed file and specified passphrase. // Generate the initial wallet seed if we are running "wallet init". if let ("init", Some(_)) = wallet_args.subcommand() { WalletSeed::init_file(&wallet_config).expect("Failed to init wallet seed file."); info!(LOGGER, "Wallet seed file created"); - let client = HTTPWalletClient::new(&wallet_config.check_node_api_http_addr); + let client = + HTTPWalletClient::new(&wallet_config.check_node_api_http_addr, node_api_secret); let _: LMDBBackend = LMDBBackend::new(wallet_config.clone(), "", client).unwrap_or_else(|e| { panic!( @@ -126,11 +129,11 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) { let passphrase = wallet_args .value_of("pass") .expect("Failed to read passphrase."); - // Handle listener startup commands { - let wallet = instantiate_wallet(wallet_config.clone(), passphrase); + let wallet = instantiate_wallet(wallet_config.clone(), passphrase, node_api_secret.clone()); let api_secret = get_first_line(wallet_config.api_secret_path.clone()); + match wallet_args.subcommand() { ("listen", Some(listen_args)) => { if let Some(port) = listen_args.value_of("port") { @@ -174,6 +177,7 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) { let wallet = Arc::new(Mutex::new(instantiate_wallet( wallet_config.clone(), passphrase, + node_api_secret, ))); let res = controller::owner_single_use(wallet.clone(), |api| { match wallet_args.subcommand() { diff --git a/src/bin/tui/menu.rs b/src/bin/tui/menu.rs index 0da1f96ec..df07fdc7f 100644 --- a/src/bin/tui/menu.rs +++ b/src/bin/tui/menu.rs @@ -63,13 +63,11 @@ pub fn create() -> Box { let mut s: ViewRef> = c.find_id(MAIN_MENU).unwrap(); s.select_down(1)(c); Some(EventResult::Consumed(None)); - }) - .on_pre_event('k', move |c| { + }).on_pre_event('k', move |c| { let mut s: ViewRef> = c.find_id(MAIN_MENU).unwrap(); s.select_up(1)(c); Some(EventResult::Consumed(None)); - }) - .on_pre_event(Key::Tab, move |c| { + }).on_pre_event(Key::Tab, move |c| { let mut s: ViewRef> = c.find_id(MAIN_MENU).unwrap(); if s.selected_id().unwrap() == s.len() - 1 { s.set_selection(0)(c); diff --git a/src/bin/tui/mining.rs b/src/bin/tui/mining.rs index 32729864e..957e937f1 100644 --- a/src/bin/tui/mining.rs +++ b/src/bin/tui/mining.rs @@ -170,23 +170,17 @@ impl TUIStatusListener for TUIMiningView { let table_view = TableView::::new() .column(StratumWorkerColumn::Id, "Worker ID", |c| { c.width_percent(10) - }) - .column(StratumWorkerColumn::IsConnected, "Connected", |c| { + }).column(StratumWorkerColumn::IsConnected, "Connected", |c| { c.width_percent(10) - }) - .column(StratumWorkerColumn::LastSeen, "Last Seen", |c| { + }).column(StratumWorkerColumn::LastSeen, "Last Seen", |c| { c.width_percent(20) - }) - .column(StratumWorkerColumn::PowDifficulty, "Pow Difficulty", |c| { + }).column(StratumWorkerColumn::PowDifficulty, "Pow Difficulty", |c| { c.width_percent(10) - }) - .column(StratumWorkerColumn::NumAccepted, "Num Accepted", |c| { + }).column(StratumWorkerColumn::NumAccepted, "Num Accepted", |c| { c.width_percent(10) - }) - .column(StratumWorkerColumn::NumRejected, "Num Rejected", |c| { + }).column(StratumWorkerColumn::NumRejected, "Num Rejected", |c| { c.width_percent(10) - }) - .column(StratumWorkerColumn::NumStale, "Num Stale", |c| { + }).column(StratumWorkerColumn::NumStale, "Num Stale", |c| { c.width_percent(10) }); @@ -194,28 +188,22 @@ impl TUIStatusListener for TUIMiningView { .child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("stratum_config_status")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("stratum_is_running_status")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("stratum_num_workers_status")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("stratum_block_height_status")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("stratum_network_difficulty_status")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("stratum_network_hashrate")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("stratum_cuckoo_size_status")), ); @@ -225,26 +213,22 @@ impl TUIStatusListener for TUIMiningView { .child(BoxView::with_full_screen( Dialog::around(table_view.with_id(TABLE_MINING_STATUS).min_size((50, 20))) .title("Mining Workers"), - )) - .with_id("mining_device_view"); + )).with_id("mining_device_view"); let diff_status_view = LinearLayout::new(Orientation::Vertical) .child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Tip Height: ")) .child(TextView::new("").with_id("diff_cur_height")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Difficulty Adjustment Window: ")) .child(TextView::new("").with_id("diff_adjust_window")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Average Block Time: ")) .child(TextView::new("").with_id("diff_avg_block_time")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Average Difficulty: ")) .child(TextView::new("").with_id("diff_avg_difficulty")), @@ -253,11 +237,9 @@ impl TUIStatusListener for TUIMiningView { let diff_table_view = TableView::::new() .column(DiffColumn::BlockNumber, "Block Number", |c| { c.width_percent(25) - }) - .column(DiffColumn::Difficulty, "Network Difficulty", |c| { + }).column(DiffColumn::Difficulty, "Network Difficulty", |c| { c.width_percent(25) - }) - .column(DiffColumn::Time, "Block Time", |c| c.width_percent(25)) + }).column(DiffColumn::Time, "Block Time", |c| c.width_percent(25)) .column(DiffColumn::Duration, "Duration", |c| c.width_percent(25)); let mining_difficulty_view = LinearLayout::new(Orientation::Vertical) @@ -268,8 +250,7 @@ impl TUIStatusListener for TUIMiningView { .with_id(TABLE_MINING_DIFF_STATUS) .min_size((50, 20)), ).title("Mining Difficulty Data"), - )) - .with_id("mining_difficulty_view"); + )).with_id("mining_difficulty_view"); let view_stack = StackView::new() .layer(mining_difficulty_view) diff --git a/src/bin/tui/peers.rs b/src/bin/tui/peers.rs index a53036a04..1f9e019d4 100644 --- a/src/bin/tui/peers.rs +++ b/src/bin/tui/peers.rs @@ -86,21 +86,18 @@ impl TUIStatusListener for TUIPeerView { .column(PeerColumn::Direction, "Direction", |c| c.width_percent(20)) .column(PeerColumn::TotalDifficulty, "Total Difficulty", |c| { c.width_percent(20) - }) - .column(PeerColumn::Version, "Version", |c| c.width_percent(20)); + }).column(PeerColumn::Version, "Version", |c| c.width_percent(20)); let peer_status_view = BoxView::with_full_screen( LinearLayout::new(Orientation::Vertical) .child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Total Peers: ")) .child(TextView::new(" ").with_id("peers_total")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Longest Chain: ")) .child(TextView::new(" ").with_id("longest_work_peer")), - ) - .child(TextView::new(" ")) + ).child(TextView::new(" ")) .child( Dialog::around(table_view.with_id(TABLE_PEER_STATUS).min_size((50, 20))) .title("Connected Peers"), diff --git a/src/bin/tui/status.rs b/src/bin/tui/status.rs index 18a83bb78..db137747e 100644 --- a/src/bin/tui/status.rs +++ b/src/bin/tui/status.rs @@ -37,35 +37,28 @@ impl TUIStatusListener for TUIStatusView { LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Current Status: ")) .child(TextView::new("Starting").with_id("basic_current_status")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Connected Peers: ")) .child(TextView::new("0").with_id("connected_peers")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Chain Height: ")) .child(TextView::new(" ").with_id("chain_height")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("Total Difficulty: ")) .child(TextView::new(" ").with_id("basic_total_difficulty")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new("------------------------")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("basic_mining_config_status")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("basic_mining_status")), - ) - .child( + ).child( LinearLayout::new(Orientation::Horizontal) .child(TextView::new(" ").with_id("basic_network_info")), ), //.child(logo_view) diff --git a/wallet/src/client.rs b/wallet/src/client.rs index 5eb13823e..503312c96 100644 --- a/wallet/src/client.rs +++ b/wallet/src/client.rs @@ -32,13 +32,15 @@ use util::{self, LOGGER}; #[derive(Clone)] pub struct HTTPWalletClient { node_url: String, + node_api_secret: Option, } impl HTTPWalletClient { /// Create a new client that will communicate with the given grin node - pub fn new(node_url: &str) -> HTTPWalletClient { + pub fn new(node_url: &str, node_api_secret: Option) -> HTTPWalletClient { HTTPWalletClient { node_url: node_url.to_owned(), + node_api_secret: node_api_secret, } } } @@ -47,6 +49,9 @@ impl WalletClient for HTTPWalletClient { fn node_url(&self) -> &str { &self.node_url } + fn node_api_secret(&self) -> Option { + self.node_api_secret.clone() + } /// Call the wallet API to create a coinbase output for the given /// block_fees. Will retry based on default "retry forever with backoff" @@ -101,7 +106,7 @@ impl WalletClient for HTTPWalletClient { } else { url = format!("{}/v1/pool/push", dest); } - api::client::post_no_ret(url.as_str(), None, tx).context( + api::client::post_no_ret(url.as_str(), self.node_api_secret(), tx).context( libwallet::ErrorKind::ClientCallback("Posting transaction to node"), )?; Ok(()) @@ -111,7 +116,7 @@ impl WalletClient for HTTPWalletClient { fn get_chain_height(&self) -> Result { let addr = self.node_url(); let url = format!("{}/v1/chain", addr); - let res = api::client::get::(url.as_str(), None).context( + let res = api::client::get::(url.as_str(), self.node_api_secret()).context( libwallet::ErrorKind::ClientCallback("Getting chain height from node"), )?; Ok(res.height) @@ -138,7 +143,7 @@ impl WalletClient for HTTPWalletClient { let url = format!("{}/v1/chain/outputs/byids?{}", addr, query_chunk.join("&"),); tasks.push(api::client::get_async::>( url.as_str(), - None, + self.node_api_secret(), )); } @@ -184,7 +189,7 @@ impl WalletClient for HTTPWalletClient { let mut api_outputs: Vec<(pedersen::Commitment, pedersen::RangeProof, bool, u64)> = Vec::new(); - match api::client::get::(url.as_str(), None) { + match api::client::get::(url.as_str(), self.node_api_secret()) { Ok(o) => { for out in o.outputs { let is_coinbase = match out.output_type { diff --git a/wallet/src/file_wallet.rs b/wallet/src/file_wallet.rs index ddecb153a..41979ec00 100644 --- a/wallet/src/file_wallet.rs +++ b/wallet/src/file_wallet.rs @@ -444,9 +444,9 @@ where // write details file let mut details_file = File::create(details_file_path).context(ErrorKind::FileWallet(&"Could not create "))?; - let res_json = serde_json::to_string_pretty(&self.details).context(ErrorKind::FileWallet( - "Error serializing wallet details file", - ))?; + let res_json = serde_json::to_string_pretty(&self.details).context( + ErrorKind::FileWallet("Error serializing wallet details file"), + )?; details_file .write_all(res_json.into_bytes().as_slice()) .context(ErrorKind::FileWallet(&"Error writing wallet details file")) diff --git a/wallet/src/libwallet/controller.rs b/wallet/src/libwallet/controller.rs index eada5ff43..080aad4cc 100644 --- a/wallet/src/libwallet/controller.rs +++ b/wallet/src/libwallet/controller.rs @@ -131,7 +131,7 @@ where api_thread .join() - .map_err(|e| ErrorKind::GenericError(format!("API thread paniced :{:?}", e)).into()) + .map_err(|e| ErrorKind::GenericError(format!("API thread panicked :{:?}", e)).into()) } type WalletResponseFuture = Box, Error = Error> + Send>; @@ -257,6 +257,7 @@ where fn handle_get_request(&self, req: &Request) -> Result, Error> { let api = APIOwner::new(self.wallet.clone()); + Ok(match req .uri() .path() diff --git a/wallet/src/libwallet/internal/updater.rs b/wallet/src/libwallet/internal/updater.rs index 4de8673ff..a1795bbff 100644 --- a/wallet/src/libwallet/internal/updater.rs +++ b/wallet/src/libwallet/internal/updater.rs @@ -56,8 +56,7 @@ where } else { out.status != OutputStatus::Spent } - }) - .collect::>(); + }).collect::>(); // only include outputs with a given tx_id if provided if let Some(id) = tx_id { @@ -74,8 +73,7 @@ where .map(|out| { let commit = wallet.get_commitment(&out.key_id).unwrap(); (out, commit) - }) - .collect(); + }).collect(); Ok(res) } diff --git a/wallet/src/libwallet/types.rs b/wallet/src/libwallet/types.rs index c051c99a4..6ccf6f08e 100644 --- a/wallet/src/libwallet/types.rs +++ b/wallet/src/libwallet/types.rs @@ -157,6 +157,8 @@ where pub trait WalletClient: Sync + Send + Clone { /// Return the URL of the check node fn node_url(&self) -> &str; + /// Return the node api secret + fn node_api_secret(&self) -> Option; /// Call the wallet API to create a coinbase transaction fn create_coinbase(&self, dest: &str, block_fees: &BlockFees) -> Result; @@ -417,7 +419,8 @@ impl BlockIdentifier { /// convert to hex string pub fn from_hex(hex: &str) -> Result { - let hash = Hash::from_hex(hex).context(ErrorKind::GenericError("Invalid hex".to_owned()))?; + let hash = + Hash::from_hex(hex).context(ErrorKind::GenericError("Invalid hex".to_owned()))?; Ok(BlockIdentifier(hash)) } } diff --git a/wallet/src/lmdb_wallet.rs b/wallet/src/lmdb_wallet.rs index 00d6e3311..5471ca52b 100644 --- a/wallet/src/lmdb_wallet.rs +++ b/wallet/src/lmdb_wallet.rs @@ -336,7 +336,11 @@ where fn save_tx_log_entry(&self, t: TxLogEntry) -> Result<(), Error> { let tx_log_key = u64_to_key(TX_LOG_ENTRY_PREFIX, t.id as u64); - self.db.borrow().as_ref().unwrap().put_ser(&tx_log_key, &t)?; + self.db + .borrow() + .as_ref() + .unwrap() + .put_ser(&tx_log_key, &t)?; Ok(()) } diff --git a/wallet/src/types.rs b/wallet/src/types.rs index 8619998f6..6d55be07e 100644 --- a/wallet/src/types.rs +++ b/wallet/src/types.rs @@ -41,6 +41,8 @@ pub struct WalletConfig { pub api_listen_port: u16, /// Location of the secret for basic auth on the Owner API pub api_secret_path: Option, + /// Location of the node api secret for basic auth on the Grin API + pub node_api_secret_path: Option, // The api address of a running server node against which transaction inputs // will be checked during send pub check_node_api_http_addr: String, @@ -55,6 +57,7 @@ impl Default for WalletConfig { api_listen_interface: "127.0.0.1".to_string(), api_listen_port: 13415, api_secret_path: Some(".api_secret".to_string()), + node_api_secret_path: Some(".api_secret".to_string()), check_node_api_http_addr: "http://127.0.0.1:13413".to_string(), data_file_dir: ".".to_string(), } diff --git a/wallet/tests/common/testclient.rs b/wallet/tests/common/testclient.rs index 22e274c66..554582922 100644 --- a/wallet/tests/common/testclient.rs +++ b/wallet/tests/common/testclient.rs @@ -180,9 +180,9 @@ where libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper"), )?; - let tx_bin = util::from_hex(wrapper.tx_hex).context(libwallet::ErrorKind::ClientCallback( - "Error parsing TxWrapper: tx_bin", - ))?; + let tx_bin = util::from_hex(wrapper.tx_hex).context( + libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper: tx_bin"), + )?; let tx: Transaction = ser::deserialize(&mut &tx_bin[..]).context( libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper: tx"), @@ -314,6 +314,9 @@ impl WalletClient for LocalWalletClient { fn node_url(&self) -> &str { "node" } + fn node_api_secret(&self) -> Option { + None + } /// Call the wallet API to create a coinbase output for the given /// block_fees. Will retry based on default "retry forever with backoff" diff --git a/wallet/tests/transaction.rs b/wallet/tests/transaction.rs index c20c29926..808a0c9e9 100644 --- a/wallet/tests/transaction.rs +++ b/wallet/tests/transaction.rs @@ -91,6 +91,7 @@ fn basic_transaction_api( // few values to keep things shorter let reward = core::consensus::REWARD; let cm = global::coinbase_maturity(0); // assume all testing precedes soft fork height + // mine a few blocks let _ = common::award_blocks_to_wallet(&chain, wallet1.clone(), 10); @@ -344,6 +345,7 @@ fn tx_rollback(test_dir: &str, backend_type: common::BackendType) -> Result<(), // few values to keep things shorter let reward = core::consensus::REWARD; let cm = global::coinbase_maturity(0); // assume all testing precedes soft fork height + // mine a few blocks let _ = common::award_blocks_to_wallet(&chain, wallet1.clone(), 5);