From 4e2684b9176d99f8c5f9c797c27a0562d6b5ac04 Mon Sep 17 00:00:00 2001 From: d11n Date: Tue, 21 Jan 2025 07:42:30 +0100 Subject: [PATCH] Remove app models and hub classes from client lib (#6567) --- .../App/IBTCPayAppHubClient.cs | 138 ------------------ .../App/Models/AcceptInviteRequest.cs | 8 - .../App/Models/AcceptInviteResult.cs | 10 -- .../App/Models/AccessTokenResult.cs | 10 -- .../App/Models/AppInstanceInfo.cs | 13 -- BTCPayServer.Client/App/Models/AppUserInfo.cs | 44 ------ .../App/Models/AuthenticationResult.cs | 7 - .../App/Models/CreateStoreData.cs | 11 -- .../App/Models/LoginRequest.cs | 10 -- .../App/Models/ResetPasswordRequest.cs | 8 - 10 files changed, 259 deletions(-) delete mode 100644 BTCPayServer.Client/App/IBTCPayAppHubClient.cs delete mode 100644 BTCPayServer.Client/App/Models/AcceptInviteRequest.cs delete mode 100644 BTCPayServer.Client/App/Models/AcceptInviteResult.cs delete mode 100644 BTCPayServer.Client/App/Models/AccessTokenResult.cs delete mode 100644 BTCPayServer.Client/App/Models/AppInstanceInfo.cs delete mode 100644 BTCPayServer.Client/App/Models/AppUserInfo.cs delete mode 100644 BTCPayServer.Client/App/Models/AuthenticationResult.cs delete mode 100644 BTCPayServer.Client/App/Models/CreateStoreData.cs delete mode 100644 BTCPayServer.Client/App/Models/LoginRequest.cs delete mode 100644 BTCPayServer.Client/App/Models/ResetPasswordRequest.cs diff --git a/BTCPayServer.Client/App/IBTCPayAppHubClient.cs b/BTCPayServer.Client/App/IBTCPayAppHubClient.cs deleted file mode 100644 index 05f7090dc..000000000 --- a/BTCPayServer.Client/App/IBTCPayAppHubClient.cs +++ /dev/null @@ -1,138 +0,0 @@ -#nullable enable -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using BTCPayServer.Client.Models; -using BTCPayServer.Lightning; -using NBitcoin; - -namespace BTCPayServer.Client.App; - -//methods available on the hub in the client -public interface IBTCPayAppHubClient -{ - Task NotifyServerEvent(ServerEvent ev); - Task NotifyNetwork(string network); - Task NotifyServerNode(string nodeInfo); - Task TransactionDetected(TransactionDetectedRequest request); - Task NewBlock(string block); - Task StartListen(string key); - - Task CreateInvoice(string key, CreateLightningInvoiceRequest createLightningInvoiceRequest); - Task GetLightningInvoice(string key, uint256 paymentHash); - Task GetLightningPayment(string key, uint256 paymentHash); - Task CancelInvoice(string key, uint256 paymentHash); - Task> GetLightningPayments(string key, ListPaymentsParams request); - Task> GetLightningInvoices(string key, ListInvoicesParams request); - Task PayInvoice(string key, string bolt11, long? amountMilliSatoshi); - Task MasterUpdated(long? deviceIdentifier); - Task GetLightningNodeInfo(string key); - Task GetLightningBalance(string key); -} - -//methods available on the hub in the server -public interface IBTCPayAppHubServer -{ - Task DeviceMasterSignal(long deviceIdentifier, bool active); - - Task> Pair(PairRequest request); - Task Handshake(AppHandshake request); - Task BroadcastTransaction(string tx); - Task GetFeeRate(int blockTarget); - Task GetBestBlock(); - Task FetchTxsAndTheirBlockHeads(string identifier, string[] txIds, string[] outpoints); - Task DeriveScript(string identifier); - Task TrackScripts(string identifier, string[] scripts); - Task UpdatePsbt(string[] identifiers, string psbt); - Task> GetUTXOs(string[] identifiers); - Task> GetTransactions(string[] identifiers); - Task SendInvoiceUpdate(LightningInvoice lightningInvoice); - Task GetCurrentMaster(); -} - -public class ServerEvent -{ - public string? Type { get; set; } - public string? StoreId { get; set; } - public string? UserId { get; set; } - public string? AppId { get; set; } - public string? InvoiceId { get; set; } - public string? Detail { get; set; } -} - -public record TxResp -{ - public TxResp(long confirmations, long? height, decimal balanceChange, DateTimeOffset timestamp, string transactionId) - { - Confirmations = confirmations; - Height = height; - BalanceChange = balanceChange; - Timestamp = timestamp; - TransactionId = transactionId; - } - - public long Confirmations { get; set; } - public long? Height { get; set; } - public decimal BalanceChange { get; set; } - public DateTimeOffset Timestamp { get; set; } - public string TransactionId { get; set; } - - public override string ToString() - { - return $"{{ Confirmations = {Confirmations}, Height = {Height}, BalanceChange = {BalanceChange}, Timestamp = {Timestamp}, TransactionId = {TransactionId} }}"; - } -} - -public class TransactionDetectedRequest -{ - public string? Identifier { get; set; } - public string? TxId { get; set; } - public string[]? SpentScripts { get; set; } - public string[]? ReceivedScripts { get; set; } - public bool Confirmed { get; set; } -} - -public class CoinResponse -{ - public bool Confirmed { get; set; } - public string? Script { get; set; } - public string? Outpoint { get; set; } - public decimal Value { get; set; } - public string? Path { get; set; } -} - -public class TxInfoResponse -{ - public Dictionary? Txs { get; set; } - public Dictionary? BlockHeaders { get; set; } - public Dictionary? BlockHeghts { get; set; } -} - -public class TransactionResponse -{ - public string? BlockHash { get; set; } - public string? Transaction { get; set; } -} - -public class BestBlockResponse -{ - public string? BlockHash { get; set; } - public int BlockHeight { get; set; } - public string? BlockHeader { get; set; } -} - -public class AppHandshake -{ - public string[]? Identifiers { get; set; } -} - -public class AppHandshakeResponse -{ - //response about identifiers being tracked successfully - public string[]? IdentifiersAcknowledged { get; set; } -} - -public class PairRequest -{ - public Dictionary Derivations { get; set; } = new(); -} diff --git a/BTCPayServer.Client/App/Models/AcceptInviteRequest.cs b/BTCPayServer.Client/App/Models/AcceptInviteRequest.cs deleted file mode 100644 index 6f0b21b04..000000000 --- a/BTCPayServer.Client/App/Models/AcceptInviteRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -#nullable enable -namespace BTCPayServer.Client.App.Models; - -public class AcceptInviteRequest -{ - public string? UserId { get; set; } - public string? Code { get; set; } -} diff --git a/BTCPayServer.Client/App/Models/AcceptInviteResult.cs b/BTCPayServer.Client/App/Models/AcceptInviteResult.cs deleted file mode 100644 index deaee0171..000000000 --- a/BTCPayServer.Client/App/Models/AcceptInviteResult.cs +++ /dev/null @@ -1,10 +0,0 @@ -#nullable enable -namespace BTCPayServer.Client.App.Models; - -public class AcceptInviteResult -{ - public string? Email { get; set; } - public bool? RequiresUserApproval { get; set; } - public bool? EmailHasBeenConfirmed { get; set; } - public string? PasswordSetCode { get; set; } -} diff --git a/BTCPayServer.Client/App/Models/AccessTokenResult.cs b/BTCPayServer.Client/App/Models/AccessTokenResult.cs deleted file mode 100644 index 63d134397..000000000 --- a/BTCPayServer.Client/App/Models/AccessTokenResult.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace BTCPayServer.Client.App.Models; - -public class AccessTokenResult -{ - public string AccessToken { get; set; } - public string RefreshToken { get; set; } - public DateTimeOffset Expiry { get; set; } -} diff --git a/BTCPayServer.Client/App/Models/AppInstanceInfo.cs b/BTCPayServer.Client/App/Models/AppInstanceInfo.cs deleted file mode 100644 index 08d76f9ed..000000000 --- a/BTCPayServer.Client/App/Models/AppInstanceInfo.cs +++ /dev/null @@ -1,13 +0,0 @@ -#nullable enable -namespace BTCPayServer.Client.App.Models; - -public class AppInstanceInfo -{ - public string BaseUrl { get; set; } = null!; - public string ServerName { get; set; } = null!; - public string? ContactUrl { get; set; } - public string? LogoUrl { get; set; } - public string? CustomThemeCssUrl { get; set; } - public string? CustomThemeExtension { get; set; } - public bool RegistrationEnabled { get; set; } -} diff --git a/BTCPayServer.Client/App/Models/AppUserInfo.cs b/BTCPayServer.Client/App/Models/AppUserInfo.cs deleted file mode 100644 index bb32049d9..000000000 --- a/BTCPayServer.Client/App/Models/AppUserInfo.cs +++ /dev/null @@ -1,44 +0,0 @@ -#nullable enable -using System.Collections.Generic; - -namespace BTCPayServer.Client.App.Models; - -public class AppUserInfo -{ - public string? UserId { get; set; } - public string? Email { get; set; } - public string? Name { get; set; } - public string? ImageUrl { get; set; } - public IEnumerable? Roles { get; set; } - public IEnumerable? Stores { get; set; } - - public void SetInfo(string email, string? name, string? imageUrl) - { - Email = email; - Name = name; - ImageUrl = imageUrl; - } - - public static bool Equals(AppUserInfo? x, AppUserInfo? y) - { - if (ReferenceEquals(x, y)) return true; - if (ReferenceEquals(x, null)) return false; - if (ReferenceEquals(y, null)) return false; - if (x.GetType() != y.GetType()) return false; - return x.UserId == y.UserId && x.Email == y.Email && - x.Name == y.Name && x.ImageUrl == y.ImageUrl && - Equals(x.Roles, y.Roles) && Equals(x.Stores, y.Stores); - } -} - -public class AppUserStoreInfo -{ - public string Id { get; set; } = null!; - public string? Name { get; set; } - public string? LogoUrl { get; set; } - public string? RoleId { get; set; } - public string? PosAppId { get; set; } - public string? DefaultCurrency { get; set; } - public bool Archived { get; set; } - public IEnumerable? Permissions { get; set; } -} diff --git a/BTCPayServer.Client/App/Models/AuthenticationResult.cs b/BTCPayServer.Client/App/Models/AuthenticationResult.cs deleted file mode 100644 index 223ebd0e3..000000000 --- a/BTCPayServer.Client/App/Models/AuthenticationResult.cs +++ /dev/null @@ -1,7 +0,0 @@ -#nullable enable -namespace BTCPayServer.Client.App.Models; - -public class AuthenticationResponse -{ - public string? AccessToken { get; set; } -} diff --git a/BTCPayServer.Client/App/Models/CreateStoreData.cs b/BTCPayServer.Client/App/Models/CreateStoreData.cs deleted file mode 100644 index 4040c8ec1..000000000 --- a/BTCPayServer.Client/App/Models/CreateStoreData.cs +++ /dev/null @@ -1,11 +0,0 @@ -#nullable enable -using System.Collections.Generic; - -namespace BTCPayServer.Client.App.Models; - -public class CreateStoreData -{ - public string? DefaultCurrency { get; set; } - public string? RecommendedExchangeId { get; set; } - public Dictionary? Exchanges { get; set; } -} diff --git a/BTCPayServer.Client/App/Models/LoginRequest.cs b/BTCPayServer.Client/App/Models/LoginRequest.cs deleted file mode 100644 index 9bb038f74..000000000 --- a/BTCPayServer.Client/App/Models/LoginRequest.cs +++ /dev/null @@ -1,10 +0,0 @@ -#nullable enable -namespace BTCPayServer.Client.App.Models; - -public class LoginRequest -{ - public string? Email { get; set; } - public string? Password { get; set; } - public string? TwoFactorCode { get; set; } - public string? TwoFactorRecoveryCode { get; set; } -} diff --git a/BTCPayServer.Client/App/Models/ResetPasswordRequest.cs b/BTCPayServer.Client/App/Models/ResetPasswordRequest.cs deleted file mode 100644 index 733728eb8..000000000 --- a/BTCPayServer.Client/App/Models/ResetPasswordRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace BTCPayServer.Client.App.Models; - -public class ResetPasswordRequest -{ - public string Email { get; set; } - public string ResetCode { get; set; } - public string NewPassword { get; set; } -}