Show warning when enabling Payjoin but supported payment methods are not using a hot wallet (#1545)

* Show warning when enabling Payjoin but supported payment methods are not using a hot wallet

https://i.imgur.com/RXBhr0n.png fixes #1474

* expose p2p port
This commit is contained in:
Andrew Camilleri
2020-05-07 22:37:10 +02:00
committed by GitHub
parent 55f416c48c
commit 2bc7fa0316
2 changed files with 28 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using NBitcoin;
using NBitcoin.DataEncoders;
using NBXplorer;
namespace BTCPayServer.Controllers
{
@@ -545,6 +546,7 @@ namespace BTCPayServer.Controllers
Provider = "CoinSwitch"
});
}
[HttpPost]
[Route("{storeId}")]
@@ -574,6 +576,7 @@ namespace BTCPayServer.Controllers
blob.InvoiceExpiration = model.InvoiceExpiration;
blob.LightningDescriptionTemplate = model.LightningDescriptionTemplate ?? string.Empty;
blob.PaymentTolerance = model.PaymentTolerance;
var payjoinChanged = blob.PayJoinEnabled != model.PayJoinEnabled;
blob.PayJoinEnabled = model.PayJoinEnabled;
if (CurrentStore.SetStoreBlob(blob))
{
@@ -583,7 +586,31 @@ namespace BTCPayServer.Controllers
if (needUpdate)
{
await _Repo.UpdateStore(CurrentStore);
TempData[WellKnownTempData.SuccessMessage] = "Store successfully updated";
if (payjoinChanged && blob.PayJoinEnabled)
{
var problematicPayjoinEnabledMethods = CurrentStore.GetSupportedPaymentMethods(_NetworkProvider)
.OfType<DerivationSchemeSettings>()
.Where(settings =>
settings.Network.SupportPayJoin &&
string.IsNullOrEmpty(_ExplorerProvider.GetExplorerClient(settings.Network)
.GetMetadata<string>(settings.AccountDerivation,
WellknownMetadataKeys.Mnemonic)))
.Select(settings => settings.PaymentId.CryptoCode)
.ToArray();
if (problematicPayjoinEnabledMethods.Any())
{
TempData.Remove(WellKnownTempData.SuccessMessage);
TempData.SetStatusMessageModel(new StatusMessageModel()
{
Severity = StatusMessageModel.StatusSeverity.Warning,
Html = $"The store was updated successfully. However, payjoin will not work for {string.Join(", ", problematicPayjoinEnabledMethods)} until you configure them to be a <a href='https://docs.btcpayserver.org/features/wallet/hotwallet' class='alert-link' target='_blank'>hot wallet</a>."
});
}
}
}
return RedirectToAction(nameof(UpdateStore), new