Add payjoin option to hot wallet setup (#2450)

* Add payjoin option to hot wallet setup

Enables payjoin by default when creating a hot wallet and offers the user an opt-out.

Test fix

* Display PayJoin option only if it is available

* Test fixes

* Update hot wallet checks

* Test fix after rebase

* Use toggle buttons for enabling options
This commit is contained in:
d11n
2021-06-18 03:25:17 +02:00
committed by GitHub
parent 6b4ff4ce2c
commit 3c80621dac
12 changed files with 108 additions and 92 deletions

View File

@@ -466,7 +466,6 @@ namespace BTCPayServer.Controllers
}
}
if (!ModelState.IsValid)
{
return View(model);
@@ -558,12 +557,9 @@ namespace BTCPayServer.Controllers
}
}
}
[HttpGet]
[Route("{storeId}")]
public IActionResult UpdateStore()
[HttpGet("{storeId}")]
public async Task<IActionResult> UpdateStore()
{
var store = HttpContext.GetStoreData();
if (store == null)
@@ -586,12 +582,17 @@ namespace BTCPayServer.Controllers
vm.PayJoinEnabled = storeBlob.PayJoinEnabled;
vm.HintWallet = storeBlob.Hints.Wallet;
vm.HintLightning = storeBlob.Hints.Lightning;
(bool canUseHotWallet, _) = await CanUseHotWallet();
vm.CanUsePayJoin = canUseHotWallet && store
.GetSupportedPaymentMethods(_NetworkProvider)
.OfType<DerivationSchemeSettings>()
.Any(settings => settings.Network.SupportPayJoin && settings.IsHotWallet);
return View(vm);
}
[HttpPost]
[Route("{storeId}")]
[HttpPost("{storeId}")]
public async Task<IActionResult> UpdateStore(StoreViewModel model, string command = null)
{
bool needUpdate = false;
@@ -635,11 +636,7 @@ namespace BTCPayServer.Controllers
{
var problematicPayjoinEnabledMethods = CurrentStore.GetSupportedPaymentMethods(_NetworkProvider)
.OfType<DerivationSchemeSettings>()
.Where(settings =>
settings.Network.SupportPayJoin &&
string.IsNullOrEmpty(_ExplorerProvider.GetExplorerClient(settings.Network)
.GetMetadata<string>(settings.AccountDerivation,
WellknownMetadataKeys.Mnemonic)))
.Where(settings => settings.Network.SupportPayJoin && !settings.IsHotWallet)
.Select(settings => settings.PaymentId.CryptoCode)
.ToArray();