mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-01-21 03:21:08 +03:00
b4eeb50c66
* udpate for beta release * initial tor explorations * rustfmt * basic tor tx send working * rustfmt * add tor proxy info to config file * rustfmt * add utilities to output tor hidden service configuration files * output tor config as part of listener startup * rustfmt * fully automate config and startup of tor process * rustfmt * remove unnecessary process kill commands from listener * rustfmt * assume defaults for tor sending config if section doesn't exist in grin-wallet.toml * rustfmt * ignore tor dev test * update default paths output by config, compilation + confirmed working on windows * rustfmt * fix on osx/unix * add timeout to tor connector, remove unwrap in client * allow specifiying tor address without 'http://[].onion' on the command line * fix api test * rustfmt * update address derivation path as per spec * rustfmt * move tor init to separate function * rustfmt * re-ignore tor dev test * listen on tor by default if tor available * rustfmt * test fix * remove explicit send via tor flag, and assume tor if address fits * rustfmt
89 lines
2.5 KiB
Rust
89 lines
2.5 KiB
Rust
// Copyright 2019 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;
|
|
use grin_wallet_libwallet as libwallet;
|
|
use grin_wallet_util::grin_api as api;
|
|
use grin_wallet_util::grin_chain as chain;
|
|
use grin_wallet_util::grin_core as core;
|
|
use grin_wallet_util::grin_keychain as keychain;
|
|
use grin_wallet_util::grin_store as store;
|
|
use grin_wallet_util::grin_util as util;
|
|
|
|
use grin_wallet_config as config;
|
|
|
|
mod adapters;
|
|
mod backends;
|
|
mod client_utils;
|
|
mod error;
|
|
mod lifecycle;
|
|
mod node_clients;
|
|
pub mod test_framework;
|
|
pub mod tor;
|
|
|
|
pub use crate::adapters::{
|
|
create_sender, HttpSlateSender, KeybaseAllChannels, KeybaseChannel, PathToSlate, SlateGetter,
|
|
SlatePutter, SlateReceiver, SlateSender,
|
|
};
|
|
pub use crate::backends::{wallet_db_exists, LMDBBackend};
|
|
pub use crate::error::{Error, ErrorKind};
|
|
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<'a, C>
|
|
where
|
|
C: NodeClient + 'a,
|
|
{
|
|
lc_provider: DefaultLCProvider<'a, C, ExtKeychain>,
|
|
}
|
|
|
|
impl<'a, C> DefaultWalletImpl<'a, C>
|
|
where
|
|
C: NodeClient + 'a,
|
|
{
|
|
pub fn new(node_client: C) -> Result<Self, Error> {
|
|
let lc_provider = DefaultLCProvider::new(node_client);
|
|
Ok(DefaultWalletImpl {
|
|
lc_provider: lc_provider,
|
|
})
|
|
}
|
|
}
|
|
|
|
impl<'a, L, C, K> WalletInst<'a, L, C, K> for DefaultWalletImpl<'a, C>
|
|
where
|
|
DefaultLCProvider<'a, C, ExtKeychain>: 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> + 'a), libwallet::Error> {
|
|
Ok(&mut self.lc_provider)
|
|
}
|
|
}
|