Default to outputting payment proof unless requested otherwise (#447)

This commit is contained in:
Yeastplume 2020-06-16 15:11:13 +01:00 committed by GitHub
parent 66e2d0d5ae
commit 2a5383d83e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 24 deletions

View file

@ -123,10 +123,10 @@ subcommands:
short: d short: d
long: dest long: dest
takes_value: true takes_value: true
- request_payment_proof: - no_payment_proof:
help: Request a payment proof from the recipient. If present, the destination must be provided as a slatepack address. help: Don't request a payment proof, even if the Recipient's Slatepack address is provided in the -dest argument
short: y short: n
long: request_payment_proof long: no_payment_proof
- fluff: - fluff:
help: Fluff the transaction (ignore Dandelion relay protocol) help: Fluff the transaction (ignore Dandelion relay protocol)
short: f short: f
@ -322,7 +322,7 @@ subcommands:
- recover: - recover:
about: Displays a recovery phrase for the wallet. (use `init -r` to perform recovery) about: Displays a recovery phrase for the wallet. (use `init -r` to perform recovery)
- address: - address:
about: Display the wallet's payment proof address about: Display the wallet's Slatepack address
- scan: - scan:
about: Checks a wallet's outputs against a live node, repairing and restoring missing outputs if required about: Checks a wallet's outputs against a live node, repairing and restoring missing outputs if required
args: args:

View file

@ -31,7 +31,6 @@ use grin_wallet_libwallet::{IssueInvoiceTxArgs, NodeClient, WalletInst, WalletLC
use grin_wallet_util::grin_core as core; use grin_wallet_util::grin_core as core;
use grin_wallet_util::grin_core::core::amount_to_hr_string; use grin_wallet_util::grin_core::core::amount_to_hr_string;
use grin_wallet_util::grin_keychain as keychain; use grin_wallet_util::grin_keychain as keychain;
use grin_wallet_util::OnionV3Address;
use linefeed::terminal::Signal; use linefeed::terminal::Signal;
use linefeed::{Interface, ReadResult}; use linefeed::{Interface, ReadResult};
use rpassword; use rpassword;
@ -503,27 +502,15 @@ pub fn parse_send_args(args: &ArgMatches) -> Result<command::SendArgs, ParseErro
}; };
let payment_proof_address = { let payment_proof_address = {
match args.is_present("request_payment_proof") { match args.is_present("no_payment_proof") {
true => match OnionV3Address::try_from(dest) { false => match SlatepackAddress::try_from(dest) {
Ok(a) => Some(SlatepackAddress::try_from(a).unwrap()), Ok(a) => Some(a),
Err(_) => { Err(_) => {
let addr = match parse_required(args, "dest") { println!("No recipient Slatepack address. No payment proof will be requested.");
Ok(a) => a, None
Err(_) => {
let msg = format!("Destination Slatepack address must be provided (-d) if payment proof is requested");
return Err(ParseError::ArgumentError(msg));
}
};
match SlatepackAddress::try_from(addr) {
Ok(a) => Some(a),
Err(e) => {
let msg = format!("Invalid slatepack address: {:?}", e);
return Err(ParseError::ArgumentError(msg));
}
}
} }
}, },
false => None, true => None,
} }
}; };