diff --git a/src/blsct/wallet/txfactory_global.cpp b/src/blsct/wallet/txfactory_global.cpp index 97929f8942711..38c0a8cd8ba0b 100644 --- a/src/blsct/wallet/txfactory_global.cpp +++ b/src/blsct/wallet/txfactory_global.cpp @@ -102,7 +102,30 @@ CTransactionRef AggregateTransactions(const std::vector& txs) std::vector vSigs; CAmount nFee = 0; + std::set setHashes; + std::set setNoAscendents; + + for (auto& tx : txs) { + setHashes.insert(tx->GetHash()); + } + + for (auto& tx : txs) { + bool fDependsOnOther = false; + for (auto& in : tx->vin) { + if (setHashes.find(in.prevout.hash) != setHashes.end()) { + fDependsOnOther = true; + break; + } + } + if (!fDependsOnOther) + setNoAscendents.insert(tx->GetHash()); + } + for (auto& tx : txs) { + if (setNoAscendents.find(tx->GetHash()) != setNoAscendents.end()) { + continue; + } + vSigs.push_back(tx->txSig); for (auto& in : tx->vin) { ret.vin.push_back(in);