This commit is contained in:
Kukks
2023-12-12 13:45:07 +01:00
parent ba670a9a83
commit 8756f2113e
3 changed files with 16 additions and 8 deletions

View File

@@ -9,7 +9,7 @@
<PropertyGroup>
<Product>Blink</Product>
<Description>Brink Lightning support</Description>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace>BTCPayServer.Plugins.Blink</RootNamespace>
</PropertyGroup>

View File

@@ -28,6 +28,9 @@ public class BlinkLightningClient : ILightningClient
private readonly string _apiKey;
private readonly Uri _apiEndpoint;
public string? WalletId { get; set; }
public string? WalletCurrency { get; set; }
private readonly Network _network;
private readonly NBXplorerDashboard _nbXplorerDashboard;
private readonly GraphQLHttpClient _client;
@@ -301,8 +304,8 @@ query Transactions($walletId: WalletId!) {
var reques = new GraphQLRequest
{
Query = @"
mutation LnInvoiceCreate($input: LnInvoiceCreateInput!) {
lnInvoiceCreate(input: $input) {
mutation lnInvoiceCreateOnBehalfOfRecipient($input: LnInvoiceCreateOnBehalfOfRecipientInput!) {
lnInvoiceCreateOnBehalfOfRecipient(input: $input) {
invoice {
createdAt
paymentHash
@@ -310,7 +313,6 @@ mutation LnInvoiceCreate($input: LnInvoiceCreateInput!) {
paymentSecret
paymentStatus
satoshis
}
}
}",
@@ -319,8 +321,9 @@ mutation LnInvoiceCreate($input: LnInvoiceCreateInput!) {
{
input = new
{
walletId = WalletId,
memo = createInvoiceRequest.Description?? createInvoiceRequest.DescriptionHash?.ToString(),
recipientWalletId = WalletId,
memo = createInvoiceRequest.Description,
descriptionHash = createInvoiceRequest.DescriptionHash?.ToString(),
amount = (long)createInvoiceRequest.Amount.ToUnit(LightMoneyUnit.Satoshi),
expiresIn = (int)createInvoiceRequest.Expiry.TotalMinutes
@@ -543,6 +546,7 @@ query GetWallet($walletId: WalletId!) {
var response = await _client.SendQueryAsync<dynamic>(request, cancellation);
WalletCurrency = response.Data.me.defaultAccount.walletById.walletCurrency;
if (response.Data.me.defaultAccount.walletById.walletCurrency == "BTC")
{
return new LightningNodeBalance()
@@ -556,8 +560,6 @@ query GetWallet($walletId: WalletId!) {
return new LightningNodeBalance();
}
public async Task<PayResponse> Pay(PayInvoiceParams payParams,
CancellationToken cancellation = new CancellationToken())

View File

@@ -109,6 +109,12 @@ public class BlinkLightningConnectionStringHandler : ILightningConnectionStringH
try
{
bclient.GetBalance().GetAwaiter().GetResult();
if (!bclient.WalletCurrency.Equals("btc", StringComparison.InvariantCultureIgnoreCase))
{
error = "Cannot use a non BTC denominated wallet";
return null;
}
}
catch (Exception e)
{