mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-23 10:08:33 +02:00
Add option to finalize and post transactions separately (for air-gap wallets) (#255)
* Add option to output finalized slate * Add subcommand to post a finalized slate file
This commit is contained in:
+48
-12
@@ -406,6 +406,8 @@ where
|
||||
pub struct FinalizeArgs {
|
||||
pub input: String,
|
||||
pub fluff: bool,
|
||||
pub nopost: bool,
|
||||
pub dest: Option<String>,
|
||||
}
|
||||
|
||||
pub fn finalize<'a, L, C, K>(
|
||||
@@ -462,19 +464,27 @@ where
|
||||
})?;
|
||||
}
|
||||
|
||||
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
|
||||
let result = api.post_tx(m, &slate.tx, args.fluff);
|
||||
match result {
|
||||
Ok(_) => {
|
||||
info!("Transaction sent successfully, check the wallet again for confirmation.");
|
||||
Ok(())
|
||||
if !args.nopost {
|
||||
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
|
||||
let result = api.post_tx(m, &slate.tx, args.fluff);
|
||||
match result {
|
||||
Ok(_) => {
|
||||
info!(
|
||||
"Transaction sent successfully, check the wallet again for confirmation."
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Tx not sent: {}", e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Tx not sent: {}", e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
})?;
|
||||
})?;
|
||||
}
|
||||
|
||||
if args.dest.is_some() {
|
||||
PathToSlate((&args.dest.unwrap()).into()).put_tx(&slate)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -720,6 +730,32 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Post
|
||||
pub struct PostArgs {
|
||||
pub input: String,
|
||||
pub fluff: bool,
|
||||
}
|
||||
|
||||
pub fn post<'a, L, C, K>(
|
||||
wallet: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
args: PostArgs,
|
||||
) -> Result<(), Error>
|
||||
where
|
||||
L: WalletLCProvider<'a, C, K>,
|
||||
C: NodeClient + 'a,
|
||||
K: keychain::Keychain + 'a,
|
||||
{
|
||||
let slate = PathToSlate((&args.input).into()).get_tx()?;
|
||||
|
||||
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
|
||||
api.post_tx(m, &slate.tx, args.fluff)?;
|
||||
info!("Posted transaction");
|
||||
return Ok(());
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Repost
|
||||
pub struct RepostArgs {
|
||||
pub id: u32,
|
||||
|
||||
Reference in New Issue
Block a user