mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 07:11:36 +02:00
reuse contract owner
This commit is contained in:
+38
-62
@@ -1812,22 +1812,15 @@ where
|
|||||||
recipient.as_ref(),
|
recipient.as_ref(),
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
let wallet_inst = owner_api.wallet_inst.clone();
|
let slate = owner_api.contract_new(keychain_mask, &contract_new_args)?;
|
||||||
let config_path = owner_api.config_path();
|
print_slatepack(
|
||||||
controller::owner_single_use(wallet_inst, keychain_mask, config_path, |api, m| {
|
owner_api,
|
||||||
let slate = api.contract_new(m, &contract_new_args)?;
|
keychain_mask,
|
||||||
|
&slate,
|
||||||
print_slatepack(
|
recipient,
|
||||||
api,
|
args.outfile,
|
||||||
keychain_mask,
|
args.as_json,
|
||||||
&slate,
|
)?;
|
||||||
recipient.clone(),
|
|
||||||
args.outfile,
|
|
||||||
args.as_json,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1951,7 +1944,7 @@ where
|
|||||||
print_contract_status("Paste slatepack:", args.as_json);
|
print_contract_status("Paste slatepack:", args.as_json);
|
||||||
let slatepack_msg = read_slatepack(&mut io::stdin().lock())
|
let slatepack_msg = read_slatepack(&mut io::stdin().lock())
|
||||||
.map_err(|e| libwallet::Error::GenericError(format!("Failed to read from stdin: {}", e)))?;
|
.map_err(|e| libwallet::Error::GenericError(format!("Failed to read from stdin: {}", e)))?;
|
||||||
let (mut slate, sender, _) =
|
let (slate, sender, _) =
|
||||||
parse_slatepack_with_mode(owner_api, keychain_mask, None, Some(slatepack_msg))?;
|
parse_slatepack_with_mode(owner_api, keychain_mask, None, Some(slatepack_msg))?;
|
||||||
let mut contract_sign_args = args.to_api_args(&slate)?;
|
let mut contract_sign_args = args.to_api_args(&slate)?;
|
||||||
// Bind the proof to the Slatepack sender; --encrypt-for is only the fallback
|
// Bind the proof to the Slatepack sender; --encrypt-for is only the fallback
|
||||||
@@ -1962,28 +1955,22 @@ where
|
|||||||
)?;
|
)?;
|
||||||
// Prefer --encrypt-for, then reply to the sender. Without either, use plaintext.
|
// Prefer --encrypt-for, then reply to the sender. Without either, use plaintext.
|
||||||
let recipient = recipient.or(sender);
|
let recipient = recipient.or(sender);
|
||||||
let wallet_inst = owner_api.wallet_inst.clone();
|
let slate = owner_api.contract_sign(keychain_mask, &slate, &contract_sign_args)?;
|
||||||
let config_path = owner_api.config_path();
|
|
||||||
controller::owner_single_use(wallet_inst, keychain_mask, config_path, |api, m| {
|
|
||||||
slate = api.contract_sign(m, &slate, &contract_sign_args)?;
|
|
||||||
|
|
||||||
let slate_out = prepare_slatepack(api, keychain_mask, &slate, recipient, args.outfile)?;
|
let slate_out = prepare_slatepack(owner_api, keychain_mask, &slate, recipient, args.outfile)?;
|
||||||
|
|
||||||
if broadcast_tx && slate_out.is_finalized {
|
if broadcast_tx && slate_out.is_finalized {
|
||||||
if let Err(e) = api.post_tx(keychain_mask, &slate, true) {
|
if let Err(e) = owner_api.post_tx(keychain_mask, &slate, true) {
|
||||||
slate_out.print(args.as_json);
|
|
||||||
return Err(e);
|
|
||||||
}
|
|
||||||
if args.as_json {
|
|
||||||
slate_out.print(true);
|
|
||||||
}
|
|
||||||
print_contract_status("Transaction was broadcasted.", args.as_json);
|
|
||||||
} else {
|
|
||||||
slate_out.print(args.as_json);
|
slate_out.print(args.as_json);
|
||||||
|
return Err(e.into());
|
||||||
}
|
}
|
||||||
|
if args.as_json {
|
||||||
Ok(())
|
slate_out.print(true);
|
||||||
})?;
|
}
|
||||||
|
print_contract_status("Transaction was broadcasted.", args.as_json);
|
||||||
|
} else {
|
||||||
|
slate_out.print(args.as_json);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -2013,13 +2000,8 @@ where
|
|||||||
args.input_slatepack_message,
|
args.input_slatepack_message,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let wallet_inst = owner_api.wallet_inst.clone();
|
let view = owner_api.contract_view(keychain_mask, &slate)?;
|
||||||
let config_path = owner_api.config_path();
|
display::contract_view(&slate, &view, was_encrypted);
|
||||||
controller::owner_single_use(wallet_inst, keychain_mask, config_path, |api, m| {
|
|
||||||
let view = api.contract_view(m, &slate)?;
|
|
||||||
display::contract_view(&slate, &view, was_encrypted);
|
|
||||||
Ok(())
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -2042,26 +2024,20 @@ where
|
|||||||
C: NodeClient + 'static,
|
C: NodeClient + 'static,
|
||||||
K: keychain::Keychain + 'static,
|
K: keychain::Keychain + 'static,
|
||||||
{
|
{
|
||||||
let wallet_inst = owner_api.wallet_inst.clone();
|
let slate_opt = owner_api.contract_revoke(
|
||||||
let config_path = owner_api.config_path();
|
keychain_mask,
|
||||||
controller::owner_single_use(wallet_inst, keychain_mask, config_path, |api, m| {
|
&ContractRevokeArgsAPI {
|
||||||
let slate_opt = api.contract_revoke(
|
tx_id: args.tx_id,
|
||||||
m,
|
src_acct_name: None,
|
||||||
&ContractRevokeArgsAPI {
|
},
|
||||||
tx_id: args.tx_id,
|
)?;
|
||||||
src_acct_name: None,
|
if let Some(slate) = slate_opt {
|
||||||
},
|
// A revoke has no counterparty, so write the replacement as plaintext.
|
||||||
)?;
|
let slate_out = prepare_slatepack(owner_api, keychain_mask, &slate, None, args.outfile)?;
|
||||||
if let Some(slate) = slate_opt {
|
println!("{}", slate_out);
|
||||||
// A revoke has no counterparty, so write the replacement as plaintext.
|
} else {
|
||||||
let slate_out = prepare_slatepack(api, keychain_mask, &slate, None, args.outfile)?;
|
println!("Contract revoked. No replacement transaction was created.");
|
||||||
println!("{}", slate_out);
|
}
|
||||||
} else {
|
|
||||||
println!("Contract revoked. No replacement transaction was created.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user