From 8741a90b8739e5600ea6fec467d92e7a9a43b14b Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Tue, 13 Feb 2024 15:25:19 +0000 Subject: [PATCH 1/6] alpha bugfixes --- src/gui/element/wallet/operation/tx_list.rs | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gui/element/wallet/operation/tx_list.rs b/src/gui/element/wallet/operation/tx_list.rs index 6a64718..7146545 100644 --- a/src/gui/element/wallet/operation/tx_list.rs +++ b/src/gui/element/wallet/operation/tx_list.rs @@ -16,7 +16,7 @@ use { config::Config, node::amount_to_hr_string, theme::{ButtonStyle, ColorPalette, ContainerStyle}, - wallet::TxLogEntry, + wallet::{TxLogEntry, TxLogEntryType}, }, grin_gui_widgets::widget::header, iced::widget::{button, pick_list, scrollable, text_input, Space}, @@ -1622,10 +1622,11 @@ pub fn data_row_container<'a, 'b>( let tx_proof_wrap = Container::new(tx_proof_wrap) .style(grin_gui_core::theme::ContainerStyle::Segmented) .padding(1); - - action_button_row = action_button_row - .push(tx_proof_wrap) - .push(Space::with_width(Length::Fixed(DEFAULT_PADDING))); + if tx_cloned_for_row.tx.tx_type != TxLogEntryType::TxSelfSpend { + action_button_row = action_button_row + .push(tx_proof_wrap) + .push(Space::with_width(Length::Fixed(DEFAULT_PADDING))); + } } if !confirmed { @@ -1684,10 +1685,13 @@ pub fn data_row_container<'a, 'b>( .style(grin_gui_core::theme::ContainerStyle::Segmented) .padding(1); - action_button_row = action_button_row - .push(tx_reload_slate_wrap) - .push(Space::with_width(Length::Fixed(DEFAULT_PADDING))) - .push(tx_cancel_wrap) + if tx_cloned_for_row.tx.tx_type != TxLogEntryType::TxSelfSpend { + action_button_row = action_button_row + .push(tx_reload_slate_wrap) + .push(Space::with_width(Length::Fixed(DEFAULT_PADDING))) + } + + action_button_row = action_button_row.push(tx_cancel_wrap) } /* From 496aaeac8e3fbe4e9e9a49436611cea27dca9a8a Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Wed, 14 Feb 2024 17:31:41 +0000 Subject: [PATCH 2/6] add explicit self-spend cancellation --- locale/en.json | 6 +-- src/gui/element/wallet/operation/apply_tx.rs | 43 ++++++++++++++++++-- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/locale/en.json b/locale/en.json index a68e0cd..df91075 100644 --- a/locale/en.json +++ b/locale/en.json @@ -239,8 +239,8 @@ "wallet-home": "Wallet - Set Name Here TBD", "wallet-create-contract": "Create Contract", "wallet-create-contract-other-address": "Other Party's Slatepack Address", - "wallet-self-send": "Self-send", - "wallet-self-send-instruction": "This is a self-send", + "wallet-self-send": "Self-spend", + "wallet-self-send-instruction": "This is a self-spend", "tx-contract-debit": "I will agree to PAY", "tx-contract-credit": "I will agree to RECEIVE", "apply-tx": "Continue Transaction", @@ -304,7 +304,7 @@ "tx-i1-finalization-1": "You are finalizing an agreement to receive [AMOUNT] Grin", "tx-s1-finalization-2": "Along with a mining fee of [AMOUNT] Grin", "tx-s1-finalization-3": "This will complete the transaction and post it to the chain, at which point it becomes irreversible.", - "tx-s1-finalization-self-send": "You are self-sending [AMOUNT] Grin", + "tx-s1-finalization-self-send": "You are self-spending [AMOUNT] Grin", "tx-done-instruction": "The transaction has been completed and posted to the chain. Please wait a few blocks for validation.", "signing-tx": "Signing...", "mw-mixnet-addresses": "MWMixnet Server Keys", diff --git a/src/gui/element/wallet/operation/apply_tx.rs b/src/gui/element/wallet/operation/apply_tx.rs index 74c3fa0..a2bd7ca 100644 --- a/src/gui/element/wallet/operation/apply_tx.rs +++ b/src/gui/element/wallet/operation/apply_tx.rs @@ -8,6 +8,7 @@ use grin_gui_core::{ use grin_gui_widgets::widget::header; use iced_aw::Card; use iced_core::Widget; +use serde::de; use std::path::PathBuf; use super::tx_list::{HeaderState, TxList}; @@ -77,6 +78,7 @@ pub enum LocalViewInteraction { ReadFromClipboardSuccess(String), ReadFromClipboardFailure, ShowSlate, + CancelSelfSpend, } pub fn handle_message<'a>( @@ -189,6 +191,33 @@ pub fn handle_message<'a>( grin_gui.wallet_state.operation_state.mode = crate::gui::element::wallet::operation::Mode::ShowSlatepack; } + LocalViewInteraction::CancelSelfSpend => { + // If this was a self-send, cancel the transaction and remove from log + if state.confirm_state.is_self_send { + // Unwrap tx id + let tx_id = match state.confirm_state.slatepack_parsed.as_ref() { + Some(p) => { + if let Some(t) = p.2.as_ref() { + Some(t.id) + } else { + None + } + } + None => None, + }; + let w = grin_gui.wallet_interface.clone(); + let fut = move || WalletInterface::cancel_tx(w, tx_id.unwrap()); + debug!("Cancelling self-spend tx: {:?}", tx_id); + + return Ok(Command::perform(fut(), |_| { + return Message::Interaction( + Interaction::WalletOperationApplyTxViewInteraction( + crate::gui::element::wallet::operation::apply_tx::LocalViewInteraction::BackCleanup, + ), + ); + })); + } + } LocalViewInteraction::Address(_) => {} LocalViewInteraction::ApplyTransaction(_) => {} } @@ -386,12 +415,18 @@ pub fn data_container<'a>(config: &'a Config, state: &'a StateContainer) -> Cont .center_y() .align_x(alignment::Horizontal::Center); - let cancel_button: Element = Button::new(cancel_button_label_container) - .style(grin_gui_core::theme::ButtonStyle::Primary) - .on_press(Interaction::WalletOperationApplyTxViewInteraction( + let cancel_button = Button::new(cancel_button_label_container) + .style(grin_gui_core::theme::ButtonStyle::Primary); + let cancel_button: Element = if state.confirm_state.is_self_send { + cancel_button.on_press(Interaction::WalletOperationApplyTxViewInteraction( + LocalViewInteraction::CancelSelfSpend, + )) + } else { + cancel_button.on_press(Interaction::WalletOperationApplyTxViewInteraction( LocalViewInteraction::Back, )) - .into(); + } + .into(); let submit_container = Container::new(submit_button.map(Message::Interaction)).padding(1); let submit_container = Container::new(submit_container) From 1c642d39515766345a404777b339f30e8a00392e Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Thu, 15 Feb 2024 12:58:19 +0000 Subject: [PATCH 3/6] update to add ability to delete self-spends --- Cargo.lock | 71 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d25dc83..d894b7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -968,18 +968,18 @@ dependencies = [ [[package]] name = "clipboard_wayland" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8134163bd07c47ae3cc29babc42c255fdb315facc790950ae2d0e561ea6f2ec0" +checksum = "003f886bc4e2987729d10c1db3424e7f80809f3fc22dbc16c685738887cb37b8" dependencies = [ "smithay-clipboard", ] [[package]] name = "clipboard_x11" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cf45b436634fee64c6d3981639b46a87eeea3c64e422643273fcefd1baef56c" +checksum = "4274ea815e013e0f9f04a2633423e14194e408a0576c943ce3d14ca56c50031c" dependencies = [ "thiserror", "x11rb 0.13.0", @@ -1172,9 +1172,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if 1.0.0", ] @@ -1287,9 +1287,9 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" [[package]] name = "curl" -version = "0.4.45" +version = "0.4.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8e5123ab8c31200ce725939049ecd4a090b242608f24048131dedf9dd195aed" +checksum = "1e2161dd6eba090ff1594084e95fd67aeccf04382ffea77999ea94ed42ec67b6" dependencies = [ "curl-sys", "libc", @@ -2792,7 +2792,7 @@ dependencies = [ [[package]] name = "grin_wallet" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#02af39143e22bd7530b0ea22b36a464440b0e523" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" dependencies = [ "built", "clap", @@ -2819,7 +2819,7 @@ dependencies = [ [[package]] name = "grin_wallet_api" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#02af39143e22bd7530b0ea22b36a464440b0e523" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" dependencies = [ "base64 0.12.3", "chrono", @@ -2844,7 +2844,7 @@ dependencies = [ [[package]] name = "grin_wallet_config" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#02af39143e22bd7530b0ea22b36a464440b0e523" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" dependencies = [ "dirs 2.0.2", "grin_core", @@ -2859,7 +2859,7 @@ dependencies = [ [[package]] name = "grin_wallet_controller" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#02af39143e22bd7530b0ea22b36a464440b0e523" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" dependencies = [ "chrono", "easy-jsonrpc-mw", @@ -2893,7 +2893,7 @@ dependencies = [ [[package]] name = "grin_wallet_impls" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#02af39143e22bd7530b0ea22b36a464440b0e523" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" dependencies = [ "base64 0.12.3", "blake2-rfc", @@ -2932,7 +2932,7 @@ dependencies = [ [[package]] name = "grin_wallet_libwallet" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#02af39143e22bd7530b0ea22b36a464440b0e523" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" dependencies = [ "age", "base64 0.9.3", @@ -2973,7 +2973,7 @@ dependencies = [ [[package]] name = "grin_wallet_util" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#02af39143e22bd7530b0ea22b36a464440b0e523" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" dependencies = [ "data-encoding", "ed25519-dalek", @@ -3119,9 +3119,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" [[package]] name = "hexf-parse" @@ -3722,7 +3722,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.5", + "hermit-abi 0.3.6", "libc", "windows-sys 0.48.0", ] @@ -3748,7 +3748,7 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.5", + "hermit-abi 0.3.6", "libc", "windows-sys 0.52.0", ] @@ -4768,7 +4768,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.5", + "hermit-abi 0.3.6", "libc", ] @@ -5350,9 +5350,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plotters" @@ -5863,9 +5863,9 @@ dependencies = [ [[package]] name = "read-fonts" -version = "0.15.4" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d70252c718fb23d41771a4f927e924700edefc2a91ecd52a2ee6f2461d4e6b64" +checksum = "c044ab88c43e2eae05b34a17fc13598736679fdb03d71b49fcfe114443ec8a86" dependencies = [ "font-types", ] @@ -7486,7 +7486,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.4", + "toml_edit 0.22.5", ] [[package]] @@ -7506,20 +7506,20 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.2.3", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" +checksum = "99e68c159e8f5ba8a28c4eb7b0c0c190d77bb479047ca713270048145a9ad28a" dependencies = [ "indexmap 2.2.3", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.1", ] [[package]] @@ -8667,9 +8667,18 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.39" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" +checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401" dependencies = [ "memchr", ] From e8ed4eee2bfe183cf568adb321d038f7e6759b74 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Wed, 21 Feb 2024 14:22:36 +0000 Subject: [PATCH 4/6] move cancel to use uuid --- Cargo.lock | 2 + Cargo.toml | 1 + crates/core/Cargo.toml | 1 + crates/core/src/wallet/mod.rs | 1246 +++++++++--------- src/gui/element/wallet/operation/apply_tx.rs | 4 +- src/gui/element/wallet/operation/home.rs | 9 +- 6 files changed, 634 insertions(+), 629 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d894b7d..218b78c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2473,6 +2473,7 @@ dependencies = [ "strfmt", "structopt", "timeago", + "uuid", "version-compare", "winapi 0.3.9", ] @@ -2529,6 +2530,7 @@ dependencies = [ "tar", "tempfile", "thiserror", + "uuid", "walkdir", "zip", "zstd", diff --git a/Cargo.toml b/Cargo.toml index a5e66fe..6c2927c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ lazy_static = "1" serde = { version = "1.0", features=['derive'] } serde_json = "1.0.59" reqwest = { version = "0.11", features = ["json", "blocking"] } +uuid = "0.8.2" [target.'cfg(target_os = "linux")'.dependencies] diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index b439cd9..0ff2b08 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -98,6 +98,7 @@ log4rs = { version = "0.12", features = [ ] } backtrace = "0.3" lazy_static = "1" +uuid = "0.8.2" iced = { version = "0.10", features = ["advanced", "tokio"] } iced_futures = { version = "0.7", features = ["async-std"] } diff --git a/crates/core/src/wallet/mod.rs b/crates/core/src/wallet/mod.rs index c79e6d7..e2a0941 100644 --- a/crates/core/src/wallet/mod.rs +++ b/crates/core/src/wallet/mod.rs @@ -22,12 +22,12 @@ use dirs; pub use global::ChainTypes; pub use grin_wallet_impls::HTTPNodeClient; pub use grin_wallet_libwallet::{ - InitTxArgs, RetrieveTxQueryArgs, RetrieveTxQuerySortOrder, Slate, SlateState, Slatepack, - SlatepackAddress, StatusMessage, TxLogEntry, TxLogEntryType, WalletInfo, + InitTxArgs, RetrieveTxQueryArgs, RetrieveTxQuerySortOrder, Slate, SlateState, Slatepack, + SlatepackAddress, StatusMessage, TxLogEntry, TxLogEntryType, WalletInfo, }; pub use grin_wallet_libwallet::contract::types::{ - ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI, ProofArgs + ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI, ProofArgs, }; pub use grin_wallet_libwallet::contract::proofs::InvoiceProof; @@ -37,7 +37,6 @@ use crate::logger; use std::convert::TryFrom; - /// Wallet configuration file name pub const WALLET_CONFIG_FILE_NAME: &str = "grin-wallet.toml"; @@ -59,643 +58,644 @@ pub const OWNER_API_SECRET_FILE_NAME: &str = ".owner_api_secret"; /// need to reconcile this with existing installs somehow pub fn get_grin_wallet_default_path(chain_type: &global::ChainTypes) -> PathBuf { - // Check if grin dir exists - let mut grin_path = match dirs::home_dir() { - Some(p) => p, - None => PathBuf::new(), - }; - grin_path.push(GRIN_HOME); - grin_path.push(chain_type.shortname()); - grin_path.push(GRIN_WALLET_TOP_LEVEL_DIR); - grin_path.push(GRIN_WALLET_DEFAULT_DIR); - - grin_path + // Check if grin dir exists + let mut grin_path = match dirs::home_dir() { + Some(p) => p, + None => PathBuf::new(), + }; + grin_path.push(GRIN_HOME); + grin_path.push(chain_type.shortname()); + grin_path.push(GRIN_WALLET_TOP_LEVEL_DIR); + grin_path.push(GRIN_WALLET_DEFAULT_DIR); + + grin_path } pub fn create_grin_wallet_path(chain_type: &global::ChainTypes, sub_dir: &str) -> PathBuf { - // Check if grin dir exists - let mut grin_path = match dirs::home_dir() { - Some(p) => p, - None => PathBuf::new(), - }; - grin_path.push(GRIN_HOME); - grin_path.push(chain_type.shortname()); - grin_path.push(GRIN_WALLET_TOP_LEVEL_DIR); - grin_path.push(sub_dir); - - grin_path + // Check if grin dir exists + let mut grin_path = match dirs::home_dir() { + Some(p) => p, + None => PathBuf::new(), + }; + grin_path.push(GRIN_HOME); + grin_path.push(chain_type.shortname()); + grin_path.push(GRIN_WALLET_TOP_LEVEL_DIR); + grin_path.push(sub_dir); + + grin_path } pub type WalletInterfaceHttpNodeClient = WalletInterface< - DefaultLCProvider<'static, HTTPNodeClient, keychain::ExtKeychain>, - HTTPNodeClient, + DefaultLCProvider<'static, HTTPNodeClient, keychain::ExtKeychain>, + HTTPNodeClient, >; pub struct WalletInterface where - L: WalletLCProvider<'static, C, grin_keychain::keychain::ExtKeychain> + 'static, - C: NodeClient + 'static + Clone, + L: WalletLCProvider<'static, C, grin_keychain::keychain::ExtKeychain> + 'static, + C: NodeClient + 'static + Clone, { - pub chain_type: Option, - pub config: Option, - // owner api will hold instantiated/opened wallets - pub owner_api: Option>, - // Also need reference to foreign API - pub foreign_api: Option>, - // Simple flag to check whether wallet has been opened - wallet_is_open: bool, - // Hold on to check node foreign API secret for now - pub check_node_foreign_api_secret_path: Option, - // Whether to use embedded node for check node - use_embedded_node: bool, - - node_client: C, + pub chain_type: Option, + pub config: Option, + // owner api will hold instantiated/opened wallets + pub owner_api: Option>, + // Also need reference to foreign API + pub foreign_api: Option>, + // Simple flag to check whether wallet has been opened + wallet_is_open: bool, + // Hold on to check node foreign API secret for now + pub check_node_foreign_api_secret_path: Option, + // Whether to use embedded node for check node + use_embedded_node: bool, + + node_client: C, } // Amount / Fee pub fn parse_abs_tx_amount_fee(tx: &TxLogEntry, subtract_fee_from_amt: bool) -> (String, String) { - let mut amt = if tx.amount_credited >= tx.amount_debited { - tx.amount_credited - tx.amount_debited - } else { - tx.amount_debited - tx.amount_credited - }; - - let fee = match tx.fee { - Some(f) => f.fee(), - None => 0, - }; - - if subtract_fee_from_amt { - amt = amt - fee; - } - - ( - amount_to_hr_string(amt, true), - amount_to_hr_string(fee, true), - ) + let mut amt = if tx.amount_credited >= tx.amount_debited { + tx.amount_credited - tx.amount_debited + } else { + tx.amount_debited - tx.amount_credited + }; + + let fee = match tx.fee { + Some(f) => f.fee(), + None => 0, + }; + + if subtract_fee_from_amt { + amt = amt - fee; + } + + ( + amount_to_hr_string(amt, true), + amount_to_hr_string(fee, true), + ) } impl WalletInterface where - L: WalletLCProvider<'static, C, grin_keychain::keychain::ExtKeychain>, - C: NodeClient + 'static + Clone, + L: WalletLCProvider<'static, C, grin_keychain::keychain::ExtKeychain>, + C: NodeClient + 'static + Clone, { - pub fn new(node_client: C) -> Self { - WalletInterface { - chain_type: None, - config: None, - owner_api: None, - foreign_api: None, - wallet_is_open: false, - check_node_foreign_api_secret_path: None, - node_client, - use_embedded_node: true, - } - } - - fn set_chain_type(&mut self, chain_type: global::ChainTypes) { - self.chain_type = Some(chain_type); - } - - pub fn set_check_node_foreign_api_secret_path(&mut self, secret: &str) { - self.check_node_foreign_api_secret_path = Some(secret.to_owned()) - } - - pub fn config_exists(&self, path: &str) -> bool { - grin_wallet_config::config_file_exists(&path) - } - - pub fn default_config_exists(&self) -> bool { - match self.chain_type { - Some(chain_type) => { - self.config_exists(get_grin_wallet_default_path(&chain_type).to_str().unwrap()) - } - _ => false, - } - } - - pub fn wallet_is_open(&self) -> bool { - self.wallet_is_open - } - - pub fn set_use_embedded_node( - wallet_interface: Arc>>, - value: bool, - ) { - let mut w = wallet_interface.write().unwrap(); - if w.use_embedded_node != value { - w.owner_api = None; - } - w.use_embedded_node = value; - } - - /// Sets the top level directory of the wallet and creates default config if config - /// doesn't already exist. The initial config is created based off of the chain type. - fn inst_wallet( - wallet_interface: Arc>>, - chain_type: global::ChainTypes, - top_level_directory: PathBuf, - ) -> Result< - Arc>>>, - GrinWalletInterfaceError, - > { - let mut w = wallet_interface.write().unwrap(); - // path for config file - let data_path = Some(top_level_directory.clone()); - - // creates default config file for chain type at data path - let config = - grin_wallet_config::initial_setup_wallet(&chain_type, data_path, true).unwrap(); - - // Update logging config - let mut logging_config = config.members.as_ref().unwrap().logging.clone().unwrap(); - logging_config.tui_running = Some(false); - logger::update_logging_config(logger::LogArea::Wallet, logging_config); - - let wallet_config = config.clone().members.unwrap().wallet; - - // Set node client address and Foreign API Secret if needed - if w.use_embedded_node { - w.node_client - .set_node_url(&wallet_config.check_node_api_http_addr); - - let check_node_secret = - file::get_first_line(w.check_node_foreign_api_secret_path.clone()); - w.node_client.set_node_api_secret(check_node_secret); - } - - let wallet_inst = - inst_wallet(wallet_config.clone(), w.node_client.clone()).unwrap_or_else(|e| { - println!("{}", e); - std::process::exit(1); - }); - - { - let mut wallet_lock = wallet_inst.lock(); - let lc = wallet_lock.lc_provider().unwrap(); - // set top level directory - lc.set_top_level_directory(top_level_directory.to_str().unwrap()); - } - - w.config = Some(config); - - Ok(wallet_inst) - } - - fn inst_apis( - wallet_interface: Arc>>, - chain_type: global::ChainTypes, - top_level_directory: PathBuf, - ) -> Result<(), GrinWalletInterfaceError> { - let wallet_inst = WalletInterface::inst_wallet( - wallet_interface.clone(), - chain_type, - top_level_directory, - )?; - let mut w = wallet_interface.write().unwrap(); - w.owner_api = Some(Owner::new(wallet_inst.clone(), None)); - w.foreign_api = Some(Foreign::new(wallet_inst.clone(), None, None, false)); - global::set_local_chain_type(chain_type); - - Ok(()) - } - - pub async fn init( - wallet_interface: Arc>>, - password: String, - top_level_directory: PathBuf, - display_name: String, - chain_type: global::ChainTypes, - recovery_phrase: Option, - ) -> Result<(String, String, String, global::ChainTypes), GrinWalletInterfaceError> { - WalletInterface::inst_apis( - wallet_interface.clone(), - chain_type, - top_level_directory.clone(), - )?; - - let w = wallet_interface.read().unwrap(); - - let recover_length = recovery_phrase.clone().map(|f| f.len()).unwrap_or(32); - let recover_phrase = recovery_phrase.map(|f| ZeroingString::from(f)); - - let args = InitArgs { - list_length: recover_length, - password: password.clone().into(), - config: w.config.clone().unwrap().clone().members.unwrap().wallet, - recovery_phrase: recover_phrase.clone(), - restore: recover_phrase.is_some(), - }; - - let (tld, ret_phrase) = match w.owner_api.as_ref() { - Some(o) => { - let tld = { - let mut w_lock = o.wallet_inst.lock(); - let p = w_lock.lc_provider()?; - let logging_config = w - .config - .clone() - .unwrap() - .clone() - .members - .unwrap() - .logging - .clone(); - - log::debug!( - "core::wallet::InitWallet Top Level Directory: {:?}", - p.get_top_level_directory(), - ); - - p.create_config( - &chain_type, - WALLET_CONFIG_FILE_NAME, - Some(args.config), - logging_config, - None, - )?; - - p.create_wallet( - None, - args.recovery_phrase, - args.list_length, - args.password.clone(), - chain_type == global::ChainTypes::Testnet, - )?; - - p.get_top_level_directory()? - }; - - (tld, o.get_mnemonic(None, args.password)?.to_string()) - } - None => ("".to_string(), "".to_string()), - }; - - Ok((tld, ret_phrase, display_name, chain_type)) - } - - pub async fn open_wallet( - wallet_interface: Arc>>, - password: String, - top_level_directory: PathBuf, - chain_type: global::ChainTypes, - ) -> Result<(), GrinWalletInterfaceError> { - WalletInterface::inst_apis( - wallet_interface.clone(), - chain_type, - top_level_directory.clone(), - )?; - - let mut w = wallet_interface.write().unwrap(); - - if let Some(o) = &w.owner_api { - // ignoring secret key - let _ = o.open_wallet(None, password.into(), false)?; - // Start the updater - o.start_updater(None, std::time::Duration::from_secs(60))?; - w.wallet_is_open = true; - // set wallet interface chain type - w.set_chain_type(chain_type); - return Ok(()); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn close_wallet( - wallet_interface: Arc>>, - ) -> Result<(), GrinWalletInterfaceError> { - let mut w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - o.close_wallet(None); - w.wallet_is_open = false; - return Ok(()); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub fn get_wallet_updater_status( - wallet_interface: Arc>>, - ) -> Result, GrinWalletInterfaceError> { - let w = wallet_interface.read().unwrap(); - if let Some(o) = &w.owner_api { - let res = o.get_updater_messages(1)?; - return Ok(res); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub fn encrypt_slatepack( - api: &Owner, - dest: &str, - unenc_slate: &Slate, - ) -> Result { - let address = match SlatepackAddress::try_from(dest) { - Ok(a) => Some(a), - Err(_) => return Err(GrinWalletInterfaceError::InvalidSlatepackAddress), - }; - // encrypt for recipient by default - let recipients = match address.clone() { - Some(a) => vec![a], - None => vec![], - }; - Ok(api.create_slatepack_message(None, &unenc_slate, Some(0), recipients)?) - } - - /// Attempt to decode and decrypt a given slatepack, also return associated transaction (if we can find it) - pub fn decrypt_slatepack( - wallet_interface: Arc>>, - slatepack: String, - ) -> Result<(Slatepack, Slate, Option), GrinWalletInterfaceError> { - let w = wallet_interface.read().unwrap(); - if let Some(o) = &w.owner_api { - let sp = o.decode_slatepack_message(None, slatepack.clone(), vec![0])?; - let slate = o.slate_from_slatepack_message(None, slatepack, vec![0])?; - let txs = o.retrieve_txs(None, false, None, Some(slate.id), None)?; - let ret_tx = if txs.1.len() > 0 { - Some(txs.1[0].clone()) - } else { - None - }; - return Ok((sp, slate, ret_tx)); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn get_wallet_info( - wallet_interface: Arc>>, - refresh_from_node: bool, - ) -> Result<(bool, WalletInfo), GrinWalletInterfaceError> { - let w = wallet_interface.read().unwrap(); - if let Some(o) = &w.owner_api { - let res = o.retrieve_summary_info(None, refresh_from_node, 2)?; - return Ok(res); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn get_txs( - wallet_interface: Arc>>, - query_args: Option, - ) -> Result<(bool, Vec), GrinWalletInterfaceError> { - let w = wallet_interface.read().unwrap(); - if let Some(o) = &w.owner_api { - let res = o.retrieve_txs(None, true, None, None, query_args)?; - /*for tx in &mut res.1 { - if tx.amount_credited == 0 && tx.amount_debited == 0 { - let saved_tx = o.get_stored_tx(None, Some(tx.id), None); - if let Ok(st) = saved_tx { - // Todo: have to check more things here, this is just for tx display - if let Some(s) = st { - println!("TWO: {}", s.amount); - tx.amount_debited = s.amount; - } - } - } - };*/ - return Ok(res); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn get_slatepack_address( - wallet_interface: Arc>>, - ) -> Result<(String, SlatepackAddress), GrinWalletInterfaceError> { - let w = wallet_interface.read().unwrap(); - if let Some(o) = &w.owner_api { - let res = o.get_slatepack_address(None, 0)?; - return Ok((res.to_string(), res)); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn create_tx( - wallet_interface: Arc>>, - init_args: InitTxArgs, - dest_slatepack_address: String, - ) -> Result<(Slate, String), GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - let _address = match SlatepackAddress::try_from(dest_slatepack_address.as_str()) { - Ok(a) => Some(a), - Err(_) => return Err(GrinWalletInterfaceError::InvalidSlatepackAddress), - }; - if let Some(o) = &w.owner_api { - let slate = { o.init_send_tx(None, init_args)? }; - o.tx_lock_outputs(None, &slate)?; - return Ok(( - slate.clone(), - WalletInterface::encrypt_slatepack(o, &dest_slatepack_address, &slate)?, - )); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn receive_tx_from_s1( - wallet_interface: Arc>>, - slate: Slate, - dest_slatepack_address: String, - ) -> Result<(Slate, Option), GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - let ret_slate; - if let Some(f) = &w.foreign_api { - ret_slate = f.receive_tx(&slate, None, None)?; - } else { - return Err(GrinWalletInterfaceError::ForeignAPINotInstantiated); - } - if let Some(o) = &w.owner_api { - let encrypted = - WalletInterface::encrypt_slatepack(o, &dest_slatepack_address, &ret_slate)?; - return Ok((ret_slate, Some(encrypted))); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn finalize_from_s2( - wallet_interface: Arc>>, - slate: Slate, - send_to_chain: bool, - ) -> Result<(Slate, Option), GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let ret_slate = o.finalize_tx(None, &slate)?; - o.post_tx(None, &ret_slate, false)?; - return Ok((ret_slate, None)); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn cancel_tx( - wallet_interface: Arc>>, - id: u32, - ) -> Result { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - o.cancel_tx(None, Some(id), None)?; - return Ok(id); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn post_tx( - wallet_interface: Arc>>, - slate: Slate, - ) -> Result<(Slate, Option), GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let ret_slate = slate.clone(); - o.post_tx(None, &ret_slate, false)?; - return Ok((ret_slate, None)); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn contract_new( - wallet_interface: Arc>>, - args: ContractNewArgsAPI, - dest_slatepack_address: String, - ) -> Result<(Slate, String), GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let slate = o.contract_new(None, &args)?; - return Ok(( - slate.clone(), - WalletInterface::encrypt_slatepack(o, &dest_slatepack_address, &slate)?, - )); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn contract_sign( - wallet_interface: Arc>>, - slate: Slate, - args: ContractSetupArgsAPI, - dest_slatepack_address: String, - send_to_chain_if_ready: bool, - ) -> Result<(Slate, Option), GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let slate = o.contract_sign(None, &slate, &args)?; - if send_to_chain_if_ready { - if slate.state == SlateState::Standard3 || slate.state == SlateState::Invoice3 { - o.post_tx(None, &slate, false)?; - return Ok((slate.clone(), None)); - } - } - return Ok(( - slate.clone(), - Some(WalletInterface::encrypt_slatepack( - o, - &dest_slatepack_address, - &slate, - )?), - )); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn contract_self_send( - wallet_interface: Arc>>, - args: ContractNewArgsAPI, - ) -> Result<(Slate, TxLogEntry), GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let slate = o.contract_new(None, &args)?; - let slate = o.contract_sign(None, &slate, &args.setup_args)?; - let tx_log_entry = o.retrieve_txs(None, false, None, Some(slate.id), None); - if let Ok(e) = tx_log_entry { - if !e.1.is_empty() { - return Ok((slate.clone(), e.1[0].clone())); - } - } - return Err(GrinWalletInterfaceError::InvalidTxLogState); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn contract_revoke( - wallet_interface: Arc>>, - args: &ContractRevokeArgsAPI, - ) -> Result, GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let slate = o.contract_revoke(None, args)?; - return Ok(slate); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn get_slate_index_matching_my_context( - wallet_interface: Arc>>, - slate: &Slate, - ) -> Result { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let index = o.get_slate_index_matching_my_context(None, slate)?; - return Ok(index); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn retrieve_payment_proof_invoice( - wallet_interface: Arc>>, - tx_id: Option, - ) -> Result { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let res = o.retrieve_payment_proof_invoice(None, true, tx_id, None)?; - return Ok(res); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - } - - pub async fn verify_payment_proof_invoice( - wallet_interface: Arc>>, - recipient_address: &str, - proof: &InvoiceProof - ) -> Result<(), GrinWalletInterfaceError> { - let w = wallet_interface.write().unwrap(); - if let Some(f) = &w.foreign_api { - let addr = SlatepackAddress::try_from(recipient_address)?; - f.verify_payment_proof_invoice(&addr.pub_key, proof).map_err(|_| GrinWalletInterfaceError::InvalidInvoiceProof) - } else { - Err(GrinWalletInterfaceError::ForeignAPINotInstantiated) - } - } - - /*pub async fn tx_lock_outputs( - wallet_interface: Arc>>, - init_args: InitTxArgs, - ) -> Result { - let w = wallet_interface.write().unwrap(); - if let Some(o) = &w.owner_api { - let slate = { - o.init_send_tx(None, init_args)? - }; - return Ok(slate); - } else { - return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); - } - }*/ - - /*pub async fn get_recovery_phrase(wallet_interface: Arc>>, password: String) -> String { - let mut w = wallet_interface.read().unwrap(); - w.owner_api.get_mnemonic(name, password.into()) - }*/ + pub fn new(node_client: C) -> Self { + WalletInterface { + chain_type: None, + config: None, + owner_api: None, + foreign_api: None, + wallet_is_open: false, + check_node_foreign_api_secret_path: None, + node_client, + use_embedded_node: true, + } + } + + fn set_chain_type(&mut self, chain_type: global::ChainTypes) { + self.chain_type = Some(chain_type); + } + + pub fn set_check_node_foreign_api_secret_path(&mut self, secret: &str) { + self.check_node_foreign_api_secret_path = Some(secret.to_owned()) + } + + pub fn config_exists(&self, path: &str) -> bool { + grin_wallet_config::config_file_exists(&path) + } + + pub fn default_config_exists(&self) -> bool { + match self.chain_type { + Some(chain_type) => { + self.config_exists(get_grin_wallet_default_path(&chain_type).to_str().unwrap()) + } + _ => false, + } + } + + pub fn wallet_is_open(&self) -> bool { + self.wallet_is_open + } + + pub fn set_use_embedded_node( + wallet_interface: Arc>>, + value: bool, + ) { + let mut w = wallet_interface.write().unwrap(); + if w.use_embedded_node != value { + w.owner_api = None; + } + w.use_embedded_node = value; + } + + /// Sets the top level directory of the wallet and creates default config if config + /// doesn't already exist. The initial config is created based off of the chain type. + fn inst_wallet( + wallet_interface: Arc>>, + chain_type: global::ChainTypes, + top_level_directory: PathBuf, + ) -> Result< + Arc>>>, + GrinWalletInterfaceError, + > { + let mut w = wallet_interface.write().unwrap(); + // path for config file + let data_path = Some(top_level_directory.clone()); + + // creates default config file for chain type at data path + let config = + grin_wallet_config::initial_setup_wallet(&chain_type, data_path, true).unwrap(); + + // Update logging config + let mut logging_config = config.members.as_ref().unwrap().logging.clone().unwrap(); + logging_config.tui_running = Some(false); + logger::update_logging_config(logger::LogArea::Wallet, logging_config); + + let wallet_config = config.clone().members.unwrap().wallet; + + // Set node client address and Foreign API Secret if needed + if w.use_embedded_node { + w.node_client + .set_node_url(&wallet_config.check_node_api_http_addr); + + let check_node_secret = + file::get_first_line(w.check_node_foreign_api_secret_path.clone()); + w.node_client.set_node_api_secret(check_node_secret); + } + + let wallet_inst = + inst_wallet(wallet_config.clone(), w.node_client.clone()).unwrap_or_else(|e| { + println!("{}", e); + std::process::exit(1); + }); + + { + let mut wallet_lock = wallet_inst.lock(); + let lc = wallet_lock.lc_provider().unwrap(); + // set top level directory + lc.set_top_level_directory(top_level_directory.to_str().unwrap()); + } + + w.config = Some(config); + + Ok(wallet_inst) + } + + fn inst_apis( + wallet_interface: Arc>>, + chain_type: global::ChainTypes, + top_level_directory: PathBuf, + ) -> Result<(), GrinWalletInterfaceError> { + let wallet_inst = WalletInterface::inst_wallet( + wallet_interface.clone(), + chain_type, + top_level_directory, + )?; + let mut w = wallet_interface.write().unwrap(); + w.owner_api = Some(Owner::new(wallet_inst.clone(), None)); + w.foreign_api = Some(Foreign::new(wallet_inst.clone(), None, None, false)); + global::set_local_chain_type(chain_type); + + Ok(()) + } + + pub async fn init( + wallet_interface: Arc>>, + password: String, + top_level_directory: PathBuf, + display_name: String, + chain_type: global::ChainTypes, + recovery_phrase: Option, + ) -> Result<(String, String, String, global::ChainTypes), GrinWalletInterfaceError> { + WalletInterface::inst_apis( + wallet_interface.clone(), + chain_type, + top_level_directory.clone(), + )?; + + let w = wallet_interface.read().unwrap(); + + let recover_length = recovery_phrase.clone().map(|f| f.len()).unwrap_or(32); + let recover_phrase = recovery_phrase.map(|f| ZeroingString::from(f)); + + let args = InitArgs { + list_length: recover_length, + password: password.clone().into(), + config: w.config.clone().unwrap().clone().members.unwrap().wallet, + recovery_phrase: recover_phrase.clone(), + restore: recover_phrase.is_some(), + }; + + let (tld, ret_phrase) = match w.owner_api.as_ref() { + Some(o) => { + let tld = { + let mut w_lock = o.wallet_inst.lock(); + let p = w_lock.lc_provider()?; + let logging_config = w + .config + .clone() + .unwrap() + .clone() + .members + .unwrap() + .logging + .clone(); + + log::debug!( + "core::wallet::InitWallet Top Level Directory: {:?}", + p.get_top_level_directory(), + ); + + p.create_config( + &chain_type, + WALLET_CONFIG_FILE_NAME, + Some(args.config), + logging_config, + None, + )?; + + p.create_wallet( + None, + args.recovery_phrase, + args.list_length, + args.password.clone(), + chain_type == global::ChainTypes::Testnet, + )?; + + p.get_top_level_directory()? + }; + + (tld, o.get_mnemonic(None, args.password)?.to_string()) + } + None => ("".to_string(), "".to_string()), + }; + + Ok((tld, ret_phrase, display_name, chain_type)) + } + + pub async fn open_wallet( + wallet_interface: Arc>>, + password: String, + top_level_directory: PathBuf, + chain_type: global::ChainTypes, + ) -> Result<(), GrinWalletInterfaceError> { + WalletInterface::inst_apis( + wallet_interface.clone(), + chain_type, + top_level_directory.clone(), + )?; + + let mut w = wallet_interface.write().unwrap(); + + if let Some(o) = &w.owner_api { + // ignoring secret key + let _ = o.open_wallet(None, password.into(), false)?; + // Start the updater + o.start_updater(None, std::time::Duration::from_secs(60))?; + w.wallet_is_open = true; + // set wallet interface chain type + w.set_chain_type(chain_type); + return Ok(()); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn close_wallet( + wallet_interface: Arc>>, + ) -> Result<(), GrinWalletInterfaceError> { + let mut w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + o.close_wallet(None); + w.wallet_is_open = false; + return Ok(()); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub fn get_wallet_updater_status( + wallet_interface: Arc>>, + ) -> Result, GrinWalletInterfaceError> { + let w = wallet_interface.read().unwrap(); + if let Some(o) = &w.owner_api { + let res = o.get_updater_messages(1)?; + return Ok(res); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub fn encrypt_slatepack( + api: &Owner, + dest: &str, + unenc_slate: &Slate, + ) -> Result { + let address = match SlatepackAddress::try_from(dest) { + Ok(a) => Some(a), + Err(_) => return Err(GrinWalletInterfaceError::InvalidSlatepackAddress), + }; + // encrypt for recipient by default + let recipients = match address.clone() { + Some(a) => vec![a], + None => vec![], + }; + Ok(api.create_slatepack_message(None, &unenc_slate, Some(0), recipients)?) + } + + /// Attempt to decode and decrypt a given slatepack, also return associated transaction (if we can find it) + pub fn decrypt_slatepack( + wallet_interface: Arc>>, + slatepack: String, + ) -> Result<(Slatepack, Slate, Option), GrinWalletInterfaceError> { + let w = wallet_interface.read().unwrap(); + if let Some(o) = &w.owner_api { + let sp = o.decode_slatepack_message(None, slatepack.clone(), vec![0])?; + let slate = o.slate_from_slatepack_message(None, slatepack, vec![0])?; + let txs = o.retrieve_txs(None, false, None, Some(slate.id), None)?; + let ret_tx = if txs.1.len() > 0 { + Some(txs.1[0].clone()) + } else { + None + }; + return Ok((sp, slate, ret_tx)); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn get_wallet_info( + wallet_interface: Arc>>, + refresh_from_node: bool, + ) -> Result<(bool, WalletInfo), GrinWalletInterfaceError> { + let w = wallet_interface.read().unwrap(); + if let Some(o) = &w.owner_api { + let res = o.retrieve_summary_info(None, refresh_from_node, 2)?; + return Ok(res); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn get_txs( + wallet_interface: Arc>>, + query_args: Option, + ) -> Result<(bool, Vec), GrinWalletInterfaceError> { + let w = wallet_interface.read().unwrap(); + if let Some(o) = &w.owner_api { + let res = o.retrieve_txs(None, true, None, None, query_args)?; + /*for tx in &mut res.1 { + if tx.amount_credited == 0 && tx.amount_debited == 0 { + let saved_tx = o.get_stored_tx(None, Some(tx.id), None); + if let Ok(st) = saved_tx { + // Todo: have to check more things here, this is just for tx display + if let Some(s) = st { + println!("TWO: {}", s.amount); + tx.amount_debited = s.amount; + } + } + } + };*/ + return Ok(res); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn get_slatepack_address( + wallet_interface: Arc>>, + ) -> Result<(String, SlatepackAddress), GrinWalletInterfaceError> { + let w = wallet_interface.read().unwrap(); + if let Some(o) = &w.owner_api { + let res = o.get_slatepack_address(None, 0)?; + return Ok((res.to_string(), res)); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn create_tx( + wallet_interface: Arc>>, + init_args: InitTxArgs, + dest_slatepack_address: String, + ) -> Result<(Slate, String), GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + let _address = match SlatepackAddress::try_from(dest_slatepack_address.as_str()) { + Ok(a) => Some(a), + Err(_) => return Err(GrinWalletInterfaceError::InvalidSlatepackAddress), + }; + if let Some(o) = &w.owner_api { + let slate = { o.init_send_tx(None, init_args)? }; + o.tx_lock_outputs(None, &slate)?; + return Ok(( + slate.clone(), + WalletInterface::encrypt_slatepack(o, &dest_slatepack_address, &slate)?, + )); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn receive_tx_from_s1( + wallet_interface: Arc>>, + slate: Slate, + dest_slatepack_address: String, + ) -> Result<(Slate, Option), GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + let ret_slate; + if let Some(f) = &w.foreign_api { + ret_slate = f.receive_tx(&slate, None, None)?; + } else { + return Err(GrinWalletInterfaceError::ForeignAPINotInstantiated); + } + if let Some(o) = &w.owner_api { + let encrypted = + WalletInterface::encrypt_slatepack(o, &dest_slatepack_address, &ret_slate)?; + return Ok((ret_slate, Some(encrypted))); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn finalize_from_s2( + wallet_interface: Arc>>, + slate: Slate, + send_to_chain: bool, + ) -> Result<(Slate, Option), GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let ret_slate = o.finalize_tx(None, &slate)?; + o.post_tx(None, &ret_slate, false)?; + return Ok((ret_slate, None)); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn cancel_tx( + wallet_interface: Arc>>, + uuid: uuid::Uuid, + ) -> Result { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + o.cancel_tx(None, None, Some(uuid))?; + return Ok(uuid); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn post_tx( + wallet_interface: Arc>>, + slate: Slate, + ) -> Result<(Slate, Option), GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let ret_slate = slate.clone(); + o.post_tx(None, &ret_slate, false)?; + return Ok((ret_slate, None)); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn contract_new( + wallet_interface: Arc>>, + args: ContractNewArgsAPI, + dest_slatepack_address: String, + ) -> Result<(Slate, String), GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let slate = o.contract_new(None, &args)?; + return Ok(( + slate.clone(), + WalletInterface::encrypt_slatepack(o, &dest_slatepack_address, &slate)?, + )); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn contract_sign( + wallet_interface: Arc>>, + slate: Slate, + args: ContractSetupArgsAPI, + dest_slatepack_address: String, + send_to_chain_if_ready: bool, + ) -> Result<(Slate, Option), GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let slate = o.contract_sign(None, &slate, &args)?; + if send_to_chain_if_ready { + if slate.state == SlateState::Standard3 || slate.state == SlateState::Invoice3 { + o.post_tx(None, &slate, false)?; + return Ok((slate.clone(), None)); + } + } + return Ok(( + slate.clone(), + Some(WalletInterface::encrypt_slatepack( + o, + &dest_slatepack_address, + &slate, + )?), + )); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn contract_self_send( + wallet_interface: Arc>>, + args: ContractNewArgsAPI, + ) -> Result<(Slate, TxLogEntry), GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let slate = o.contract_new(None, &args)?; + let slate = o.contract_sign(None, &slate, &args.setup_args)?; + let tx_log_entry = o.retrieve_txs(None, false, None, Some(slate.id), None); + if let Ok(e) = tx_log_entry { + if !e.1.is_empty() { + return Ok((slate.clone(), e.1[0].clone())); + } + } + return Err(GrinWalletInterfaceError::InvalidTxLogState); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn contract_revoke( + wallet_interface: Arc>>, + args: &ContractRevokeArgsAPI, + ) -> Result, GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let slate = o.contract_revoke(None, args)?; + return Ok(slate); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn get_slate_index_matching_my_context( + wallet_interface: Arc>>, + slate: &Slate, + ) -> Result { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let index = o.get_slate_index_matching_my_context(None, slate)?; + return Ok(index); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn retrieve_payment_proof_invoice( + wallet_interface: Arc>>, + tx_id: Option, + ) -> Result { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let res = o.retrieve_payment_proof_invoice(None, true, tx_id, None)?; + return Ok(res); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + } + + pub async fn verify_payment_proof_invoice( + wallet_interface: Arc>>, + recipient_address: &str, + proof: &InvoiceProof, + ) -> Result<(), GrinWalletInterfaceError> { + let w = wallet_interface.write().unwrap(); + if let Some(f) = &w.foreign_api { + let addr = SlatepackAddress::try_from(recipient_address)?; + f.verify_payment_proof_invoice(&addr.pub_key, proof) + .map_err(|_| GrinWalletInterfaceError::InvalidInvoiceProof) + } else { + Err(GrinWalletInterfaceError::ForeignAPINotInstantiated) + } + } + + /*pub async fn tx_lock_outputs( + wallet_interface: Arc>>, + init_args: InitTxArgs, + ) -> Result { + let w = wallet_interface.write().unwrap(); + if let Some(o) = &w.owner_api { + let slate = { + o.init_send_tx(None, init_args)? + }; + return Ok(slate); + } else { + return Err(GrinWalletInterfaceError::OwnerAPINotInstantiated); + } + }*/ + + /*pub async fn get_recovery_phrase(wallet_interface: Arc>>, password: String) -> String { + let mut w = wallet_interface.read().unwrap(); + w.owner_api.get_mnemonic(name, password.into()) + }*/ } diff --git a/src/gui/element/wallet/operation/apply_tx.rs b/src/gui/element/wallet/operation/apply_tx.rs index a2bd7ca..269e2bc 100644 --- a/src/gui/element/wallet/operation/apply_tx.rs +++ b/src/gui/element/wallet/operation/apply_tx.rs @@ -95,7 +95,7 @@ pub fn handle_message<'a>( let tx_id = match state.confirm_state.slatepack_parsed.as_ref() { Some(p) => { if let Some(t) = p.2.as_ref() { - Some(t.id) + t.tx_slate_id.clone() } else { None } @@ -198,7 +198,7 @@ pub fn handle_message<'a>( let tx_id = match state.confirm_state.slatepack_parsed.as_ref() { Some(p) => { if let Some(t) = p.2.as_ref() { - Some(t.id) + t.tx_slate_id.clone() } else { None } diff --git a/src/gui/element/wallet/operation/home.rs b/src/gui/element/wallet/operation/home.rs index 2bbb959..5586c29 100644 --- a/src/gui/element/wallet/operation/home.rs +++ b/src/gui/element/wallet/operation/home.rs @@ -104,7 +104,7 @@ pub enum LocalViewInteraction { CancelTx(u32, String), TxDetails(TxLogEntryWrap), TxProof(TxLogEntryWrap), - TxCancelledOk(u32, String), + TxCancelledOk(String), TxCancelError(Arc>>), ProofRetrievedOk(InvoiceProof, TxLogEntryWrap), ProofRetrievedError(Arc>>), @@ -404,14 +404,15 @@ pub fn handle_message<'a>( log::debug!("Interaction::WalletOperationHomeViewInteraction::CancelTx"); let w = grin_gui.wallet_interface.clone(); + let in_uuid = uuid.clone(); - let fut = move || WalletInterface::cancel_tx(w, id); + let fut = move || WalletInterface::cancel_tx(w, uuid::Uuid::parse_str(&uuid).unwrap()); return Ok(Command::perform(fut(), |r| { match r.context("Failed to Cancel Transaction") { Ok(ret) => { Message::Interaction(Interaction::WalletOperationHomeViewInteraction( - LocalViewInteraction::TxCancelledOk(ret, uuid), + LocalViewInteraction::TxCancelledOk(in_uuid), )) } Err(e) => { @@ -422,7 +423,7 @@ pub fn handle_message<'a>( } })); } - LocalViewInteraction::TxCancelledOk(id, uuid) => { + LocalViewInteraction::TxCancelledOk(uuid) => { // Delete file if let Some(dir) = grin_gui.config.get_wallet_slatepack_dir() { let out_file_name = format!("{}/{}.slatepack", dir, uuid); From f62428bc93c71d9412a328a7b157b6ad5b894765 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Fri, 23 Feb 2024 17:05:29 +0000 Subject: [PATCH 5/6] add updated --- Cargo.lock | 242 +++++++++++++++++++++++++---------------------------- 1 file changed, 116 insertions(+), 126 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 218b78c..a9ed98d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,9 +94,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" +checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f" dependencies = [ "cfg-if 1.0.0", "once_cell", @@ -175,9 +175,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "approx" @@ -270,7 +270,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 5.0.0", + "event-listener 5.1.0", "event-listener-strategy 0.5.0", "futures-core", "pin-project-lite 0.2.13", @@ -337,7 +337,7 @@ dependencies = [ "futures-io", "futures-lite 2.2.0", "parking", - "polling 3.4.0", + "polling 3.5.0", "rustix 0.38.31", "slab", "tracing", @@ -695,9 +695,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" [[package]] name = "byte-tools" @@ -722,7 +722,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -806,7 +806,7 @@ checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" dependencies = [ "bitflags 2.4.2", "log", - "polling 3.4.0", + "polling 3.5.0", "rustix 0.38.31", "slab", "thiserror", @@ -844,11 +844,10 @@ checksum = "a2698f953def977c68f935bb0dfa959375ad4638570e969e2f1e9f433cbf1af6" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" dependencies = [ - "jobserver", "libc", ] @@ -916,7 +915,7 @@ dependencies = [ "num-traits 0.2.18", "serde", "wasm-bindgen", - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -1296,7 +1295,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "socket2 0.5.5", + "socket2 0.5.6", "windows-sys 0.52.0", ] @@ -1538,7 +1537,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -1734,9 +1733,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.0.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72557800024fabbaa2449dd4bf24e37b93702d457a4d4f2b0dd1f0f039f20c1" +checksum = "b7ad6fd685ce13acd6d9541a30f6db6567a7a24c9ffd4ba2955d29e3f22c8b27" dependencies = [ "concurrent-queue", "parking", @@ -1759,7 +1758,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" dependencies = [ - "event-listener 5.0.0", + "event-listener 5.1.0", "pin-project-lite 0.2.13", ] @@ -2119,7 +2118,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -2794,7 +2793,7 @@ dependencies = [ [[package]] name = "grin_wallet" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#6f226ea3e26917a472f24ccd677993439a142695" dependencies = [ "built", "clap", @@ -2821,7 +2820,7 @@ dependencies = [ [[package]] name = "grin_wallet_api" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#6f226ea3e26917a472f24ccd677993439a142695" dependencies = [ "base64 0.12.3", "chrono", @@ -2846,7 +2845,7 @@ dependencies = [ [[package]] name = "grin_wallet_config" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#6f226ea3e26917a472f24ccd677993439a142695" dependencies = [ "dirs 2.0.2", "grin_core", @@ -2861,7 +2860,7 @@ dependencies = [ [[package]] name = "grin_wallet_controller" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#6f226ea3e26917a472f24ccd677993439a142695" dependencies = [ "chrono", "easy-jsonrpc-mw", @@ -2895,7 +2894,7 @@ dependencies = [ [[package]] name = "grin_wallet_impls" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#6f226ea3e26917a472f24ccd677993439a142695" dependencies = [ "base64 0.12.3", "blake2-rfc", @@ -2934,7 +2933,7 @@ dependencies = [ [[package]] name = "grin_wallet_libwallet" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#6f226ea3e26917a472f24ccd677993439a142695" dependencies = [ "age", "base64 0.9.3", @@ -2975,7 +2974,7 @@ dependencies = [ [[package]] name = "grin_wallet_util" version = "5.2.0-beta.1" -source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#074fa243b5a91a341a67e71c12f747914aeda4de" +source = "git+https://github.com/mimblewimble/grin-wallet?branch=contracts#6f226ea3e26917a472f24ccd677993439a142695" dependencies = [ "data-encoding", "ed25519-dalek", @@ -3269,7 +3268,7 @@ dependencies = [ "httpdate 1.0.3", "itoa 1.0.10", "pin-project-lite 0.2.13", - "socket2 0.5.5", + "socket2 0.5.6", "tokio 1.36.0", "tower-service", "tracing", @@ -3400,7 +3399,7 @@ dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", "strsim 0.10.0", - "syn 2.0.48", + "syn 2.0.50", "unic-langid", ] @@ -3414,7 +3413,7 @@ dependencies = [ "i18n-config", "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -3655,16 +3654,16 @@ dependencies = [ [[package]] name = "image" -version = "0.24.8" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", "color_quant", "jpeg-decoder 0.3.1", "num-traits 0.2.18", - "png 0.17.11", + "png 0.17.13", ] [[package]] @@ -3848,15 +3847,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" -[[package]] -name = "jobserver" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" -dependencies = [ - "libc", -] - [[package]] name = "jpeg-decoder" version = "0.1.22" @@ -4813,7 +4803,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -4935,9 +4925,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.63" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ "bitflags 2.4.2", "cfg-if 1.0.0", @@ -4956,7 +4946,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -4967,9 +4957,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.99" +version = "0.9.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" dependencies = [ "cc", "libc", @@ -5016,7 +5006,7 @@ dependencies = [ "proc-macro-error", "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -5048,7 +5038,7 @@ checksum = "e05d1c929301fee6830dafa764341118829b2535c216b0571e3821ecac5c885b" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -5280,7 +5270,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -5318,7 +5308,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -5364,7 +5354,7 @@ checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" dependencies = [ "chrono", "font-kit", - "image 0.24.8", + "image 0.24.9", "lazy_static", "num-traits 0.2.18", "pathfinder_geometry", @@ -5389,7 +5379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cebbe1f70205299abc69e8b295035bb52a6a70ee35474ad10011f0a4efb8543" dependencies = [ "gif 0.12.0", - "image 0.24.8", + "image 0.24.9", "plotters-backend", ] @@ -5429,9 +5419,9 @@ dependencies = [ [[package]] name = "png" -version = "0.17.11" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f6c3c3e617595665b8ea2ff95a86066be38fb121ff920a9c0eb282abcd1da5a" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -5458,9 +5448,9 @@ dependencies = [ [[package]] name = "polling" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30054e72317ab98eddd8561db0f6524df3367636884b7b21b703e4b280a84a14" +checksum = "24f040dee2588b4963afb4e420540439d126f73fdacf4a9c486a96d840bac3c9" dependencies = [ "cfg-if 1.0.0", "concurrent-queue", @@ -5555,9 +5545,9 @@ dependencies = [ [[package]] name = "profiling" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0f7f43585c34e4fdd7497d746bc32e14458cf11c69341cc0587b1d825dde42" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" [[package]] name = "qr_code" @@ -6142,7 +6132,7 @@ dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", "rust-embed-utils", - "syn 2.0.48", + "syn 2.0.50", "walkdir", ] @@ -6180,7 +6170,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.21", + "semver 1.0.22", ] [[package]] @@ -6301,9 +6291,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "safemem" @@ -6491,9 +6481,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "semver-parser" @@ -6503,9 +6493,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -6522,20 +6512,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa 1.0.10", "ryu", @@ -6758,9 +6748,9 @@ dependencies = [ [[package]] name = "smithay-clipboard" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb62b280ce5a5cba847669933a0948d00904cf83845c944eae96a4738cea1a6" +checksum = "c091e7354ea8059d6ad99eace06dd13ddeedbb0ac72d40a9a6e7ff790525882d" dependencies = [ "libc", "smithay-client-toolkit 0.18.1", @@ -6790,12 +6780,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -7000,9 +6990,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", @@ -7170,7 +7160,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -7186,9 +7176,9 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if 1.0.0", "once_cell", @@ -7245,7 +7235,7 @@ dependencies = [ "arrayvec 0.7.4", "bytemuck", "cfg-if 1.0.0", - "png 0.17.11", + "png 0.17.13", "tiny-skia-path 0.8.4", ] @@ -7260,7 +7250,7 @@ dependencies = [ "bytemuck", "cfg-if 1.0.0", "log", - "png 0.17.11", + "png 0.17.13", "tiny-skia-path 0.10.0", ] @@ -7346,7 +7336,7 @@ dependencies = [ "mio 0.8.10", "num_cpus", "pin-project-lite 0.2.13", - "socket2 0.5.5", + "socket2 0.5.6", "windows-sys 0.48.0", ] @@ -7488,7 +7478,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.5", + "toml_edit 0.22.6", ] [[package]] @@ -7513,15 +7503,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e68c159e8f5ba8a28c4eb7b0c0c190d77bb479047ca713270048145a9ad28a" +checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" dependencies = [ "indexmap 2.2.3", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.1", + "winnow 0.6.2", ] [[package]] @@ -7550,7 +7540,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -7703,18 +7693,18 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-script" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d817255e1bed6dfd4ca47258685d14d2bdcfbc64fdc9e3819bd5848057b8ecc" +checksum = "ad8d71f5726e5f285a935e9fe8edfd53f0491eb6e9a5774097fdabee7cd8c9cd" [[package]] name = "unicode-segmentation" @@ -7908,7 +7898,7 @@ dependencies = [ "once_cell", "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", "wasm-bindgen-shared", ] @@ -7942,7 +7932,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8431,7 +8421,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -8458,7 +8448,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -8493,17 +8483,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.3", + "windows_aarch64_msvc 0.52.3", + "windows_i686_gnu 0.52.3", + "windows_i686_msvc 0.52.3", + "windows_x86_64_gnu 0.52.3", + "windows_x86_64_gnullvm 0.52.3", + "windows_x86_64_msvc 0.52.3", ] [[package]] @@ -8520,9 +8510,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" [[package]] name = "windows_aarch64_msvc" @@ -8538,9 +8528,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" [[package]] name = "windows_i686_gnu" @@ -8556,9 +8546,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" [[package]] name = "windows_i686_msvc" @@ -8574,9 +8564,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" [[package]] name = "windows_x86_64_gnu" @@ -8592,9 +8582,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" [[package]] name = "windows_x86_64_gnullvm" @@ -8610,9 +8600,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" [[package]] name = "windows_x86_64_msvc" @@ -8628,9 +8618,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" [[package]] name = "winit" @@ -8678,9 +8668,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401" +checksum = "7a4191c47f15cc3ec71fcb4913cb83d58def65dd3787610213c649283b5ce178" dependencies = [ "memchr", ] @@ -8892,7 +8882,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] @@ -8912,7 +8902,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2 1.0.78", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.50", ] [[package]] From 9c96020e8a3e0a11f2e15b963b6ef921aaf7de55 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Mon, 26 Feb 2024 10:40:48 +0000 Subject: [PATCH 6/6] small fixes + version increment --- Cargo.lock | 6 +++--- Cargo.toml | 6 +++--- crates/core/Cargo.toml | 2 +- crates/widgets/Cargo.toml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9ed98d..4f63e11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2432,7 +2432,7 @@ dependencies = [ [[package]] name = "grin-gui" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "anyhow", "async-std", @@ -2479,7 +2479,7 @@ dependencies = [ [[package]] name = "grin-gui-core" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "async-std", "backtrace", @@ -2537,7 +2537,7 @@ dependencies = [ [[package]] name = "grin-gui-widgets" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" dependencies = [ "iced", "iced_core", diff --git a/Cargo.toml b/Cargo.toml index 6c2927c..5ba3aac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "grin-gui" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" authors = ["Grin Developers "] description = "GUI wrapping grin and grin-wallet. Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format." license = "Apache-2.0" @@ -16,8 +16,8 @@ no-self-update = ["grin-gui-core/no-self-update"] debug = ["iced/debug"] [dependencies] -grin-gui-core = { version = "0.1.0-alpha.4", path = "crates/core", features = ["wgpu"]} -grin-gui-widgets = { version = "0.1.0-alpha.4", path = "crates/widgets" } +grin-gui-core = { version = "0.1.0-alpha.5", path = "crates/core", features = ["wgpu"]} +grin-gui-widgets = { version = "0.1.0-alpha.5", path = "crates/widgets" } iced = { version = "0.10", features = ["canvas", "tokio"] } iced_futures = { version = "0.7", features = ["async-std"] } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 0ff2b08..d2b37db 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "grin-gui-core" description = "Core GUI library for Grin GUI" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" authors = ["Yeastplume", "Casper Rogild Storm"] license = "GPL-3.0" homepage = "https://github.com/mimblewimble/grin-gui" diff --git a/crates/widgets/Cargo.toml b/crates/widgets/Cargo.toml index 341eab6..7ee49f9 100644 --- a/crates/widgets/Cargo.toml +++ b/crates/widgets/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "grin-gui-widgets" description = "Widget library for Grin Core GUI" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" authors = ["Yeastplume", "Casper Rogild Storm", "tarkah "] license = "GPL-3.0" homepage = "https://github.com/mimblewimble/grin-gui"