[bisq-network/bisq] Move Payment account creation and removal from UI to core (#3586)

Ɓukasz Usarz notifications at github.com
Tue Nov 19 16:18:17 UTC 2019


lusarz commented on this pull request.



> +
+            }
+            accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload());
+        }
+        return paymentAccount;
+    }
+
+    public void removePaymentAccount(String id) {
+        PaymentAccount paymentAccount = user.getPaymentAccount(id);
+        if (paymentAccount == null) {
+            throw new NotFoundException(format("Payment account %s not found", id));
+        }
+        boolean isPaymentAccountUsed = openOfferManager.getObservableList().stream()
+                .anyMatch(openOffer -> id.equals(openOffer.getOffer().getMakerPaymentAccountId()));
+        if (isPaymentAccountUsed) {
+            throw new PaymentAccountInUseException(format("Payment account %s is used for open offer", id));

No, and I don't have strong opinion what is better - Exceptions or ResultObject. I usually use Exceptions, but now I see a lot of opinions in net that recommends ResultObject. I think this approach might be interesting. Client code with a lot of `catch` blocks doesn't looks too nice. 

Just give it a try, maybe you'll find some pros :)

Also consistency argument is relevant here. Validation in bisq [(for example here)](https://github.com/bisq-network/bisq/blob/049655b6857449aaca789c9cee5358daf0a54419/core/src/main/java/bisq/core/util/validation/InputValidator.java#L26-L28) uses ResultObject instead of throwing typed exceptions.

-- 
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/3586#discussion_r348024215
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191119/edf67571/attachment.html>


More information about the bisq-github mailing list