wownero crashes when receiving transaction #484

Open
opened 4 weeks ago by mrcyjanek · 0 comments

Hey! Wownero contains some crashes caused by the fact that listener is not set when using wallet_api (#483)

Here is a patch that I've used to workaround/fix the issue (took from upstream monero code)

From 1286d8b67484dd976997cccd726d4ea9318a6ecd Mon Sep 17 00:00:00 2001
From: Czarek Nakamoto <cyjan@mrcyjanek.net>
Date: Tue, 2 Apr 2024 11:56:09 +0200
Subject: [PATCH] FIX: wallet listener crashing

---
 src/wallet/api/wallet.cpp | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 3bbc60d74..b42289842 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -201,8 +201,11 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback
                      << ", burnt: " << print_money(burnt)
                      << ", raw_output_value: " << print_money(amount)
                      << ", idx: " << subaddr_index);
-        m_listener->moneyReceived(tx_hash, amount);
-        m_listener->updated();
+        // do not signal on sent tx if wallet is not syncronized completely
+        if (m_listener && m_wallet->synchronized()) {
+            m_listener->moneyReceived(tx_hash, amount);
+            m_listener->updated();
+        }
     }
 
     virtual void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index)
@@ -214,8 +217,11 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback
                      << ", tx: " << tx_hash
                      << ", amount: " << print_money(amount)
                      << ", idx: " << subaddr_index);
-        m_listener->unconfirmedMoneyReceived(tx_hash, amount);
-        m_listener->updated();
+        // do not signal on sent tx if wallet is not syncronized completely
+        if (m_listener && m_wallet->synchronized()) {
+            m_listener->unconfirmedMoneyReceived(tx_hash, amount);
+            m_listener->updated();
+        }
     }
 
     virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& in_tx,
@@ -227,8 +233,11 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback
                      << ", tx: " << tx_hash
                      << ", amount: " << print_money(amount)
                      << ", idx: " << subaddr_index);
-        m_listener->moneySpent(tx_hash, amount);
-        m_listener->updated();
+        // do not signal on sent tx if wallet is not syncronized completely
+        if (m_listener && m_wallet->synchronized()) {
+            m_listener->moneySpent(tx_hash, amount);
+            m_listener->updated();
+        }
     }
 
     virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx)
-- 
2.44.0

Hey! Wownero contains some crashes caused by the fact that listener is not set when using wallet_api (#483) Here is a patch that I've used to workaround/fix the issue (took from upstream monero code) ```patch From 1286d8b67484dd976997cccd726d4ea9318a6ecd Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto <cyjan@mrcyjanek.net> Date: Tue, 2 Apr 2024 11:56:09 +0200 Subject: [PATCH] FIX: wallet listener crashing --- src/wallet/api/wallet.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 3bbc60d74..b42289842 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -201,8 +201,11 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback << ", burnt: " << print_money(burnt) << ", raw_output_value: " << print_money(amount) << ", idx: " << subaddr_index); - m_listener->moneyReceived(tx_hash, amount); - m_listener->updated(); + // do not signal on sent tx if wallet is not syncronized completely + if (m_listener && m_wallet->synchronized()) { + m_listener->moneyReceived(tx_hash, amount); + m_listener->updated(); + } } virtual void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index) @@ -214,8 +217,11 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback << ", tx: " << tx_hash << ", amount: " << print_money(amount) << ", idx: " << subaddr_index); - m_listener->unconfirmedMoneyReceived(tx_hash, amount); - m_listener->updated(); + // do not signal on sent tx if wallet is not syncronized completely + if (m_listener && m_wallet->synchronized()) { + m_listener->unconfirmedMoneyReceived(tx_hash, amount); + m_listener->updated(); + } } virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& in_tx, @@ -227,8 +233,11 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback << ", tx: " << tx_hash << ", amount: " << print_money(amount) << ", idx: " << subaddr_index); - m_listener->moneySpent(tx_hash, amount); - m_listener->updated(); + // do not signal on sent tx if wallet is not syncronized completely + if (m_listener && m_wallet->synchronized()) { + m_listener->moneySpent(tx_hash, amount); + m_listener->updated(); + } } virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) -- 2.44.0 ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: wownero/wownero#484
Loading…
There is no content yet.