[bisq-network/bisq] Implement api methods 'keepfunds', 'withdrawfunds' (#4711)

sqrrm notifications at github.com
Sat Oct 31 17:41:19 UTC 2020


@sqrrm approved this pull request.

utACK

A comment to tend to in a later PR

The usage of the wallet and the key might have to be refactored for safer key handling, but I think that should be done as a focused refactoring.

>      }
 
     String getTradeRole(String tradeId) {
         return tradeUtil.getRole(getTrade(tradeId));
     }
 
     Trade getTrade(String tradeId) {
-        return tradeManager.getTradeById(tradeId).orElseThrow(() ->
-                new IllegalArgumentException(format("trade with id '%s' not found", tradeId)));
+        return getOpenTrade(tradeId).orElseGet(() ->
+                getClosedTrade(tradeId).orElseThrow(() ->
+                        new IllegalArgumentException(format("trade with id '%s' not found", tradeId))
+                ));
+    }
+
+    private Optional<Trade> getOpenTrade(String tradeId) {
+        return tradeManager.getTradeById(tradeId);
+    }
+
+    private Optional<Trade> getClosedTrade(String tradeId) {
+        return closedTradableManager.getTradableById(tradeId).map(value -> (Trade) value);

There is no guarantee that the `Tradable` is a `Trade` here, probably good to add a check for `instanceof`.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4711#pullrequestreview-521156292
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201031/51e973cd/attachment.html>


More information about the bisq-github mailing list