[bisq-network/bisq] Add getRole(tradeId) to core api (#4701)

Stan notifications at github.com
Fri Oct 30 14:44:15 UTC 2020


@ghubstan commented on this pull request.



> +     * @return String describing a trader's role for a given trade
+     */
+    public String getRole(Trade trade) {
+        Contract contract = trade.getContract();
+        if (contract == null)
+            throw new IllegalStateException(format("could not get role because no contract was found for trade '%s'",
+                    trade.getShortId()));
+
+        Offer offer = trade.getOffer();
+        if (offer == null)
+            throw new IllegalStateException(format("could not get role because no offer was found for trade '%s'",
+                    trade.getShortId()));
+
+        return getRole(contract.isBuyerMakerAndSellerTaker(),
+                offer.isMyOffer(keyRing),
+                offer.getCurrencyCode());

Below is an example of the console output for a CLI's `gettrade id` command, where the role = `BTC buyer as taker`, showing what is being bought or sold.

```
ID      My Role             Price in USD for 1 BTC  Amount(BTC)  Tx Fee(BTC)  Taker Fee(BTC)  Deposit Published  Deposit Confirmed  Fiat Sent  Fiat Received  Payout Published  Withdrawn  
AGnSOw  BTC buyer as taker             13,263.6578   0.12500000   0.00068800      0.00037500  YES                NO                 NO         NO             NO                NO        
```

-- 
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/4701#discussion_r515148393
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201030/83d8cee6/attachment.html>


More information about the bisq-github mailing list