fix(wallet): activity duplicate in case of non-native transfer

The "hash" (a.k.a. ID) column was used for matching transfer entry which
works only for native transfers which have the `ID` same as hash.

Closes: #14071
This commit is contained in:
Stefan 2024-04-04 23:02:07 +03:00 committed by Stefan Dunca
parent 9d12856329
commit 62405b4def
2 changed files with 3 additions and 2 deletions

View File

@ -341,6 +341,7 @@ func (c *transfersCommand) confirmPendingTransactions(tx *sql.Tx, allTransfers [
continue continue
} else if err != nil { } else if err != nil {
log.Warn("GetOwnedMultiTransactionID", "error", err) log.Warn("GetOwnedMultiTransactionID", "error", err)
existingMTID, err := GetOwnedMultiTransactionID(tx, chainID, txHash, tr.Address)
continue continue
} }
mTID = w_common.NewAndSet(existingMTID) mTID = w_common.NewAndSet(existingMTID)

View File

@ -562,8 +562,8 @@ func markBlocksAsLoaded(chainID uint64, creator statementCreator, address common
} }
// GetOwnedMultiTransactionID returns sql.ErrNoRows if no transaction is found for the given identity // GetOwnedMultiTransactionID returns sql.ErrNoRows if no transaction is found for the given identity
func GetOwnedMultiTransactionID(tx *sql.Tx, chainID w_common.ChainID, id common.Hash, address common.Address) (mTID int64, err error) { func GetOwnedMultiTransactionID(tx *sql.Tx, chainID w_common.ChainID, hash common.Hash, address common.Address) (mTID int64, err error) {
row := tx.QueryRow(`SELECT COALESCE(multi_transaction_id, 0) FROM transfers WHERE network_id = ? AND hash = ? AND address = ?`, chainID, id, address) row := tx.QueryRow(`SELECT COALESCE(multi_transaction_id, 0) FROM transfers WHERE network_id = ? AND tx_hash = ? AND address = ?`, chainID, hash, address)
err = row.Scan(&mTID) err = row.Scan(&mTID)
if err != nil { if err != nil {
return 0, err return 0, err