2019-10-03 17:16:09 +03:00
|
|
|
// Copyright 2019 The Grin Developers
|
2019-02-13 18:05:19 +03:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
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
2019-07-29 15:25:03 +03:00
|
|
|
//! Grin wallet command-line function implementations
|
|
|
|
|
|
|
|
use crate::api::TLSConfig;
|
2020-02-06 12:08:24 +03:00
|
|
|
use crate::apiwallet::Owner;
|
2019-10-14 22:24:09 +03:00
|
|
|
use crate::config::{TorConfig, WalletConfig, WALLET_CONFIG_FILE_NAME};
|
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
2019-07-29 15:25:03 +03:00
|
|
|
use crate::core::{core, global};
|
|
|
|
use crate::error::{Error, ErrorKind};
|
|
|
|
use crate::impls::{create_sender, KeybaseAllChannels, SlateGetter as _, SlateReceiver as _};
|
2020-05-19 13:19:03 +03:00
|
|
|
use crate::impls::{HttpSlateSender, PathToSlate, SlatePutter};
|
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
2019-07-29 15:25:03 +03:00
|
|
|
use crate::keychain;
|
2019-11-28 18:13:52 +03:00
|
|
|
use crate::libwallet::{
|
2020-05-19 13:19:03 +03:00
|
|
|
self, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, Slate, SlateVersion,
|
|
|
|
WalletLCProvider,
|
2019-11-28 18:13:52 +03:00
|
|
|
};
|
2019-08-06 14:50:41 +03:00
|
|
|
use crate::util::secp::key::SecretKey;
|
2020-01-24 16:02:09 +03:00
|
|
|
use crate::util::{Mutex, ZeroingString};
|
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
2019-07-29 15:25:03 +03:00
|
|
|
use crate::{controller, display};
|
2020-01-24 16:02:09 +03:00
|
|
|
use grin_wallet_util::OnionV3Address;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
use serde_json as json;
|
2019-02-13 18:05:19 +03:00
|
|
|
use std::fs::File;
|
2020-01-22 16:16:24 +03:00
|
|
|
use std::io::{Read, Write};
|
2020-02-06 12:08:24 +03:00
|
|
|
use std::sync::atomic::Ordering;
|
2019-02-13 18:05:19 +03:00
|
|
|
use std::sync::Arc;
|
|
|
|
use std::thread;
|
|
|
|
use std::time::Duration;
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
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
2019-07-29 15:25:03 +03:00
|
|
|
fn show_recovery_phrase(phrase: ZeroingString) {
|
|
|
|
println!("Your recovery phrase is:");
|
|
|
|
println!();
|
|
|
|
println!("{}", &*phrase);
|
|
|
|
println!();
|
|
|
|
println!("Please back-up these words in a non-digital format.");
|
|
|
|
}
|
2019-02-13 18:05:19 +03:00
|
|
|
|
|
|
|
/// Arguments common to all wallet commands
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct GlobalArgs {
|
|
|
|
pub account: String,
|
2019-09-12 15:18:15 +03:00
|
|
|
pub api_secret: Option<String>,
|
2019-02-13 18:05:19 +03:00
|
|
|
pub node_api_secret: Option<String>,
|
|
|
|
pub show_spent: bool,
|
|
|
|
pub password: Option<ZeroingString>,
|
|
|
|
pub tls_conf: Option<TLSConfig>,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Arguments for init command
|
|
|
|
pub struct InitArgs {
|
|
|
|
/// BIP39 recovery phrase length
|
|
|
|
pub list_length: usize,
|
|
|
|
pub password: ZeroingString,
|
|
|
|
pub config: WalletConfig,
|
|
|
|
pub recovery_phrase: Option<ZeroingString>,
|
|
|
|
pub restore: bool,
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn init<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2020-05-18 15:04:09 +03:00
|
|
|
_g_args: &GlobalArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
args: InitArgs,
|
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-05-18 15:04:09 +03:00
|
|
|
// Assume global chain type has already been initialized.
|
|
|
|
let chain_type = global::get_chain_type();
|
|
|
|
|
2020-02-06 12:08:24 +03:00
|
|
|
let mut w_lock = owner_api.wallet_inst.lock();
|
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
2019-07-29 15:25:03 +03:00
|
|
|
let p = w_lock.lc_provider()?;
|
2020-05-18 15:04:09 +03:00
|
|
|
p.create_config(&chain_type, WALLET_CONFIG_FILE_NAME, None, None, None)?;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
p.create_wallet(
|
|
|
|
None,
|
2019-02-13 18:05:19 +03:00
|
|
|
args.recovery_phrase,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
args.list_length,
|
|
|
|
args.password.clone(),
|
2019-09-02 18:03:35 +03:00
|
|
|
false,
|
2019-02-13 18:05:19 +03:00
|
|
|
)?;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
|
|
|
|
let m = p.get_mnemonic(None, args.password)?;
|
|
|
|
show_recovery_phrase(m);
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Argument for recover
|
|
|
|
pub struct RecoverArgs {
|
|
|
|
pub passphrase: ZeroingString,
|
|
|
|
}
|
|
|
|
|
2020-02-06 12:08:24 +03:00
|
|
|
pub fn recover<L, C, K>(owner_api: &mut Owner<L, C, K>, args: RecoverArgs) -> Result<(), Error>
|
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
2019-07-29 15:25:03 +03:00
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
let mut w_lock = owner_api.wallet_inst.lock();
|
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
2019-07-29 15:25:03 +03:00
|
|
|
let p = w_lock.lc_provider()?;
|
2019-12-03 11:45:36 +03:00
|
|
|
let m = p.get_mnemonic(None, args.passphrase)?;
|
|
|
|
show_recovery_phrase(m);
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Arguments for listen command
|
|
|
|
pub struct ListenArgs {
|
|
|
|
pub method: String,
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn listen<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-09-02 18:03:35 +03:00
|
|
|
keychain_mask: Arc<Mutex<Option<SecretKey>>>,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
config: &WalletConfig,
|
2019-10-14 22:24:09 +03:00
|
|
|
tor_config: &TorConfig,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
args: &ListenArgs,
|
|
|
|
g_args: &GlobalArgs,
|
2020-02-06 12:08:24 +03:00
|
|
|
cli_mode: bool,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
|
|
|
{
|
2019-03-17 22:14:58 +03:00
|
|
|
let res = match args.method.as_str() {
|
2020-02-06 12:08:24 +03:00
|
|
|
"http" => {
|
|
|
|
let wallet_inst = owner_api.wallet_inst.clone();
|
|
|
|
let config = config.clone();
|
|
|
|
let tor_config = tor_config.clone();
|
|
|
|
let g_args = g_args.clone();
|
|
|
|
let api_thread = thread::Builder::new()
|
|
|
|
.name("wallet-http-listener".to_string())
|
|
|
|
.spawn(move || {
|
|
|
|
let res = controller::foreign_listener(
|
|
|
|
wallet_inst,
|
|
|
|
keychain_mask,
|
|
|
|
&config.api_listen_addr(),
|
|
|
|
g_args.tls_conf.clone(),
|
|
|
|
tor_config.use_tor_listener,
|
|
|
|
);
|
|
|
|
if let Err(e) = res {
|
|
|
|
error!("Error starting listener: {}", e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if let Ok(t) = api_thread {
|
|
|
|
if !cli_mode {
|
|
|
|
let r = t.join();
|
|
|
|
if let Err(_) = r {
|
|
|
|
error!("Error starting listener");
|
|
|
|
return Err(ErrorKind::ListenerError.into());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
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
2019-07-29 15:25:03 +03:00
|
|
|
"keybase" => KeybaseAllChannels::new()?.listen(
|
|
|
|
config.clone(),
|
|
|
|
g_args.password.clone().unwrap(),
|
|
|
|
&g_args.account,
|
|
|
|
g_args.node_api_secret.clone(),
|
|
|
|
),
|
|
|
|
method => {
|
|
|
|
return Err(ErrorKind::ArgumentError(format!(
|
|
|
|
"No listener for method \"{}\".",
|
|
|
|
method
|
|
|
|
))
|
|
|
|
.into());
|
2019-03-17 22:14:58 +03:00
|
|
|
}
|
2019-02-13 18:05:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
if let Err(e) = res {
|
|
|
|
return Err(ErrorKind::LibWallet(e.kind(), e.cause_string()).into());
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
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
2019-07-29 15:25:03 +03:00
|
|
|
pub fn owner_api<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
config: &WalletConfig,
|
2019-11-28 18:13:52 +03:00
|
|
|
tor_config: &TorConfig,
|
2019-02-13 18:05:19 +03:00
|
|
|
g_args: &GlobalArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
L: WalletLCProvider<'static, C, K> + Send + Sync + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
|
|
|
{
|
2019-09-02 18:03:35 +03:00
|
|
|
// keychain mask needs to be a sinlge instance, in case the foreign API is
|
|
|
|
// also being run at the same time
|
|
|
|
let km = Arc::new(Mutex::new(keychain_mask));
|
2019-02-13 18:05:19 +03:00
|
|
|
let res = controller::owner_listener(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api.wallet_inst.clone(),
|
2019-09-02 18:03:35 +03:00
|
|
|
km,
|
2019-02-13 18:05:19 +03:00
|
|
|
config.owner_api_listen_addr().as_str(),
|
2019-09-12 15:18:15 +03:00
|
|
|
g_args.api_secret.clone(),
|
2019-02-13 18:05:19 +03:00
|
|
|
g_args.tls_conf.clone(),
|
|
|
|
config.owner_api_include_foreign.clone(),
|
2019-11-28 18:13:52 +03:00
|
|
|
Some(tor_config.clone()),
|
2019-02-13 18:05:19 +03:00
|
|
|
);
|
|
|
|
if let Err(e) = res {
|
|
|
|
return Err(ErrorKind::LibWallet(e.kind(), e.cause_string()).into());
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Arguments for account command
|
|
|
|
pub struct AccountArgs {
|
|
|
|
pub create: Option<String>,
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn account<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
args: AccountArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2019-02-13 18:05:19 +03:00
|
|
|
if args.create.is_none() {
|
2020-02-06 12:08:24 +03:00
|
|
|
let res = controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-08-06 14:50:41 +03:00
|
|
|
let acct_mappings = api.accounts(m)?;
|
2019-02-13 18:05:19 +03:00
|
|
|
// give logging thread a moment to catch up
|
|
|
|
thread::sleep(Duration::from_millis(200));
|
|
|
|
display::accounts(acct_mappings);
|
|
|
|
Ok(())
|
|
|
|
});
|
|
|
|
if let Err(e) = res {
|
|
|
|
error!("Error listing accounts: {}", e);
|
|
|
|
return Err(ErrorKind::LibWallet(e.kind(), e.cause_string()).into());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let label = args.create.unwrap();
|
2020-02-06 12:08:24 +03:00
|
|
|
let res = controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-08-06 14:50:41 +03:00
|
|
|
api.create_account_path(m, &label)?;
|
2019-02-13 18:05:19 +03:00
|
|
|
thread::sleep(Duration::from_millis(200));
|
|
|
|
info!("Account: '{}' Created!", label);
|
|
|
|
Ok(())
|
|
|
|
});
|
|
|
|
if let Err(e) = res {
|
|
|
|
thread::sleep(Duration::from_millis(200));
|
|
|
|
error!("Error creating account '{}': {}", label, e);
|
|
|
|
return Err(ErrorKind::LibWallet(e.kind(), e.cause_string()).into());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Arguments for the send command
|
|
|
|
pub struct SendArgs {
|
|
|
|
pub amount: u64,
|
|
|
|
pub minimum_confirmations: u64,
|
|
|
|
pub selection_strategy: String,
|
|
|
|
pub estimate_selection_strategies: bool,
|
|
|
|
pub method: String,
|
|
|
|
pub dest: String,
|
|
|
|
pub change_outputs: usize,
|
|
|
|
pub fluff: bool,
|
|
|
|
pub max_outputs: usize,
|
2019-03-12 19:48:14 +03:00
|
|
|
pub target_slate_version: Option<u16>,
|
2020-01-24 16:02:09 +03:00
|
|
|
pub payment_proof_address: Option<OnionV3Address>,
|
2019-12-04 16:04:28 +03:00
|
|
|
pub ttl_blocks: Option<u64>,
|
2020-05-19 13:19:03 +03:00
|
|
|
//TODO: Remove HF3
|
|
|
|
pub output_v4_slate: bool,
|
2019-02-13 18:05:19 +03:00
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn send<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-10-14 22:24:09 +03:00
|
|
|
tor_config: Option<TorConfig>,
|
2019-02-13 18:05:19 +03:00
|
|
|
args: SendArgs,
|
|
|
|
dark_scheme: bool,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
let wallet_inst = owner_api.wallet_inst.clone();
|
2020-05-19 13:19:03 +03:00
|
|
|
// Check other version, and if it only supports 3 set the target slate
|
|
|
|
// version to 3 to avoid removing the transaction object
|
|
|
|
// TODO: This block is temporary, for the period between the release of v4.0.0 and HF3,
|
|
|
|
// after which this should be removable
|
|
|
|
let mut args = args;
|
|
|
|
{
|
|
|
|
let invalid = || {
|
|
|
|
ErrorKind::GenericError(format!(
|
|
|
|
"Invalid wallet comm type and destination. method: {}, dest: {}",
|
|
|
|
args.method, args.dest
|
|
|
|
))
|
|
|
|
};
|
|
|
|
let trailing = match args.dest.ends_with('/') {
|
|
|
|
true => "",
|
|
|
|
false => "/",
|
|
|
|
};
|
|
|
|
let url_str = format!("{}{}v2/foreign", args.dest, trailing);
|
|
|
|
match args.method.as_ref() {
|
|
|
|
"http" => {
|
|
|
|
let v_sender = HttpSlateSender::new(&args.dest).map_err(|_| invalid())?;
|
|
|
|
let other_version = v_sender.check_other_version(&url_str)?;
|
|
|
|
if other_version == SlateVersion::V3 {
|
|
|
|
args.target_slate_version = Some(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"tor" => {
|
|
|
|
let v_sender = HttpSlateSender::with_socks_proxy(
|
|
|
|
&args.dest,
|
|
|
|
&tor_config.as_ref().unwrap().socks_proxy_addr,
|
|
|
|
&tor_config.as_ref().unwrap().send_config_dir,
|
|
|
|
)
|
|
|
|
.map_err(|_| invalid())?;
|
|
|
|
let other_version = v_sender.check_other_version(&url_str)?;
|
|
|
|
if other_version == SlateVersion::V3 {
|
|
|
|
args.target_slate_version = Some(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"file" => {
|
|
|
|
// For files spit out a V3 Slate if we're before HF3,
|
|
|
|
// Or V4 slate otherwise
|
|
|
|
let cur_height = {
|
|
|
|
libwallet::wallet_lock!(wallet_inst, w);
|
|
|
|
w.w2n_client().get_chain_tip()?.0
|
|
|
|
};
|
|
|
|
// TODO: Floonet HF4
|
|
|
|
if cur_height < 786240 && !args.output_v4_slate {
|
|
|
|
args.target_slate_version = Some(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// end block to delete post HF3
|
|
|
|
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-02-13 18:05:19 +03:00
|
|
|
if args.estimate_selection_strategies {
|
|
|
|
let strategies = vec!["smallest", "all"]
|
|
|
|
.into_iter()
|
|
|
|
.map(|strategy| {
|
2019-03-29 19:00:02 +03:00
|
|
|
let init_args = InitTxArgs {
|
|
|
|
src_acct_name: None,
|
|
|
|
amount: args.amount,
|
|
|
|
minimum_confirmations: args.minimum_confirmations,
|
|
|
|
max_outputs: args.max_outputs as u32,
|
|
|
|
num_change_outputs: args.change_outputs as u32,
|
|
|
|
selection_strategy_is_use_all: strategy == "all",
|
|
|
|
estimate_only: Some(true),
|
|
|
|
..Default::default()
|
|
|
|
};
|
2019-08-06 14:50:41 +03:00
|
|
|
let slate = api.init_send_tx(m, init_args).unwrap();
|
2019-03-29 19:00:02 +03:00
|
|
|
(strategy, slate.amount, slate.fee)
|
2019-02-13 18:05:19 +03:00
|
|
|
})
|
|
|
|
.collect();
|
|
|
|
display::estimate(args.amount, strategies, dark_scheme);
|
|
|
|
} else {
|
2019-03-29 19:00:02 +03:00
|
|
|
let init_args = InitTxArgs {
|
|
|
|
src_acct_name: None,
|
|
|
|
amount: args.amount,
|
|
|
|
minimum_confirmations: args.minimum_confirmations,
|
|
|
|
max_outputs: args.max_outputs as u32,
|
|
|
|
num_change_outputs: args.change_outputs as u32,
|
|
|
|
selection_strategy_is_use_all: args.selection_strategy == "all",
|
|
|
|
target_slate_version: args.target_slate_version,
|
2020-01-24 16:02:09 +03:00
|
|
|
payment_proof_recipient_address: args.payment_proof_address.clone(),
|
2019-12-04 16:04:28 +03:00
|
|
|
ttl_blocks: args.ttl_blocks,
|
2019-03-29 19:00:02 +03:00
|
|
|
send_args: None,
|
|
|
|
..Default::default()
|
|
|
|
};
|
2019-08-06 14:50:41 +03:00
|
|
|
let result = api.init_send_tx(m, init_args);
|
2019-03-14 18:05:13 +03:00
|
|
|
let mut slate = match result {
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(s) => {
|
|
|
|
info!(
|
|
|
|
"Tx created: {} grin to {} (strategy '{}')",
|
|
|
|
core::amount_to_hr_string(args.amount, false),
|
|
|
|
args.dest,
|
|
|
|
args.selection_strategy,
|
|
|
|
);
|
|
|
|
s
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
info!("Tx not created: {}", e);
|
|
|
|
return Err(e);
|
|
|
|
}
|
|
|
|
};
|
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
2019-07-29 15:25:03 +03:00
|
|
|
|
|
|
|
match args.method.as_str() {
|
|
|
|
"file" => {
|
2020-05-19 13:19:03 +03:00
|
|
|
PathToSlate((&args.dest).into()).put_tx(&slate, false)?;
|
|
|
|
api.tx_lock_outputs(m, &slate)?;
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
"binfile" => {
|
|
|
|
PathToSlate((&args.dest).into()).put_tx(&slate, true)?;
|
|
|
|
api.tx_lock_outputs(m, &slate)?;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
"self" => {
|
2020-05-19 13:19:03 +03:00
|
|
|
api.tx_lock_outputs(m, &slate)?;
|
2019-08-06 14:50:41 +03:00
|
|
|
let km = match keychain_mask.as_ref() {
|
|
|
|
None => None,
|
|
|
|
Some(&m) => Some(m.to_owned()),
|
|
|
|
};
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::foreign_single_use(wallet_inst, km, |api| {
|
2020-05-19 13:19:03 +03:00
|
|
|
slate = api.receive_tx(&slate, Some(&args.dest))?;
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
}
|
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
2019-07-29 15:25:03 +03:00
|
|
|
method => {
|
2019-10-14 22:24:09 +03:00
|
|
|
let sender = create_sender(method, &args.dest, tor_config)?;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
slate = sender.send_tx(&slate)?;
|
2020-05-19 13:19:03 +03:00
|
|
|
api.tx_lock_outputs(m, &slate)?;
|
2019-02-13 18:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
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
2019-07-29 15:25:03 +03:00
|
|
|
|
2019-08-06 14:50:41 +03:00
|
|
|
slate = api.finalize_tx(m, &slate)?;
|
2020-05-19 13:19:03 +03:00
|
|
|
let result = api.post_tx(m, &slate, args.fluff);
|
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
2019-07-29 15:25:03 +03:00
|
|
|
match result {
|
|
|
|
Ok(_) => {
|
|
|
|
info!("Tx sent ok",);
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
error!("Tx sent fail: {}", e);
|
|
|
|
return Err(e);
|
2019-02-13 18:05:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Receive command argument
|
|
|
|
pub struct ReceiveArgs {
|
|
|
|
pub input: String,
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn receive<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
g_args: &GlobalArgs,
|
|
|
|
args: ReceiveArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K>,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-05-19 13:19:03 +03:00
|
|
|
let (mut slate, was_bin) = PathToSlate((&args.input).into()).get_tx()?;
|
2019-08-06 14:50:41 +03:00
|
|
|
let km = match keychain_mask.as_ref() {
|
|
|
|
None => None,
|
|
|
|
Some(&m) => Some(m.to_owned()),
|
|
|
|
};
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::foreign_single_use(owner_api.wallet_inst.clone(), km, |api| {
|
2020-05-19 13:19:03 +03:00
|
|
|
slate = api.receive_tx(&slate, Some(&g_args.account))?;
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(())
|
|
|
|
})?;
|
2020-05-19 13:19:03 +03:00
|
|
|
PathToSlate(format!("{}.response", args.input).into()).put_tx(&slate, was_bin)?;
|
2019-02-13 18:05:19 +03:00
|
|
|
info!(
|
2019-05-31 10:33:23 +03:00
|
|
|
"Response file {}.response generated, and can be sent back to the transaction originator.",
|
2019-02-13 18:05:19 +03:00
|
|
|
args.input
|
|
|
|
);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Finalize command args
|
|
|
|
pub struct FinalizeArgs {
|
|
|
|
pub input: String,
|
|
|
|
pub fluff: bool,
|
2019-11-18 13:19:00 +03:00
|
|
|
pub nopost: bool,
|
|
|
|
pub dest: Option<String>,
|
2019-02-13 18:05:19 +03:00
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn finalize<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
args: FinalizeArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-05-19 13:19:03 +03:00
|
|
|
let (mut slate, was_bin) = PathToSlate((&args.input).into()).get_tx()?;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
|
2019-05-09 21:06:32 +03:00
|
|
|
// Rather than duplicating the entire command, we'll just
|
|
|
|
// try to determine what kind of finalization this is
|
|
|
|
// based on the slate contents
|
|
|
|
// for now, we can tell this is an invoice transaction
|
|
|
|
// if the receipient (participant 1) hasn't completed sigs
|
2020-05-19 13:19:03 +03:00
|
|
|
let mut is_invoice = false;
|
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
|
|
|
is_invoice = api.context_is_invoice(m, &slate)?;
|
|
|
|
Ok(())
|
|
|
|
})?;
|
2019-05-09 21:06:32 +03:00
|
|
|
|
|
|
|
if is_invoice {
|
2019-08-06 14:50:41 +03:00
|
|
|
let km = match keychain_mask.as_ref() {
|
|
|
|
None => None,
|
|
|
|
Some(&m) => Some(m.to_owned()),
|
|
|
|
};
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::foreign_single_use(owner_api.wallet_inst.clone(), km, |api| {
|
2020-03-10 21:19:27 +03:00
|
|
|
slate = api.finalize_invoice_tx(&slate)?;
|
2019-05-09 21:06:32 +03:00
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
} else {
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2020-03-10 21:19:27 +03:00
|
|
|
slate = api.finalize_tx(m, &slate)?;
|
2019-05-09 21:06:32 +03:00
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
}
|
2019-02-13 18:05:19 +03:00
|
|
|
|
2019-11-18 13:19:00 +03:00
|
|
|
if !args.nopost {
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2020-05-19 13:19:03 +03:00
|
|
|
let result = api.post_tx(m, &slate, args.fluff);
|
2019-11-18 13:19:00 +03:00
|
|
|
match result {
|
|
|
|
Ok(_) => {
|
|
|
|
info!(
|
|
|
|
"Transaction sent successfully, check the wallet again for confirmation."
|
|
|
|
);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
error!("Tx not sent: {}", e);
|
|
|
|
Err(e)
|
|
|
|
}
|
2019-02-13 18:05:19 +03:00
|
|
|
}
|
2019-11-18 13:19:00 +03:00
|
|
|
})?;
|
|
|
|
}
|
|
|
|
|
|
|
|
if args.dest.is_some() {
|
2020-05-19 13:19:03 +03:00
|
|
|
PathToSlate((&args.dest.unwrap()).into()).put_tx(&slate, was_bin)?;
|
2019-11-18 13:19:00 +03:00
|
|
|
}
|
2019-05-09 21:06:32 +03:00
|
|
|
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-05-09 21:06:32 +03:00
|
|
|
/// Issue Invoice Args
|
|
|
|
pub struct IssueInvoiceArgs {
|
|
|
|
/// output file
|
|
|
|
pub dest: String,
|
|
|
|
/// issue invoice tx args
|
|
|
|
pub issue_args: IssueInvoiceTxArgs,
|
2020-05-19 13:19:03 +03:00
|
|
|
/// whether to output as bin
|
|
|
|
pub bin: bool,
|
|
|
|
// TODO: Remove HF3
|
|
|
|
/// whether to output a V4 slate
|
|
|
|
pub output_v4_slate: bool,
|
2019-05-09 21:06:32 +03:00
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn issue_invoice_tx<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-05-09 21:06:32 +03:00
|
|
|
args: IssueInvoiceArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-05-19 13:19:03 +03:00
|
|
|
//TODO: Remove block HF3
|
|
|
|
let args = {
|
|
|
|
let mut a = args;
|
|
|
|
let wallet_inst = owner_api.wallet_inst.clone();
|
|
|
|
let cur_height = {
|
|
|
|
libwallet::wallet_lock!(wallet_inst, w);
|
|
|
|
w.w2n_client().get_chain_tip()?.0
|
|
|
|
};
|
|
|
|
// TODO: Floonet HF4
|
|
|
|
if cur_height < 786240 && !a.output_v4_slate && !a.bin {
|
|
|
|
a.issue_args.target_slate_version = Some(3);
|
|
|
|
}
|
|
|
|
a
|
|
|
|
};
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-08-06 14:50:41 +03:00
|
|
|
let slate = api.issue_invoice_tx(m, args.issue_args)?;
|
2020-05-19 13:19:03 +03:00
|
|
|
PathToSlate((&args.dest).into()).put_tx(&slate, args.bin)?;
|
2019-05-09 21:06:32 +03:00
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Arguments for the process_invoice command
|
|
|
|
pub struct ProcessInvoiceArgs {
|
|
|
|
pub minimum_confirmations: u64,
|
|
|
|
pub selection_strategy: String,
|
|
|
|
pub method: String,
|
|
|
|
pub dest: String,
|
|
|
|
pub max_outputs: usize,
|
|
|
|
pub input: String,
|
|
|
|
pub estimate_selection_strategies: bool,
|
2019-12-04 16:04:28 +03:00
|
|
|
pub ttl_blocks: Option<u64>,
|
2019-05-09 21:06:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Process invoice
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn process_invoice<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-10-14 22:24:09 +03:00
|
|
|
tor_config: Option<TorConfig>,
|
2019-05-09 21:06:32 +03:00
|
|
|
args: ProcessInvoiceArgs,
|
|
|
|
dark_scheme: bool,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-05-19 13:19:03 +03:00
|
|
|
let (slate, _) = PathToSlate((&args.input).into()).get_tx()?;
|
2020-02-06 12:08:24 +03:00
|
|
|
let wallet_inst = owner_api.wallet_inst.clone();
|
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-05-09 21:06:32 +03:00
|
|
|
if args.estimate_selection_strategies {
|
|
|
|
let strategies = vec!["smallest", "all"]
|
|
|
|
.into_iter()
|
|
|
|
.map(|strategy| {
|
|
|
|
let init_args = InitTxArgs {
|
|
|
|
src_acct_name: None,
|
|
|
|
amount: slate.amount,
|
|
|
|
minimum_confirmations: args.minimum_confirmations,
|
|
|
|
max_outputs: args.max_outputs as u32,
|
|
|
|
num_change_outputs: 1u32,
|
|
|
|
selection_strategy_is_use_all: strategy == "all",
|
|
|
|
estimate_only: Some(true),
|
|
|
|
..Default::default()
|
|
|
|
};
|
2019-08-06 14:50:41 +03:00
|
|
|
let slate = api.init_send_tx(m, init_args).unwrap();
|
2019-05-09 21:06:32 +03:00
|
|
|
(strategy, slate.amount, slate.fee)
|
|
|
|
})
|
|
|
|
.collect();
|
|
|
|
display::estimate(slate.amount, strategies, dark_scheme);
|
|
|
|
} else {
|
|
|
|
let init_args = InitTxArgs {
|
|
|
|
src_acct_name: None,
|
|
|
|
amount: 0,
|
|
|
|
minimum_confirmations: args.minimum_confirmations,
|
|
|
|
max_outputs: args.max_outputs as u32,
|
|
|
|
num_change_outputs: 1u32,
|
|
|
|
selection_strategy_is_use_all: args.selection_strategy == "all",
|
2019-12-04 16:04:28 +03:00
|
|
|
ttl_blocks: args.ttl_blocks,
|
2019-05-09 21:06:32 +03:00
|
|
|
send_args: None,
|
|
|
|
..Default::default()
|
|
|
|
};
|
2019-08-06 14:50:41 +03:00
|
|
|
let result = api.process_invoice_tx(m, &slate, init_args);
|
2019-05-09 21:06:32 +03:00
|
|
|
let mut slate = match result {
|
|
|
|
Ok(s) => {
|
|
|
|
info!(
|
|
|
|
"Invoice processed: {} grin to {} (strategy '{}')",
|
|
|
|
core::amount_to_hr_string(slate.amount, false),
|
|
|
|
args.dest,
|
|
|
|
args.selection_strategy,
|
|
|
|
);
|
|
|
|
s
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
info!("Tx not created: {}", e);
|
|
|
|
return Err(e);
|
|
|
|
}
|
|
|
|
};
|
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
2019-07-29 15:25:03 +03:00
|
|
|
|
|
|
|
match args.method.as_str() {
|
|
|
|
"file" => {
|
|
|
|
let slate_putter = PathToSlate((&args.dest).into());
|
2020-05-19 13:19:03 +03:00
|
|
|
slate_putter.put_tx(&slate, false)?;
|
|
|
|
api.tx_lock_outputs(m, &slate)?;
|
|
|
|
}
|
|
|
|
"filebin" => {
|
|
|
|
let slate_putter = PathToSlate((&args.dest).into());
|
|
|
|
slate_putter.put_tx(&slate, true)?;
|
|
|
|
api.tx_lock_outputs(m, &slate)?;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
}
|
|
|
|
"self" => {
|
2020-05-19 13:19:03 +03:00
|
|
|
api.tx_lock_outputs(m, &slate)?;
|
2019-08-06 14:50:41 +03:00
|
|
|
let km = match keychain_mask.as_ref() {
|
|
|
|
None => None,
|
|
|
|
Some(&m) => Some(m.to_owned()),
|
|
|
|
};
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::foreign_single_use(wallet_inst, km, |api| {
|
2019-05-09 21:06:32 +03:00
|
|
|
slate = api.finalize_invoice_tx(&slate)?;
|
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
}
|
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
2019-07-29 15:25:03 +03:00
|
|
|
method => {
|
2019-10-14 22:24:09 +03:00
|
|
|
let sender = create_sender(method, &args.dest, tor_config)?;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
slate = sender.send_tx(&slate)?;
|
2020-05-19 13:19:03 +03:00
|
|
|
api.tx_lock_outputs(m, &slate)?;
|
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
2019-07-29 15:25:03 +03:00
|
|
|
}
|
2019-05-09 21:06:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
2019-02-13 18:05:19 +03:00
|
|
|
/// Info command args
|
|
|
|
pub struct InfoArgs {
|
|
|
|
pub minimum_confirmations: u64,
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn info<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
g_args: &GlobalArgs,
|
|
|
|
args: InfoArgs,
|
|
|
|
dark_scheme: bool,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
let updater_running = owner_api.updater_running.load(Ordering::Relaxed);
|
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-02-13 18:05:19 +03:00
|
|
|
let (validated, wallet_info) =
|
2019-08-06 14:50:41 +03:00
|
|
|
api.retrieve_summary_info(m, true, args.minimum_confirmations)?;
|
2020-02-06 12:08:24 +03:00
|
|
|
display::info(
|
|
|
|
&g_args.account,
|
|
|
|
&wallet_info,
|
|
|
|
validated || updater_running,
|
|
|
|
dark_scheme,
|
|
|
|
);
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn outputs<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
g_args: &GlobalArgs,
|
|
|
|
dark_scheme: bool,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
let updater_running = owner_api.updater_running.load(Ordering::Relaxed);
|
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-08-06 14:50:41 +03:00
|
|
|
let res = api.node_height(m)?;
|
|
|
|
let (validated, outputs) = api.retrieve_outputs(m, g_args.show_spent, true, None)?;
|
2020-02-06 12:08:24 +03:00
|
|
|
display::outputs(
|
|
|
|
&g_args.account,
|
|
|
|
res.height,
|
|
|
|
validated || updater_running,
|
|
|
|
outputs,
|
|
|
|
dark_scheme,
|
|
|
|
)?;
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Txs command args
|
|
|
|
pub struct TxsArgs {
|
|
|
|
pub id: Option<u32>,
|
2019-07-08 11:43:56 +03:00
|
|
|
pub tx_slate_id: Option<Uuid>,
|
2019-02-13 18:05:19 +03:00
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn txs<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
g_args: &GlobalArgs,
|
|
|
|
args: TxsArgs,
|
|
|
|
dark_scheme: bool,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
let updater_running = owner_api.updater_running.load(Ordering::Relaxed);
|
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-08-06 14:50:41 +03:00
|
|
|
let res = api.node_height(m)?;
|
|
|
|
let (validated, txs) = api.retrieve_txs(m, true, args.id, args.tx_slate_id)?;
|
2019-07-08 11:43:56 +03:00
|
|
|
let include_status = !args.id.is_some() && !args.tx_slate_id.is_some();
|
2019-02-13 18:05:19 +03:00
|
|
|
display::txs(
|
|
|
|
&g_args.account,
|
2019-03-29 19:00:02 +03:00
|
|
|
res.height,
|
2020-02-06 12:08:24 +03:00
|
|
|
validated || updater_running,
|
2019-02-13 18:05:19 +03:00
|
|
|
&txs,
|
|
|
|
include_status,
|
|
|
|
dark_scheme,
|
|
|
|
)?;
|
2019-07-08 11:43:56 +03:00
|
|
|
|
|
|
|
// if given a particular transaction id or uuid, also get and display associated
|
2019-02-13 18:05:19 +03:00
|
|
|
// inputs/outputs and messages
|
2019-07-08 11:43:56 +03:00
|
|
|
let id = if args.id.is_some() {
|
|
|
|
args.id
|
|
|
|
} else if args.tx_slate_id.is_some() {
|
|
|
|
if let Some(tx) = txs.iter().find(|t| t.tx_slate_id == args.tx_slate_id) {
|
|
|
|
Some(tx.id)
|
|
|
|
} else {
|
|
|
|
println!("Could not find a transaction matching given txid.\n");
|
|
|
|
None
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
|
|
|
|
|
|
|
if id.is_some() {
|
2019-08-06 14:50:41 +03:00
|
|
|
let (_, outputs) = api.retrieve_outputs(m, true, false, id)?;
|
2020-02-06 12:08:24 +03:00
|
|
|
display::outputs(
|
|
|
|
&g_args.account,
|
|
|
|
res.height,
|
|
|
|
validated || updater_running,
|
|
|
|
outputs,
|
|
|
|
dark_scheme,
|
|
|
|
)?;
|
2019-02-13 18:05:19 +03:00
|
|
|
// should only be one here, but just in case
|
2019-04-25 09:59:45 +03:00
|
|
|
for tx in txs {
|
2019-11-28 18:13:52 +03:00
|
|
|
display::payment_proof(&tx)?;
|
2019-02-13 18:05:19 +03:00
|
|
|
}
|
2019-07-08 11:43:56 +03:00
|
|
|
}
|
|
|
|
|
2019-02-13 18:05:19 +03:00
|
|
|
Ok(())
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:19:00 +03:00
|
|
|
/// Post
|
|
|
|
pub struct PostArgs {
|
|
|
|
pub input: String,
|
|
|
|
pub fluff: bool,
|
|
|
|
}
|
|
|
|
|
2019-11-20 14:01:38 +03:00
|
|
|
pub fn post<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-11-18 13:19:00 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
|
|
|
args: PostArgs,
|
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-20 14:01:38 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
2019-11-18 13:19:00 +03:00
|
|
|
{
|
2020-05-19 13:19:03 +03:00
|
|
|
let slate = PathToSlate((&args.input).into()).get_tx()?.0;
|
2019-11-18 13:19:00 +03:00
|
|
|
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2020-05-19 13:19:03 +03:00
|
|
|
api.post_tx(m, &slate, args.fluff)?;
|
2019-11-18 13:19:00 +03:00
|
|
|
info!("Posted transaction");
|
|
|
|
return Ok(());
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-02-13 18:05:19 +03:00
|
|
|
/// Repost
|
|
|
|
pub struct RepostArgs {
|
|
|
|
pub id: u32,
|
|
|
|
pub dump_file: Option<String>,
|
|
|
|
pub fluff: bool,
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn repost<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
args: RepostArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-08-06 14:50:41 +03:00
|
|
|
let (_, txs) = api.retrieve_txs(m, true, Some(args.id), None)?;
|
2020-05-19 13:19:03 +03:00
|
|
|
let stored_tx = api.get_stored_tx(m, txs[0].tx_slate_id.unwrap())?;
|
2019-02-13 18:05:19 +03:00
|
|
|
if stored_tx.is_none() {
|
|
|
|
error!(
|
|
|
|
"Transaction with id {} does not have transaction data. Not reposting.",
|
|
|
|
args.id
|
|
|
|
);
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
match args.dump_file {
|
|
|
|
None => {
|
|
|
|
if txs[0].confirmed {
|
|
|
|
error!(
|
|
|
|
"Transaction with id {} is confirmed. Not reposting.",
|
|
|
|
args.id
|
|
|
|
);
|
|
|
|
return Ok(());
|
|
|
|
}
|
2020-05-19 13:19:03 +03:00
|
|
|
let mut slate = Slate::blank(2, false);
|
|
|
|
slate.tx = Some(stored_tx.unwrap());
|
|
|
|
api.post_tx(m, &slate, args.fluff)?;
|
2019-02-13 18:05:19 +03:00
|
|
|
info!("Reposted transaction at {}", args.id);
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
Some(f) => {
|
|
|
|
let mut tx_file = File::create(f.clone())?;
|
|
|
|
tx_file.write_all(json::to_string(&stored_tx).unwrap().as_bytes())?;
|
|
|
|
tx_file.sync_all()?;
|
|
|
|
info!("Dumped transaction data for tx {} to {}", args.id, f);
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Cancel
|
|
|
|
pub struct CancelArgs {
|
|
|
|
pub tx_id: Option<u32>,
|
|
|
|
pub tx_slate_id: Option<Uuid>,
|
|
|
|
pub tx_id_string: String,
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn cancel<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-02-13 18:05:19 +03:00
|
|
|
args: CancelArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-08-06 14:50:41 +03:00
|
|
|
let result = api.cancel_tx(m, args.tx_id, args.tx_slate_id);
|
2019-02-13 18:05:19 +03:00
|
|
|
match result {
|
|
|
|
Ok(_) => {
|
|
|
|
info!("Transaction {} Cancelled", args.tx_id_string);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
error!("TX Cancellation failed: {}", e);
|
|
|
|
Err(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-03-07 19:19:47 +03:00
|
|
|
/// wallet check
|
|
|
|
pub struct CheckArgs {
|
|
|
|
pub delete_unconfirmed: bool,
|
2019-11-06 13:04:42 +03:00
|
|
|
pub start_height: Option<u64>,
|
2020-02-07 13:17:37 +03:00
|
|
|
pub backwards_from_tip: Option<u64>,
|
2019-03-07 19:19:47 +03:00
|
|
|
}
|
|
|
|
|
2019-11-18 13:49:51 +03:00
|
|
|
pub fn scan<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-08-06 14:50:41 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
2019-03-07 19:19:47 +03:00
|
|
|
args: CheckArgs,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
2019-11-18 13:49:51 +03:00
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
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
2019-07-29 15:25:03 +03:00
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2020-02-07 13:17:37 +03:00
|
|
|
let tip_height = api.node_height(m)?.height;
|
|
|
|
let start_height = match args.backwards_from_tip {
|
|
|
|
Some(b) => tip_height.saturating_sub(b),
|
|
|
|
None => match args.start_height {
|
|
|
|
Some(s) => s,
|
|
|
|
None => 1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
warn!("Starting output scan from height {} ...", start_height);
|
|
|
|
let result = api.scan(m, Some(start_height), args.delete_unconfirmed);
|
2019-02-13 18:05:19 +03:00
|
|
|
match result {
|
|
|
|
Ok(_) => {
|
|
|
|
warn!("Wallet check complete",);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
error!("Wallet check failed: {}", e);
|
|
|
|
error!("Backtrace: {}", e.backtrace().unwrap());
|
|
|
|
Err(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
2019-11-28 18:13:52 +03:00
|
|
|
|
|
|
|
/// Payment Proof Address
|
|
|
|
pub fn address<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2019-11-28 18:13:52 +03:00
|
|
|
g_args: &GlobalArgs,
|
|
|
|
keychain_mask: Option<&SecretKey>,
|
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2019-11-28 18:13:52 +03:00
|
|
|
// Just address at derivation index 0 for now
|
|
|
|
let pub_key = api.get_public_proof_address(m, 0)?;
|
2020-01-24 16:02:09 +03:00
|
|
|
let addr = OnionV3Address::from_bytes(pub_key.to_bytes());
|
|
|
|
println!();
|
|
|
|
println!("Address for account - {}", g_args.account);
|
|
|
|
println!("-------------------------------------");
|
|
|
|
println!("{}", addr);
|
|
|
|
println!();
|
|
|
|
Ok(())
|
2019-11-28 18:13:52 +03:00
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
2020-01-22 16:16:24 +03:00
|
|
|
|
|
|
|
/// Proof Export Args
|
|
|
|
pub struct ProofExportArgs {
|
|
|
|
pub output_file: String,
|
|
|
|
pub id: Option<u32>,
|
|
|
|
pub tx_slate_id: Option<Uuid>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proof_export<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2020-01-22 16:16:24 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
|
|
|
args: ProofExportArgs,
|
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2020-01-22 16:16:24 +03:00
|
|
|
let result = api.retrieve_payment_proof(m, true, args.id, args.tx_slate_id);
|
|
|
|
match result {
|
|
|
|
Ok(p) => {
|
|
|
|
// actually export proof
|
|
|
|
let mut proof_file = File::create(args.output_file.clone())?;
|
|
|
|
proof_file.write_all(json::to_string_pretty(&p).unwrap().as_bytes())?;
|
|
|
|
proof_file.sync_all()?;
|
|
|
|
warn!("Payment proof exported to {}", args.output_file);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
error!("Proof export failed: {}", e);
|
|
|
|
Err(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Proof Verify Args
|
|
|
|
pub struct ProofVerifyArgs {
|
|
|
|
pub input_file: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proof_verify<L, C, K>(
|
2020-02-06 12:08:24 +03:00
|
|
|
owner_api: &mut Owner<L, C, K>,
|
2020-01-22 16:16:24 +03:00
|
|
|
keychain_mask: Option<&SecretKey>,
|
|
|
|
args: ProofVerifyArgs,
|
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
L: WalletLCProvider<'static, C, K> + 'static,
|
|
|
|
C: NodeClient + 'static,
|
|
|
|
K: keychain::Keychain + 'static,
|
|
|
|
{
|
2020-02-06 12:08:24 +03:00
|
|
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
2020-01-22 16:16:24 +03:00
|
|
|
let mut proof_f = match File::open(&args.input_file) {
|
|
|
|
Ok(p) => p,
|
|
|
|
Err(e) => {
|
|
|
|
let msg = format!("{}", e);
|
|
|
|
error!(
|
|
|
|
"Unable to open payment proof file at {}: {}",
|
|
|
|
args.input_file, e
|
|
|
|
);
|
|
|
|
return Err(libwallet::ErrorKind::PaymentProofParsing(msg).into());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let mut proof = String::new();
|
|
|
|
proof_f.read_to_string(&mut proof)?;
|
|
|
|
// read
|
|
|
|
let proof: PaymentProof = match json::from_str(&proof) {
|
|
|
|
Ok(p) => p,
|
|
|
|
Err(e) => {
|
|
|
|
let msg = format!("{}", e);
|
|
|
|
error!("Unable to parse payment proof file: {}", e);
|
|
|
|
return Err(libwallet::ErrorKind::PaymentProofParsing(msg).into());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let result = api.verify_payment_proof(m, &proof);
|
|
|
|
match result {
|
|
|
|
Ok((iam_sender, iam_recipient)) => {
|
|
|
|
println!("Payment proof's signatures are valid.");
|
|
|
|
if iam_sender {
|
|
|
|
println!("The proof's sender address belongs to this wallet.");
|
|
|
|
}
|
|
|
|
if iam_recipient {
|
|
|
|
println!("The proof's recipient address belongs to this wallet.");
|
|
|
|
}
|
|
|
|
if !iam_recipient && !iam_sender {
|
|
|
|
println!(
|
|
|
|
"Neither the proof's sender nor recipient address belongs to this wallet."
|
|
|
|
);
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
error!("Proof not valid: {}", e);
|
|
|
|
Err(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
}
|