Lock outputs before sending with Tor (#814)

Co-authored-by: wiesche <wiesche89@googlemail.com>
(cherry picked from commit 452a3ec51b)
This commit is contained in:
ardocrat
2026-10-11 00:45:56 +03:00
parent cec94917de
commit 2302135709
27 changed files with 2275 additions and 3452 deletions
+26 -8
View File
@@ -439,7 +439,6 @@ where
target_slate_version: args.target_slate_version,
payment_proof_recipient_address,
ttl_blocks: args.ttl_blocks,
send_args: None,
late_lock: Some(args.late_lock),
..Default::default()
};
@@ -494,14 +493,14 @@ where
tor_config.bridge.bridge_line = Some(b);
}
let output_sp = || -> Result<(), Error> {
let output_sp = |owner_api: &mut Owner<L, C, K>, lock_outputs: bool| -> Result<(), Error> {
Ok(output_slatepack(
owner_api,
keychain_mask,
&slate,
dest.clone(),
args.outfile,
true,
lock_outputs,
false,
args.slatepack_qr,
)?)
@@ -509,7 +508,11 @@ where
let can_send = tor_config.send_tor(args.skip_tor);
if test_mode || !can_send || dest.is_none() {
return output_sp();
return output_sp(owner_api, !args.late_lock);
}
if !args.late_lock {
owner_api.tx_lock_outputs(keychain_mask, &slate)?;
}
let dest = dest.as_ref().unwrap();
@@ -517,7 +520,6 @@ where
match res {
Ok(s) => {
owner_api.tx_lock_outputs(keychain_mask, &s)?;
let ret_slate = owner_api.finalize_tx(keychain_mask, &s)?;
let result = owner_api.post_tx(keychain_mask, &ret_slate, args.fluff);
match result {
@@ -532,7 +534,13 @@ where
}
Err(e) => {
error!("Error sending slate sync: {}", e);
output_sp()?;
output_sp(owner_api, false)?;
if !args.late_lock {
println!(
"Outputs are locked. To unlock them, cancel with `cancel -t {}`.",
slate.id
);
}
}
}
Ok(())
@@ -581,7 +589,18 @@ where
println!();
if !finalizing {
println!("Slatepack data follows. Please provide this output to the other party");
let cancel_hint = if lock {
format!(
" or cancel it manually with `cancel -t {}` command",
slate.id
)
} else {
"".to_string()
};
println!(
"Slatepack data follows. Please provide this output to the other party{}.",
cancel_hint
);
} else {
println!("Slatepack data follows.");
}
@@ -1074,7 +1093,6 @@ where
selection_strategy_is_use_all: args.selection_strategy == "all",
refresh_outputs_from_node: !info_updated,
ttl_blocks: args.ttl_blocks,
send_args: None,
..Default::default()
};
let result = owner_api.process_invoice_tx(keychain_mask, &slate, init_args);
-17
View File
@@ -136,23 +136,6 @@ fn init_tor_listener(
Ok(process)
}
/// Instantiate wallet Owner API for a single-use (command line) call
/// Return a function containing a loaded API context to call
pub fn owner_single_use<L, F, C, K>(
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
keychain_mask: Option<&SecretKey>,
config_path: PathBuf,
f: F,
) -> Result<(), Error>
where
L: WalletLCProvider<'static, C, K> + 'static,
F: FnOnce(&mut Owner<L, C, K>, Option<&SecretKey>) -> Result<(), Error>,
C: NodeClient + 'static,
K: Keychain + 'static,
{
f(&mut Owner::new(wallet, None, config_path), keychain_mask)
}
/// Instantiate wallet Foreign API for a single-use (command line) call
/// Return a function containing a loaded API context to call
pub fn foreign_single_use<'a, L, F, C, K>(