mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Breakout listen -i to separate method (#337)
* Rename wallet 'receive' to 'listen' * Handle use of previous 'receive' command gracefully and clarify docs * Move listen port from main wallet config to subcommand and break input out into own file method * Clean up arg description * Add placeholder to docs for file method in wallet * Tidy wallet help text * Rename pending wallet 'receive' to 'request' * Restore receive method for file based transactions
This commit is contained in:
parent
b893a6c8ee
commit
7ef752f61c
2 changed files with 28 additions and 21 deletions
|
@ -53,6 +53,10 @@ Builds a transaction to send someone some coins. Creates and outputs a transacti
|
|||
|
||||
Replaced by `listen` (see above). The `receive` command might later be recycled to actively accept one or several specific transactions.
|
||||
|
||||
### grin wallet request
|
||||
|
||||
(tbd)
|
||||
|
||||
### grin wallet burn
|
||||
|
||||
*TESTING ONLY*: Burns the provided amount to a known key. Similar to send but burns an output to allow single-party
|
||||
|
|
|
@ -169,11 +169,6 @@ fn main() {
|
|||
.help("Directory in which to store wallet files (defaults to current \
|
||||
directory)")
|
||||
.takes_value(true))
|
||||
.arg(Arg::with_name("port")
|
||||
.short("l")
|
||||
.long("port")
|
||||
.help("Port on which to run the wallet listener when in listen mode")
|
||||
.takes_value(true))
|
||||
.arg(Arg::with_name("external")
|
||||
.short("e")
|
||||
.long("external")
|
||||
|
@ -197,19 +192,23 @@ fn main() {
|
|||
.long("key_derivations")
|
||||
.default_value("1000")
|
||||
.takes_value(true))
|
||||
|
||||
.subcommand(SubCommand::with_name("listen")
|
||||
.about("Run the wallet in listening mode. If an input file is \
|
||||
provided, will process it, otherwise runs in server mode waiting \
|
||||
for send requests.")
|
||||
.about("Runs the wallet in listening mode waiting for transactions.")
|
||||
.arg(Arg::with_name("port")
|
||||
.short("l")
|
||||
.long("port")
|
||||
.help("Port on which to run the wallet listener")
|
||||
.takes_value(true)))
|
||||
|
||||
.subcommand(SubCommand::with_name("receive")
|
||||
.about("Processes a JSON transaction file.")
|
||||
.arg(Arg::with_name("input")
|
||||
.help("Partial transaction to receive, expects as a JSON file.")
|
||||
.help("Partial transaction to process, expects a JSON file.")
|
||||
.short("i")
|
||||
.long("input")
|
||||
.takes_value(true)))
|
||||
|
||||
.subcommand(SubCommand::with_name("receive")
|
||||
.about("Depreciated, use 'listen' instead"))
|
||||
|
||||
|
||||
.subcommand(SubCommand::with_name("send")
|
||||
.about("Builds a transaction to send someone some coins. By default, \
|
||||
the transaction will just be printed to stdout. If a destination is \
|
||||
|
@ -372,10 +371,6 @@ fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) {
|
|||
// just get defaults from the global config
|
||||
let mut wallet_config = global_config.members.unwrap().wallet;
|
||||
|
||||
if let Some(port) = wallet_args.value_of("port") {
|
||||
wallet_config.api_listen_port = port.to_string();
|
||||
}
|
||||
|
||||
if wallet_args.is_present("external") {
|
||||
wallet_config.api_listen_interface = "0.0.0.0".to_string();
|
||||
}
|
||||
|
@ -417,14 +412,22 @@ fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) {
|
|||
.expect("Failed to derive keychain from seed file and passphrase.");
|
||||
|
||||
match wallet_args.subcommand() {
|
||||
("listen", Some(listen_args)) => if let Some(f) = listen_args.value_of("input") {
|
||||
let mut file = File::open(f).expect("Unable to open transaction file.");
|
||||
("listen", Some(listen_args)) => {
|
||||
if let Some(port) = listen_args.value_of("port") {
|
||||
wallet_config.api_listen_port = port.to_string();
|
||||
}
|
||||
wallet::server::start_rest_apis(wallet_config, keychain);
|
||||
},
|
||||
("receive", Some(receive_args)) => {
|
||||
let input = receive_args
|
||||
.value_of("input")
|
||||
.expect("Input file required");
|
||||
let mut file = File::open(input)
|
||||
.expect("Unable to open transaction file.");
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents)
|
||||
.expect("Unable to read transaction file.");
|
||||
wallet::receive_json_tx_str(&wallet_config, &keychain, contents.as_str()).unwrap();
|
||||
} else {
|
||||
wallet::server::start_rest_apis(wallet_config, keychain);
|
||||
},
|
||||
("send", Some(send_args)) => {
|
||||
let amount = send_args
|
||||
|
|
Loading…
Reference in a new issue