// Copyright 2021 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //! Concrete implementations of types found in libwallet, organised this //! way mostly to avoid any circular dependencies of any kind //! Functions in this crate should not use the wallet api crate directly use blake2_rfc as blake2; #[macro_use] extern crate serde_derive; #[macro_use] extern crate log; #[macro_use] extern crate serde_json; use grin_api as api; use grin_chain as chain; use grin_core as core; use grin_keychain as keychain; use grin_util as util; use grin_wallet_libwallet as libwallet; use grin_wallet_config as config; mod adapters; mod client_utils; mod error; mod lifecycle; mod node_clients; pub mod test_framework; pub mod tor; pub use crate::adapters::{ PathToSlate, PathToSlatepack, SlateGetter, SlatePutter, SlateReceiver, SlateSender, TorSlateSender, }; pub use crate::error::Error; pub use crate::lifecycle::DefaultLCProvider; pub use crate::node_clients::HTTPNodeClient; use crate::keychain::{ExtKeychain, Keychain}; use libwallet::{NodeClient, WalletInst, WalletLCProvider}; /// Main wallet instance pub struct DefaultWalletImpl where C: NodeClient, { lc_provider: DefaultLCProvider, } impl DefaultWalletImpl where C: NodeClient, { pub fn new(node_client: C) -> Result { let lc_provider = DefaultLCProvider::new(node_client); Ok(DefaultWalletImpl { lc_provider }) } } impl<'a, L, C, K> WalletInst<'a, L, C, K> for DefaultWalletImpl where DefaultLCProvider: WalletLCProvider<'a, C, K>, L: WalletLCProvider<'a, C, K>, C: NodeClient + 'a, K: Keychain + 'a, { fn lc_provider(&mut self) -> Result<&mut dyn WalletLCProvider<'a, C, K>, libwallet::Error> { Ok(&mut self.lc_provider) } }