mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 22:11:48 +01:00
Fix issue around new bech uppercase + vault supported flag (#2337)
This commit is contained in:
parent
e31b5529b0
commit
30c7cbba96
6 changed files with 18 additions and 14 deletions
|
@ -26,7 +26,8 @@ namespace BTCPayServer
|
|||
DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType),
|
||||
CoinType = NetworkType == ChainName.Mainnet ? new KeyPath("17'") : new KeyPath("1'"),
|
||||
SupportRBF = true,
|
||||
SupportPayJoin = true
|
||||
SupportPayJoin = true,
|
||||
VaultSupported = true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace BTCPayServer
|
|||
|
||||
public virtual bool WalletSupported { get; set; } = true;
|
||||
public virtual bool ReadonlyWallet { get; set; } = false;
|
||||
|
||||
public virtual bool VaultSupported { get; set; } = false;
|
||||
public int MaxTrackedConfirmation { get; internal set; } = 6;
|
||||
public string UriScheme { get; internal set; }
|
||||
public bool SupportPayJoin { get; set; } = false;
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace BTCPayServer
|
|||
CoinType = NetworkType == ChainName.Mainnet ? new KeyPath("0'") : new KeyPath("1'"),
|
||||
SupportRBF = true,
|
||||
SupportPayJoin = true,
|
||||
VaultSupported = true,
|
||||
//https://github.com/spesmilo/electrum/blob/11733d6bc271646a00b69ff07657119598874da4/electrum/constants.py
|
||||
ElectrumMapping = NetworkType == ChainName.Mainnet
|
||||
? new Dictionary<uint, DerivationType>()
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||
private readonly IFeeProviderFactory _FeeRateProviderFactory;
|
||||
private readonly NBXplorerDashboard _dashboard;
|
||||
private readonly Services.Wallets.BTCPayWalletProvider _WalletProvider;
|
||||
private readonly string _bech32Prefix;
|
||||
private readonly Dictionary<string, string> _bech32Prefix;
|
||||
|
||||
public BitcoinLikePaymentHandler(ExplorerClientProvider provider,
|
||||
BTCPayNetworkProvider networkProvider,
|
||||
|
@ -38,11 +38,12 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||
_dashboard = dashboard;
|
||||
_WalletProvider = walletProvider;
|
||||
|
||||
|
||||
var currentNetwork = (BTCPayNetwork)networkProvider.GetNetwork("BTC");
|
||||
_bech32Prefix = Encoders.ASCII.EncodeData(
|
||||
currentNetwork.NBitcoinNetwork.GetBech32Encoder(Bech32Type.WITNESS_PUBKEY_ADDRESS, false).HumanReadablePart
|
||||
);
|
||||
_bech32Prefix = networkProvider.GetAll().OfType<BTCPayNetwork>()
|
||||
.Where(network => network.NBitcoinNetwork?.Consensus?.SupportSegwit is true).ToDictionary(network => network.CryptoCode,
|
||||
network => Encoders.ASCII.EncodeData(
|
||||
network.NBitcoinNetwork.GetBech32Encoder(Bech32Type.WITNESS_PUBKEY_ADDRESS, false)
|
||||
.HumanReadablePart));
|
||||
|
||||
}
|
||||
|
||||
class Prepare
|
||||
|
@ -62,9 +63,8 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||
model.FeeRate = ((BitcoinLikeOnChainPaymentMethod) paymentMethod.GetPaymentMethodDetails()).GetFeeRate();
|
||||
model.PaymentMethodName = GetPaymentMethodName(network);
|
||||
|
||||
|
||||
var lightningFallback = "";
|
||||
if (storeBlob.OnChainWithLnInvoiceFallback)
|
||||
if (network.SupportLightning && storeBlob.OnChainWithLnInvoiceFallback)
|
||||
{
|
||||
var lightningInfo = invoiceResponse.CryptoInfo.FirstOrDefault(a =>
|
||||
a.GetpaymentMethodId() == new PaymentMethodId(model.CryptoCode, PaymentTypes.LightningLike));
|
||||
|
@ -82,10 +82,10 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||
// + lightningFallback.ToUpperInvariant().Replace("LIGHTNING=", "lightning=", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// We're leading the way in Bitcoin community with adding UPPERCASE Bech32 addresses in QR Code
|
||||
if (model.BtcAddress.StartsWith(_bech32Prefix, StringComparison.OrdinalIgnoreCase))
|
||||
if (_bech32Prefix.TryGetValue(model.CryptoCode, out var prefix) && model.BtcAddress.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
model.InvoiceBitcoinUrlQR = model.InvoiceBitcoinUrlQR.Replace(
|
||||
$"bitcoin:{model.BtcAddress}", $"bitcoin:{model.BtcAddress.ToUpperInvariant()}",
|
||||
$"{network.UriScheme}:{model.BtcAddress}", $"{network.UriScheme}:{model.BtcAddress.ToUpperInvariant()}",
|
||||
StringComparison.OrdinalIgnoreCase
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@model WalletSetupViewModel
|
||||
@inject BTCPayNetworkProvider BTCPayNetworkProvider
|
||||
@addTagHelper *, BundlerMinifier.TagHelpers
|
||||
@{
|
||||
Layout = "_LayoutWalletSetup";
|
||||
|
@ -16,7 +17,7 @@
|
|||
<p class="lead text-secondary mt-3">The following methods assume that you already have an existing wallet created and backed up.</p>
|
||||
</header>
|
||||
|
||||
@if (Model.CryptoCode == "BTC")
|
||||
@if (BTCPayNetworkProvider.GetNetwork<BTCPayNetwork>(Model.CryptoCode).VaultSupported)
|
||||
{
|
||||
<div class="mt-5">
|
||||
<div class="list-group">
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
@inject BTCPayNetworkProvider BTCPayNetworkProvider
|
||||
@model (string CryptoCode, bool NBXSeedAvailable)
|
||||
|
||||
|
||||
|
@ -6,7 +7,7 @@
|
|||
Sign with...
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="SendMenu">
|
||||
@if (Model.CryptoCode == "BTC")
|
||||
@if (BTCPayNetworkProvider.GetNetwork<BTCPayNetwork>(Model.CryptoCode).VaultSupported)
|
||||
{
|
||||
<button name="command" type="submit" class="dropdown-item" value="vault">... a hardware wallet</button>
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue