<p>This is an experiment to see how the Bisq daemon could work with REST clients.</p>
<p>There is a single gRPC <code>CallService</code> that takes a random string (method name + params) from either gRPC or REST clients, and returns a gRPC (HTTP 2) or REST (HTTP 1.1) response.  All method/parameter validation happens on the server.</p>
<p>For REST clients, there is one <code>POST /v1/call</code> endpoint.  Service method names and parameters are sent in the HTTP request body, for example:</p>
<pre><code>curl -v -X POST http://host:port/v1/call -H "Authorization:xyz"  -H "Content-Type: application/json" -d '{"params": "method arg1 \"arg2\" arg3"}'
</code></pre>
<p>Like in the gRPC client/server implementation in the main branch, gRPC server authentication is as simple as possible -- no TLS.</p>
<p>Since there is no <code>grpc-web</code> or <code>grpc-gateway</code> Java implementation yet, I created separate <a href="https://github.com/ghubstan/bisq-grpc-gateway">Golang based HTTP proxy</a> to forward REST requests.  To be explicit, REST requests must go through the <a href="https://github.com/ghubstan/bisq-grpc-gateway">bisq-grpc-gateway</a> prototype.  Not having a Java/HTTP gateway may result in an immediate <code>NACK</code>, but <code>proxy.go</code> should never grow too complex, and it can be replaced when/if <code>grpc-web</code> for Java is released.</p>
<p>One of the primary motivations for experimenting with this now has been <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/cbeams/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cbeams">@cbeams</a>'s discussion about the need to serve REST clients in general, and specifically, getting Bisq deployed in <a href="https://mynodebtc.com" rel="nofollow">mNode</a>.</p>
<p>Also included in this PR is a possible solution to the <code>server not available</code> problem.  The idea is that if the server cannot access a wallet's balance for any reason, it cannot do anything.  See commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/bisq-network/bisq/commit/1011809dfb2af0773838dcd7d919770676918590/hovercard" href="https://github.com/bisq-network/bisq/commit/1011809dfb2af0773838dcd7d919770676918590"><tt>1011809</tt></a>.</p>
<p>Hopefully, commits examined in order best explains how this POC works.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/bisq-network/bisq/pull/4275'>https://github.com/bisq-network/bisq/pull/4275</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Add new single-endpoint gRPC 'CallService'</li>
  <li>Extract HTTP 1.1 auth header in auth interceptor</li>
  <li>Define CoreApi Method enum</li>
  <li>Add CoreHelpService</li>
  <li>Inject new gRPC CallService into GrpcServer</li>
  <li>Throw gRPC StatusRuntimeException if params missing</li>
  <li>Throw gRPC INVALID_ARG ex for unsupported method</li>
  <li>Throw "server not available" ex if balance is N/A</li>
  <li>Call the CoreApi methods</li>
  <li>Add new single endpoint gRPC client</li>
  <li>Update bats gRPC test script</li>
  <li>Add new HTTP 1.1 / REST test script</li>
  <li>Move test.http along side test.sh</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-c197962302397baf3a4cc36463dce5ea">build.gradle</a>
    (2)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-7f2a6500cb1ccd847be1d0d9a60a13ea">cli/src/main/java/bisq/cli/CliMainV1.java</a>
    (160)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-a814e7867ab3d8e908458cfb49021d98">cli/test.http</a>
    (79)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-9368479f5696839c056de9f5b7d62e7b">cli/test.sh</a>
    (92)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-6fd3a1bb17b4e9d1355ef9a5afc364e9">core/src/main/java/bisq/core/grpc/CoreApi.java</a>
    (33)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-083a883df09aa6eb282ebd2515038bb3">core/src/main/java/bisq/core/grpc/CoreHelpService.java</a>
    (30)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-ea7895179b07915bcd86e7846070e6e9">core/src/main/java/bisq/core/grpc/GrpcCallService.java</a>
    (42)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-b40e718a2d958cd97d68e432cea92e3b">core/src/main/java/bisq/core/grpc/GrpcCoreBridge.java</a>
    (227)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-64eb5835ca37d8f1ab4af8939934a860">core/src/main/java/bisq/core/grpc/GrpcServer.java</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-4a53112f2594f4140879a04293dff59a">core/src/main/java/bisq/core/grpc/GrpcWalletService.java</a>
    (1)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-e20d63d81f8a55f21f639e04c73d0dfb">core/src/main/java/bisq/core/grpc/Method.java</a>
    (11)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-c493ce020267a0600bbbb421fc95722e">core/src/main/java/bisq/core/grpc/PasswordAuthInterceptor.java</a>
    (18)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/4275/files#diff-328b3309bc03d9ffb3ffb9e780dc7e91">proto/src/main/proto/grpc.proto</a>
    (17)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/bisq-network/bisq/pull/4275.patch'>https://github.com/bisq-network/bisq/pull/4275.patch</a></li>
  <li><a href='https://github.com/bisq-network/bisq/pull/4275.diff'>https://github.com/bisq-network/bisq/pull/4275.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/4275">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNVB7VQLFIZW3U7IOU3RTRCQNANCNFSM4NLKNX7A">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNX5TTYGHM3FL43C5C3RTRCQNA5CNFSM4NLKNX7KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4JKES2LQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/4275",
"url": "https://github.com/bisq-network/bisq/pull/4275",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>