A Java client for the Portal WebSocket Server, providing Nostr-based authentication and Lightning Network payment processing capabilities.
-
Add the Jitpack repository to your
build.gradle:repositories { maven { url 'https://jitpack.io' } }Or if you are using Maven, add the following to your
pom.xml:<repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository>
-
Add the dependency to your
build.gradle:dependencies { implementation 'com.github.PortalTechnologiesInc:jvm-client:0.1.0' }Or if you are using Maven, add the following to your
pom.xml:<dependency> <groupId>com.github.PortalTechnologiesInc</groupId> <artifactId>jvm-client</artifactId> <version>0.1.0</version> </dependency>
-
Once you’re done, you may now proceed integrating the SDK into your project.
Create an instance of PortalSDK by passing the health and websocket endpoints of your portal server:
var portalSDK = new PortalSDK(healthEndpoint, wsEndpoint);The connect method will establish a connection to the server and authenticate the client.
portalSDK.connect(authToken);You can send a command to the server by calling the sendCommand method.
portalSDK.sendCommand(request, (response, err) -> {
if(err != null) {
logger.error("error sending command: {}", err);
return;
}
logger.info("command sent successfully: {}", response);
});portalSDK.sendCommand(new CalculateNextOccurrenceRequest("weekly", System.currentTimeMillis() / 1000), (res, err) -> {
if(err != null) {
logger.error("error calculating next occurrence: {}", err);
return;
}
logger.info("next occurrence: {}", res.next_occurrence());
});Commands are implemented as specific request classes in src/main/java/cc/getportal/command/request/, and used via the sendCommand() method of the PortalSDK class.
Some key available commands include:
AuthRequest: Authenticate using a token.KeyHandshakeUrlRequest: Get handshake URL for key and relays.RequestSinglePaymentRequest: Request a single payment.MintCashuRequest: Mint Cashu tokens.
See
src/main/java/cc/getportal/command/request/for all available commands and additional details.
To use a command, instantiate its request class and pass it to PortalSDK.sendCommand(...). The full list of commands may evolve; check the request folder for the latest options.
- See portal-demo for a Kotlin example.
PortalSDK- Main client classPortalRequest- Represents a request to the serverPortalResponse- Represents a response from the serverPortalNotification- Represents a notification from the server
For questions or issues, see the official documentation or open an issue on the project's GitHub repository.