Skip to content

Commit

Permalink
Limit UTXOs for transactions (#906)
Browse files Browse the repository at this point in the history
* Limit UTXOs for transactions

To avoid HSM crash :p

* use configuration
  • Loading branch information
BertrandD authored Sep 15, 2022
1 parent 1b4dbe7 commit 9037104
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/src/wallet/bitcoin/BitcoinLikeAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,14 @@ namespace ledger {
auto keychain = self->getKeychain();
soci::session session(self->getWallet()->getDatabase()->getPool());

return BitcoinLikeUTXODatabaseHelper::queryAllUtxos(session, self->getAccountUid(), self->getWallet()->getCurrency());
auto utxos = BitcoinLikeUTXODatabaseHelper::queryAllUtxos(session, self->getAccountUid(), self->getWallet()->getCurrency());
const auto maxUtxo = self->getWallet()->getConfig()->getInt("MAX_UTXO").value_or(std::numeric_limits<int>::max());

if (utxos.size() > maxUtxo) {
throw std::runtime_error(fmt::format("Too many utxos. Got {}, but max is {}.", utxos.size(), maxUtxo));
}

return utxos;
});
};
auto getTransaction = [self](const std::string &hash) -> FuturePtr<BitcoinLikeBlockchainExplorerTransaction> {
Expand Down

0 comments on commit 9037104

Please sign in to comment.