GithubHelp home page GithubHelp logo

Comments (9)

citkane avatar citkane commented on June 15, 2024

Usage examples

1 - You are developing a new Bisq module

Let us imagine a fictional Bisq module called Foo which eg, interacts with the network to do some analysis and reporting about valuable insight. Maybe you also want it to provide a report template to be served over html.

Step one

  • create an empty Maven project and declare a dependency to bisq-engine.
  • declare any additional Bisq modules / dependencies you may need.
  • point Maven to engine's main classpath

At this point you can do mvn clean install and have a runnable jar with command line options to launch a Bisq node tailored to Foo's needs:

  • With / without desktop GUI
  • With / without http server on localhost at specified port.The http endpoint will already serve a documented Swagger interface for existing API endpoints.
  • (TODO) flags for a wider range of boot-strap scenarios. (eg, maybe Foo needs to be a seeednode)

Step two

  • construct Foo's business logic. You will already have all the low level services at io.bisq.business.Data and a wealth of pre-existing logic constructors at io.bisq.business.actions.
  • use the pre-existing formatters and validators under io.bisq.business
  • build any additional logic, formatting or validation Foo may need under the io.bisq.business classpaths.
  • (TODO) Run required additional boot logic by overriding a container class that engine will supply.
  • provide additional REST endpoints for Foo by extending the io.bisq.engine.api class. This will be automatically documented by Swagger if the existing Spring annotation pattern is maintained.

You will now have a deployable module, ready for testing.

Step three

  • Test
  • Issue pull requests to bisq-business to provide your new logic routines to the whole stack.
  • Refactor Foo to exclude classes that have been merged into bisq-business

You are now ready to provide Foo as a deployable Bisq module.

2 - A professional trader needs Bisq automation and reporting

Let us imagine a trader who has a wide portfolio of coin assets. They need to maintain 3 Bisq instances on different base markets and already have an automated trading logic routine that they have written and maintain in the fictional language called "NotJava". They have called this Bar.

Additionally, they would like to go on holiday, or business trips, and monitor their portfolio via a remote interface. If they see that Bar is not agreeing with their gut instinct, they want to be able to intervene manually.

(bisq-front is currently at proof of concept, so these steps are feasible but fictional)

Step one

  • Install bisq-front by preferred method (Docker, git pull, deployable OS package, etc)
  • Browse to http port where there is GUI setup interface
  • Select 3 Bisq nodes for the needed base markets
  • Specify if you want a desktop GUI for initial setup and funding
  • Select that you need a TOR hidden service for remote access.
  • Specify that you also want this to also be a TOR relay / exit / etc. node.
  • Select that you want a full BTC node to be installed, from which you will fund your trades
  • Select that you also want to be a "Eclaire" lightning node
  • Select any additional modules you want installed in your stack (maybe you also want to run a market info node and earn some BSQ)

Step two

  • Hit install
  • Bisq front returns with needed data, eg .onion address's, api ports for each Bisq node, etc.
  • Browse to bisq-front admin interface / additional modules and point it to Bar
  • Tell Bisq front that this is a "NotJava" module and you would like to run it with the following arguments.
  • Tell bisq-front about what input / outputs Bar uses and then map them to Bisq API endpoints from dropdowns.
  • Hit save

A happy trader is up and running.

from proposals.

blabno avatar blabno commented on June 15, 2024

I agree that we should have some business objects performing actions in a stateless manner, i.e. instead of operating with stateful CreateOfferDataModel, there should be some service or manager that accepts just those 8 input params (paymentAccountId, currency, amount, price, etc.).
However, it should reside in the core module.

from proposals.

blabno avatar blabno commented on June 15, 2024

As to API I think it should be just a loadable extension like in Arquillian. It works on top of Service Provider Interfaces https://docs.oracle.com/javase/tutorial/ext/basics/spi.html
JavaFX also should be loaded that way.

from proposals.

blabno avatar blabno commented on June 15, 2024

I don't see much point in hiding REST API behind WebSockets. WebSockets could be some addition used to get real-time updates on asynchronous events, but most of the traffic should go directly to the API (over TOR of course).
API should be secured at least with a password (without any username) transmitted as request header (never as cookie).
Ideally API should generate auth tokens that have expire after some short amount of time (i.e. 1h). Tokens could be generated as a result of successfull signin with password.

from proposals.

citkane avatar citkane commented on June 15, 2024

@blabno
The architecture is that all business logic, for all Bisq modules, is in one place. This is agnostic.

Whether the javaFx GUI or the API is trying to create an offer is irrelevant. Bisq must run the same code from the same place. This works. What needs refinement is sequencing logic (which is handled in viewmodels for the gui). If the request is coming from elsewhere, it needs an io.bisq.business.actions method to say for eg.:

  • format and validate inputs
  • check if user has enough BTC
  • fund wallet and listen for network return
  • commit offer
  • close listeners

Please have a look here: https://github.com/citkane/bisq-business/tree/master/business/src/main/java/io/bisq/business/actions . We can discuss on Friday why this is already working statefully, but what we do not want to do is get tangled up in re-building logic which already exists, is tested and works for a few years already.

Let us forget about the semantic of API for this paragraph. We are looking for REST endpoints. This is provided by Spring, which is already an integral part of the overall Bisq architecture. engine provides the classpath for these, Spring takes care of the auto-discovery, and Swagger takes care of the documentation. Please take a look at how simple these become here: https://github.com/citkane/bisq-engine/tree/master/engine/src/main/java/io/bisq/engine/app/api. Spring Boot provides the optional http server, bundled into the shaded jar.

Any dev creating a Bisq module should be able to provide an API easily, out of the Bisq box, by declaring very simple REST endpoints on the bisq.io.engine.api classpath and calling business logic from io.bisq.business. We do not want to get core involved in any of this and we do not want to load any more dependencies or create any more layers.

We want to constrain any possibility of connection to Bisq to localhost only. The security model lies outside of a Bisq shaded jar. If we try to be absolute about the security model and open a Bisq module to the outside world, we are inviting a world of pain.

There is an architecture that makes things simpler, more re-useable and easier to maintain. This is what I am proposing here.

from proposals.

blabno avatar blabno commented on June 15, 2024

What kind of auto-discovery is spring supposed to do?

Why constrain to localhost, this won't grant much security? It won't protect you against <img src="http://localhost:8080/bisq-api/give-me-all-your-money"/>

from proposals.

citkane avatar citkane commented on June 15, 2024

Spring isn't supposed to do anything, it just does it. It uses @beans, which automatically configure in the java compilation and make it possible for a dev to manage a wide range of powerful options through annotations.

For eg, we define the REST classpath here: https://github.com/citkane/bisq-engine/blob/master/engine/src/main/java/io/bisq/engine/app/SwaggerConfig.java

This is why the REST methods are so clean and simple.

<img src="http://localhost:8080/bisq-api/give-me-all-your-money"/>

is not going to give me anything unless I am sitting at a browser running on 'localhost', which is the same as having access to the GUI running on localhost, which is why wallets should be encrypted.

So, we can use the existing Bisq logic to check any API call for wallet encryption, the same as we check if TAC's have been accepted here: https://github.com/citkane/bisq-business/blob/fd8498ccf535f363cebd9677d3780ec2cc660689/business/src/main/java/io/bisq/business/Handlers.java#L47

from proposals.

citkane avatar citkane commented on June 15, 2024

@blabno , just to be clear, all of the above is functional. You can clone it, compile it and test it.

from proposals.

cbeams avatar cbeams commented on June 15, 2024

Closing due to inactivity and, per the guidance in #11, the fact that this proposal isn't really something discrete that can be approved or rejected. Nothing wrong, by the way—examples like this one help show us how we need to refine proposals to make it a manageable process for everyone.

What I liked about this proposal is the raw initiative that it took to put together. What I didn't like is that it proposed too much, and demanded too much of me to be able to form a decision about it. There were multiple new components involved, and the whole thing was overwhelming. I couldn't justify digging into it at the expense of everything else I needed to do, and I (for better or worse) assumed that because it was so broad in scope, and because it was submitted by someone who has not contributed to Bisq before, that it almost certainly would not be something I'd give a 👍 to as-is. The net effect was that I ignored this proposal. Perhaps that is the same experience others had, I don't know.

I think that successful proposals from new(er) contributors will be small and well-defined ones. The more experience, track record and reputation one has, the more it becomes reasonable to request (and actually get) other contributors' attention with more ambitious proposals like this one.

from proposals.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.