Trust the payment method details for the payjoin enabled and make invoice logs consistent (#1450)

This commit is contained in:
Andrew Camilleri
2020-04-10 09:00:41 +02:00
committed by GitHub
parent d47e225dce
commit 6274958409
2 changed files with 6 additions and 5 deletions

View File

@@ -164,16 +164,17 @@ namespace BTCPayServer.Payments.Bitcoin
network.SupportPayJoin;
if (onchainMethod.PayjoinEnabled)
{
var prefix = $"{supportedPaymentMethod.PaymentId.ToPrettyString()}:";
var nodeSupport = _dashboard?.Get(network.CryptoCode)?.Status?.BitcoinStatus?.Capabilities
?.CanSupportTransactionCheck is true;
bool isHotwallet = supportedPaymentMethod.Source == "NBXplorer";
onchainMethod.PayjoinEnabled &= isHotwallet && nodeSupport;
if (!isHotwallet)
logs.Write("Payjoin should have been enabled, but your store is not a hotwallet");
logs.Write($"{prefix} Payjoin should have been enabled, but your store is not a hotwallet");
if (!nodeSupport)
logs.Write("Payjoin should have been enabled, but your version of NBXplorer or full node does not support it.");
logs.Write($"{prefix} Payjoin should have been enabled, but your version of NBXplorer or full node does not support it.");
if (onchainMethod.PayjoinEnabled)
logs.Write("Payjoin is enabled for this invoice.");
logs.Write($"{prefix} Payjoin is enabled for this invoice.");
}
return onchainMethod;

View File

@@ -470,9 +470,9 @@ namespace BTCPayServer.Services.Invoices
dto.MinerFees.TryAdd(cryptoInfo.CryptoCode, minerInfo);
var bip21 = ((BTCPayNetwork)info.Network).GenerateBIP21(cryptoInfo.Address, cryptoInfo.Due);
if (((details as BitcoinLikeOnChainPaymentMethod)?.PayjoinEnabled??false) && cryptoInfo.CryptoCode.Equals("BTC", StringComparison.InvariantCultureIgnoreCase))
if ((details as BitcoinLikeOnChainPaymentMethod)?.PayjoinEnabled is true)
{
bip21 += $"&bpu={ServerUrl.WithTrailingSlash()}{cryptoCode}/bpu";
bip21 += $"&{PayjoinClient.BIP21EndpointKey}={ServerUrl.WithTrailingSlash()}{cryptoCode}/{PayjoinClient.BIP21EndpointKey}";
}
cryptoInfo.PaymentUrls = new NBitpayClient.InvoicePaymentUrls()
{