wallet: update to last version, removing separate node module, added ability to finalize tx over tor

This commit is contained in:
ardocrat
2026-06-23 15:35:17 +03:00
parent 3981ebe3ed
commit 20db758bc2
9 changed files with 574 additions and 471 deletions
+1 -4
View File
@@ -1,10 +1,7 @@
[submodule "node"]
path = node
url = https://code.gri.mw/ardocrat/node
[submodule "wallet"]
path = wallet
url = https://code.gri.mw/ardocrat/wallet
branch = grim
branch = grim-staging
[submodule "tor/webtunnel"]
path = tor/webtunnel
url = https://code.gri.mw/WEB/webtunnel
Generated
+509 -415
View File
File diff suppressed because it is too large Load Diff
+8 -14
View File
@@ -29,14 +29,14 @@ panic = "abort"
log = "0.4.27"
# node
grin_api = { path = "node/api" }
grin_chain = { path = "node/chain" }
grin_config = { path = "node/config" }
grin_core = { path = "node/core" }
grin_p2p = { path = "node/p2p" }
grin_servers = { path = "node/servers" }
grin_keychain = { path = "node/keychain" }
grin_util = { path = "node/util" }
grin_api = { path = "wallet/grin/api" }
grin_chain = { path = "wallet/grin/chain" }
grin_config = { path = "wallet/grin/config" }
grin_core = { path = "wallet/grin/core" }
grin_p2p = { path = "wallet/grin/p2p" }
grin_servers = { path = "wallet/grin/servers" }
grin_keychain = { path = "wallet/grin/keychain" }
grin_util = { path = "wallet/grin/util" }
# wallet
grin_wallet_impls = { path = "wallet/impls" }
@@ -53,10 +53,7 @@ rust-i18n = "3.1.5"
## other
log4rs = "1.4.0"
anyhow = "1.0.97"
pin-project = "1.1.10"
backtrace = "0.3.76"
thiserror = "2.0.18"
futures = "0.3.31"
dirs = "6.0.0"
sys-locale = "0.3.2"
@@ -101,12 +98,9 @@ tor-hsrproxy = "0.43.0"
tor-keymgr = "0.43.0"
tor-llcrypto = "0.43.0"
tor-hscrypto = "0.43.0"
tor-error = "0.43.0"
sha2 = "0.10.8"
ed25519-dalek = "2.1.1"
curve25519-dalek = "4.1.3"
tls-api = "0.12.0"
tls-api-native-tls = "0.12.1"
safelog = "0.8.1"
## stratum server
Submodule node deleted from bce5a7144b
+1 -1
View File
@@ -646,7 +646,7 @@ impl WalletTransactionsContent {
if let Some(a) = &tx.receiver {
wallet.task(WalletTask::SendTor(tx.data.clone(), a.clone()));
} else {
wallet.task(WalletTask::PayTor(tx.data.clone()));
wallet.task(WalletTask::FinalizeTor(tx.data.clone()));
}
});
}
+7 -7
View File
@@ -12,13 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::scroll_area::ScrollBarVisibility;
use egui::{Align, CornerRadius, Id, Layout, RichText, ScrollArea, StrokeKind};
use grin_core::core::amount_to_hr_string;
use grin_util::ToHex;
use grin_wallet_libwallet::TxLogEntryType;
use std::fs;
use crate::AppConfig;
use crate::gui::Colors;
use crate::gui::icons::{
@@ -34,6 +27,13 @@ use crate::gui::views::{Modal, QrCodeContent, View};
use crate::wallet::Wallet;
use crate::wallet::types::{WalletTask, WalletTx};
use egui::scroll_area::ScrollBarVisibility;
use egui::{Align, CornerRadius, Id, Layout, RichText, ScrollArea, StrokeKind};
use grin_core::core::amount_to_hr_string;
use grin_util::ToHex;
use grin_wallet_libwallet::TxLogEntryType;
use std::fs;
/// Transaction information [`Modal`] content.
pub struct WalletTransactionContent {
/// Transaction identifier.
+2 -2
View File
@@ -406,9 +406,9 @@ pub enum WalletTask {
/// * tx
/// * receiver
SendTor(TxLogEntry, SlatepackAddress),
/// Pay over Tor.
/// Finalize over Tor.
/// * tx
PayTor(TxLogEntry),
FinalizeTor(TxLogEntry),
/// Invoice creation.
/// * amount
Receive(u64, Option<SlatepackAddress>),
+42 -23
View File
@@ -39,6 +39,7 @@ use grin_wallet_impls::{DefaultLCProvider, DefaultWalletImpl, HTTPNodeClient};
use grin_wallet_libwallet::api_impl::owner::{
cancel_tx, init_send_tx, retrieve_summary_info, retrieve_txs, verify_payment_proof,
};
use grin_wallet_libwallet::api_impl::types::update_tx_slate_state;
use grin_wallet_libwallet::{
Error, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, Slate, SlateState,
SlateVersion, SlatepackAddress, StatusMessage, StoredProofInfo, TxLogEntry, TxLogEntryType,
@@ -1316,6 +1317,18 @@ impl Wallet {
None
}
/// Update transaction slate state.
fn update_slate_state(&self, slate: &Slate) -> Result<(), Error> {
let r_inst = self.instance.as_ref().read();
let instance = r_inst.clone().unwrap();
let mut w_lock = instance.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
let keychain_mask = self.keychain_mask();
let parent_key = w.parent_key_id();
update_tx_slate_state(w, keychain_mask.as_ref(), &parent_key, slate)?;
Ok(())
}
/// Delete transaction from database.
fn delete_tx(&self, id: u32) -> Result<(), Error> {
self.on_tx_action(id, Some(WalletTxAction::Deleting));
@@ -1735,6 +1748,7 @@ fn start_sync(wallet: Wallet) -> Thread {
/// Handle wallet task.
async fn handle_task(w: &Wallet, t: WalletTask) {
// Send amount over Tor.
let send_tor = async |tx: TxLogEntry, s: &Slate, r: &SlatepackAddress| match w
.send_tor(tx.id, &s, r, false)
.await
@@ -1746,34 +1760,35 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
w.on_task_result(Some(tx), &t);
}
Err(e) => {
error!("send tor post error: {:?}", e);
error!("Send Tor post error: {:?}", e);
w.on_tx_error(tx.id, Some(e));
}
},
Err(e) => {
error!("send tor finalize error: {:?}", e);
error!("Send Tor finalize error: {:?}", e);
w.task(WalletTask::Cancel(tx.id));
}
},
Err(e) => {
error!("send tor error: {:?}", e);
error!("Send Tor error: {:?}", e);
w.on_tx_error(tx.id, Some(e));
w.on_task_result(Some(tx), &t);
}
};
// Invoice-flow counterpart to send_tor. After signing an invoice the payer
// posts the slate to the merchant's foreign-api finalize_tx; the merchant
// finalizes + broadcasts on their side, so no local finalize/post is needed.
let pay_tor = async |tx: TxLogEntry, s: &Slate, r: &SlatepackAddress| match w
// Finalize tx over Tor.
let finalize_tor = async |tx: TxLogEntry, s: &Slate, r: &SlatepackAddress| match w
.send_tor(tx.id, &s, r, true)
.await
{
Ok(_) => {
Ok(s) => {
w.on_tx_action(tx.id, None);
let _ = w.update_slate_state(&s);
let _ = w.create_slatepack_message(&s, None);
sync_wallet_data(&w, false);
w.on_task_result(Some(tx), &t);
}
Err(e) => {
error!("pay tor error: {:?}", e);
error!("Finalize Tor error: {:?}", e);
w.on_tx_error(tx.id, Some(e));
w.on_task_result(Some(tx), &t);
}
@@ -1809,17 +1824,8 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
w.message_opening.store(false, Ordering::Relaxed);
return;
}
// Create response or finalize.
match s.state {
SlateState::Standard1 => {
if let Ok(_) = w.receive(&s, dest) {
sync_wallet_data(&w, false);
let tx = w.retrieve_tx_by_id(None, Some(s.id));
w.on_task_result(tx, &t);
}
}
SlateState::Invoice1 => {
if let Ok(signed) = w.pay(&s, None) {
// Finalize over Tor if service is running.
let maybe_finalize_tor = async |s: Slate| {
sync_wallet_data(&w, false);
let tx = w.retrieve_tx_by_id(None, Some(s.id));
let id = w.identifier();
@@ -1827,11 +1833,24 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
if let Some(tx) = tx.as_ref() {
if let Some(addr) = dest {
w.message_opening.store(false, Ordering::Relaxed);
pay_tor(tx.clone(), &signed, &addr).await;
finalize_tor(tx.clone(), &s, &addr).await;
return;
}
}
}
};
// Create response or finalize.
match s.state {
SlateState::Standard1 => {
if let Ok(s) = w.receive(&s, None) {
maybe_finalize_tor(s).await;
w.on_task_result(tx, &t);
}
}
SlateState::Invoice1 => {
if let Ok(s) = w.pay(&s, None) {
sync_wallet_data(&w, false);
maybe_finalize_tor(s).await;
w.on_task_result(tx, &t);
}
}
@@ -1907,10 +1926,10 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
send_tor(tx.clone(), &slate, r).await;
}
}
WalletTask::PayTor(tx) => {
WalletTask::FinalizeTor(tx) => {
if let Some((slate, dest)) = w.get_tx_slate(tx.id) {
if let Some(dest) = dest {
pay_tor(tx.clone(), &slate, &dest).await;
finalize_tor(tx.clone(), &slate, &dest).await;
}
}
}
+1 -1
Submodule wallet updated: c2db754552...5c54e7cf8d