mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 15:21:39 +02:00
* version bump for next potential release * Merge master into milestone/2.1.0 (#182) * Derive --version output dynamically from cargo package version (#174) * add --txid to the `wallet txs` command (#176) * add --txid to the `wallet txs` command * add test for `wallet txs` command with `--txid` parameter * Refactor - Split WalletCommAdapter into multiple traits (#180) * Derive --version output dynamically from cargo package version (#174) * add server auth argument to http client * Revert "add server auth argument to http client" This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee. * modify WalletCommAdapter, moving dest argument into fields on implementors, visiting havok on automated tests, at least one of which is now out of date and failing * Split WalletCommAdapter into four traits, one for each of its intended behaviors. * Remove two vestigals 1. args, a stringly typed argument to put_tx 2. NullAdapter, which is no longer used * Remove unused "params" argument from listen method. * Re-add previously existing TODO comment * Fix non-test build * completely Fix non-test build * Full Lifecycle API Support (#184) * refactoring wallet lib traits * rustfmt * rustfmt * add new files * explicit lifetime specifiers on all wallet traits * rustfmt * modify apis to use new walletinst * rustfmt * converting controller crate * rustfmt * controller crate compiling * rustfmt * compilation * rustfmt * Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl * rustfmt * full compilation, changing recovery + init to new model * rustfmt * wallet initialisation working, init command output and flow identical to v2.0.0 wallet * rustfmt * fix listener and owner api startup * rustfmt * rustfmt * move encryption test * rustfmt * fix api doctests * rustfmt * fix for most tests in controller crate * rustfmt * fix for check tests in controller crate * fix main wallet tests * rustfmt * add explicit functions to handle mnemonic recovery, fix CLI recovery workflow * rustfmt * update keybase adapter to use new wallet format * rustfmt * test fix * remove debug output
88 lines
2.5 KiB
Rust
88 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 error;
|
|
mod lifecycle;
|
|
mod node_clients;
|
|
pub mod test_framework;
|
|
|
|
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)
|
|
}
|
|
}
|