mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Update NBitcoin, fix warnings on nullable (#2718)
This commit is contained in:
@@ -27,8 +27,8 @@
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NBitcoin" Version="5.0.81" />
|
||||
<PackageReference Include="BTCPayServer.Lightning.Common" Version="1.2.0" />
|
||||
<PackageReference Include="NBitcoin" Version="6.0.4" />
|
||||
<PackageReference Include="BTCPayServer.Lightning.Common" Version="1.2.4" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="NBXplorer.Client" Version="3.0.21" />
|
||||
<PackageReference Include="NBXplorer.Client" Version="4.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Altcoins)' != 'true'">
|
||||
<Compile Remove="Altcoins\**\*.cs"></Compile>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.6.0" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||
<PackageReference Include="NBitcoin" Version="5.0.81" />
|
||||
<PackageReference Include="NBitcoin" Version="6.0.4" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="DigitalRuby.ExchangeSharp" Version="0.6.3" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1937,7 +1937,7 @@ namespace BTCPayServer.Tests
|
||||
}
|
||||
|
||||
var methods = await adminClient.GetStorePaymentMethods(store.Id);
|
||||
Assert.Equal(1, methods.Count);
|
||||
Assert.Single(methods);
|
||||
VerifyLightning(methods);
|
||||
|
||||
var randK = new Mnemonic(Wordlist.English, WordCount.Twelve).DeriveExtKey().Neuter().ToString(Network.RegTest);
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace BTCPayServer.Tests
|
||||
{
|
||||
var tx = network.NBitcoinNetwork.CreateTransaction();
|
||||
tx.Inputs.Add(new OutPoint(RandomUtils.GetUInt256(), 0), Script.Empty);
|
||||
tx.Outputs.Add(Money.Coins(1.0m), new Key().ScriptPubKey);
|
||||
tx.Outputs.Add(Money.Coins(1.0m), new Key().GetScriptPubKey(ScriptPubKeyType.Legacy));
|
||||
return tx;
|
||||
}
|
||||
|
||||
@@ -184,12 +184,16 @@ namespace BTCPayServer.Tests
|
||||
|
||||
foreach (ScriptPubKeyType senderAddressType in Enum.GetValues(typeof(ScriptPubKeyType)))
|
||||
{
|
||||
if (senderAddressType == ScriptPubKeyType.TaprootBIP86)
|
||||
continue;
|
||||
var senderUser = tester.NewAccount();
|
||||
senderUser.GrantAccess(true);
|
||||
senderUser.RegisterDerivationScheme("BTC", senderAddressType);
|
||||
|
||||
foreach (ScriptPubKeyType receiverAddressType in Enum.GetValues(typeof(ScriptPubKeyType)))
|
||||
{
|
||||
if (receiverAddressType == ScriptPubKeyType.TaprootBIP86)
|
||||
continue;
|
||||
var senderCoin = await senderUser.ReceiveUTXO(Money.Satoshis(100000), network);
|
||||
|
||||
Logs.Tester.LogInformation($"Testing payjoin with sender: {senderAddressType} receiver: {receiverAddressType}");
|
||||
|
||||
@@ -1689,7 +1689,10 @@ namespace BTCPayServer.Tests
|
||||
var invoice2Address =
|
||||
BitcoinAddress.Create(invoice2.BitcoinAddress, user.SupportedNetwork.NBitcoinNetwork);
|
||||
uint256 invoice2tx1Id =
|
||||
await tester.ExplorerNode.SendToAddressAsync(invoice2Address, invoice2.BtcDue, replaceable: true);
|
||||
await tester.ExplorerNode.SendToAddressAsync(invoice2Address, invoice2.BtcDue, new NBitcoin.RPC.SendToAddressParameters()
|
||||
{
|
||||
Replaceable = true
|
||||
});
|
||||
Transaction invoice2Tx1 = null;
|
||||
TestUtils.Eventually(() =>
|
||||
{
|
||||
@@ -1707,7 +1710,7 @@ namespace BTCPayServer.Tests
|
||||
output = invoice2Tx2.Outputs.First(o =>
|
||||
o.ScriptPubKey == invoice2Address.ScriptPubKey);
|
||||
output.Value -= new Money(10_000, MoneyUnit.Satoshi);
|
||||
output.ScriptPubKey = new Key().ScriptPubKey;
|
||||
output.ScriptPubKey = new Key().GetScriptPubKey(ScriptPubKeyType.Legacy);
|
||||
invoice2Tx2 = await tester.ExplorerNode.SignRawTransactionAsync(invoice2Tx2);
|
||||
await tester.ExplorerNode.SendRawTransactionAsync(invoice2Tx2);
|
||||
tester.ExplorerNode.Generate(1);
|
||||
|
||||
@@ -84,7 +84,7 @@ services:
|
||||
- customer_lnd
|
||||
- merchant_lnd
|
||||
nbxplorer:
|
||||
image: nicolasdorier/nbxplorer:2.1.49
|
||||
image: nicolasdorier/nbxplorer:2.1.53
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "32838:32838"
|
||||
|
||||
@@ -81,7 +81,7 @@ services:
|
||||
- customer_lnd
|
||||
- merchant_lnd
|
||||
nbxplorer:
|
||||
image: nicolasdorier/nbxplorer:2.1.49
|
||||
image: nicolasdorier/nbxplorer:2.1.53
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "32838:32838"
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BIP78.Sender" Version="0.2.0" />
|
||||
<PackageReference Include="BTCPayServer.Hwi" Version="2.0.1" />
|
||||
<PackageReference Include="BTCPayServer.Lightning.All" Version="1.2.7" />
|
||||
<PackageReference Include="BTCPayServer.Lightning.All" Version="1.2.9" />
|
||||
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
||||
<PackageReference Include="BundlerMinifier.Core" Version="3.2.435" />
|
||||
<PackageReference Include="BundlerMinifier.TagHelpers" Version="3.2.435" />
|
||||
|
||||
@@ -504,11 +504,11 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
return Task.FromResult(GetFromActionResult(_chainPaymentMethodsController.GetOnChainPaymentMethods(storeId, enabled)));
|
||||
}
|
||||
|
||||
public override async Task<OnChainPaymentMethodData> GetStoreOnChainPaymentMethod(string storeId,
|
||||
public override Task<OnChainPaymentMethodData> GetStoreOnChainPaymentMethod(string storeId,
|
||||
string cryptoCode, CancellationToken token = default)
|
||||
{
|
||||
return GetFromActionResult(
|
||||
await _chainPaymentMethodsController.GetOnChainPaymentMethod(storeId, cryptoCode));
|
||||
return Task.FromResult(GetFromActionResult(
|
||||
_chainPaymentMethodsController.GetOnChainPaymentMethod(storeId, cryptoCode)));
|
||||
}
|
||||
|
||||
public override async Task RemoveStoreOnChainPaymentMethod(string storeId, string cryptoCode,
|
||||
@@ -534,13 +534,13 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
paymentMethod, offset, amount)));
|
||||
}
|
||||
|
||||
public override async Task<OnChainPaymentMethodPreviewResultData> PreviewStoreOnChainPaymentMethodAddresses(
|
||||
public override Task<OnChainPaymentMethodPreviewResultData> PreviewStoreOnChainPaymentMethodAddresses(
|
||||
string storeId, string cryptoCode, int offset = 0, int amount = 10,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
return GetFromActionResult<OnChainPaymentMethodPreviewResultData>(
|
||||
await _chainPaymentMethodsController.GetOnChainPaymentMethodPreview(storeId, cryptoCode, offset,
|
||||
amount));
|
||||
return Task.FromResult(GetFromActionResult<OnChainPaymentMethodPreviewResultData>(
|
||||
_chainPaymentMethodsController.GetOnChainPaymentMethodPreview(storeId, cryptoCode, offset,
|
||||
amount)));
|
||||
}
|
||||
|
||||
public override Task<ApiHealthData> GetHealth(CancellationToken token = default)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Abstractions.Constants;
|
||||
@@ -122,7 +123,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(paymentMethodData?.ConnectionString))
|
||||
if (string.IsNullOrEmpty(paymentMethodData.ConnectionString))
|
||||
{
|
||||
ModelState.AddModelError(nameof(LightningNetworkPaymentMethodData.ConnectionString),
|
||||
"Missing connectionString");
|
||||
@@ -131,8 +132,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
if (!ModelState.IsValid)
|
||||
return this.CreateValidationError(ModelState);
|
||||
|
||||
LightningSupportedPaymentMethod paymentMethod = null;
|
||||
if (!string.IsNullOrEmpty(paymentMethodData.ConnectionString))
|
||||
LightningSupportedPaymentMethod? paymentMethod = null;
|
||||
if (!string.IsNullOrEmpty(paymentMethodData!.ConnectionString))
|
||||
{
|
||||
if (paymentMethodData.ConnectionString == LightningSupportedPaymentMethod.InternalNode)
|
||||
{
|
||||
@@ -189,8 +190,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
return Ok(GetExistingLightningLikePaymentMethod(cryptoCode, store));
|
||||
}
|
||||
|
||||
private LightningNetworkPaymentMethodData GetExistingLightningLikePaymentMethod(string cryptoCode,
|
||||
StoreData store = null)
|
||||
private LightningNetworkPaymentMethodData? GetExistingLightningLikePaymentMethod(string cryptoCode,
|
||||
StoreData? store = null)
|
||||
{
|
||||
store ??= Store;
|
||||
var storeBlob = store.GetStoreBlob();
|
||||
@@ -201,13 +202,13 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
.FirstOrDefault(method => method.PaymentId == id);
|
||||
|
||||
var excluded = storeBlob.IsExcluded(id);
|
||||
return paymentMethod == null
|
||||
return paymentMethod is null
|
||||
? null
|
||||
: new LightningNetworkPaymentMethodData(paymentMethod.PaymentId.CryptoCode,
|
||||
paymentMethod.GetDisplayableConnectionString(), !excluded);
|
||||
}
|
||||
|
||||
private bool GetNetwork(string cryptoCode, out BTCPayNetwork network)
|
||||
private bool GetNetwork(string cryptoCode, [MaybeNullWhen(false)] out BTCPayNetwork network)
|
||||
{
|
||||
network = _btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode);
|
||||
network = network?.SupportLightning is true ? network : null;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
|
||||
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}")]
|
||||
public async Task<ActionResult<OnChainPaymentMethodData>> GetOnChainPaymentMethod(
|
||||
public ActionResult<OnChainPaymentMethodData> GetOnChainPaymentMethod(
|
||||
string storeId,
|
||||
string cryptoCode)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
|
||||
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/preview")]
|
||||
public async Task<IActionResult> GetOnChainPaymentMethodPreview(
|
||||
public IActionResult GetOnChainPaymentMethodPreview(
|
||||
string storeId,
|
||||
string cryptoCode,
|
||||
int offset = 0, int amount = 10)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -83,8 +84,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet")]
|
||||
public async Task<IActionResult> ShowOnChainWalletOverview(string storeId, string cryptoCode)
|
||||
{
|
||||
if (IsInvalidWalletRequest(cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)) return actionResult;
|
||||
if (IsInvalidWalletRequest(cryptoCode, out var network,
|
||||
out var derivationScheme, out var actionResult)) return actionResult;
|
||||
|
||||
var wallet = _btcPayWalletProvider.GetWallet(network);
|
||||
var balance = await wallet.GetBalance(derivationScheme.AccountDerivation);
|
||||
@@ -102,8 +103,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/feerate")]
|
||||
public async Task<IActionResult> GetOnChainFeeRate(string storeId, string cryptoCode, int? blockTarget = null)
|
||||
{
|
||||
if (IsInvalidWalletRequest(cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)) return actionResult;
|
||||
if (IsInvalidWalletRequest(cryptoCode, out var network,
|
||||
out var derivationScheme, out var actionResult)) return actionResult;
|
||||
|
||||
var feeRateTarget = blockTarget?? Store.GetStoreBlob().RecommendedFeeBlockTarget;
|
||||
return Ok(new OnChainWalletFeeRateData()
|
||||
@@ -117,8 +118,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/address")]
|
||||
public async Task<IActionResult> GetOnChainWalletReceiveAddress(string storeId, string cryptoCode, bool forceGenerate = false)
|
||||
{
|
||||
if (IsInvalidWalletRequest(cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)) return actionResult;
|
||||
if (IsInvalidWalletRequest(cryptoCode, out var network,
|
||||
out var derivationScheme, out var actionResult)) return actionResult;
|
||||
|
||||
var kpi = await _walletReceiveService.GetOrGenerate(new WalletId(storeId, cryptoCode), forceGenerate);
|
||||
if (kpi is null)
|
||||
@@ -145,8 +146,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[HttpDelete("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/address")]
|
||||
public async Task<IActionResult> UnReserveOnChainWalletReceiveAddress(string storeId, string cryptoCode)
|
||||
{
|
||||
if (IsInvalidWalletRequest(cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)) return actionResult;
|
||||
if (IsInvalidWalletRequest(cryptoCode, out var network,
|
||||
out var derivationScheme, out var actionResult)) return actionResult;
|
||||
|
||||
var addr = await _walletReceiveService.UnReserveAddress(new WalletId(storeId, cryptoCode));
|
||||
if (addr is null)
|
||||
@@ -166,8 +167,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[FromQuery] int limit = int.MaxValue
|
||||
)
|
||||
{
|
||||
if (IsInvalidWalletRequest(cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)) return actionResult;
|
||||
if (IsInvalidWalletRequest(cryptoCode, out var network,
|
||||
out var derivationScheme, out var actionResult)) return actionResult;
|
||||
|
||||
var wallet = _btcPayWalletProvider.GetWallet(network);
|
||||
var walletId = new WalletId(storeId, cryptoCode);
|
||||
@@ -203,8 +204,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
public async Task<IActionResult> GetOnChainWalletTransaction(string storeId, string cryptoCode,
|
||||
string transactionId)
|
||||
{
|
||||
if (IsInvalidWalletRequest(cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)) return actionResult;
|
||||
if (IsInvalidWalletRequest(cryptoCode, out var network,
|
||||
out var derivationScheme, out var actionResult)) return actionResult;
|
||||
|
||||
var wallet = _btcPayWalletProvider.GetWallet(network);
|
||||
var tx = await wallet.FetchTransaction(derivationScheme.AccountDerivation, uint256.Parse(transactionId));
|
||||
@@ -225,8 +226,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/wallet/utxos")]
|
||||
public async Task<IActionResult> GetOnChainWalletUTXOs(string storeId, string cryptoCode)
|
||||
{
|
||||
if (IsInvalidWalletRequest(cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)) return actionResult;
|
||||
if (IsInvalidWalletRequest(cryptoCode, out var network,
|
||||
out var derivationScheme, out var actionResult)) return actionResult;
|
||||
|
||||
var wallet = _btcPayWalletProvider.GetWallet(network);
|
||||
|
||||
@@ -258,8 +259,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
public async Task<IActionResult> CreateOnChainTransaction(string storeId, string cryptoCode,
|
||||
[FromBody] CreateOnChainTransactionRequest request)
|
||||
{
|
||||
if (IsInvalidWalletRequest(cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)) return actionResult;
|
||||
if (IsInvalidWalletRequest(cryptoCode, out var network,
|
||||
out var derivationScheme, out var actionResult)) return actionResult;
|
||||
if (network.ReadonlyWallet)
|
||||
{
|
||||
return this.CreateAPIError("not-available",
|
||||
@@ -445,8 +446,13 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
psbt.PSBT.RebaseKeyPaths(signingKeySettings.AccountKey, rootedKeyPath);
|
||||
var accountKey = signingKey.Derive(rootedKeyPath.KeyPath);
|
||||
|
||||
if (signingContext?.EnforceLowR is bool v)
|
||||
psbt.PSBT.Settings.SigningOptions.EnforceLowR = v;
|
||||
else if (psbt.Suggestions?.ShouldEnforceLowR is bool v2)
|
||||
psbt.PSBT.Settings.SigningOptions.EnforceLowR = v2;
|
||||
|
||||
var changed = psbt.PSBT.PSBTChanged(() => psbt.PSBT.SignAll(derivationScheme.AccountDerivation, accountKey,
|
||||
rootedKeyPath, new SigningOptions() {EnforceLowR = signingContext?.EnforceLowR is bool v ? v : psbt.Suggestions.ShouldEnforceLowR }));
|
||||
rootedKeyPath));
|
||||
|
||||
if (!changed)
|
||||
{
|
||||
@@ -458,7 +464,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
var transaction = psbt.PSBT.ExtractTransaction();
|
||||
var transactionHash = transaction.GetHash();
|
||||
BroadcastResult broadcastResult;
|
||||
if (!string.IsNullOrEmpty(signingContext.PayJoinBIP21))
|
||||
if (!string.IsNullOrEmpty(signingContext?.PayJoinBIP21))
|
||||
{
|
||||
signingContext.OriginalPSBT = psbt.PSBT.ToBase64();
|
||||
try
|
||||
@@ -468,8 +474,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
var payjoinPSBT = await _payjoinClient.RequestPayjoin(
|
||||
new BitcoinUrlBuilder(signingContext.PayJoinBIP21, network.NBitcoinNetwork), new PayjoinWallet(derivationScheme),
|
||||
psbt.PSBT, CancellationToken.None);
|
||||
payjoinPSBT = psbt.PSBT.SignAll(derivationScheme.AccountDerivation, accountKey, rootedKeyPath,
|
||||
new SigningOptions() {EnforceLowR = !(signingContext?.EnforceLowR is false)});
|
||||
psbt.PSBT.Settings.SigningOptions = new SigningOptions() { EnforceLowR = !(signingContext?.EnforceLowR is false) };
|
||||
payjoinPSBT = psbt.PSBT.SignAll(derivationScheme.AccountDerivation, accountKey, rootedKeyPath);
|
||||
payjoinPSBT.Finalize();
|
||||
var payjoinTransaction = payjoinPSBT.ExtractTransaction();
|
||||
var hash = payjoinTransaction.GetHash();
|
||||
@@ -508,11 +514,10 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
return await _authorizationService.CanUseHotWallet(await _settingsRepository.GetPolicies(), User);
|
||||
}
|
||||
|
||||
private bool IsInvalidWalletRequest(string cryptoCode, out BTCPayNetwork network,
|
||||
out DerivationSchemeSettings derivationScheme, out IActionResult actionResult)
|
||||
private bool IsInvalidWalletRequest(string cryptoCode, [MaybeNullWhen(true)] out BTCPayNetwork network,
|
||||
[MaybeNullWhen(true)] out DerivationSchemeSettings derivationScheme, [MaybeNullWhen(false)] out IActionResult actionResult)
|
||||
{
|
||||
derivationScheme = null;
|
||||
actionResult = null;
|
||||
network = _btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(cryptoCode);
|
||||
if (network is null)
|
||||
{
|
||||
@@ -535,6 +540,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
return true;
|
||||
}
|
||||
|
||||
actionResult = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -440,9 +440,9 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
//Keep compatibility with Bitpay
|
||||
invoiceId = invoiceId ?? id;
|
||||
id = invoiceId;
|
||||
//
|
||||
|
||||
if (invoiceId is null)
|
||||
return NotFound();
|
||||
var model = await GetInvoiceModel(invoiceId, paymentMethodId == null ? null : PaymentMethodId.Parse(paymentMethodId), lang);
|
||||
if (model == null)
|
||||
return NotFound();
|
||||
@@ -472,24 +472,24 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
//Keep compatibility with Bitpay
|
||||
invoiceId = invoiceId ?? id;
|
||||
id = invoiceId;
|
||||
//
|
||||
|
||||
var model = await GetInvoiceModel(invoiceId, paymentMethodId == null ? null : PaymentMethodId.Parse(paymentMethodId), lang);
|
||||
if (invoiceId is null)
|
||||
return NotFound();
|
||||
var model = await GetInvoiceModel(invoiceId, paymentMethodId is null ? null : PaymentMethodId.Parse(paymentMethodId), lang);
|
||||
if (model == null)
|
||||
return NotFound();
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
private async Task<PaymentModel?> GetInvoiceModel(string invoiceId, PaymentMethodId paymentMethodId, string? lang)
|
||||
private async Task<PaymentModel?> GetInvoiceModel(string invoiceId, PaymentMethodId? paymentMethodId, string? lang)
|
||||
{
|
||||
var invoice = await _InvoiceRepository.GetInvoice(invoiceId);
|
||||
if (invoice == null)
|
||||
return null;
|
||||
var store = await _StoreRepository.FindStore(invoice.StoreId);
|
||||
bool isDefaultPaymentId = false;
|
||||
if (paymentMethodId == null)
|
||||
if (paymentMethodId is null)
|
||||
{
|
||||
paymentMethodId = store.GetDefaultPaymentId(_NetworkProvider);
|
||||
isDefaultPaymentId = true;
|
||||
@@ -846,6 +846,11 @@ namespace BTCPayServer.Controllers
|
||||
ModelState.AddModelError(nameof(model.StoreId), "You need to configure the derivation scheme in order to create an invoice");
|
||||
return View(model);
|
||||
}
|
||||
if (model.Amount is null)
|
||||
{
|
||||
ModelState.AddModelError(nameof(model.Amount), "Thhe invoice amount can't be empty");
|
||||
return View(model);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -910,7 +915,7 @@ namespace BTCPayServer.Controllers
|
||||
public class InvoiceStateChangeModel
|
||||
{
|
||||
public bool NotFound { get; set; }
|
||||
public string StatusString { get; set; }
|
||||
public string? StatusString { get; set; }
|
||||
}
|
||||
|
||||
private string GetUserId()
|
||||
@@ -933,7 +938,7 @@ namespace BTCPayServer.Controllers
|
||||
var jObject = JObject.Parse(posData);
|
||||
foreach (var item in jObject)
|
||||
{
|
||||
switch (item.Value.Type)
|
||||
switch (item.Value?.Type)
|
||||
{
|
||||
case JTokenType.Array:
|
||||
var items = item.Value.AsEnumerable().ToList();
|
||||
@@ -945,6 +950,8 @@ namespace BTCPayServer.Controllers
|
||||
case JTokenType.Object:
|
||||
result.TryAdd(item.Key, ParsePosData(item.Value.ToString()));
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
default:
|
||||
result.TryAdd(item.Key, item.Value.ToString());
|
||||
break;
|
||||
|
||||
@@ -335,13 +335,14 @@ namespace BTCPayServer.Controllers
|
||||
derivationSchemeSettings, network, cancellationToken);
|
||||
try
|
||||
{
|
||||
proposedPayjoin.Settings.SigningOptions = new SigningOptions()
|
||||
{
|
||||
EnforceLowR = !(vm.SigningContext?.EnforceLowR is false)
|
||||
};
|
||||
var extKey = ExtKey.Parse(vm.SigningKey, network.NBitcoinNetwork);
|
||||
proposedPayjoin = proposedPayjoin.SignAll(derivationSchemeSettings.AccountDerivation,
|
||||
extKey,
|
||||
RootedKeyPath.Parse(vm.SigningKeyPath), new SigningOptions()
|
||||
{
|
||||
EnforceLowR = !(vm.SigningContext?.EnforceLowR is false)
|
||||
});
|
||||
RootedKeyPath.Parse(vm.SigningKeyPath));
|
||||
vm.SigningContext.PSBT = proposedPayjoin.ToBase64();
|
||||
vm.SigningContext.OriginalPSBT = psbt.ToBase64();
|
||||
proposedPayjoin.Finalize();
|
||||
|
||||
@@ -925,10 +925,11 @@ namespace BTCPayServer.Controllers
|
||||
return View(nameof(SignWithSeed), viewModel);
|
||||
}
|
||||
|
||||
var changed = psbt.PSBTChanged( () => psbt.SignAll(settings.AccountDerivation, signingKey, rootedKeyPath, new SigningOptions()
|
||||
psbt.Settings.SigningOptions = new SigningOptions()
|
||||
{
|
||||
EnforceLowR = !(viewModel.SigningContext?.EnforceLowR is false)
|
||||
}));
|
||||
};
|
||||
var changed = psbt.PSBTChanged( () => psbt.SignAll(settings.AccountDerivation, signingKey, rootedKeyPath));
|
||||
if (!changed)
|
||||
{
|
||||
ModelState.AddModelError(nameof(viewModel.SeedOrKey), "Impossible to sign the transaction. Probable causes: Incorrect account key path in wallet settings or PSBT already signed.");
|
||||
|
||||
@@ -302,7 +302,9 @@ public class BitcoinLikePayoutHandler : IPayoutHandler
|
||||
.ThenInclude(o => o.StoreData)
|
||||
.Where(p => p.State == PayoutState.AwaitingPayment)
|
||||
.Where(p => p.PaymentMethodId == paymentMethodId.ToString())
|
||||
#pragma warning disable CA1307 // Specify StringComparison
|
||||
.Where(p => destination.Equals(p.Destination))
|
||||
#pragma warning restore CA1307 // Specify StringComparison
|
||||
.ToListAsync();
|
||||
var payoutByDestination = payouts.ToDictionary(p => p.Destination);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace BTCPayServer
|
||||
if (str == null)
|
||||
throw new ArgumentNullException(nameof(str));
|
||||
str = str.Trim();
|
||||
var outputDescriptor = OutputDescriptor.Parse(str);
|
||||
var outputDescriptor = OutputDescriptor.Parse(str, Network);
|
||||
switch(outputDescriptor)
|
||||
{
|
||||
case OutputDescriptor.PK _:
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace BTCPayServer.HostedServices
|
||||
await Task.Delay(wait, CancellationToken);
|
||||
ctx = await CreateRedeliveryRequest(originalDeliveryId);
|
||||
// This may have changed
|
||||
if (!ctx.WebhookBlob.AutomaticRedelivery ||
|
||||
if (ctx is null || !ctx.WebhookBlob.AutomaticRedelivery ||
|
||||
!ShouldDeliver(ctx.WebhookEvent.Type, ctx.WebhookBlob))
|
||||
break;
|
||||
result = await SendAndSaveDelivery(ctx);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
|
||||
namespace BTCPayServer.Models.StoreViewModels
|
||||
@@ -11,7 +10,7 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||
public string Url { get; set; }
|
||||
public bool LastDeliverySuccessful { get; set; } = true;
|
||||
public DateTimeOffset? LastDeliveryTimeStamp { get; set; } = null;
|
||||
public string? LastDeliveryErrorMessage { get; set; } = null;
|
||||
public string LastDeliveryErrorMessage { get; set; } = null;
|
||||
}
|
||||
public WebhookViewModel[] Webhooks { get; set; }
|
||||
}
|
||||
|
||||
@@ -462,10 +462,11 @@ namespace BTCPayServer.Payments.PayJoin
|
||||
var coin = selectedUtxo.AsCoin(derivationSchemeSettings.AccountDerivation);
|
||||
signedInput.UpdateFromCoin(coin);
|
||||
var privateKey = accountKey.Derive(selectedUtxo.KeyPath).PrivateKey;
|
||||
signedInput.Sign(privateKey, new SigningOptions()
|
||||
signedInput.PSBT.Settings.SigningOptions = new SigningOptions()
|
||||
{
|
||||
EnforceLowR = enforcedLowR
|
||||
});
|
||||
};
|
||||
signedInput.Sign(privateKey);
|
||||
signedInput.FinalizeInput();
|
||||
newTx.Inputs[signedInput.Index].WitScript = newPsbt.Inputs[(int)signedInput.Index].FinalScriptWitness;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace BTCPayServer.Services
|
||||
acceptedLocales[locale] = qualityScore;
|
||||
}
|
||||
}
|
||||
catch (System.FormatException e)
|
||||
catch (System.FormatException)
|
||||
{
|
||||
// Can't use this piece, moving on...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user