Merge milestone/2.1.0 into master (#199)

* 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
This commit is contained in:
Yeastplume
2019-07-29 13:25:03 +01:00
committed by GitHub
parent 7b6d597d39
commit c40e8a915b
54 changed files with 2405 additions and 1942 deletions
+12 -12
View File
@@ -35,15 +35,15 @@ pub fn check_version() -> VersionInfo {
}
/// Build a coinbase transaction
pub fn build_coinbase<T: ?Sized, C, K>(
pub fn build_coinbase<'a, T: ?Sized, C, K>(
w: &mut T,
block_fees: &BlockFees,
test_mode: bool,
) -> Result<CbData, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
updater::build_coinbase(&mut *w, block_fees, test_mode)
}
@@ -54,7 +54,7 @@ pub fn verify_slate_messages(slate: &Slate) -> Result<(), Error> {
}
/// Receive a tx as recipient
pub fn receive_tx<T: ?Sized, C, K>(
pub fn receive_tx<'a, T: ?Sized, C, K>(
w: &mut T,
slate: &Slate,
dest_acct_name: Option<&str>,
@@ -62,9 +62,9 @@ pub fn receive_tx<T: ?Sized, C, K>(
use_test_rng: bool,
) -> Result<Slate, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let mut ret_slate = slate.clone();
let parent_key_id = match dest_acct_name {
@@ -113,11 +113,11 @@ where
}
/// Receive an tx that this wallet has issued
pub fn finalize_invoice_tx<T: ?Sized, C, K>(w: &mut T, slate: &Slate) -> Result<Slate, Error>
pub fn finalize_invoice_tx<'a, T: ?Sized, C, K>(w: &mut T, slate: &Slate) -> Result<Slate, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let mut sl = slate.clone();
let context = w.get_private_context(sl.id.as_bytes(), 1)?;
+70 -70
View File
@@ -33,46 +33,46 @@ use crate::{
const USER_MESSAGE_MAX_LEN: usize = 256;
/// List of accounts
pub fn accounts<T: ?Sized, C, K>(w: &mut T) -> Result<Vec<AcctPathMapping>, Error>
pub fn accounts<'a, T: ?Sized, C, K>(w: &mut T) -> Result<Vec<AcctPathMapping>, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
keys::accounts(&mut *w)
}
/// new account path
pub fn create_account_path<T: ?Sized, C, K>(w: &mut T, label: &str) -> Result<Identifier, Error>
pub fn create_account_path<'a, T: ?Sized, C, K>(w: &mut T, label: &str) -> Result<Identifier, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
keys::new_acct_path(&mut *w, label)
}
/// set active account
pub fn set_active_account<T: ?Sized, C, K>(w: &mut T, label: &str) -> Result<(), Error>
pub fn set_active_account<'a, T: ?Sized, C, K>(w: &mut T, label: &str) -> Result<(), Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
w.set_parent_key_id_by_name(label)
}
/// retrieve outputs
pub fn retrieve_outputs<T: ?Sized, C, K>(
pub fn retrieve_outputs<'a, T: ?Sized, C, K>(
w: &mut T,
include_spent: bool,
refresh_from_node: bool,
tx_id: Option<u32>,
) -> Result<(bool, Vec<OutputCommitMapping>), Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let parent_key_id = w.parent_key_id();
@@ -88,16 +88,16 @@ where
}
/// Retrieve txs
pub fn retrieve_txs<T: ?Sized, C, K>(
pub fn retrieve_txs<'a, T: ?Sized, C, K>(
w: &mut T,
refresh_from_node: bool,
tx_id: Option<u32>,
tx_slate_id: Option<Uuid>,
) -> Result<(bool, Vec<TxLogEntry>), Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let parent_key_id = w.parent_key_id();
@@ -113,15 +113,15 @@ where
}
/// Retrieve summary info
pub fn retrieve_summary_info<T: ?Sized, C, K>(
pub fn retrieve_summary_info<'a, T: ?Sized, C, K>(
w: &mut T,
refresh_from_node: bool,
minimum_confirmations: u64,
) -> Result<(bool, WalletInfo), Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let parent_key_id = w.parent_key_id();
@@ -135,15 +135,15 @@ where
}
/// Initiate tx as sender
pub fn init_send_tx<T: ?Sized, C, K>(
pub fn init_send_tx<'a, T: ?Sized, C, K>(
w: &mut T,
args: InitTxArgs,
use_test_rng: bool,
) -> Result<Slate, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let parent_key_id = match args.src_acct_name {
Some(d) => {
@@ -211,15 +211,15 @@ where
}
/// Initiate a transaction as the recipient (invoicing)
pub fn issue_invoice_tx<T: ?Sized, C, K>(
pub fn issue_invoice_tx<'a, T: ?Sized, C, K>(
w: &mut T,
args: IssueInvoiceTxArgs,
use_test_rng: bool,
) -> Result<Slate, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let parent_key_id = match args.dest_acct_name {
Some(d) => {
@@ -268,16 +268,16 @@ where
/// Receive an invoice tx, essentially adding inputs to whatever
/// output was specified
pub fn process_invoice_tx<T: ?Sized, C, K>(
pub fn process_invoice_tx<'a, T: ?Sized, C, K>(
w: &mut T,
slate: &Slate,
args: InitTxArgs,
use_test_rng: bool,
) -> Result<Slate, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let mut ret_slate = slate.clone();
let parent_key_id = match args.src_acct_name {
@@ -345,26 +345,26 @@ where
}
/// Lock sender outputs
pub fn tx_lock_outputs<T: ?Sized, C, K>(
pub fn tx_lock_outputs<'a, T: ?Sized, C, K>(
w: &mut T,
slate: &Slate,
participant_id: usize,
) -> Result<(), Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let context = w.get_private_context(slate.id.as_bytes(), participant_id)?;
selection::lock_tx_context(&mut *w, slate, &context)
}
/// Finalize slate
pub fn finalize_tx<T: ?Sized, C, K>(w: &mut T, slate: &Slate) -> Result<Slate, Error>
pub fn finalize_tx<'a, T: ?Sized, C, K>(w: &mut T, slate: &Slate) -> Result<Slate, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let mut sl = slate.clone();
let context = w.get_private_context(sl.id.as_bytes(), 0)?;
@@ -380,15 +380,15 @@ where
}
/// cancel tx
pub fn cancel_tx<T: ?Sized, C, K>(
pub fn cancel_tx<'a, T: ?Sized, C, K>(
w: &mut T,
tx_id: Option<u32>,
tx_slate_id: Option<Uuid>,
) -> Result<(), Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let parent_key_id = w.parent_key_id();
if !update_outputs(w, false) {
@@ -400,23 +400,23 @@ where
}
/// get stored tx
pub fn get_stored_tx<T: ?Sized, C, K>(
pub fn get_stored_tx<'a, T: ?Sized, C, K>(
w: &T,
entry: &TxLogEntry,
) -> Result<Option<Transaction>, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
w.get_stored_tx(entry)
}
/// Posts a transaction to the chain
/// take a client impl instead of wallet so as not to have to lock the wallet
pub fn post_tx<C>(client: &C, tx: &Transaction, fluff: bool) -> Result<(), Error>
pub fn post_tx<'a, C>(client: &C, tx: &Transaction, fluff: bool) -> Result<(), Error>
where
C: NodeClient,
C: NodeClient + 'a,
{
let tx_hex = grin_util::to_hex(ser::ser_vec(tx).unwrap());
let res = client.post_tx(&TxWrapper { tx_hex: tx_hex }, fluff);
@@ -439,32 +439,32 @@ pub fn verify_slate_messages(slate: &Slate) -> Result<(), Error> {
}
/// Attempt to restore contents of wallet
pub fn restore<T: ?Sized, C, K>(w: &mut T) -> Result<(), Error>
pub fn restore<'a, T: ?Sized, C, K>(w: &mut T) -> Result<(), Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
w.restore()
}
/// check repair
pub fn check_repair<T: ?Sized, C, K>(w: &mut T, delete_unconfirmed: bool) -> Result<(), Error>
pub fn check_repair<'a, T: ?Sized, C, K>(w: &mut T, delete_unconfirmed: bool) -> Result<(), Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
update_outputs(w, true);
w.check_repair(delete_unconfirmed)
}
/// node height
pub fn node_height<T: ?Sized, C, K>(w: &mut T) -> Result<NodeHeightResult, Error>
pub fn node_height<'a, T: ?Sized, C, K>(w: &mut T) -> Result<NodeHeightResult, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let res = w.w2n_client().get_chain_height();
match res {
@@ -487,11 +487,11 @@ where
}
/// Attempt to update outputs in wallet, return whether it was successful
fn update_outputs<T: ?Sized, C, K>(w: &mut T, update_all: bool) -> bool
fn update_outputs<'a, T: ?Sized, C, K>(w: &mut T, update_all: bool) -> bool
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
T: WalletBackend<'a, C, K>,
C: NodeClient + 'a,
K: Keychain + 'a,
{
let parent_key_id = w.parent_key_id();
match updater::refresh_outputs(&mut *w, &parent_key_id, update_all) {