enable multisig from prepare_multisig

This commit is contained in:
creating2morrow 2024-06-28 04:43:54 -04:00
parent 20cafa906f
commit 2171dafdbf
5 changed files with 18 additions and 61 deletions

View file

@ -101,7 +101,6 @@ NEVidebla-EKOnomia (invisible economy)
* can be overriden with remote node * can be overriden with remote node
* use the `--remote-node` flag * use the `--remote-node` flag
* [monero-wallet-rpc](https://www.getmonero.org/downloads/#cli) - (not included) interface for xmr wallet ops * [monero-wallet-rpc](https://www.getmonero.org/downloads/#cli) - (not included) interface for xmr wallet ops
* [monero-wallet-cli](https://www.getmonero.org/downloads/#cli) - enable experimental multisig
* [i2p-zero](https://github.com/creating2morrow/i2p-zero/releases/tag/v1.21-neveko) - (not included) tunnel creation and http proxy * [i2p-zero](https://github.com/creating2morrow/i2p-zero/releases/tag/v1.21-neveko) - (not included) tunnel creation and http proxy
most of the complex logic stays in neveko-core, exported from [lib.rs](./neveko-core/src/lib.rs) most of the complex logic stays in neveko-core, exported from [lib.rs](./neveko-core/src/lib.rs)

View file

@ -787,10 +787,14 @@ pub async fn prepare_wallet() -> reqres::XmrRpcPrepareResponse {
info!("executing {}", RpcFields::Prepare.value()); info!("executing {}", RpcFields::Prepare.value());
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let host = get_rpc_host(); let host = get_rpc_host();
let req = reqres::XmrRpcRequest { let params = reqres::XmrRpcPrepareParams {
enable_experimental_multisig: true,
};
let req = reqres::XmrRpcPrepareRequest {
jsonrpc: RpcFields::JsonRpcVersion.value(), jsonrpc: RpcFields::JsonRpcVersion.value(),
id: RpcFields::Id.value(), id: RpcFields::Id.value(),
method: RpcFields::Prepare.value(), method: RpcFields::Prepare.value(),
params,
}; };
let login: RpcLogin = get_rpc_creds(); let login: RpcLogin = get_rpc_creds();
match client match client
@ -1577,56 +1581,3 @@ pub async fn p_get_transactions(
} }
// End XMR daemon methods // End XMR daemon methods
/// enable multisig - `monero-wallet-cli --password <> --wallet-file <> set
/// enable-multisig-experimental 1`
pub fn enable_experimental_multisig(wallet_file: &String) {
warn!("Enabling experimental multisig...");
let bin_dir = get_monero_location();
let user = std::env::var("USER").unwrap_or(utils::empty_string());
let file_path = format!(
"/home/{}/.{}/stagenet/wallet/{}",
&user,
crate::APP_NAME,
&wallet_file
);
let wallet_password = utils::empty_string();
let release_env = utils::get_release_env();
let args = if release_env == utils::ReleaseEnvironment::Production {
vec![
"--password",
&wallet_password,
"--wallet-file",
&file_path,
"set",
"enable-multisig-experimental",
"1",
]
} else {
vec![
"--stagenet",
"--password",
&wallet_password,
"--wallet-file",
&file_path,
"set",
"enable-multisig-experimental",
"1",
]
};
let mut output = Command::new(format!("{}/monero-wallet-cli", bin_dir))
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.args(args)
.spawn()
.expect("failed to enable experimental msig");
let _ = std::io::stdout().flush();
let mut stdin = output.stdin.take().expect("Failed to open stdin");
std::thread::spawn(move || {
stdin
.write_all(&wallet_password.as_bytes())
.expect("Failed to write to stdin");
});
let d_output = output.wait_with_output().expect("Failed to read stdout");
debug!("{:?}", d_output);
}

View file

@ -72,9 +72,7 @@ pub async fn create(j_order: Json<reqres::OrderRequest>) -> Order {
monero::close_wallet(&orid, &wallet_password).await; monero::close_wallet(&orid, &wallet_password).await;
return Default::default(); return Default::default();
} }
// enable multisig
monero::close_wallet(&orid, &order_wallet_password).await; monero::close_wallet(&orid, &order_wallet_password).await;
monero::enable_experimental_multisig(&orid);
debug!("insert order: {:?}", &new_order); debug!("insert order: {:?}", &new_order);
let s = db::Interface::async_open().await; let s = db::Interface::async_open().await;
// inject adjudicator separately, modifying the order model is mendokusai // inject adjudicator separately, modifying the order model is mendokusai
@ -826,7 +824,5 @@ pub async fn init_adjudicator_wallet(orid: &String) {
if !m_wallet { if !m_wallet {
log::error!("failed to create adjudicator wallet"); log::error!("failed to create adjudicator wallet");
} }
// enable multisig
monero::close_wallet(&orid, &password).await; monero::close_wallet(&orid, &password).await;
monero::enable_experimental_multisig(&orid);
} }

View file

@ -45,6 +45,11 @@ pub struct XmrRpcOpenWalletParams {
pub password: String, pub password: String,
} }
#[derive(Deserialize, Serialize, Debug)]
pub struct XmrRpcPrepareParams {
pub enable_experimental_multisig: bool
}
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
pub struct XmrRpcMakeParams { pub struct XmrRpcMakeParams {
pub multisig_info: Vec<String>, pub multisig_info: Vec<String>,
@ -226,6 +231,14 @@ pub struct XmrRpcBalanceRequest {
pub params: XmrRpcBalanceParams, pub params: XmrRpcBalanceParams,
} }
#[derive(Deserialize, Serialize, Debug)]
pub struct XmrRpcPrepareRequest {
pub jsonrpc: String,
pub id: String,
pub method: String,
pub params: XmrRpcPrepareParams,
}
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
pub struct XmrRpcMakeRequest { pub struct XmrRpcMakeRequest {
pub jsonrpc: String, pub jsonrpc: String,

View file

@ -1841,9 +1841,7 @@ fn send_prepare_info_req(
let _ = tx.send(utils::empty_string()); let _ = tx.send(utils::empty_string());
return; return;
} }
// enable multisig
monero::close_wallet(&w_orid, &wallet_password).await; monero::close_wallet(&w_orid, &wallet_password).await;
monero::enable_experimental_multisig(&w_orid);
monero::open_wallet(&w_orid, &wallet_password).await; monero::open_wallet(&w_orid, &wallet_password).await;
let prepare_info = monero::prepare_wallet().await; let prepare_info = monero::prepare_wallet().await;
let ref_prepare_info: &String = &prepare_info.result.multisig_info; let ref_prepare_info: &String = &prepare_info.result.multisig_info;