mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
Dotnet reformat
This commit is contained in:
@@ -52,10 +52,10 @@ public class Field
|
|||||||
public string HelpText;
|
public string HelpText;
|
||||||
|
|
||||||
[JsonExtensionData] public IDictionary<string, JToken> AdditionalData { get; set; }
|
[JsonExtensionData] public IDictionary<string, JToken> AdditionalData { get; set; }
|
||||||
public List<Field> Fields { get; set; } = new ();
|
public List<Field> Fields { get; set; } = new();
|
||||||
|
|
||||||
// The field is considered "valid" if there are no validation errors
|
// The field is considered "valid" if there are no validation errors
|
||||||
public List<string> ValidationErrors = new ();
|
public List<string> ValidationErrors = new();
|
||||||
|
|
||||||
public virtual bool IsValid()
|
public virtual bool IsValid()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BTCPayServer.Client.Models;
|
namespace BTCPayServer.Client.Models;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace BTCPayServer.Services.Rates
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RateSourceInfo RateSourceInfo => new RateSourceInfo("NULL","NULL", "https://NULL.NULL");
|
public RateSourceInfo RateSourceInfo => new RateSourceInfo("NULL", "NULL", "https://NULL.NULL");
|
||||||
|
|
||||||
public Task<PairRate[]> GetRatesAsync(CancellationToken cancellationToken)
|
public Task<PairRate[]> GetRatesAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace BTCPayServer.Services.Rates
|
|||||||
AvailableRateProviders.Add(new(rsi.Id, rsi.DisplayName, rsi.Url, RateSource.Coingecko));
|
AvailableRateProviders.Add(new(rsi.Id, rsi.DisplayName, rsi.Url, RateSource.Coingecko));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AvailableRateProviders.Sort((a,b) => StringComparer.Ordinal.Compare(a.DisplayName, b.DisplayName));
|
AvailableRateProviders.Sort((a, b) => StringComparer.Ordinal.Compare(a.DisplayName, b.DisplayName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AvailableRateProvider> AvailableRateProviders { get; } = new List<AvailableRateProvider>();
|
public List<AvailableRateProvider> AvailableRateProviders { get; } = new List<AvailableRateProvider>();
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ namespace BTCPayServer.Tests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void RoundupCurrenciesCorrectly()
|
public void RoundupCurrenciesCorrectly()
|
||||||
{
|
{
|
||||||
DisplayFormatter displayFormatter = new (CurrencyNameTable.Instance);
|
DisplayFormatter displayFormatter = new(CurrencyNameTable.Instance);
|
||||||
foreach (var test in new[]
|
foreach (var test in new[]
|
||||||
{
|
{
|
||||||
(0.0005m, "0.0005 USD", "USD"), (0.001m, "0.001 USD", "USD"), (0.01m, "0.01 USD", "USD"),
|
(0.0005m, "0.0005 USD", "USD"), (0.001m, "0.001 USD", "USD"), (0.01m, "0.01 USD", "USD"),
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public class FormTests : UnitTestBase
|
|||||||
form.SetValues(obj);
|
form.SetValues(obj);
|
||||||
obj = service.GetValues(form);
|
obj = service.GetValues(form);
|
||||||
Assert.Null(obj["test"].Value<string>());
|
Assert.Null(obj["test"].Value<string>());
|
||||||
form.SetValues(new JObject{ ["test"] = "hello" });
|
form.SetValues(new JObject { ["test"] = "hello" });
|
||||||
obj = service.GetValues(form);
|
obj = service.GetValues(form);
|
||||||
Assert.Equal("hello", obj["test"].Value<string>());
|
Assert.Equal("hello", obj["test"].Value<string>());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,7 +302,8 @@ namespace BTCPayServer.Tests
|
|||||||
{
|
{
|
||||||
await client.GetApp("some random ID lol");
|
await client.GetApp("some random ID lol");
|
||||||
});
|
});
|
||||||
await AssertHttpError(404, async () => {
|
await AssertHttpError(404, async () =>
|
||||||
|
{
|
||||||
await client.GetPosApp("some random ID lol");
|
await client.GetPosApp("some random ID lol");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -462,10 +463,12 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Equal("Crowdfund", app.AppType);
|
Assert.Equal("Crowdfund", app.AppType);
|
||||||
|
|
||||||
// Make sure we return a 404 if we try to get an app that doesn't exist
|
// Make sure we return a 404 if we try to get an app that doesn't exist
|
||||||
await AssertHttpError(404, async () => {
|
await AssertHttpError(404, async () =>
|
||||||
|
{
|
||||||
await client.GetApp("some random ID lol");
|
await client.GetApp("some random ID lol");
|
||||||
});
|
});
|
||||||
await AssertHttpError(404, async () => {
|
await AssertHttpError(404, async () =>
|
||||||
|
{
|
||||||
await client.GetCrowdfundApp("some random ID lol");
|
await client.GetCrowdfundApp("some random ID lol");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -488,7 +491,8 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
// Test deleting the newly created app
|
// Test deleting the newly created app
|
||||||
await client.DeleteApp(retrievedApp.Id);
|
await client.DeleteApp(retrievedApp.Id);
|
||||||
await AssertHttpError(404, async () => {
|
await AssertHttpError(404, async () =>
|
||||||
|
{
|
||||||
await client.GetApp(retrievedApp.Id);
|
await client.GetApp(retrievedApp.Id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1256,7 +1260,10 @@ namespace BTCPayServer.Tests
|
|||||||
//update store
|
//update store
|
||||||
Assert.Empty(newStore.PaymentMethodCriteria);
|
Assert.Empty(newStore.PaymentMethodCriteria);
|
||||||
await client.GenerateOnChainWallet(newStore.Id, "BTC", new GenerateOnChainWalletRequest());
|
await client.GenerateOnChainWallet(newStore.Id, "BTC", new GenerateOnChainWalletRequest());
|
||||||
var updatedStore = await client.UpdateStore(newStore.Id, new UpdateStoreRequest() { Name = "B", PaymentMethodCriteria = new List<PaymentMethodCriteriaData>()
|
var updatedStore = await client.UpdateStore(newStore.Id, new UpdateStoreRequest()
|
||||||
|
{
|
||||||
|
Name = "B",
|
||||||
|
PaymentMethodCriteria = new List<PaymentMethodCriteriaData>()
|
||||||
{
|
{
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
@@ -1265,7 +1272,8 @@ namespace BTCPayServer.Tests
|
|||||||
PaymentMethod = "BTC",
|
PaymentMethod = "BTC",
|
||||||
CurrencyCode = "USD"
|
CurrencyCode = "USD"
|
||||||
}
|
}
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
Assert.Equal("B", updatedStore.Name);
|
Assert.Equal("B", updatedStore.Name);
|
||||||
var s = (await client.GetStore(newStore.Id));
|
var s = (await client.GetStore(newStore.Id));
|
||||||
Assert.Equal("B", s.Name);
|
Assert.Equal("B", s.Name);
|
||||||
@@ -1275,7 +1283,7 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.True(pmc.Above);
|
Assert.True(pmc.Above);
|
||||||
Assert.Equal("BTC", pmc.PaymentMethod);
|
Assert.Equal("BTC", pmc.PaymentMethod);
|
||||||
Assert.Equal("USD", pmc.CurrencyCode);
|
Assert.Equal("USD", pmc.CurrencyCode);
|
||||||
updatedStore = await client.UpdateStore(newStore.Id, new UpdateStoreRequest() { Name = "B"});
|
updatedStore = await client.UpdateStore(newStore.Id, new UpdateStoreRequest() { Name = "B" });
|
||||||
Assert.Empty(newStore.PaymentMethodCriteria);
|
Assert.Empty(newStore.PaymentMethodCriteria);
|
||||||
|
|
||||||
//list stores
|
//list stores
|
||||||
@@ -3193,7 +3201,7 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Timeout =TestTimeout)]
|
[Fact(Timeout = TestTimeout)]
|
||||||
[Trait("Integration", "Integration")]
|
[Trait("Integration", "Integration")]
|
||||||
public async Task StoreLightningAddressesAPITests()
|
public async Task StoreLightningAddressesAPITests()
|
||||||
{
|
{
|
||||||
@@ -3205,7 +3213,7 @@ namespace BTCPayServer.Tests
|
|||||||
var store = await adminClient.GetStore(admin.StoreId);
|
var store = await adminClient.GetStore(admin.StoreId);
|
||||||
|
|
||||||
Assert.Empty(await adminClient.GetStorePaymentMethods(store.Id));
|
Assert.Empty(await adminClient.GetStorePaymentMethods(store.Id));
|
||||||
var store2 = (await adminClient.CreateStore(new CreateStoreRequest() {Name = "test2"})).Id;
|
var store2 = (await adminClient.CreateStore(new CreateStoreRequest() { Name = "test2" })).Id;
|
||||||
var address1 = Guid.NewGuid().ToString("n").Substring(0, 8);
|
var address1 = Guid.NewGuid().ToString("n").Substring(0, 8);
|
||||||
var address2 = Guid.NewGuid().ToString("n").Substring(0, 8);
|
var address2 = Guid.NewGuid().ToString("n").Substring(0, 8);
|
||||||
|
|
||||||
@@ -3221,7 +3229,7 @@ namespace BTCPayServer.Tests
|
|||||||
{
|
{
|
||||||
await adminClient.AddOrUpdateStoreLightningAddress(store2, address1, new LightningAddressData());
|
await adminClient.AddOrUpdateStoreLightningAddress(store2, address1, new LightningAddressData());
|
||||||
});
|
});
|
||||||
Assert.Equal(1,Assert.Single(await adminClient.GetStoreLightningAddresses(store.Id)).Max);
|
Assert.Equal(1, Assert.Single(await adminClient.GetStoreLightningAddresses(store.Id)).Max);
|
||||||
Assert.Empty(await adminClient.GetStoreLightningAddresses(store2));
|
Assert.Empty(await adminClient.GetStoreLightningAddresses(store2));
|
||||||
|
|
||||||
await adminClient.AddOrUpdateStoreLightningAddress(store2, address2, new LightningAddressData());
|
await adminClient.AddOrUpdateStoreLightningAddress(store2, address2, new LightningAddressData());
|
||||||
@@ -3986,7 +3994,7 @@ clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfi
|
|||||||
await AssertHttpError(403, async () => await managerClient.GetCustodianAccountDepositAddress(storeId, accountId, MockCustodian.DepositPaymentMethod));
|
await AssertHttpError(403, async () => await managerClient.GetCustodianAccountDepositAddress(storeId, accountId, MockCustodian.DepositPaymentMethod));
|
||||||
|
|
||||||
// Test: GetDepositAddress, wrong payment method
|
// Test: GetDepositAddress, wrong payment method
|
||||||
await AssertApiError( 400, "unsupported-payment-method", async () => await depositClient.GetCustodianAccountDepositAddress(storeId, accountId, "WRONG-PaymentMethod"));
|
await AssertApiError(400, "unsupported-payment-method", async () => await depositClient.GetCustodianAccountDepositAddress(storeId, accountId, "WRONG-PaymentMethod"));
|
||||||
|
|
||||||
// Test: GetDepositAddress, wrong store ID
|
// Test: GetDepositAddress, wrong store ID
|
||||||
await AssertHttpError(403, async () => await depositClient.GetCustodianAccountDepositAddress("WRONG-STORE", accountId, MockCustodian.DepositPaymentMethod));
|
await AssertHttpError(403, async () => await depositClient.GetCustodianAccountDepositAddress("WRONG-STORE", accountId, MockCustodian.DepositPaymentMethod));
|
||||||
@@ -4001,7 +4009,7 @@ clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfi
|
|||||||
|
|
||||||
|
|
||||||
// Test: Trade, unauth
|
// Test: Trade, unauth
|
||||||
var tradeRequest = new TradeRequestData { FromAsset = MockCustodian.TradeFromAsset, ToAsset = MockCustodian.TradeToAsset, Qty = new TradeQuantity(MockCustodian.TradeQtyBought, TradeQuantity.ValueType.Exact)};
|
var tradeRequest = new TradeRequestData { FromAsset = MockCustodian.TradeFromAsset, ToAsset = MockCustodian.TradeToAsset, Qty = new TradeQuantity(MockCustodian.TradeQtyBought, TradeQuantity.ValueType.Exact) };
|
||||||
await AssertHttpError(401, async () => await unauthClient.MarketTradeCustodianAccountAsset(storeId, accountId, tradeRequest));
|
await AssertHttpError(401, async () => await unauthClient.MarketTradeCustodianAccountAsset(storeId, accountId, tradeRequest));
|
||||||
|
|
||||||
// Test: Trade, auth, but wrong permission
|
// Test: Trade, auth, but wrong permission
|
||||||
@@ -4067,7 +4075,7 @@ clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfi
|
|||||||
|
|
||||||
// Test: GetTradeQuote, wrong asset
|
// Test: GetTradeQuote, wrong asset
|
||||||
await AssertHttpError(404, async () => await tradeClient.GetCustodianAccountTradeQuote(storeId, accountId, "WRONG-ASSET", MockCustodian.TradeToAsset));
|
await AssertHttpError(404, async () => await tradeClient.GetCustodianAccountTradeQuote(storeId, accountId, "WRONG-ASSET", MockCustodian.TradeToAsset));
|
||||||
await AssertHttpError(404, async () => await tradeClient.GetCustodianAccountTradeQuote(storeId, accountId, MockCustodian.TradeFromAsset , "WRONG-ASSET"));
|
await AssertHttpError(404, async () => await tradeClient.GetCustodianAccountTradeQuote(storeId, accountId, MockCustodian.TradeFromAsset, "WRONG-ASSET"));
|
||||||
|
|
||||||
// Test: wrong account ID
|
// Test: wrong account ID
|
||||||
await AssertHttpError(404, async () => await tradeClient.GetCustodianAccountTradeQuote(storeId, "WRONG-ACCOUNT-ID", MockCustodian.TradeFromAsset, MockCustodian.TradeToAsset));
|
await AssertHttpError(404, async () => await tradeClient.GetCustodianAccountTradeQuote(storeId, "WRONG-ACCOUNT-ID", MockCustodian.TradeFromAsset, MockCustodian.TradeToAsset));
|
||||||
@@ -4128,14 +4136,14 @@ clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfi
|
|||||||
|
|
||||||
// Test: SimulateWithdrawal, wrong payment method
|
// Test: SimulateWithdrawal, wrong payment method
|
||||||
var wrongPaymentMethodSimulateWithdrawalRequest = new WithdrawRequestData("WRONG-PAYMENT-METHOD", qty);
|
var wrongPaymentMethodSimulateWithdrawalRequest = new WithdrawRequestData("WRONG-PAYMENT-METHOD", qty);
|
||||||
await AssertApiError( 400, "unsupported-payment-method", async () => await withdrawalClient.SimulateCustodianAccountWithdrawal(storeId, accountId, wrongPaymentMethodSimulateWithdrawalRequest));
|
await AssertApiError(400, "unsupported-payment-method", async () => await withdrawalClient.SimulateCustodianAccountWithdrawal(storeId, accountId, wrongPaymentMethodSimulateWithdrawalRequest));
|
||||||
|
|
||||||
// Test: SimulateWithdrawal, wrong account ID
|
// Test: SimulateWithdrawal, wrong account ID
|
||||||
await AssertHttpError(404, async () => await withdrawalClient.SimulateCustodianAccountWithdrawal(storeId, "WRONG-ACCOUNT-ID", simulateWithdrawalRequest));
|
await AssertHttpError(404, async () => await withdrawalClient.SimulateCustodianAccountWithdrawal(storeId, "WRONG-ACCOUNT-ID", simulateWithdrawalRequest));
|
||||||
|
|
||||||
// Test: SimulateWithdrawal, wrong store ID
|
// Test: SimulateWithdrawal, wrong store ID
|
||||||
// TODO it is wierd that 403 is considered normal, but it is like this for all calls where the store is wrong... I'd have preferred a 404 error, because the store cannot be found.
|
// TODO it is wierd that 403 is considered normal, but it is like this for all calls where the store is wrong... I'd have preferred a 404 error, because the store cannot be found.
|
||||||
await AssertHttpError(403, async () => await withdrawalClient.SimulateCustodianAccountWithdrawal( "WRONG-STORE-ID",accountId, simulateWithdrawalRequest));
|
await AssertHttpError(403, async () => await withdrawalClient.SimulateCustodianAccountWithdrawal("WRONG-STORE-ID", accountId, simulateWithdrawalRequest));
|
||||||
|
|
||||||
// Test: SimulateWithdrawal, correct payment method, wrong amount
|
// Test: SimulateWithdrawal, correct payment method, wrong amount
|
||||||
var wrongAmountSimulateWithdrawalRequest = new WithdrawRequestData(MockCustodian.WithdrawalPaymentMethod, TradeQuantity.Parse("0.666"));
|
var wrongAmountSimulateWithdrawalRequest = new WithdrawRequestData(MockCustodian.WithdrawalPaymentMethod, TradeQuantity.Parse("0.666"));
|
||||||
@@ -4159,14 +4167,14 @@ clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfi
|
|||||||
|
|
||||||
// Test: CreateWithdrawal, wrong payment method
|
// Test: CreateWithdrawal, wrong payment method
|
||||||
var wrongPaymentMethodCreateWithdrawalRequest = new WithdrawRequestData("WRONG-PAYMENT-METHOD", qty);
|
var wrongPaymentMethodCreateWithdrawalRequest = new WithdrawRequestData("WRONG-PAYMENT-METHOD", qty);
|
||||||
await AssertApiError( 400, "unsupported-payment-method", async () => await withdrawalClient.CreateCustodianAccountWithdrawal(storeId, accountId, wrongPaymentMethodCreateWithdrawalRequest));
|
await AssertApiError(400, "unsupported-payment-method", async () => await withdrawalClient.CreateCustodianAccountWithdrawal(storeId, accountId, wrongPaymentMethodCreateWithdrawalRequest));
|
||||||
|
|
||||||
// Test: CreateWithdrawal, wrong account ID
|
// Test: CreateWithdrawal, wrong account ID
|
||||||
await AssertHttpError(404, async () => await withdrawalClient.CreateCustodianAccountWithdrawal(storeId, "WRONG-ACCOUNT-ID", createWithdrawalRequest));
|
await AssertHttpError(404, async () => await withdrawalClient.CreateCustodianAccountWithdrawal(storeId, "WRONG-ACCOUNT-ID", createWithdrawalRequest));
|
||||||
|
|
||||||
// Test: CreateWithdrawal, wrong store ID
|
// Test: CreateWithdrawal, wrong store ID
|
||||||
// TODO it is wierd that 403 is considered normal, but it is like this for all calls where the store is wrong... I'd have preferred a 404 error, because the store cannot be found.
|
// TODO it is wierd that 403 is considered normal, but it is like this for all calls where the store is wrong... I'd have preferred a 404 error, because the store cannot be found.
|
||||||
await AssertHttpError(403, async () => await withdrawalClient.CreateCustodianAccountWithdrawal( "WRONG-STORE-ID",accountId, createWithdrawalRequest));
|
await AssertHttpError(403, async () => await withdrawalClient.CreateCustodianAccountWithdrawal("WRONG-STORE-ID", accountId, createWithdrawalRequest));
|
||||||
|
|
||||||
// Test: CreateWithdrawal, correct payment method, wrong amount
|
// Test: CreateWithdrawal, correct payment method, wrong amount
|
||||||
var wrongAmountCreateWithdrawalRequest = new WithdrawRequestData(MockCustodian.WithdrawalPaymentMethod, TradeQuantity.Parse("0.666"));
|
var wrongAmountCreateWithdrawalRequest = new WithdrawRequestData(MockCustodian.WithdrawalPaymentMethod, TradeQuantity.Parse("0.666"));
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public class MockCustodian : ICustodian, ICanDeposit, ICanTrade, ICanWithdraw
|
|||||||
{
|
{
|
||||||
if (paymentMethod == WithdrawalPaymentMethod)
|
if (paymentMethod == WithdrawalPaymentMethod)
|
||||||
{
|
{
|
||||||
if (amount.ToString(CultureInfo.InvariantCulture).Equals(""+WithdrawalAmount, StringComparison.InvariantCulture) || WithdrawalAmountPercentage.Equals(amount))
|
if (amount.ToString(CultureInfo.InvariantCulture).Equals("" + WithdrawalAmount, StringComparison.InvariantCulture) || WithdrawalAmountPercentage.Equals(amount))
|
||||||
{
|
{
|
||||||
return Task.FromResult(CreateWithdrawResult());
|
return Task.FromResult(CreateWithdrawResult());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace BTCPayServer.Tests
|
|||||||
Driver.AssertNoError();
|
Driver.AssertNoError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PayInvoice(bool mine = false, decimal? amount= null)
|
public void PayInvoice(bool mine = false, decimal? amount = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (amount is not null)
|
if (amount is not null)
|
||||||
|
|||||||
@@ -61,34 +61,34 @@ namespace BTCPayServer.Tests
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// <summary>
|
// /// <summary>
|
||||||
// /// This will take the translations from v1 or v2
|
// /// This will take the translations from v1 or v2
|
||||||
// /// and upload them to transifex if not found
|
// /// and upload them to transifex if not found
|
||||||
// /// </summary>
|
// /// </summary>
|
||||||
// [FactWithSecret("TransifexAPIToken")]
|
// [FactWithSecret("TransifexAPIToken")]
|
||||||
// [Trait("Utilities", "Utilities")]
|
// [Trait("Utilities", "Utilities")]
|
||||||
//#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
//#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||||
// public async Task UpdateTransifex()
|
// public async Task UpdateTransifex()
|
||||||
// {
|
// {
|
||||||
// // DO NOT RUN IT, THIS WILL ERASE THE CURRENT TRANSIFEX TRANSLATIONS
|
// // DO NOT RUN IT, THIS WILL ERASE THE CURRENT TRANSIFEX TRANSLATIONS
|
||||||
|
|
||||||
// var client = GetTransifexClient();
|
// var client = GetTransifexClient();
|
||||||
// var translations = JsonTranslation.GetTranslations(TranslationFolder.CheckoutV2);
|
// var translations = JsonTranslation.GetTranslations(TranslationFolder.CheckoutV2);
|
||||||
// var enTranslations = translations["en"];
|
// var enTranslations = translations["en"];
|
||||||
// translations.Remove("en");
|
// translations.Remove("en");
|
||||||
|
|
||||||
// foreach (var t in translations)
|
// foreach (var t in translations)
|
||||||
// {
|
// {
|
||||||
// foreach (var w in t.Value.Words.ToArray())
|
// foreach (var w in t.Value.Words.ToArray())
|
||||||
// {
|
// {
|
||||||
// if (t.Value.Words[w.Key] == null)
|
// if (t.Value.Words[w.Key] == null)
|
||||||
// t.Value.Words[w.Key] = enTranslations.Words[w.Key];
|
// t.Value.Words[w.Key] = enTranslations.Words[w.Key];
|
||||||
// }
|
// }
|
||||||
// t.Value.Words.Remove("code");
|
// t.Value.Words.Remove("code");
|
||||||
// t.Value.Words.Remove("NOTICE_WARN");
|
// t.Value.Words.Remove("NOTICE_WARN");
|
||||||
// }
|
// }
|
||||||
// await client.UpdateTranslations(translations);
|
// await client.UpdateTranslations(translations);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
//#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||||
|
|
||||||
@@ -577,7 +577,7 @@ retry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Translate(Dictionary<string,string> sourceTranslations)
|
public void Translate(Dictionary<string, string> sourceTranslations)
|
||||||
{
|
{
|
||||||
foreach (var o in sourceTranslations)
|
foreach (var o in sourceTranslations)
|
||||||
if (o.Value != null)
|
if (o.Value != null)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace BTCPayServer
|
namespace BTCPayServer
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace BTCPayServer.Components.LabelManager
|
|||||||
{
|
{
|
||||||
ExcludeTypes = excludeTypes,
|
ExcludeTypes = excludeTypes,
|
||||||
WalletObjectId = walletObjectId,
|
WalletObjectId = walletObjectId,
|
||||||
SelectedLabels = selectedLabels?? Array.Empty<string>(),
|
SelectedLabels = selectedLabels ?? Array.Empty<string>(),
|
||||||
DisplayInline = displayInline,
|
DisplayInline = displayInline,
|
||||||
RichLabelInfo = richLabelInfo,
|
RichLabelInfo = richLabelInfo,
|
||||||
AutoUpdate = autoUpdate,
|
AutoUpdate = autoUpdate,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace BTCPayServer.Components.QRCode
|
|||||||
{
|
{
|
||||||
public class QRCode : ViewComponent
|
public class QRCode : ViewComponent
|
||||||
{
|
{
|
||||||
private static QRCodeGenerator _qrGenerator = new ();
|
private static QRCodeGenerator _qrGenerator = new();
|
||||||
|
|
||||||
public IViewComponentResult Invoke(string data)
|
public IViewComponentResult Invoke(string data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class StoreRecentTransactions : ViewComponent
|
|||||||
var network = derivationSettings.Network;
|
var network = derivationSettings.Network;
|
||||||
var wallet = _walletProvider.GetWallet(network);
|
var wallet = _walletProvider.GetWallet(network);
|
||||||
var allTransactions = await wallet.FetchTransactionHistory(derivationSettings.AccountDerivation, 0, 5, TimeSpan.FromDays(31.0));
|
var allTransactions = await wallet.FetchTransactionHistory(derivationSettings.AccountDerivation, 0, 5, TimeSpan.FromDays(31.0));
|
||||||
var walletTransactionsInfo = await _walletRepository.GetWalletTransactionsInfo( vm.WalletId , allTransactions.Select(t => t.TransactionId.ToString()).ToArray());
|
var walletTransactionsInfo = await _walletRepository.GetWalletTransactionsInfo(vm.WalletId, allTransactions.Select(t => t.TransactionId.ToString()).ToArray());
|
||||||
|
|
||||||
transactions = allTransactions
|
transactions = allTransactions
|
||||||
.Select(tx =>
|
.Select(tx =>
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace BTCPayServer.Configuration
|
|||||||
foreach (var n in new BTCPayNetworkProvider(networkType).GetAll().OfType<BTCPayNetwork>())
|
foreach (var n in new BTCPayNetworkProvider(networkType).GetAll().OfType<BTCPayNetwork>())
|
||||||
{
|
{
|
||||||
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.explorer.url={n.NBXplorerNetwork.DefaultSettings.DefaultUrl}");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.explorer.url={n.NBXplorerNetwork.DefaultSettings.DefaultUrl}");
|
||||||
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.explorer.cookiefile={ n.NBXplorerNetwork.DefaultSettings.DefaultCookieFile}");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.explorer.cookiefile={n.NBXplorerNetwork.DefaultSettings.DefaultCookieFile}");
|
||||||
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.blockexplorerlink=https://mempool.space/tx/{{0}}");
|
builder.AppendLine(CultureInfo.InvariantCulture, $"#{n.CryptoCode}.blockexplorerlink=https://mempool.space/tx/{{0}}");
|
||||||
if (n.SupportLightning)
|
if (n.SupportLightning)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
return new PointOfSaleSettings()
|
return new PointOfSaleSettings()
|
||||||
{
|
{
|
||||||
Title = request.Title,
|
Title = request.Title,
|
||||||
DefaultView = (PosViewType) request.DefaultView,
|
DefaultView = (PosViewType)request.DefaultView,
|
||||||
ShowCustomAmount = request.ShowCustomAmount,
|
ShowCustomAmount = request.ShowCustomAmount,
|
||||||
ShowDiscount = request.ShowDiscount,
|
ShowDiscount = request.ShowDiscount,
|
||||||
EnableTips = request.EnableTips,
|
EnableTips = request.EnableTips,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ using BTCPayServer.Security;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Cors;
|
using Microsoft.AspNetCore.Cors;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using StoreData = BTCPayServer.Data.StoreData;
|
|
||||||
using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData;
|
using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData;
|
||||||
|
using StoreData = BTCPayServer.Data.StoreData;
|
||||||
|
|
||||||
namespace BTCPayServer.Controllers.Greenfield
|
namespace BTCPayServer.Controllers.Greenfield
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -264,7 +264,8 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
pullPaymentId = pullPaymentId
|
pullPaymentId = pullPaymentId
|
||||||
}, Request.Scheme, Request.Host.ToString())!);
|
}, Request.Scheme, Request.Host.ToString())!);
|
||||||
|
|
||||||
return base.Ok(new PullPaymentLNURL() {
|
return base.Ok(new PullPaymentLNURL()
|
||||||
|
{
|
||||||
LNURLBech32 = LNURL.LNURL.EncodeUri(lnurlEndpoint, "withdrawRequest", true).ToString(),
|
LNURLBech32 = LNURL.LNURL.EncodeUri(lnurlEndpoint, "withdrawRequest", true).ToString(),
|
||||||
LNURLUri = LNURL.LNURL.EncodeUri(lnurlEndpoint, "withdrawRequest", false).ToString()
|
LNURLUri = LNURL.LNURL.EncodeUri(lnurlEndpoint, "withdrawRequest", false).ToString()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
return new LightningAddressData();
|
return new LightningAddressData();
|
||||||
return new LightningAddressData()
|
return new LightningAddressData()
|
||||||
{
|
{
|
||||||
Username = data.Username, Max = blob.Max, Min = blob.Min, CurrencyCode = blob.CurrencyCode
|
Username = data.Username,
|
||||||
|
Max = blob.Max,
|
||||||
|
Min = blob.Min,
|
||||||
|
CurrencyCode = blob.CurrencyCode
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +44,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
[HttpGet("~/api/v1/stores/{storeId}/lightning-addresses")]
|
[HttpGet("~/api/v1/stores/{storeId}/lightning-addresses")]
|
||||||
public async Task<IActionResult> GetStoreLightningAddresses(string storeId)
|
public async Task<IActionResult> GetStoreLightningAddresses(string storeId)
|
||||||
{
|
{
|
||||||
return Ok((await _lightningAddressService.Get(new LightningAddressQuery() {StoreIds = new[] {storeId}}))
|
return Ok((await _lightningAddressService.Get(new LightningAddressQuery() { StoreIds = new[] { storeId } }))
|
||||||
.Select(ToModel).ToArray());
|
.Select(ToModel).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +67,8 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
{
|
{
|
||||||
var res = await _lightningAddressService.Get(new LightningAddressQuery()
|
var res = await _lightningAddressService.Get(new LightningAddressQuery()
|
||||||
{
|
{
|
||||||
Usernames = new[] {username}, StoreIds = new[] {storeId},
|
Usernames = new[] { username },
|
||||||
|
StoreIds = new[] { storeId },
|
||||||
});
|
});
|
||||||
return res?.Any() is true ? Ok(ToModel(res.First())) : this.CreateAPIError(404, "lightning-address-not-found", "The lightning address was not present.");
|
return res?.Any() is true ? Ok(ToModel(res.First())) : this.CreateAPIError(404, "lightning-address-not-found", "The lightning address was not present.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
Amount = criteria.Value.Value,
|
Amount = criteria.Value.Value,
|
||||||
CurrencyCode = criteria.Value.Currency,
|
CurrencyCode = criteria.Value.Currency,
|
||||||
PaymentMethod = criteria.PaymentMethod.ToStringNormalized()
|
PaymentMethod = criteria.PaymentMethod.ToStringNormalized()
|
||||||
})?.ToList()?? new List<PaymentMethodCriteriaData>()
|
})?.ToList() ?? new List<PaymentMethodCriteriaData>()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,8 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
if (string.IsNullOrEmpty(pmc.CurrencyCode))
|
if (string.IsNullOrEmpty(pmc.CurrencyCode))
|
||||||
{
|
{
|
||||||
request.AddModelError(data => data.PaymentMethodCriteria[index].CurrencyCode, "CurrencyCode is required", this);
|
request.AddModelError(data => data.PaymentMethodCriteria[index].CurrencyCode, "CurrencyCode is required", this);
|
||||||
}else if (CurrencyNameTable.Instance.GetCurrencyData(pmc.CurrencyCode, false) is null)
|
}
|
||||||
|
else if (CurrencyNameTable.Instance.GetCurrencyData(pmc.CurrencyCode, false) is null)
|
||||||
{
|
{
|
||||||
request.AddModelError(data => data.PaymentMethodCriteria[index].CurrencyCode, "CurrencyCode is invalid", this);
|
request.AddModelError(data => data.PaymentMethodCriteria[index].CurrencyCode, "CurrencyCode is invalid", this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ using LightningAddressData = BTCPayServer.Client.Models.LightningAddressData;
|
|||||||
using NotificationData = BTCPayServer.Client.Models.NotificationData;
|
using NotificationData = BTCPayServer.Client.Models.NotificationData;
|
||||||
using PaymentRequestData = BTCPayServer.Client.Models.PaymentRequestData;
|
using PaymentRequestData = BTCPayServer.Client.Models.PaymentRequestData;
|
||||||
using PayoutData = BTCPayServer.Client.Models.PayoutData;
|
using PayoutData = BTCPayServer.Client.Models.PayoutData;
|
||||||
|
using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData;
|
||||||
using PullPaymentData = BTCPayServer.Client.Models.PullPaymentData;
|
using PullPaymentData = BTCPayServer.Client.Models.PullPaymentData;
|
||||||
using StoreData = BTCPayServer.Client.Models.StoreData;
|
using StoreData = BTCPayServer.Client.Models.StoreData;
|
||||||
using StoreWebhookData = BTCPayServer.Client.Models.StoreWebhookData;
|
using StoreWebhookData = BTCPayServer.Client.Models.StoreWebhookData;
|
||||||
using WebhookDeliveryData = BTCPayServer.Client.Models.WebhookDeliveryData;
|
using WebhookDeliveryData = BTCPayServer.Client.Models.WebhookDeliveryData;
|
||||||
using PayoutProcessorData = BTCPayServer.Client.Models.PayoutProcessorData;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Controllers.Greenfield
|
namespace BTCPayServer.Controllers.Greenfield
|
||||||
{
|
{
|
||||||
@@ -1238,7 +1238,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
return Task.FromResult(GetFromActionResult<StoreRateConfiguration>(GetController<GreenfieldStoreRateConfigurationController>().GetStoreRateConfiguration()));
|
return Task.FromResult(GetFromActionResult<StoreRateConfiguration>(GetController<GreenfieldStoreRateConfigurationController>().GetStoreRateConfiguration()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<List<StoreRateResult>> GetStoreRates (string storeId,
|
public override async Task<List<StoreRateResult>> GetStoreRates(string storeId,
|
||||||
string[] currencyPair, CancellationToken token = default)
|
string[] currencyPair, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
return GetFromActionResult<List<StoreRateResult>>(await GetController<GreenfieldStoreRatesController>().GetStoreRates(currencyPair));
|
return GetFromActionResult<List<StoreRateResult>>(await GetController<GreenfieldStoreRatesController>().GetStoreRates(currencyPair));
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class LightningAddressService
|
|||||||
{
|
{
|
||||||
data.Username = NormalizeUsername(data.Username);
|
data.Username = NormalizeUsername(data.Username);
|
||||||
await using var context = _applicationDbContextFactory.CreateContext();
|
await using var context = _applicationDbContextFactory.CreateContext();
|
||||||
var result = (await GetCore(context, new LightningAddressQuery() { Usernames = new[] { data.Username} }))
|
var result = (await GetCore(context, new LightningAddressQuery() { Usernames = new[] { data.Username } }))
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
if (result is not null)
|
if (result is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace BTCPayServer.Controllers
|
|||||||
[HttpGet("/cheat/permissions")]
|
[HttpGet("/cheat/permissions")]
|
||||||
[HttpGet("/cheat/permissions/stores/{storeId}")]
|
[HttpGet("/cheat/permissions/stores/{storeId}")]
|
||||||
[CheatModeRoute]
|
[CheatModeRoute]
|
||||||
public async Task<IActionResult> CheatPermissions([FromServices]IAuthorizationService authorizationService, string storeId = null)
|
public async Task<IActionResult> CheatPermissions([FromServices] IAuthorizationService authorizationService, string storeId = null)
|
||||||
{
|
{
|
||||||
var vm = new CheatPermissionsViewModel();
|
var vm = new CheatPermissionsViewModel();
|
||||||
vm.StoreId = storeId;
|
vm.StoreId = storeId;
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ namespace BTCPayServer.Controllers
|
|||||||
var metaData = PosDataParser.ParsePosData(invoice.Metadata.ToJObject());
|
var metaData = PosDataParser.ParsePosData(invoice.Metadata.ToJObject());
|
||||||
var additionalData = metaData
|
var additionalData = metaData
|
||||||
.Where(dict => !InvoiceAdditionalDataExclude.Contains(dict.Key))
|
.Where(dict => !InvoiceAdditionalDataExclude.Contains(dict.Key))
|
||||||
.ToDictionary(dict=> dict.Key, dict=> dict.Value);
|
.ToDictionary(dict => dict.Key, dict => dict.Value);
|
||||||
var model = new InvoiceDetailsModel
|
var model = new InvoiceDetailsModel
|
||||||
{
|
{
|
||||||
StoreId = store.Id,
|
StoreId = store.Id,
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ namespace BTCPayServer
|
|||||||
case PayResult.Error:
|
case PayResult.Error:
|
||||||
default:
|
default:
|
||||||
await _pullPaymentHostedService.Cancel(
|
await _pullPaymentHostedService.Cancel(
|
||||||
new PullPaymentHostedService.CancelRequest(new []
|
new PullPaymentHostedService.CancelRequest(new[]
|
||||||
{ claimResponse.PayoutData.Id }, null));
|
{ claimResponse.PayoutData.Id }, null));
|
||||||
|
|
||||||
return BadRequest(new LNUrlStatusResponse
|
return BadRequest(new LNUrlStatusResponse
|
||||||
@@ -305,7 +305,7 @@ namespace BTCPayServer
|
|||||||
};
|
};
|
||||||
|
|
||||||
var invoiceMetadata = new InvoiceMetadata();
|
var invoiceMetadata = new InvoiceMetadata();
|
||||||
invoiceMetadata.OrderId =AppService.GetAppOrderId(app);
|
invoiceMetadata.OrderId = AppService.GetAppOrderId(app);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
invoiceMetadata.ItemCode = item.Id;
|
invoiceMetadata.ItemCode = item.Id;
|
||||||
@@ -355,8 +355,8 @@ namespace BTCPayServer
|
|||||||
public string InvoiceMetadata { get; set; }
|
public string InvoiceMetadata { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentDictionary<string, LightningAddressItem> Items { get; } = new ();
|
public ConcurrentDictionary<string, LightningAddressItem> Items { get; } = new();
|
||||||
public ConcurrentDictionary<string, string[]> StoreToItemMap { get; } = new ();
|
public ConcurrentDictionary<string, string[]> StoreToItemMap { get; } = new();
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@@ -466,7 +466,7 @@ namespace BTCPayServer
|
|||||||
lnurlRequest ??= new LNURLPayRequest();
|
lnurlRequest ??= new LNURLPayRequest();
|
||||||
lnUrlMetadata ??= new Dictionary<string, string>();
|
lnUrlMetadata ??= new Dictionary<string, string>();
|
||||||
|
|
||||||
if (lnUrlMetadata?.TryGetValue("text/identifier", out var lnAddress) is true && lnAddress is string)
|
if (lnUrlMetadata?.TryGetValue("text/identifier", out var lnAddress) is true && lnAddress is not null)
|
||||||
{
|
{
|
||||||
var pm = i.GetPaymentMethod(pmi);
|
var pm = i.GetPaymentMethod(pmi);
|
||||||
var paymentMethodDetails = (LNURLPayPaymentMethodDetails)pm.GetPaymentMethodDetails();
|
var paymentMethodDetails = (LNURLPayPaymentMethodDetails)pm.GetPaymentMethodDetails();
|
||||||
@@ -759,7 +759,7 @@ namespace BTCPayServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
JObject metadata = null;
|
JObject metadata = null;
|
||||||
if (!string.IsNullOrEmpty(vm.Add.InvoiceMetadata) )
|
if (!string.IsNullOrEmpty(vm.Add.InvoiceMetadata))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -224,14 +224,14 @@ namespace BTCPayServer.Controllers
|
|||||||
var prBlob = result.GetBlob();
|
var prBlob = result.GetBlob();
|
||||||
if (prBlob.FormResponse is not null)
|
if (prBlob.FormResponse is not null)
|
||||||
{
|
{
|
||||||
return RedirectToAction("PayPaymentRequest", new {payReqId});
|
return RedirectToAction("PayPaymentRequest", new { payReqId });
|
||||||
}
|
}
|
||||||
var prFormId = prBlob.FormId;
|
var prFormId = prBlob.FormId;
|
||||||
var formData = await FormDataService.GetForm(prFormId);
|
var formData = await FormDataService.GetForm(prFormId);
|
||||||
if (formData is null)
|
if (formData is null)
|
||||||
{
|
{
|
||||||
|
|
||||||
return RedirectToAction("PayPaymentRequest", new {payReqId});
|
return RedirectToAction("PayPaymentRequest", new { payReqId });
|
||||||
}
|
}
|
||||||
|
|
||||||
var form = Form.Parse(formData.Config);
|
var form = Form.Parse(formData.Config);
|
||||||
@@ -243,7 +243,7 @@ namespace BTCPayServer.Controllers
|
|||||||
prBlob.FormResponse = FormDataService.GetValues(form);
|
prBlob.FormResponse = FormDataService.GetValues(form);
|
||||||
result.SetBlob(prBlob);
|
result.SetBlob(prBlob);
|
||||||
await _PaymentRequestRepository.CreateOrUpdatePaymentRequest(result);
|
await _PaymentRequestRepository.CreateOrUpdatePaymentRequest(result);
|
||||||
return RedirectToAction("PayPaymentRequest", new {payReqId});
|
return RedirectToAction("PayPaymentRequest", new { payReqId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewModel.FormName = formData.Name;
|
viewModel.FormName = formData.Name;
|
||||||
@@ -283,7 +283,7 @@ namespace BTCPayServer.Controllers
|
|||||||
var formData = await FormDataService.GetForm(result.FormId);
|
var formData = await FormDataService.GetForm(result.FormId);
|
||||||
if (formData is not null)
|
if (formData is not null)
|
||||||
{
|
{
|
||||||
return RedirectToAction("ViewPaymentRequestForm", new {payReqId});
|
return RedirectToAction("ViewPaymentRequestForm", new { payReqId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -455,9 +455,9 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
IncludeArchived = false,
|
IncludeArchived = false,
|
||||||
IncludeStoreData = true,
|
IncludeStoreData = true,
|
||||||
Stores = new[] {storeId},
|
Stores = new[] { storeId },
|
||||||
PayoutIds = payoutIds,
|
PayoutIds = payoutIds,
|
||||||
PaymentMethods = new[] {paymentMethodId.ToString()}
|
PaymentMethods = new[] { paymentMethodId.ToString() }
|
||||||
}, ctx, cancellationToken);
|
}, ctx, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ namespace BTCPayServer.Controllers
|
|||||||
ModelState.Remove(nameof(vm.PSBT));
|
ModelState.Remove(nameof(vm.PSBT));
|
||||||
ModelState.Remove(nameof(vm.FileName));
|
ModelState.Remove(nameof(vm.FileName));
|
||||||
ModelState.Remove(nameof(vm.UploadedPSBTFile));
|
ModelState.Remove(nameof(vm.UploadedPSBTFile));
|
||||||
await FetchTransactionDetails(walletId,derivationSchemeSettings, vm, network);
|
await FetchTransactionDetails(walletId, derivationSchemeSettings, vm, network);
|
||||||
return View("WalletPSBTDecoded", vm);
|
return View("WalletPSBTDecoded", vm);
|
||||||
|
|
||||||
case "save-psbt":
|
case "save-psbt":
|
||||||
@@ -391,7 +391,7 @@ namespace BTCPayServer.Controllers
|
|||||||
walletObjectIds.Add(new ObjectTypeId(WalletObjectData.Types.Utxo, input.PrevOut.ToString()));
|
walletObjectIds.Add(new ObjectTypeId(WalletObjectData.Types.Utxo, input.PrevOut.ToString()));
|
||||||
walletObjectIds.Add(new ObjectTypeId(WalletObjectData.Types.Tx, input.PrevOut.Hash.ToString()));
|
walletObjectIds.Add(new ObjectTypeId(WalletObjectData.Types.Tx, input.PrevOut.Hash.ToString()));
|
||||||
var address = txOut?.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork)?.ToString();
|
var address = txOut?.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork)?.ToString();
|
||||||
if(address != null)
|
if (address != null)
|
||||||
walletObjectIds.Add(new ObjectTypeId(WalletObjectData.Types.Address, address));
|
walletObjectIds.Add(new ObjectTypeId(WalletObjectData.Types.Address, address));
|
||||||
inputToObjects.Add(input.Index, walletObjectIds.ToArray());
|
inputToObjects.Add(input.Index, walletObjectIds.ToArray());
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ namespace BTCPayServer.Controllers
|
|||||||
dest.Positive = balanceChange2 >= Money.Zero;
|
dest.Positive = balanceChange2 >= Money.Zero;
|
||||||
dest.Destination = output.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork)?.ToString() ?? output.ScriptPubKey.ToString();
|
dest.Destination = output.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork)?.ToString() ?? output.ScriptPubKey.ToString();
|
||||||
var address = output.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork)?.ToString();
|
var address = output.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork)?.ToString();
|
||||||
if(address != null)
|
if (address != null)
|
||||||
outputToObjects.Add(dest.Destination, new ObjectTypeId(WalletObjectData.Types.Address, address));
|
outputToObjects.Add(dest.Destination, new ObjectTypeId(WalletObjectData.Types.Address, address));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -442,13 +442,14 @@ namespace BTCPayServer.Controllers
|
|||||||
.DistinctBy(id => $"{id.Type}:{id.Id}").ToArray();
|
.DistinctBy(id => $"{id.Type}:{id.Id}").ToArray();
|
||||||
|
|
||||||
var labelInfo = await WalletRepository.GetWalletTransactionsInfo(walletId, combinedTypeIds);
|
var labelInfo = await WalletRepository.GetWalletTransactionsInfo(walletId, combinedTypeIds);
|
||||||
foreach (KeyValuePair<uint,ObjectTypeId[]> inputToObject in inputToObjects)
|
foreach (KeyValuePair<uint, ObjectTypeId[]> inputToObject in inputToObjects)
|
||||||
{
|
{
|
||||||
var keys = inputToObject.Value.Select(id => id.Id).ToArray();
|
var keys = inputToObject.Value.Select(id => id.Id).ToArray();
|
||||||
WalletTransactionInfo ix = null;
|
WalletTransactionInfo ix = null;
|
||||||
foreach (var key in keys)
|
foreach (var key in keys)
|
||||||
{
|
{
|
||||||
if (!labelInfo.TryGetValue(key, out var i)) continue;
|
if (!labelInfo.TryGetValue(key, out var i))
|
||||||
|
continue;
|
||||||
if (ix is null)
|
if (ix is null)
|
||||||
{
|
{
|
||||||
ix = i;
|
ix = i;
|
||||||
@@ -458,7 +459,8 @@ namespace BTCPayServer.Controllers
|
|||||||
ix.Merge(i);
|
ix.Merge(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ix is null) continue;
|
if (ix is null)
|
||||||
|
continue;
|
||||||
|
|
||||||
var labels = _labelService.CreateTransactionTagModels(ix, Request);
|
var labels = _labelService.CreateTransactionTagModels(ix, Request);
|
||||||
var input = vm.Inputs.First(model => model.Index == inputToObject.Key);
|
var input = vm.Inputs.First(model => model.Index == inputToObject.Key);
|
||||||
@@ -466,7 +468,8 @@ namespace BTCPayServer.Controllers
|
|||||||
}
|
}
|
||||||
foreach (var outputToObject in outputToObjects)
|
foreach (var outputToObject in outputToObjects)
|
||||||
{
|
{
|
||||||
if (!labelInfo.TryGetValue(outputToObject.Value.Id, out var ix)) continue;
|
if (!labelInfo.TryGetValue(outputToObject.Value.Id, out var ix))
|
||||||
|
continue;
|
||||||
var labels = _labelService.CreateTransactionTagModels(ix, Request);
|
var labels = _labelService.CreateTransactionTagModels(ix, Request);
|
||||||
var destination = vm.Destinations.First(model => model.Destination == outputToObject.Key);
|
var destination = vm.Destinations.First(model => model.Destination == outputToObject.Key);
|
||||||
destination.Labels = labels;
|
destination.Labels = labels;
|
||||||
@@ -491,7 +494,7 @@ namespace BTCPayServer.Controllers
|
|||||||
if (derivationSchemeSettings == null)
|
if (derivationSchemeSettings == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
await FetchTransactionDetails(walletId,derivationSchemeSettings, vm, network);
|
await FetchTransactionDetails(walletId, derivationSchemeSettings, vm, network);
|
||||||
|
|
||||||
switch (command)
|
switch (command)
|
||||||
{
|
{
|
||||||
@@ -622,7 +625,7 @@ namespace BTCPayServer.Controllers
|
|||||||
BackUrl = vm.BackUrl
|
BackUrl = vm.BackUrl
|
||||||
});
|
});
|
||||||
case "decode":
|
case "decode":
|
||||||
await FetchTransactionDetails(walletId,derivationSchemeSettings, vm, network);
|
await FetchTransactionDetails(walletId, derivationSchemeSettings, vm, network);
|
||||||
return View("WalletPSBTDecoded", vm);
|
return View("WalletPSBTDecoded", vm);
|
||||||
default:
|
default:
|
||||||
vm.Errors.Add("Unknown command");
|
vm.Errors.Add("Unknown command");
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ namespace BTCPayServer.Controllers
|
|||||||
CryptoImage = GetImage(paymentMethod.PaymentId, network),
|
CryptoImage = GetImage(paymentMethod.PaymentId, network),
|
||||||
PaymentLink = bip21.ToString(),
|
PaymentLink = bip21.ToString(),
|
||||||
ReturnUrl = returnUrl ?? HttpContext.Request.GetTypedHeaders().Referer?.AbsolutePath,
|
ReturnUrl = returnUrl ?? HttpContext.Request.GetTypedHeaders().Referer?.AbsolutePath,
|
||||||
SelectedLabels = labels?? Array.Empty<string>()
|
SelectedLabels = labels ?? Array.Empty<string>()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,10 +787,10 @@ namespace BTCPayServer.Controllers
|
|||||||
switch (response.Result)
|
switch (response.Result)
|
||||||
{
|
{
|
||||||
case ClaimRequest.ClaimResult.Duplicate:
|
case ClaimRequest.ClaimResult.Duplicate:
|
||||||
errorMessage += $"{claimRequest.Value} to {claimRequest.Destination.ToString() } - address reuse<br/>";
|
errorMessage += $"{claimRequest.Value} to {claimRequest.Destination.ToString()} - address reuse<br/>";
|
||||||
break;
|
break;
|
||||||
case ClaimRequest.ClaimResult.AmountTooLow:
|
case ClaimRequest.ClaimResult.AmountTooLow:
|
||||||
errorMessage += $"{claimRequest.Value} to {claimRequest.Destination.ToString() } - amount too low<br/>";
|
errorMessage += $"{claimRequest.Value} to {claimRequest.Destination.ToString()} - amount too low<br/>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,7 +211,9 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
|
|||||||
{
|
{
|
||||||
var payouts = (await PullPaymentHostedService.GetPayouts(new PullPaymentHostedService.PayoutQuery()
|
var payouts = (await PullPaymentHostedService.GetPayouts(new PullPaymentHostedService.PayoutQuery()
|
||||||
{
|
{
|
||||||
States = new[] {PayoutState.AwaitingPayment}, Stores = new[] {storeId}, PayoutIds = payoutIds
|
States = new[] { PayoutState.AwaitingPayment },
|
||||||
|
Stores = new[] { storeId },
|
||||||
|
PayoutIds = payoutIds
|
||||||
}, context)).Where(data =>
|
}, context)).Where(data =>
|
||||||
PaymentMethodId.TryParse(data.PaymentMethodId, out var paymentMethodId) &&
|
PaymentMethodId.TryParse(data.PaymentMethodId, out var paymentMethodId) &&
|
||||||
CanHandle(paymentMethodId))
|
CanHandle(paymentMethodId))
|
||||||
@@ -234,7 +236,9 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
|
|||||||
{
|
{
|
||||||
var payouts = (await PullPaymentHostedService.GetPayouts(new PullPaymentHostedService.PayoutQuery()
|
var payouts = (await PullPaymentHostedService.GetPayouts(new PullPaymentHostedService.PayoutQuery()
|
||||||
{
|
{
|
||||||
States = new[] {PayoutState.AwaitingPayment}, Stores = new[] {storeId}, PayoutIds = payoutIds
|
States = new[] { PayoutState.AwaitingPayment },
|
||||||
|
Stores = new[] { storeId },
|
||||||
|
PayoutIds = payoutIds
|
||||||
}, context)).Where(data =>
|
}, context)).Where(data =>
|
||||||
PaymentMethodId.TryParse(data.PaymentMethodId, out var paymentMethodId) &&
|
PaymentMethodId.TryParse(data.PaymentMethodId, out var paymentMethodId) &&
|
||||||
CanHandle(paymentMethodId))
|
CanHandle(paymentMethodId))
|
||||||
|
|||||||
@@ -87,9 +87,12 @@ namespace BTCPayServer
|
|||||||
var match = derivationRegex.Match(xpub.Trim());
|
var match = derivationRegex.Match(xpub.Trim());
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(match.Groups[1].Value)) rootFingerprint = HDFingerprint.Parse(match.Groups[1].Value);
|
if (!string.IsNullOrEmpty(match.Groups[1].Value))
|
||||||
if (!string.IsNullOrEmpty(match.Groups[2].Value)) accountKeyPath = KeyPath.Parse(match.Groups[2].Value);
|
rootFingerprint = HDFingerprint.Parse(match.Groups[1].Value);
|
||||||
if (!string.IsNullOrEmpty(match.Groups[3].Value)) xpub = match.Groups[3].Value;
|
if (!string.IsNullOrEmpty(match.Groups[2].Value))
|
||||||
|
accountKeyPath = KeyPath.Parse(match.Groups[2].Value);
|
||||||
|
if (!string.IsNullOrEmpty(match.Groups[3].Value))
|
||||||
|
xpub = match.Groups[3].Value;
|
||||||
}
|
}
|
||||||
derivationSchemeSettings.AccountOriginal = xpub.Trim();
|
derivationSchemeSettings.AccountOriginal = xpub.Trim();
|
||||||
derivationSchemeSettings.AccountDerivation = electrum ? derivationSchemeParser.ParseElectrum(derivationSchemeSettings.AccountOriginal) : derivationSchemeParser.Parse(derivationSchemeSettings.AccountOriginal);
|
derivationSchemeSettings.AccountDerivation = electrum ? derivationSchemeParser.ParseElectrum(derivationSchemeSettings.AccountOriginal) : derivationSchemeParser.Parse(derivationSchemeSettings.AccountOriginal);
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ namespace BTCPayServer
|
|||||||
{
|
{
|
||||||
pattern = pattern.Replace(" ", "");
|
pattern = pattern.Replace(" ", "");
|
||||||
int[] res = new int[pattern.Length / 2];
|
int[] res = new int[pattern.Length / 2];
|
||||||
for (int i = 0; i < pattern.Length; i+=2)
|
for (int i = 0; i < pattern.Length; i += 2)
|
||||||
{
|
{
|
||||||
var b = pattern[i..(i + 2)];
|
var b = pattern[i..(i + 2)];
|
||||||
if (b == "XX")
|
if (b == "XX")
|
||||||
res[i/2] = -1;
|
res[i / 2] = -1;
|
||||||
else
|
else
|
||||||
res[i/2] = byte.Parse(b, System.Globalization.NumberStyles.HexNumber);
|
res[i / 2] = byte.Parse(b, System.Globalization.NumberStyles.HexNumber);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ namespace BTCPayServer.Filters
|
|||||||
if (matchedDomainMapping != null && req.Method != "POST" && !req.HasFormContentType)
|
if (matchedDomainMapping != null && req.Method != "POST" && !req.HasFormContentType)
|
||||||
{
|
{
|
||||||
var uri = new UriBuilder(req.Scheme, matchedDomainMapping.Domain);
|
var uri = new UriBuilder(req.Scheme, matchedDomainMapping.Domain);
|
||||||
if (req.Host.Port.HasValue) uri.Port = req.Host.Port.Value;
|
if (req.Host.Port.HasValue)
|
||||||
|
uri.Port = req.Host.Port.Value;
|
||||||
context.RouteContext.HttpContext.Response.Redirect(uri.ToString());
|
context.RouteContext.HttpContext.Response.Redirect(uri.ToString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class FormDataService
|
|||||||
{"Address", ("Request shipping address", "Provide your address", StaticFormAddress)},
|
{"Address", ("Request shipping address", "Provide your address", StaticFormAddress)},
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task<SelectList> GetSelect(string storeId ,string selectedFormId)
|
public async Task<SelectList> GetSelect(string storeId, string selectedFormId)
|
||||||
{
|
{
|
||||||
var forms = await GetForms(storeId);
|
var forms = await GetForms(storeId);
|
||||||
return new SelectList(_hardcodedOptions.Select(pair => new SelectListItem(pair.Value.selectText, pair.Key, selectedFormId == pair.Key)).Concat(forms.Select(data => new SelectListItem(data.Name, data.Id, data.Id == selectedFormId))),
|
return new SelectList(_hardcodedOptions.Select(pair => new SelectListItem(pair.Value.selectText, pair.Key, selectedFormId == pair.Key)).Concat(forms.Select(data => new SelectListItem(data.Name, data.Id, data.Id == selectedFormId))),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class FieldValueMirror : IFormComponentProvider
|
|||||||
{
|
{
|
||||||
if (form.GetFieldByFullName(field.Value) is null)
|
if (form.GetFieldByFullName(field.Value) is null)
|
||||||
{
|
{
|
||||||
field.ValidationErrors = new List<string>() {$"{field.Name} requires {field.Value} to be present"};
|
field.ValidationErrors = new List<string>() { $"{field.Name} requires {field.Value} to be present" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class HtmlSelectFormProvider : FormComponentProviderBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SelectField: Field
|
public class SelectField : Field
|
||||||
{
|
{
|
||||||
public List<SelectListItem> Options { get; set; }
|
public List<SelectListItem> Options { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class UIFormsController : Controller
|
|||||||
[HttpGet("~/stores/{storeId}/forms/new")]
|
[HttpGet("~/stores/{storeId}/forms/new")]
|
||||||
public IActionResult Create(string storeId)
|
public IActionResult Create(string storeId)
|
||||||
{
|
{
|
||||||
var vm = new ModifyForm {FormConfig = new Form().ToString()};
|
var vm = new ModifyForm { FormConfig = new Form().ToString() };
|
||||||
return View("Modify", vm);
|
return View("Modify", vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +57,11 @@ public class UIFormsController : Controller
|
|||||||
public async Task<IActionResult> Modify(string storeId, string id)
|
public async Task<IActionResult> Modify(string storeId, string id)
|
||||||
{
|
{
|
||||||
var form = await _formDataService.GetForm(storeId, id);
|
var form = await _formDataService.GetForm(storeId, id);
|
||||||
if (form is null) return NotFound();
|
if (form is null)
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
var config = Form.Parse(form.Config);
|
var config = Form.Parse(form.Config);
|
||||||
return View(new ModifyForm {Name = form.Name, FormConfig = config.ToString(), Public = form.Public});
|
return View(new ModifyForm { Name = form.Name, FormConfig = config.ToString(), Public = form.Public });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("~/stores/{storeId}/forms/modify/{id?}")]
|
[HttpPost("~/stores/{storeId}/forms/modify/{id?}")]
|
||||||
@@ -95,7 +96,11 @@ public class UIFormsController : Controller
|
|||||||
{
|
{
|
||||||
var formData = new FormData
|
var formData = new FormData
|
||||||
{
|
{
|
||||||
Id = id, StoreId = storeId, Name = modifyForm.Name, Config = modifyForm.FormConfig,Public = modifyForm.Public
|
Id = id,
|
||||||
|
StoreId = storeId,
|
||||||
|
Name = modifyForm.Name,
|
||||||
|
Config = modifyForm.FormConfig,
|
||||||
|
Public = modifyForm.Public
|
||||||
};
|
};
|
||||||
var isNew = id is null;
|
var isNew = id is null;
|
||||||
await _formDataService.AddOrUpdateForm(formData);
|
await _formDataService.AddOrUpdateForm(formData);
|
||||||
@@ -106,7 +111,7 @@ public class UIFormsController : Controller
|
|||||||
});
|
});
|
||||||
if (isNew)
|
if (isNew)
|
||||||
{
|
{
|
||||||
return RedirectToAction("Modify", new {storeId, id = formData.Id});
|
return RedirectToAction("Modify", new { storeId, id = formData.Id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -123,9 +128,10 @@ public class UIFormsController : Controller
|
|||||||
await _formDataService.RemoveForm(id, storeId);
|
await _formDataService.RemoveForm(id, storeId);
|
||||||
TempData.SetStatusMessageModel(new StatusMessageModel
|
TempData.SetStatusMessageModel(new StatusMessageModel
|
||||||
{
|
{
|
||||||
Severity = StatusMessageModel.StatusSeverity.Success, Message = "Form removed"
|
Severity = StatusMessageModel.StatusSeverity.Success,
|
||||||
|
Message = "Form removed"
|
||||||
});
|
});
|
||||||
return RedirectToAction("FormsList", new {storeId});
|
return RedirectToAction("FormsList", new { storeId });
|
||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -202,6 +208,6 @@ public class UIFormsController : Controller
|
|||||||
var request = _formDataService.GenerateInvoiceParametersFromForm(form);
|
var request = _formDataService.GenerateInvoiceParametersFromForm(form);
|
||||||
var inv = await invoiceController.CreateInvoiceCoreRaw(request, store, Request.GetAbsoluteRoot());
|
var inv = await invoiceController.CreateInvoiceCoreRaw(request, store, Request.GetAbsoluteRoot());
|
||||||
|
|
||||||
return RedirectToAction("Checkout", "UIInvoice", new {invoiceId = inv.Id});
|
return RedirectToAction("Checkout", "UIInvoice", new { invoiceId = inv.Id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace BTCPayServer.HostedServices
|
|||||||
{
|
{
|
||||||
await _walletRepository.EnsureWalletObjectLink(txWalletObject, walletObjectData.Key);
|
await _walletRepository.EnsureWalletObjectLink(txWalletObject, walletObjectData.Key);
|
||||||
//if the object is an address, we also link the labels to the tx
|
//if the object is an address, we also link the labels to the tx
|
||||||
if(walletObjectData.Value.Type == WalletObjectData.Types.Address)
|
if (walletObjectData.Value.Type == WalletObjectData.Types.Address)
|
||||||
{
|
{
|
||||||
var neighbours = walletObjectData.Value.GetNeighbours().ToArray();
|
var neighbours = walletObjectData.Value.GetNeighbours().ToArray();
|
||||||
var labels = neighbours
|
var labels = neighbours
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Configuration.Provider;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@@ -26,6 +27,8 @@ using BTCPayServer.Payments.Lightning;
|
|||||||
using BTCPayServer.Payments.PayJoin;
|
using BTCPayServer.Payments.PayJoin;
|
||||||
using BTCPayServer.PayoutProcessors;
|
using BTCPayServer.PayoutProcessors;
|
||||||
using BTCPayServer.Plugins;
|
using BTCPayServer.Plugins;
|
||||||
|
using BTCPayServer.Rating;
|
||||||
|
using BTCPayServer.Rating.Providers;
|
||||||
using BTCPayServer.Security;
|
using BTCPayServer.Security;
|
||||||
using BTCPayServer.Security.Bitpay;
|
using BTCPayServer.Security.Bitpay;
|
||||||
using BTCPayServer.Security.Greenfield;
|
using BTCPayServer.Security.Greenfield;
|
||||||
@@ -42,6 +45,7 @@ using BTCPayServer.Services.PaymentRequests;
|
|||||||
using BTCPayServer.Services.Rates;
|
using BTCPayServer.Services.Rates;
|
||||||
using BTCPayServer.Services.Stores;
|
using BTCPayServer.Services.Stores;
|
||||||
using BTCPayServer.Services.Wallets;
|
using BTCPayServer.Services.Wallets;
|
||||||
|
using ExchangeSharp;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
@@ -61,10 +65,6 @@ using NBXplorer.DerivationStrategy;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NicolasDorier.RateLimits;
|
using NicolasDorier.RateLimits;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using ExchangeSharp;
|
|
||||||
using BTCPayServer.Rating;
|
|
||||||
using System.Configuration.Provider;
|
|
||||||
using BTCPayServer.Rating.Providers;
|
|
||||||
#if ALTCOINS
|
#if ALTCOINS
|
||||||
using BTCPayServer.Services.Altcoins.Monero;
|
using BTCPayServer.Services.Altcoins.Monero;
|
||||||
using BTCPayServer.Services.Altcoins.Zcash;
|
using BTCPayServer.Services.Altcoins.Zcash;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace BTCPayServer.Models
|
|||||||
public string FormUrl { get; set; }
|
public string FormUrl { get; set; }
|
||||||
public bool AllowExternal { get; set; }
|
public bool AllowExternal { get; set; }
|
||||||
|
|
||||||
public MultiValueDictionary<string, string> FormParameters { get; set; } = new ();
|
public MultiValueDictionary<string, string> FormParameters { get; set; } = new();
|
||||||
public Dictionary<string, string> RouteParameters { get; set; } = new ();
|
public Dictionary<string, string> RouteParameters { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ namespace BTCPayServer.Models.WalletViewModels
|
|||||||
public string Link { get; set; }
|
public string Link { get; set; }
|
||||||
public bool Positive { get; set; }
|
public bool Positive { get; set; }
|
||||||
public string Balance { get; set; }
|
public string Balance { get; set; }
|
||||||
public HashSet<TransactionTagModel> Tags { get; set; } = new ();
|
public HashSet<TransactionTagModel> Tags { get; set; } = new();
|
||||||
}
|
}
|
||||||
public HashSet<(string Text, string Color, string TextColor)> Labels { get; set; } = new ();
|
public HashSet<(string Text, string Color, string TextColor)> Labels { get; set; } = new();
|
||||||
public List<TransactionViewModel> Transactions { get; set; } = new ();
|
public List<TransactionViewModel> Transactions { get; set; } = new();
|
||||||
public override int CurrentPageCount => Transactions.Count;
|
public override int CurrentPageCount => Transactions.Count;
|
||||||
public string CryptoCode { get; set; }
|
public string CryptoCode { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ namespace BTCPayServer.Plugins.Crowdfund.Controllers
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var info = (ViewCrowdfundViewModel) await _app.GetInfo(app);
|
var info = (ViewCrowdfundViewModel)await _app.GetInfo(app);
|
||||||
info.HubPath = AppHub.GetHubPath(Request);
|
info.HubPath = AppHub.GetHubPath(Request);
|
||||||
info.SimpleDisplay = Request.Query.ContainsKey("simple");
|
info.SimpleDisplay = Request.Query.ContainsKey("simple");
|
||||||
return info;
|
return info;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace BTCPayServer.Plugins.Crowdfund
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CrowdfundAppType: AppBaseType, IHasSaleStatsAppType, IHasItemStatsAppType
|
public class CrowdfundAppType : AppBaseType, IHasSaleStatsAppType, IHasItemStatsAppType
|
||||||
{
|
{
|
||||||
private readonly LinkGenerator _linkGenerator;
|
private readonly LinkGenerator _linkGenerator;
|
||||||
private readonly IOptions<BTCPayServerOptions> _options;
|
private readonly IOptions<BTCPayServerOptions> _options;
|
||||||
@@ -146,7 +146,7 @@ namespace BTCPayServer.Plugins.Crowdfund
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var invoices = await AppService.GetInvoicesForApp(_invoiceRepository,appData, lastResetDate);
|
var invoices = await AppService.GetInvoicesForApp(_invoiceRepository, appData, lastResetDate);
|
||||||
var completeInvoices = invoices.Where(IsComplete).ToArray();
|
var completeInvoices = invoices.Where(IsComplete).ToArray();
|
||||||
var pendingInvoices = invoices.Where(IsPending).ToArray();
|
var pendingInvoices = invoices.Where(IsPending).ToArray();
|
||||||
var paidInvoices = invoices.Where(IsPaid).ToArray();
|
var paidInvoices = invoices.Where(IsPaid).ToArray();
|
||||||
@@ -256,7 +256,7 @@ namespace BTCPayServer.Plugins.Crowdfund
|
|||||||
public override Task<string> ViewLink(AppData app)
|
public override Task<string> ViewLink(AppData app)
|
||||||
{
|
{
|
||||||
return Task.FromResult(_linkGenerator.GetPathByAction(nameof(UICrowdfundController.ViewCrowdfund),
|
return Task.FromResult(_linkGenerator.GetPathByAction(nameof(UICrowdfundController.ViewCrowdfund),
|
||||||
"UICrowdfund", new {appId = app.Id}, _options.Value.RootPath)!);
|
"UICrowdfund", new { appId = app.Id }, _options.Value.RootPath)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsPaid(InvoiceEntity entity)
|
private static bool IsPaid(InvoiceEntity entity)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class FakeCustodian : ICustodian, ICanDeposit, ICanWithdraw, ICanTrade
|
|||||||
if (ValidWithdrawalPaymentMethod.Equals(paymentMethod))
|
if (ValidWithdrawalPaymentMethod.Equals(paymentMethod))
|
||||||
{
|
{
|
||||||
LedgerEntryData ledgerEntryWithdrawal = new(ValidAsset, -amount, LedgerEntryData.LedgerEntryType.Withdrawal);
|
LedgerEntryData ledgerEntryWithdrawal = new(ValidAsset, -amount, LedgerEntryData.LedgerEntryType.Withdrawal);
|
||||||
LedgerEntryData ledgerEntryFee = new(ValidAsset, - _btcWithdrawalFee, LedgerEntryData.LedgerEntryType.Fee);
|
LedgerEntryData ledgerEntryFee = new(ValidAsset, -_btcWithdrawalFee, LedgerEntryData.LedgerEntryType.Fee);
|
||||||
List<LedgerEntryData> ledgerEntries = new();
|
List<LedgerEntryData> ledgerEntries = new();
|
||||||
ledgerEntries.Add(ledgerEntryWithdrawal);
|
ledgerEntries.Add(ledgerEntryWithdrawal);
|
||||||
ledgerEntries.Add(ledgerEntryFee);
|
ledgerEntries.Add(ledgerEntryFee);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace BTCPayServer.Plugins
|
|||||||
public async Task<PublishedVersion[]> GetPublishedVersions(string btcpayVersion, bool includePreRelease)
|
public async Task<PublishedVersion[]> GetPublishedVersions(string btcpayVersion, bool includePreRelease)
|
||||||
{
|
{
|
||||||
var queryString = $"?includePreRelease={includePreRelease}";
|
var queryString = $"?includePreRelease={includePreRelease}";
|
||||||
if(btcpayVersion is not null)
|
if (btcpayVersion is not null)
|
||||||
queryString += $"&btcpayVersion={btcpayVersion}&";
|
queryString += $"&btcpayVersion={btcpayVersion}&";
|
||||||
var result = await httpClient.GetStringAsync($"api/v1/plugins{queryString}");
|
var result = await httpClient.GetStringAsync($"api/v1/plugins{queryString}");
|
||||||
return JsonConvert.DeserializeObject<PublishedVersion[]>(result, serializerSettings) ?? throw new InvalidOperationException();
|
return JsonConvert.DeserializeObject<PublishedVersion[]>(result, serializerSettings) ?? throw new InvalidOperationException();
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace BTCPayServer.Plugins
|
|||||||
// Formatted either as "<PLUGIN_IDENTIFIER>::<PathToDll>" or "<PathToDll>"
|
// Formatted either as "<PLUGIN_IDENTIFIER>::<PathToDll>" or "<PathToDll>"
|
||||||
var idx = plugin.IndexOf("::");
|
var idx = plugin.IndexOf("::");
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
pluginsToLoad.Add((plugin[0..idx], plugin[(idx+1)..]));
|
pluginsToLoad.Add((plugin[0..idx], plugin[(idx + 1)..]));
|
||||||
else
|
else
|
||||||
pluginsToLoad.Add((Path.GetFileNameWithoutExtension(plugin), plugin));
|
pluginsToLoad.Add((Path.GetFileNameWithoutExtension(plugin), plugin));
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ namespace BTCPayServer.Plugins
|
|||||||
if (ordersByPlugin.TryAdd(p.PluginIdentifier, order))
|
if (ordersByPlugin.TryAdd(p.PluginIdentifier, order))
|
||||||
order++;
|
order++;
|
||||||
}
|
}
|
||||||
pluginsToLoad.Sort((a,b) => ordersByPlugin[a.PluginIdentifier] - ordersByPlugin[b.PluginIdentifier]);
|
pluginsToLoad.Sort((a, b) => ordersByPlugin[a.PluginIdentifier] - ordersByPlugin[b.PluginIdentifier]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UsePlugins(this IApplicationBuilder applicationBuilder)
|
public static void UsePlugins(this IApplicationBuilder applicationBuilder)
|
||||||
|
|||||||
@@ -337,19 +337,20 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
|||||||
if (appPosData.DiscountAmount > 0)
|
if (appPosData.DiscountAmount > 0)
|
||||||
{
|
{
|
||||||
receiptData.Add("Discount",
|
receiptData.Add("Discount",
|
||||||
$"{_displayFormatter.Currency(appPosData.DiscountAmount, settings.Currency, DisplayFormatter.CurrencyFormat.Symbol) } {(appPosData.DiscountPercentage > 0 ? $"({appPosData.DiscountPercentage}%)" : string.Empty)}");
|
$"{_displayFormatter.Currency(appPosData.DiscountAmount, settings.Currency, DisplayFormatter.CurrencyFormat.Symbol)} {(appPosData.DiscountPercentage > 0 ? $"({appPosData.DiscountPercentage}%)" : string.Empty)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appPosData.Tip > 0)
|
if (appPosData.Tip > 0)
|
||||||
{
|
{
|
||||||
receiptData.Add("Tip",
|
receiptData.Add("Tip",
|
||||||
$"{_displayFormatter.Currency(appPosData.Tip, settings.Currency, DisplayFormatter.CurrencyFormat.Symbol) }");
|
$"{_displayFormatter.Currency(appPosData.Tip, settings.Currency, DisplayFormatter.CurrencyFormat.Symbol)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
entity.Metadata.SetAdditionalData("receiptData", receiptData);
|
entity.Metadata.SetAdditionalData("receiptData", receiptData);
|
||||||
|
|
||||||
if (formResponseJObject is null) return;
|
if (formResponseJObject is null)
|
||||||
|
return;
|
||||||
var meta = entity.Metadata.ToJObject();
|
var meta = entity.Metadata.ToJObject();
|
||||||
meta.Merge(formResponseJObject);
|
meta.Merge(formResponseJObject);
|
||||||
entity.Metadata = InvoiceMetadata.FromJObject(meta);
|
entity.Metadata = InvoiceMetadata.FromJObject(meta);
|
||||||
@@ -456,7 +457,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
|||||||
{
|
{
|
||||||
var controller = nameof(UIPointOfSaleController).TrimEnd("Controller", StringComparison.InvariantCulture);
|
var controller = nameof(UIPointOfSaleController).TrimEnd("Controller", StringComparison.InvariantCulture);
|
||||||
var redirectUrl =
|
var redirectUrl =
|
||||||
Request.GetAbsoluteUri(Url.Action(nameof(ViewPointOfSale), controller, new {appId, viewType}));
|
Request.GetAbsoluteUri(Url.Action(nameof(ViewPointOfSale), controller, new { appId, viewType }));
|
||||||
formParameters.Add("formResponse", FormDataService.GetValues(form).ToString());
|
formParameters.Add("formResponse", FormDataService.GetValues(form).ToString());
|
||||||
return View("PostRedirect", new PostRedirectViewModel
|
return View("PostRedirect", new PostRedirectViewModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace BTCPayServer.Plugins.PointOfSale
|
|||||||
Print
|
Print
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PointOfSaleAppType: AppBaseType, IHasSaleStatsAppType, IHasItemStatsAppType
|
public class PointOfSaleAppType : AppBaseType, IHasSaleStatsAppType, IHasItemStatsAppType
|
||||||
{
|
{
|
||||||
private readonly LinkGenerator _linkGenerator;
|
private readonly LinkGenerator _linkGenerator;
|
||||||
private readonly IOptions<BTCPayServerOptions> _btcPayServerOptions;
|
private readonly IOptions<BTCPayServerOptions> _btcPayServerOptions;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace BTCPayServer
|
namespace BTCPayServer
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
StoreRepository storeRepository,
|
StoreRepository storeRepository,
|
||||||
HtmlSanitizer htmlSanitizer)
|
HtmlSanitizer htmlSanitizer)
|
||||||
{
|
{
|
||||||
_appTypes = apps.ToDictionary(a => a.Type, a=> a);
|
_appTypes = apps.ToDictionary(a => a.Type, a => a);
|
||||||
_ContextFactory = contextFactory;
|
_ContextFactory = contextFactory;
|
||||||
_InvoiceRepository = invoiceRepository;
|
_InvoiceRepository = invoiceRepository;
|
||||||
_Currencies = currencies;
|
_Currencies = currencies;
|
||||||
@@ -83,8 +83,8 @@ namespace BTCPayServer.Services.Apps
|
|||||||
{
|
{
|
||||||
if (GetAppType(appData.AppType) is not IHasItemStatsAppType salesType)
|
if (GetAppType(appData.AppType) is not IHasItemStatsAppType salesType)
|
||||||
throw new InvalidOperationException("This app isn't a SalesAppBaseType");
|
throw new InvalidOperationException("This app isn't a SalesAppBaseType");
|
||||||
var paidInvoices = await GetInvoicesForApp(_InvoiceRepository,appData,
|
var paidInvoices = await GetInvoicesForApp(_InvoiceRepository, appData,
|
||||||
null, new []
|
null, new[]
|
||||||
{
|
{
|
||||||
InvoiceState.ToString(InvoiceStatusLegacy.Paid),
|
InvoiceState.ToString(InvoiceStatusLegacy.Paid),
|
||||||
InvoiceState.ToString(InvoiceStatusLegacy.Confirmed),
|
InvoiceState.ToString(InvoiceStatusLegacy.Confirmed),
|
||||||
@@ -132,7 +132,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
if (GetAppType(app.AppType) is not IHasSaleStatsAppType salesType)
|
if (GetAppType(app.AppType) is not IHasSaleStatsAppType salesType)
|
||||||
throw new InvalidOperationException("This app isn't a SalesAppBaseType");
|
throw new InvalidOperationException("This app isn't a SalesAppBaseType");
|
||||||
var paidInvoices = await GetInvoicesForApp(_InvoiceRepository, app, DateTimeOffset.UtcNow - TimeSpan.FromDays(numberOfDays),
|
var paidInvoices = await GetInvoicesForApp(_InvoiceRepository, app, DateTimeOffset.UtcNow - TimeSpan.FromDays(numberOfDays),
|
||||||
new []
|
new[]
|
||||||
{
|
{
|
||||||
InvoiceState.ToString(InvoiceStatusLegacy.Paid),
|
InvoiceState.ToString(InvoiceStatusLegacy.Paid),
|
||||||
InvoiceState.ToString(InvoiceStatusLegacy.Confirmed),
|
InvoiceState.ToString(InvoiceStatusLegacy.Confirmed),
|
||||||
@@ -217,7 +217,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
{
|
{
|
||||||
StoreId = new[] { appData.StoreDataId },
|
StoreId = new[] { appData.StoreDataId },
|
||||||
OrderId = appData.TagAllInvoices ? null : new[] { GetAppOrderId(appData) },
|
OrderId = appData.TagAllInvoices ? null : new[] { GetAppOrderId(appData) },
|
||||||
Status = status?? new[]{
|
Status = status ?? new[]{
|
||||||
InvoiceState.ToString(InvoiceStatusLegacy.New),
|
InvoiceState.ToString(InvoiceStatusLegacy.New),
|
||||||
InvoiceState.ToString(InvoiceStatusLegacy.Paid),
|
InvoiceState.ToString(InvoiceStatusLegacy.Paid),
|
||||||
InvoiceState.ToString(InvoiceStatusLegacy.Confirmed),
|
InvoiceState.ToString(InvoiceStatusLegacy.Confirmed),
|
||||||
@@ -386,7 +386,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
return serializer.Serialize(mappingNode);
|
return serializer.Serialize(mappingNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewPointOfSaleViewModel.Item[] Parse( string template, string currency)
|
public ViewPointOfSaleViewModel.Item[] Parse(string template, string currency)
|
||||||
{
|
{
|
||||||
return Parse(_HtmlSanitizer, _displayFormatter, template, currency);
|
return Parse(_HtmlSanitizer, _displayFormatter, template, currency);
|
||||||
}
|
}
|
||||||
@@ -401,7 +401,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
if (string.IsNullOrWhiteSpace(template))
|
if (string.IsNullOrWhiteSpace(template))
|
||||||
return Array.Empty<ViewPointOfSaleViewModel.Item>();
|
return Array.Empty<ViewPointOfSaleViewModel.Item>();
|
||||||
using var input = new StringReader(template);
|
using var input = new StringReader(template);
|
||||||
YamlStream stream = new ();
|
YamlStream stream = new();
|
||||||
stream.Load(input);
|
stream.Load(input);
|
||||||
var root = (YamlMappingNode)stream.Documents[0].RootNode;
|
var root = (YamlMappingNode)stream.Documents[0].RootNode;
|
||||||
return root
|
return root
|
||||||
@@ -410,7 +410,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
.Where(kv => kv.Value != null)
|
.Where(kv => kv.Value != null)
|
||||||
.Select(c =>
|
.Select(c =>
|
||||||
{
|
{
|
||||||
ViewPointOfSaleViewModel.Item.ItemPrice price = new ();
|
ViewPointOfSaleViewModel.Item.ItemPrice price = new();
|
||||||
var pValue = c.GetDetail("price")?.FirstOrDefault();
|
var pValue = c.GetDetail("price")?.FirstOrDefault();
|
||||||
|
|
||||||
switch (c.GetDetailString("custom") ?? c.GetDetailString("price_type")?.ToLowerInvariant())
|
switch (c.GetDetailString("custom") ?? c.GetDetailString("price_type")?.ToLowerInvariant())
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ namespace BTCPayServer.Services
|
|||||||
|
|
||||||
public class DomainToAppMappingItem
|
public class DomainToAppMappingItem
|
||||||
{
|
{
|
||||||
[Display(Name = "Domain")] [Required] [HostName] public string Domain { get; set; }
|
[Display(Name = "Domain")][Required][HostName] public string Domain { get; set; }
|
||||||
[Display(Name = "App")] [Required] public string AppId { get; set; }
|
[Display(Name = "App")][Required] public string AppId { get; set; }
|
||||||
|
|
||||||
public string AppType { get; set; }
|
public string AppType { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Abstractions.Contracts;
|
using BTCPayServer.Abstractions.Contracts;
|
||||||
using BTCPayServer.Plugins.Test.Services;
|
using BTCPayServer.Plugins.Test.Services;
|
||||||
|
|||||||
Reference in New Issue
Block a user