mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-11-27 17:43:54 +01:00
Merge upstream staging into contracts
Catches up with #773, #779 and #781. Only the import blocks in command.rs and api/foreign.rs conflicted.
This commit is contained in:
+49
-33
@@ -322,12 +322,12 @@ pub struct SendArgs {
|
||||
pub selection_strategy: String,
|
||||
pub estimate_selection_strategies: bool,
|
||||
pub late_lock: bool,
|
||||
pub dest: String,
|
||||
pub dest: Option<String>,
|
||||
pub change_outputs: usize,
|
||||
pub fluff: bool,
|
||||
pub max_outputs: usize,
|
||||
pub target_slate_version: Option<u16>,
|
||||
pub payment_proof_address: Option<SlatepackAddress>,
|
||||
pub payment_proof_address: Option<String>,
|
||||
pub ttl_blocks: Option<u64>,
|
||||
pub skip_tor: Option<bool>,
|
||||
pub outfile: Option<String>,
|
||||
@@ -348,6 +348,15 @@ where
|
||||
C: NodeClient + 'static,
|
||||
K: keychain::Keychain + 'static,
|
||||
{
|
||||
let dest = if args.estimate_selection_strategies {
|
||||
None
|
||||
} else {
|
||||
args.dest
|
||||
.as_deref()
|
||||
.map(SlatepackAddress::try_from)
|
||||
.transpose()?
|
||||
};
|
||||
|
||||
let mut slate = Slate::blank(2, false);
|
||||
let mut amount = args.amount;
|
||||
if args.use_max_amount {
|
||||
@@ -376,6 +385,11 @@ where
|
||||
.collect::<Result<Vec<_>, grin_wallet_libwallet::Error>>()?;
|
||||
display::estimate(amount, strategies, dark_scheme);
|
||||
} else {
|
||||
let payment_proof_recipient_address = args
|
||||
.payment_proof_address
|
||||
.as_deref()
|
||||
.map(SlatepackAddress::try_from)
|
||||
.transpose()?;
|
||||
let init_args = InitTxArgs {
|
||||
src_acct_name: None,
|
||||
amount,
|
||||
@@ -385,7 +399,7 @@ where
|
||||
num_change_outputs: args.change_outputs as u32,
|
||||
selection_strategy_is_use_all: args.selection_strategy == "all",
|
||||
target_slate_version: args.target_slate_version,
|
||||
payment_proof_recipient_address: args.payment_proof_address.clone(),
|
||||
payment_proof_recipient_address,
|
||||
ttl_blocks: args.ttl_blocks,
|
||||
send_args: None,
|
||||
late_lock: Some(args.late_lock),
|
||||
@@ -397,7 +411,9 @@ where
|
||||
info!(
|
||||
"Tx created: {} grin to {} (strategy '{}')",
|
||||
core::amount_to_hr_string(amount, false),
|
||||
args.dest,
|
||||
dest.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_else(|| "no destination".to_string()),
|
||||
args.selection_strategy,
|
||||
);
|
||||
s
|
||||
@@ -422,7 +438,7 @@ where
|
||||
owner_api,
|
||||
keychain_mask,
|
||||
&slate,
|
||||
args.dest.as_str(),
|
||||
dest.clone(),
|
||||
args.outfile,
|
||||
true,
|
||||
false,
|
||||
@@ -431,11 +447,12 @@ where
|
||||
};
|
||||
|
||||
let can_send = tor_config.send_tor(args.skip_tor);
|
||||
if test_mode || !can_send {
|
||||
if test_mode || !can_send || dest.is_none() {
|
||||
return output_sp();
|
||||
}
|
||||
|
||||
let res = try_slatepack_sync_workflow(&slate, &args.dest, Some(tor_config), None, false);
|
||||
let dest = dest.as_ref().unwrap();
|
||||
let res = try_slatepack_sync_workflow(&slate, dest, Some(tor_config), None, false);
|
||||
|
||||
match res {
|
||||
Ok(s) => {
|
||||
@@ -464,7 +481,7 @@ pub fn output_slatepack<L, C, K>(
|
||||
owner_api: &mut Owner<L, C, K>,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
slate: &Slate,
|
||||
dest: &str,
|
||||
dest: Option<SlatepackAddress>,
|
||||
out_file_override: Option<String>,
|
||||
lock: bool,
|
||||
finalizing: bool,
|
||||
@@ -476,12 +493,8 @@ where
|
||||
K: keychain::Keychain + 'static,
|
||||
{
|
||||
// Output the slatepack file to stdout and to a file
|
||||
let address = match SlatepackAddress::try_from(dest) {
|
||||
Ok(a) => Some(a),
|
||||
Err(_) => None,
|
||||
};
|
||||
// encrypt for recipient by default
|
||||
let recipients = match address.clone() {
|
||||
let recipients = match dest.clone() {
|
||||
Some(a) => vec![a],
|
||||
None => vec![],
|
||||
};
|
||||
@@ -527,7 +540,7 @@ where
|
||||
println!();
|
||||
}
|
||||
}
|
||||
if address.is_some() {
|
||||
if dest.is_some() {
|
||||
println!("The slatepack data is encrypted for the recipient only");
|
||||
} else {
|
||||
println!("The slatepack data is NOT encrypted");
|
||||
@@ -783,17 +796,12 @@ where
|
||||
},
|
||||
)?;
|
||||
|
||||
let dest = match ret_address {
|
||||
Some(a) => String::try_from(&a)?,
|
||||
None => String::from(""),
|
||||
};
|
||||
|
||||
let output_sp = || -> Result<(), Error> {
|
||||
Ok(output_slatepack(
|
||||
owner_api,
|
||||
keychain_mask,
|
||||
&slate,
|
||||
&dest,
|
||||
ret_address.clone(),
|
||||
args.outfile,
|
||||
false,
|
||||
false,
|
||||
@@ -802,11 +810,12 @@ where
|
||||
};
|
||||
|
||||
let can_send = tor_config.send_tor(args.skip_tor);
|
||||
if test_mode || !can_send {
|
||||
if test_mode || !can_send || ret_address.is_none() {
|
||||
return output_sp();
|
||||
}
|
||||
|
||||
let res = try_slatepack_sync_workflow(&slate, &dest, Some(tor_config), None, true);
|
||||
let dest = ret_address.as_ref().unwrap();
|
||||
let res = try_slatepack_sync_workflow(&slate, dest, Some(tor_config), None, true);
|
||||
|
||||
match res {
|
||||
Ok(s) => {
|
||||
@@ -974,7 +983,7 @@ where
|
||||
owner_api,
|
||||
keychain_mask,
|
||||
&slate,
|
||||
"",
|
||||
None,
|
||||
args.outfile,
|
||||
false,
|
||||
true,
|
||||
@@ -987,7 +996,7 @@ where
|
||||
/// Issue Invoice Args
|
||||
pub struct IssueInvoiceArgs {
|
||||
/// Slatepack address
|
||||
pub dest: String,
|
||||
pub dest: Option<String>,
|
||||
/// issue invoice tx args
|
||||
pub issue_args: IssueInvoiceTxArgs,
|
||||
/// output file override
|
||||
@@ -1006,6 +1015,11 @@ where
|
||||
C: NodeClient + 'static,
|
||||
K: keychain::Keychain + 'static,
|
||||
{
|
||||
let dest = args
|
||||
.dest
|
||||
.as_deref()
|
||||
.map(SlatepackAddress::try_from)
|
||||
.transpose()?;
|
||||
let issue_args = args.issue_args.clone();
|
||||
|
||||
let slate = owner_api.issue_invoice_tx(keychain_mask, issue_args)?;
|
||||
@@ -1014,7 +1028,7 @@ where
|
||||
owner_api,
|
||||
keychain_mask,
|
||||
&slate,
|
||||
args.dest.as_str(),
|
||||
dest,
|
||||
args.outfile,
|
||||
false,
|
||||
false,
|
||||
@@ -1027,7 +1041,7 @@ where
|
||||
pub struct ProcessInvoiceArgs {
|
||||
pub minimum_confirmations: u64,
|
||||
pub selection_strategy: String,
|
||||
pub ret_address: Option<SlatepackAddress>,
|
||||
pub ret_address: Option<String>,
|
||||
pub max_outputs: usize,
|
||||
pub slate: Slate,
|
||||
pub estimate_selection_strategies: bool,
|
||||
@@ -1052,11 +1066,12 @@ where
|
||||
C: NodeClient + 'static,
|
||||
K: keychain::Keychain + 'static,
|
||||
{
|
||||
let ret_address = args
|
||||
.ret_address
|
||||
.as_deref()
|
||||
.map(SlatepackAddress::try_from)
|
||||
.transpose()?;
|
||||
let mut slate = args.slate.clone();
|
||||
let dest = match args.ret_address.clone() {
|
||||
Some(a) => String::try_from(&a)?,
|
||||
None => String::from(""),
|
||||
};
|
||||
|
||||
if args.estimate_selection_strategies {
|
||||
let strategies = vec!["smallest", "all"]
|
||||
@@ -1115,7 +1130,7 @@ where
|
||||
owner_api,
|
||||
keychain_mask,
|
||||
&slate,
|
||||
&dest,
|
||||
ret_address.clone(),
|
||||
args.outfile,
|
||||
true,
|
||||
false,
|
||||
@@ -1124,11 +1139,12 @@ where
|
||||
};
|
||||
|
||||
let can_send = tor_config.send_tor(args.skip_tor);
|
||||
if test_mode || !can_send {
|
||||
if test_mode || !can_send || ret_address.is_none() {
|
||||
return output_sp();
|
||||
}
|
||||
|
||||
let res = try_slatepack_sync_workflow(&slate, &dest, Some(tor_config), None, true);
|
||||
let dest = ret_address.as_ref().unwrap();
|
||||
let res = try_slatepack_sync_workflow(&slate, dest, Some(tor_config), None, true);
|
||||
|
||||
match res {
|
||||
Ok(s) => {
|
||||
|
||||
Reference in New Issue
Block a user