Provide wallet 'plugin' architecture (#1983)
* remove receive_coinbase fn from wallet to wallet client * start moving clients into separate mod * rustfmt * move wallet client + start listener into wallet 'clients' * rustfmt * refactor API to make it more modular and completely decouple sending * rustfmt * further decouple API from sending methods * rustfmt * remove wallet to wallet client trait * rustfmt * rename / refactor client + adapters * rustfmt * add adapter concept * add midding node_clients dir * add file and null adapters * rustfmt * remove receive from owner api * factor out receiving slates into trait * rustfmt * adding listen trait * rustfmt * change listener to use trait * rustfmt * add test for file-based exchange * replace http api send command * rustfmt * move controller out of libwallet and into top-level wallet dir * rustfmt * add moved controller
This commit is contained in:
@@ -24,7 +24,7 @@ the code is organized into the following components (from highest-level to lowes
|
||||
* **libTx** - Library that provides lower-level transaction building, rangeproof and signing functions, highly-reusable by wallet implementors.
|
||||
* **Wallet Traits** - A set of generic traits defined within libWallet and the `keychain` crate . A wallet implementation such as Grin's current
|
||||
default only needs to implement these traits in order to provide a wallet:
|
||||
* **WalletToNodeClient** - Defines communication between the wallet, a running grin node and/or other wallets
|
||||
* **NodeClient** - Defines communication between the wallet, a running grin node and/or other wallets
|
||||
* **WalletBackend** - Defines the storage implementation of the wallet
|
||||
* **KeyChain** - Defines key derivation operations
|
||||
|
||||
@@ -66,22 +66,22 @@ pub fn retrieve_outputs<T: ?Sized, C, K>(
|
||||
) -> Result<Vec<OutputData>, Error>
|
||||
where
|
||||
!·T: WalletBackend<C, K>,
|
||||
!·C: WalletToNodeClient,
|
||||
!·C: NodeClient,
|
||||
!·K: Keychain,
|
||||
{
|
||||
```
|
||||
|
||||
With `T` in this instance being a class that implements the `WalletBackend` trait, which is further parameterized with implementations of
|
||||
`WalletToNodeClient` and `Keychain`.
|
||||
`NodeClient` and `Keychain`.
|
||||
|
||||
There is currently only a single implementation of the Keychain trait within the Grin code, in the `keychain` crate exported as `ExtKeyChain`.
|
||||
The `Keychain` trait makes several assumptions about the underlying implementation, particularly that it will adhere to a
|
||||
[BIP-38 style](https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki) 'master key -> child key' model.
|
||||
|
||||
There are two implementations of `WalletToNodeClient` within the code, the main version being the `HTTPWalletToNodeClient` found within `wallet/src/client.rs` and
|
||||
the seconds a test client that communicates with an in-process instance of a chain. The WalletToNodeClient isolates all network calls, so upgrading wallet
|
||||
There are two implementations of `NodeClient` within the code, the main version being the `HTTPNodeClient` found within `wallet/src/client.rs` and
|
||||
the seconds a test client that communicates with an in-process instance of a chain. The NodeClient isolates all network calls, so upgrading wallet
|
||||
communication from the current simple http interaction to a more secure protocol (or allowing for many options) should be a simple
|
||||
matter of dropping in different `WalletToNodeClient` implementations.
|
||||
matter of dropping in different `NodeClient` implementations.
|
||||
|
||||
There are also two implementations of `WalletBackend` within the code at the base of the `wallet` crate. `LMDBBackend` found within
|
||||
`wallet/src/lmdb_wallet.rs` is the main implementation, and is now used by all grin wallet commands. The earlier `FileWallet` still exists
|
||||
|
||||
@@ -40,7 +40,7 @@ folder "Provided by Grin" as services {
|
||||
package "Traits Implemented by Wallets" as traits {
|
||||
database "WalletBackend" as wallet_backend
|
||||
database "KeyChain" as keychain
|
||||
component "WalletToNodeClient" as wallet_client
|
||||
component "NodeClient" as wallet_client
|
||||
}
|
||||
|
||||
note left of wallet_client
|
||||
|
||||
Reference in New Issue
Block a user