forked from btcpayserver/btcpayserver
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
137 changed files
with
1,275 additions
and
940 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
#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<LightningInvoice> CreateInvoice(string key, CreateLightningInvoiceRequest createLightningInvoiceRequest); | ||
Task<LightningInvoice?> GetLightningInvoice(string key, uint256 paymentHash); | ||
Task<LightningPayment?> GetLightningPayment(string key, uint256 paymentHash); | ||
Task CancelInvoice(string key, uint256 paymentHash); | ||
Task<List<LightningPayment>> GetLightningPayments(string key, ListPaymentsParams request); | ||
Task<List<LightningInvoice>> GetLightningInvoices(string key, ListInvoicesParams request); | ||
Task<PayResponse> PayInvoice(string key, string bolt11, long? amountMilliSatoshi); | ||
Task MasterUpdated(long? deviceIdentifier); | ||
Task<LightningNodeInformation> GetLightningNodeInfo(string key); | ||
Task<LightningNodeBalance> GetLightningBalance(string key); | ||
} | ||
|
||
//methods available on the hub in the server | ||
public interface IBTCPayAppHubServer | ||
{ | ||
Task<bool> DeviceMasterSignal(long deviceIdentifier, bool active); | ||
|
||
Task<Dictionary<string,string>> Pair(PairRequest request); | ||
Task<AppHandshakeResponse> Handshake(AppHandshake request); | ||
Task<bool> BroadcastTransaction(string tx); | ||
Task<decimal> GetFeeRate(int blockTarget); | ||
Task<BestBlockResponse> GetBestBlock(); | ||
Task<TxInfoResponse> FetchTxsAndTheirBlockHeads(string identifier, string[] txIds, string[] outpoints); | ||
Task<string> DeriveScript(string identifier); | ||
Task TrackScripts(string identifier, string[] scripts); | ||
Task<string> UpdatePsbt(string[] identifiers, string psbt); | ||
Task<CoinResponse[]> GetUTXOs(string[] identifiers); | ||
Task<Dictionary<string, TxResp[]>> GetTransactions(string[] identifiers); | ||
Task SendInvoiceUpdate(LightningInvoice lightningInvoice); | ||
Task<long?> 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 string? Identifier{ get; set; } | ||
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<string,TransactionResponse>? Txs { get; set; } | ||
public Dictionary<string,string>? BlockHeaders { get; set; } | ||
public Dictionary<string,int>? 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<string, string?> Derivations { get; set; } = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#nullable enable | ||
namespace BTCPayServer.Client.App.Models; | ||
|
||
public class AcceptInviteRequest | ||
{ | ||
public string? UserId { get; set; } | ||
public string? Code { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#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<string>? Roles { get; set; } | ||
public IEnumerable<AppUserStoreInfo>? 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<string>? Permissions { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#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<string, string>? Exchanges { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using BTCPayServer.JsonConverters; | ||
using Newtonsoft.Json; | ||
|
||
namespace BTCPayServer.Client.Models; | ||
|
||
public class AppCartItem | ||
{ | ||
public string Id { get; set; } | ||
public string Title { get; set; } | ||
public int Count { get; set; } | ||
[JsonConverter(typeof(NumericStringJsonConverter))] | ||
public decimal Price { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
using BTCPayServer.JsonConverters; | ||
using Newtonsoft.Json; | ||
|
||
namespace BTCPayServer.Client.Models; | ||
|
||
public class CreatePosInvoiceRequest | ||
{ | ||
public string AppId { get; set; } | ||
public List<AppCartItem> Cart { get; set; } | ||
[JsonProperty(ItemConverterType = typeof(NumericStringJsonConverter))] | ||
public List<decimal> Amounts { get; set; } | ||
public int? DiscountPercent { get; set; } | ||
public int? TipPercent { get; set; } | ||
[JsonConverter(typeof(NumericStringJsonConverter))] | ||
public decimal? DiscountAmount { get; set; } | ||
[JsonConverter(typeof(NumericStringJsonConverter))] | ||
public decimal? Tip { get; set; } | ||
[JsonConverter(typeof(NumericStringJsonConverter))] | ||
public decimal? Subtotal { get; set; } | ||
[JsonConverter(typeof(NumericStringJsonConverter))] | ||
public decimal? Total { get; set; } | ||
public string PosData { get; set; } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.