From 2ade0a7a453ab3717b0df942a4f025ea800ccfa9 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Tue, 13 Mar 2018 05:59:49 -0700 Subject: [PATCH] Only ADD_TRANSACTION if we are not already tracking the transaction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LND’s SubscribeTransactions will announce transactions multiple times. I haven’t looked into which circumstances this occur, but an easy fix is to filter out the incoming transactions that we already have on record. Fixes #317 --- app/reducers/transaction.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index 435afd7e..c5f69e86 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -105,7 +105,13 @@ const ACTION_HANDLERS = { [RECEIVE_TRANSACTIONS]: (state, { transactions }) => ({ ...state, transactionLoading: false, transactions }), [TRANSACTION_SUCCESSFULL]: state => ({ ...state, sendingTransaction: false }), [TRANSACTION_FAILED]: state => ({ ...state, sendingTransaction: false }), - [ADD_TRANSACTION]: (state, { transaction }) => ({ ...state, transactions: [transaction, ...state.transactions] }) + [ADD_TRANSACTION]: (state, { transaction }) => ( + // add the transaction only if we are not already aware of it + state.transactions.find(tx => (tx.tx_hash === transaction.tx_hash)) ? state : { + ...state, + transactions: [transaction, ...state.transactions] + } + ) } // ------------------------------------