From 1432a6d9a9eee1e99d352b929b784cb99e8f01ae Mon Sep 17 00:00:00 2001
From: "roman.khlopkov" <roman.khlopkov@demlabs.net>
Date: Tue, 18 Jun 2024 17:01:46 +0300
Subject: [PATCH] [*] Crossnet TX double-spend fix

---
 dap-sdk                        | 2 +-
 modules/net/dap_chain_ledger.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/dap-sdk b/dap-sdk
index 0edcf99d6e..9b0654100c 160000
--- a/dap-sdk
+++ b/dap-sdk
@@ -1 +1 @@
-Subproject commit 0edcf99d6ebccfd95abea2c04d95cba593bfb918
+Subproject commit 9b0654100cf3cdb0bce6d54005fb8b70ab059681
diff --git a/modules/net/dap_chain_ledger.c b/modules/net/dap_chain_ledger.c
index 09dbcc62be..917fd65dd3 100644
--- a/modules/net/dap_chain_ledger.c
+++ b/modules/net/dap_chain_ledger.c
@@ -4295,7 +4295,8 @@ int dap_ledger_tx_cache_check(dap_ledger_t *a_ledger,
                 l_bound_item->in.addr_from = *l_addr_from;
                 dap_strncpy(l_bound_item->in.token_ticker, l_token, DAP_CHAIN_TICKER_SIZE_MAX - 1);
                 // 4. compare public key hashes in the signature of the current transaction and in the 'out' item of the previous transaction
-                if (!dap_hash_fast_compare(&l_tx_first_sign_pkey_hash, &l_addr_from->data.hash_fast)) {
+                if (l_addr_from->net_id.uint64 != a_ledger->net->pub.id.uint64 ||
+                        !dap_hash_fast_compare(&l_tx_first_sign_pkey_hash, &l_addr_from->data.hash_fast)) {
                     l_err_num = DAP_LEDGER_TX_CHECK_PKEY_HASHES_DONT_MATCH;
                     break;
                 }
-- 
GitLab