wallet: update to last version, removing separate node module, added ability to finalize tx over tor
This commit is contained in:
+1
-4
@@ -1,10 +1,7 @@
|
|||||||
[submodule "node"]
|
|
||||||
path = node
|
|
||||||
url = https://code.gri.mw/ardocrat/node
|
|
||||||
[submodule "wallet"]
|
[submodule "wallet"]
|
||||||
path = wallet
|
path = wallet
|
||||||
url = https://code.gri.mw/ardocrat/wallet
|
url = https://code.gri.mw/ardocrat/wallet
|
||||||
branch = grim
|
branch = grim-staging
|
||||||
[submodule "tor/webtunnel"]
|
[submodule "tor/webtunnel"]
|
||||||
path = tor/webtunnel
|
path = tor/webtunnel
|
||||||
url = https://code.gri.mw/WEB/webtunnel
|
url = https://code.gri.mw/WEB/webtunnel
|
||||||
|
|||||||
Generated
+509
-415
File diff suppressed because it is too large
Load Diff
+8
-14
@@ -29,14 +29,14 @@ panic = "abort"
|
|||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
|
|
||||||
# node
|
# node
|
||||||
grin_api = { path = "node/api" }
|
grin_api = { path = "wallet/grin/api" }
|
||||||
grin_chain = { path = "node/chain" }
|
grin_chain = { path = "wallet/grin/chain" }
|
||||||
grin_config = { path = "node/config" }
|
grin_config = { path = "wallet/grin/config" }
|
||||||
grin_core = { path = "node/core" }
|
grin_core = { path = "wallet/grin/core" }
|
||||||
grin_p2p = { path = "node/p2p" }
|
grin_p2p = { path = "wallet/grin/p2p" }
|
||||||
grin_servers = { path = "node/servers" }
|
grin_servers = { path = "wallet/grin/servers" }
|
||||||
grin_keychain = { path = "node/keychain" }
|
grin_keychain = { path = "wallet/grin/keychain" }
|
||||||
grin_util = { path = "node/util" }
|
grin_util = { path = "wallet/grin/util" }
|
||||||
|
|
||||||
# wallet
|
# wallet
|
||||||
grin_wallet_impls = { path = "wallet/impls" }
|
grin_wallet_impls = { path = "wallet/impls" }
|
||||||
@@ -53,10 +53,7 @@ rust-i18n = "3.1.5"
|
|||||||
|
|
||||||
## other
|
## other
|
||||||
log4rs = "1.4.0"
|
log4rs = "1.4.0"
|
||||||
anyhow = "1.0.97"
|
|
||||||
pin-project = "1.1.10"
|
|
||||||
backtrace = "0.3.76"
|
backtrace = "0.3.76"
|
||||||
thiserror = "2.0.18"
|
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
sys-locale = "0.3.2"
|
sys-locale = "0.3.2"
|
||||||
@@ -101,12 +98,9 @@ tor-hsrproxy = "0.43.0"
|
|||||||
tor-keymgr = "0.43.0"
|
tor-keymgr = "0.43.0"
|
||||||
tor-llcrypto = "0.43.0"
|
tor-llcrypto = "0.43.0"
|
||||||
tor-hscrypto = "0.43.0"
|
tor-hscrypto = "0.43.0"
|
||||||
tor-error = "0.43.0"
|
|
||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
ed25519-dalek = "2.1.1"
|
ed25519-dalek = "2.1.1"
|
||||||
curve25519-dalek = "4.1.3"
|
curve25519-dalek = "4.1.3"
|
||||||
tls-api = "0.12.0"
|
|
||||||
tls-api-native-tls = "0.12.1"
|
|
||||||
safelog = "0.8.1"
|
safelog = "0.8.1"
|
||||||
|
|
||||||
## stratum server
|
## stratum server
|
||||||
|
|||||||
-1
Submodule node deleted from bce5a7144b
@@ -646,7 +646,7 @@ impl WalletTransactionsContent {
|
|||||||
if let Some(a) = &tx.receiver {
|
if let Some(a) = &tx.receiver {
|
||||||
wallet.task(WalletTask::SendTor(tx.data.clone(), a.clone()));
|
wallet.task(WalletTask::SendTor(tx.data.clone(), a.clone()));
|
||||||
} else {
|
} else {
|
||||||
wallet.task(WalletTask::PayTor(tx.data.clone()));
|
wallet.task(WalletTask::FinalizeTor(tx.data.clone()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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::AppConfig;
|
||||||
use crate::gui::Colors;
|
use crate::gui::Colors;
|
||||||
use crate::gui::icons::{
|
use crate::gui::icons::{
|
||||||
@@ -34,6 +27,13 @@ use crate::gui::views::{Modal, QrCodeContent, View};
|
|||||||
use crate::wallet::Wallet;
|
use crate::wallet::Wallet;
|
||||||
use crate::wallet::types::{WalletTask, WalletTx};
|
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.
|
/// Transaction information [`Modal`] content.
|
||||||
pub struct WalletTransactionContent {
|
pub struct WalletTransactionContent {
|
||||||
/// Transaction identifier.
|
/// Transaction identifier.
|
||||||
|
|||||||
+2
-2
@@ -406,9 +406,9 @@ pub enum WalletTask {
|
|||||||
/// * tx
|
/// * tx
|
||||||
/// * receiver
|
/// * receiver
|
||||||
SendTor(TxLogEntry, SlatepackAddress),
|
SendTor(TxLogEntry, SlatepackAddress),
|
||||||
/// Pay over Tor.
|
/// Finalize over Tor.
|
||||||
/// * tx
|
/// * tx
|
||||||
PayTor(TxLogEntry),
|
FinalizeTor(TxLogEntry),
|
||||||
/// Invoice creation.
|
/// Invoice creation.
|
||||||
/// * amount
|
/// * amount
|
||||||
Receive(u64, Option<SlatepackAddress>),
|
Receive(u64, Option<SlatepackAddress>),
|
||||||
|
|||||||
+45
-26
@@ -39,6 +39,7 @@ use grin_wallet_impls::{DefaultLCProvider, DefaultWalletImpl, HTTPNodeClient};
|
|||||||
use grin_wallet_libwallet::api_impl::owner::{
|
use grin_wallet_libwallet::api_impl::owner::{
|
||||||
cancel_tx, init_send_tx, retrieve_summary_info, retrieve_txs, verify_payment_proof,
|
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::{
|
use grin_wallet_libwallet::{
|
||||||
Error, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, Slate, SlateState,
|
Error, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, Slate, SlateState,
|
||||||
SlateVersion, SlatepackAddress, StatusMessage, StoredProofInfo, TxLogEntry, TxLogEntryType,
|
SlateVersion, SlatepackAddress, StatusMessage, StoredProofInfo, TxLogEntry, TxLogEntryType,
|
||||||
@@ -1316,6 +1317,18 @@ impl Wallet {
|
|||||||
None
|
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.
|
/// Delete transaction from database.
|
||||||
fn delete_tx(&self, id: u32) -> Result<(), Error> {
|
fn delete_tx(&self, id: u32) -> Result<(), Error> {
|
||||||
self.on_tx_action(id, Some(WalletTxAction::Deleting));
|
self.on_tx_action(id, Some(WalletTxAction::Deleting));
|
||||||
@@ -1735,6 +1748,7 @@ fn start_sync(wallet: Wallet) -> Thread {
|
|||||||
|
|
||||||
/// Handle wallet task.
|
/// Handle wallet task.
|
||||||
async fn handle_task(w: &Wallet, t: WalletTask) {
|
async fn handle_task(w: &Wallet, t: WalletTask) {
|
||||||
|
// Send amount over Tor.
|
||||||
let send_tor = async |tx: TxLogEntry, s: &Slate, r: &SlatepackAddress| match w
|
let send_tor = async |tx: TxLogEntry, s: &Slate, r: &SlatepackAddress| match w
|
||||||
.send_tor(tx.id, &s, r, false)
|
.send_tor(tx.id, &s, r, false)
|
||||||
.await
|
.await
|
||||||
@@ -1746,34 +1760,35 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
|
|||||||
w.on_task_result(Some(tx), &t);
|
w.on_task_result(Some(tx), &t);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("send tor post error: {:?}", e);
|
error!("Send Tor post error: {:?}", e);
|
||||||
w.on_tx_error(tx.id, Some(e));
|
w.on_tx_error(tx.id, Some(e));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("send tor finalize error: {:?}", e);
|
error!("Send Tor finalize error: {:?}", e);
|
||||||
w.task(WalletTask::Cancel(tx.id));
|
w.task(WalletTask::Cancel(tx.id));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("send tor error: {:?}", e);
|
error!("Send Tor error: {:?}", e);
|
||||||
w.on_tx_error(tx.id, Some(e));
|
w.on_tx_error(tx.id, Some(e));
|
||||||
w.on_task_result(Some(tx), &t);
|
w.on_task_result(Some(tx), &t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Invoice-flow counterpart to send_tor. After signing an invoice the payer
|
// Finalize tx over Tor.
|
||||||
// posts the slate to the merchant's foreign-api finalize_tx; the merchant
|
let finalize_tor = async |tx: TxLogEntry, s: &Slate, r: &SlatepackAddress| match w
|
||||||
// finalizes + broadcasts on their side, so no local finalize/post is needed.
|
|
||||||
let pay_tor = async |tx: TxLogEntry, s: &Slate, r: &SlatepackAddress| match w
|
|
||||||
.send_tor(tx.id, &s, r, true)
|
.send_tor(tx.id, &s, r, true)
|
||||||
.await
|
.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);
|
sync_wallet_data(&w, false);
|
||||||
w.on_task_result(Some(tx), &t);
|
w.on_task_result(Some(tx), &t);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("pay tor error: {:?}", e);
|
error!("Finalize Tor error: {:?}", e);
|
||||||
w.on_tx_error(tx.id, Some(e));
|
w.on_tx_error(tx.id, Some(e));
|
||||||
w.on_task_result(Some(tx), &t);
|
w.on_task_result(Some(tx), &t);
|
||||||
}
|
}
|
||||||
@@ -1809,29 +1824,33 @@ async fn handle_task(w: &Wallet, t: WalletTask) {
|
|||||||
w.message_opening.store(false, Ordering::Relaxed);
|
w.message_opening.store(false, Ordering::Relaxed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 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();
|
||||||
|
if Tor::is_service_running(&id) {
|
||||||
|
if let Some(tx) = tx.as_ref() {
|
||||||
|
if let Some(addr) = dest {
|
||||||
|
w.message_opening.store(false, Ordering::Relaxed);
|
||||||
|
finalize_tor(tx.clone(), &s, &addr).await;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
// Create response or finalize.
|
// Create response or finalize.
|
||||||
match s.state {
|
match s.state {
|
||||||
SlateState::Standard1 => {
|
SlateState::Standard1 => {
|
||||||
if let Ok(_) = w.receive(&s, dest) {
|
if let Ok(s) = w.receive(&s, None) {
|
||||||
sync_wallet_data(&w, false);
|
maybe_finalize_tor(s).await;
|
||||||
let tx = w.retrieve_tx_by_id(None, Some(s.id));
|
|
||||||
w.on_task_result(tx, &t);
|
w.on_task_result(tx, &t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SlateState::Invoice1 => {
|
SlateState::Invoice1 => {
|
||||||
if let Ok(signed) = w.pay(&s, None) {
|
if let Ok(s) = w.pay(&s, None) {
|
||||||
sync_wallet_data(&w, false);
|
sync_wallet_data(&w, false);
|
||||||
let tx = w.retrieve_tx_by_id(None, Some(s.id));
|
maybe_finalize_tor(s).await;
|
||||||
let id = w.identifier();
|
|
||||||
if Tor::is_service_running(&id) {
|
|
||||||
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;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
w.on_task_result(tx, &t);
|
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;
|
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((slate, dest)) = w.get_tx_slate(tx.id) {
|
||||||
if let Some(dest) = dest {
|
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
Reference in New Issue
Block a user