From 2741267a56e66b331dddd37f50dc309dad3e3113 Mon Sep 17 00:00:00 2001 From: Wheatley from Portal <256330434+portal-wheatley@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:22:51 +0000 Subject: [PATCH 1/3] feat: slim RequestInvoice with RequestInvoiceParams - Remove request_id and current_exchange_rate from client params - Server (portal-rest) now computes exchange rate and validates invoice amount - Aligns with lib PR #158 --- .../command/request/RequestInvoiceParams.java | 18 ++++++++++++++++++ .../command/request/RequestInvoiceRequest.java | 5 ++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/main/java/cc/getportal/command/request/RequestInvoiceParams.java diff --git a/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java b/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java new file mode 100644 index 0000000..e37cb59 --- /dev/null +++ b/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java @@ -0,0 +1,18 @@ +package cc.getportal.command.request; + +import cc.getportal.model.Currency; +import org.jetbrains.annotations.Nullable; + +/** + * Slim parameters for RequestInvoice command. + * Server (portal-rest) computes exchange rate from amount/currency. + * Request ID is derived from command.id. + */ +public record RequestInvoiceParams( + long amount, + Currency currency, + String expires_at, + @Nullable String description, + @Nullable String refund_invoice +) { +} diff --git a/src/main/java/cc/getportal/command/request/RequestInvoiceRequest.java b/src/main/java/cc/getportal/command/request/RequestInvoiceRequest.java index 2220489..2652041 100644 --- a/src/main/java/cc/getportal/command/request/RequestInvoiceRequest.java +++ b/src/main/java/cc/getportal/command/request/RequestInvoiceRequest.java @@ -1,6 +1,5 @@ package cc.getportal.command.request; -import cc.getportal.model.InvoiceRequestContent; import cc.getportal.command.PortalRequest; import cc.getportal.command.notification.UnitNotification; import cc.getportal.command.response.RequestInvoiceResponse; @@ -11,9 +10,9 @@ public class RequestInvoiceRequest extends PortalRequest subkeys; - private final InvoiceRequestContent content; + private final RequestInvoiceParams content; - public RequestInvoiceRequest(String recipientKey, List subkeys, InvoiceRequestContent content) { + public RequestInvoiceRequest(String recipientKey, List subkeys, RequestInvoiceParams content) { recipient_key = recipientKey; this.subkeys = subkeys; this.content = content; From ec17abe1ec0cd749ea0af47cdffa9d8f391ba4d2 Mon Sep 17 00:00:00 2001 From: Wheatley from Portal <256330434+portal-wheatley@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:36:57 +0000 Subject: [PATCH 2/3] fix: RequestInvoiceParams accepts long expires_at like other *Params classes --- .../getportal/command/request/RequestInvoiceParams.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java b/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java index e37cb59..62fd3ea 100644 --- a/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java +++ b/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java @@ -1,6 +1,7 @@ package cc.getportal.command.request; import cc.getportal.model.Currency; +import com.google.gson.annotations.SerializedName; import org.jetbrains.annotations.Nullable; /** @@ -11,8 +12,13 @@ public record RequestInvoiceParams( long amount, Currency currency, - String expires_at, + @SerializedName("expires_at") + String expiresAt, @Nullable String description, @Nullable String refund_invoice ) { + + public RequestInvoiceParams(long amount, Currency currency, long expiresAt, @Nullable String description, @Nullable String refund_invoice) { + this(amount, currency, String.valueOf(expiresAt), description, refund_invoice); + } } From 72abbb6c7514bcae6111949af6e01b85618be1ef Mon Sep 17 00:00:00 2001 From: Wheatley from Portal <256330434+portal-wheatley@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:50:54 +0000 Subject: [PATCH 3/3] feat: add optional request_id to RequestInvoiceParams, fallback to command id --- .../command/request/RequestInvoiceParams.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java b/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java index 62fd3ea..1ddbfb5 100644 --- a/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java +++ b/src/main/java/cc/getportal/command/request/RequestInvoiceParams.java @@ -15,10 +15,16 @@ public record RequestInvoiceParams( @SerializedName("expires_at") String expiresAt, @Nullable String description, - @Nullable String refund_invoice + @Nullable String refund_invoice, + /** Optional request ID. If not provided, the command ID is used by the server. */ + @Nullable String request_id ) { - + public RequestInvoiceParams(long amount, Currency currency, long expiresAt, @Nullable String description, @Nullable String refund_invoice) { - this(amount, currency, String.valueOf(expiresAt), description, refund_invoice); + this(amount, currency, String.valueOf(expiresAt), description, refund_invoice, null); + } + + public RequestInvoiceParams(long amount, Currency currency, long expiresAt, @Nullable String description, @Nullable String refund_invoice, @Nullable String requestId) { + this(amount, currency, String.valueOf(expiresAt), description, refund_invoice, requestId); } }