mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 13:26:47 +01:00
Liquid fixes (#6340)
make sure link provider is per payment method of liquid assets. Also remove ETB as it has been unused. Also hide the send button as it is not supported thrrough BTCPay
This commit is contained in:
parent
92f9b226fe
commit
373b90e3b5
@ -63,7 +63,6 @@ namespace BTCPayServer.Tests
|
||||
//no tether on our regtest, lets create it and set it
|
||||
var tether = tester.NetworkProvider.GetNetwork<ElementsBTCPayNetwork>("USDT");
|
||||
var lbtc = tester.NetworkProvider.GetNetwork<ElementsBTCPayNetwork>("LBTC");
|
||||
var etb = tester.NetworkProvider.GetNetwork<ElementsBTCPayNetwork>("ETB");
|
||||
var issueAssetResult = await tester.LBTCExplorerNode.SendCommandAsync("issueasset", 100000, 0);
|
||||
tether.AssetId = uint256.Parse(issueAssetResult.Result["asset"].ToString());
|
||||
((ElementsBTCPayNetwork)tester.PayTester.GetService<BTCPayWalletProvider>().GetWallet("USDT").Network)
|
||||
@ -71,15 +70,10 @@ namespace BTCPayServer.Tests
|
||||
Assert.Equal(tether.AssetId, tester.NetworkProvider.GetNetwork<ElementsBTCPayNetwork>("USDT").AssetId);
|
||||
Assert.Equal(tether.AssetId, ((ElementsBTCPayNetwork)tester.PayTester.GetService<BTCPayWalletProvider>().GetWallet("USDT").Network).AssetId);
|
||||
|
||||
var issueAssetResult2 = await tester.LBTCExplorerNode.SendCommandAsync("issueasset", 100000, 0);
|
||||
etb.AssetId = uint256.Parse(issueAssetResult2.Result["asset"].ToString());
|
||||
((ElementsBTCPayNetwork)tester.PayTester.GetService<BTCPayWalletProvider>().GetWallet("ETB").Network)
|
||||
.AssetId = etb.AssetId;
|
||||
|
||||
|
||||
user.RegisterDerivationScheme("LBTC");
|
||||
user.RegisterDerivationScheme("USDT");
|
||||
user.RegisterDerivationScheme("ETB");
|
||||
|
||||
//test: register 2 assets on the same elements network and make sure paying an invoice on one does not affect the other in any way
|
||||
var invoice = await user.BitPay.CreateInvoiceAsync(new Invoice(0.1m, "BTC"));
|
||||
@ -109,11 +103,7 @@ namespace BTCPayServer.Tests
|
||||
Assert.Equal("paid", localInvoice.Status);
|
||||
Assert.Single(localInvoice.CryptoInfo.Single(info => info.CryptoCode.Equals("USDT", StringComparison.InvariantCultureIgnoreCase)).Payments);
|
||||
});
|
||||
|
||||
//test precision based on https://github.com/ElementsProject/elements/issues/805#issuecomment-601277606
|
||||
var etbBip21 = new BitcoinUrlBuilder(invoice.CryptoInfo.Single(info => info.CryptoCode == "ETB").PaymentUrls.BIP21, etb.NBitcoinNetwork);
|
||||
//precision = 2, 1ETB = 0.00000100
|
||||
Assert.Equal(100, etbBip21.Amount.Satoshi);
|
||||
|
||||
|
||||
var lbtcBip21 = new BitcoinUrlBuilder(invoice.CryptoInfo.Single(info => info.CryptoCode == "LBTC").PaymentUrls.BIP21, lbtc.NBitcoinNetwork);
|
||||
//precision = 8, 0.1 = 0.1
|
||||
|
@ -106,9 +106,14 @@
|
||||
</li>
|
||||
@if (ViewData.IsCategoryActive(typeof(WalletsNavPages), scheme.WalletId.ToString()) || ViewData.IsPageActive([WalletsNavPages.Settings], scheme.WalletId.ToString()) || ViewData.IsPageActive([StoreNavPages.OnchainSettings], categoryId))
|
||||
{
|
||||
<li class="nav-item nav-item-sub">
|
||||
<a id="WalletNav-Send" class="nav-link @ViewData.ActivePageClass([WalletsNavPages.Send, WalletsNavPages.PSBT], scheme.WalletId.ToString())" asp-area="" asp-controller="UIWallets" asp-action="WalletSend" asp-route-walletId="@scheme.WalletId" text-translate="true">Send</a>
|
||||
</li>
|
||||
@if (!scheme.ReadonlyWallet)
|
||||
{
|
||||
<li class="nav-item nav-item-sub">
|
||||
<a id="WalletNav-Send" class="nav-link @ViewData.ActivePageClass([WalletsNavPages.Send, WalletsNavPages.PSBT], scheme.WalletId.ToString())" asp-area="" asp-controller="UIWallets" asp-action="WalletSend" asp-route-walletId="@scheme.WalletId" text-translate="true">Send</a>
|
||||
</li>
|
||||
}
|
||||
|
||||
|
||||
<li class="nav-item nav-item-sub">
|
||||
<a id="WalletNav-Receive" class="nav-link @ViewData.ActivePageClass(WalletsNavPages.Receive, scheme.WalletId.ToString())" asp-area="" asp-controller="UIWallets" asp-action="WalletReceive" asp-route-walletId="@scheme.WalletId" text-translate="true">Receive</a>
|
||||
</li>
|
||||
|
@ -146,6 +146,7 @@ public partial class UIStoresController
|
||||
Crypto = network.CryptoCode,
|
||||
PaymentMethodId = handler.PaymentMethodId,
|
||||
WalletSupported = network.WalletSupported,
|
||||
ReadonlyWallet = network.ReadonlyWallet,
|
||||
Value = value,
|
||||
WalletId = new WalletId(store.Id, network.CryptoCode),
|
||||
Enabled = !excludeFilters.Match(handler.PaymentMethodId) && strategy != null,
|
||||
|
@ -9,6 +9,7 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||
public string Value { get; set; }
|
||||
public WalletId WalletId { get; set; }
|
||||
public bool WalletSupported { get; set; }
|
||||
public bool ReadonlyWallet { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public bool Collapsed { get; set; }
|
||||
}
|
||||
|
@ -104,7 +104,6 @@ namespace BTCPayServer.Payments
|
||||
"XMR",
|
||||
"ZEC",
|
||||
"LCAD",
|
||||
"ETB",
|
||||
"LBTC",
|
||||
"USDt",
|
||||
"MONA",
|
||||
|
@ -1,15 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BTCPayServer.Abstractions.Models;
|
||||
using BTCPayServer.Hosting;
|
||||
using BTCPayServer.Logging;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NBitcoin;
|
||||
using NBitcoin.Protocol;
|
||||
using NBXplorer;
|
||||
|
||||
namespace BTCPayServer.Plugins.Altcoins
|
||||
@ -37,15 +28,12 @@ namespace BTCPayServer.Plugins.Altcoins
|
||||
{
|
||||
// Activating LBTC automatically activate the other liquid assets
|
||||
InitUSDT(services, selectedChains, liquidNBX);
|
||||
InitETB(services, selectedChains, liquidNBX);
|
||||
InitLCAD(services, selectedChains, liquidNBX);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedChains.Contains("USDT"))
|
||||
InitUSDT(services, selectedChains, liquidNBX);
|
||||
if (selectedChains.Contains("ETB"))
|
||||
InitETB(services, selectedChains, liquidNBX);
|
||||
if (selectedChains.Contains("LCAD"))
|
||||
InitLCAD(services, selectedChains, liquidNBX);
|
||||
}
|
||||
|
@ -27,7 +27,11 @@ public partial class AltcoinsPlugin
|
||||
CryptoImagePath = "imlegacy/liquid.png",
|
||||
DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(ChainName),
|
||||
CoinType = ChainName == ChainName.Mainnet ? new KeyPath("1776'") : new KeyPath("1'"),
|
||||
SupportRBF = true
|
||||
SupportRBF = true,
|
||||
SupportLightning = false,
|
||||
SupportPayJoin = false,
|
||||
VaultSupported = false,
|
||||
ReadonlyWallet = true
|
||||
}.SetDefaultElectrumMapping(ChainName);
|
||||
|
||||
var blockExplorerLink = ChainName == ChainName.Mainnet ? "https://liquid.network/tx/{0}" : "https://liquid.network/testnet/tx/{0}";
|
||||
|
@ -30,10 +30,13 @@ public partial class AltcoinsPlugin
|
||||
DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(ChainName),
|
||||
CoinType = ChainName == ChainName.Mainnet ? new KeyPath("1776'") : new KeyPath("1'"),
|
||||
SupportRBF = true,
|
||||
SupportLightning = false
|
||||
SupportLightning = false,
|
||||
SupportPayJoin = false,
|
||||
VaultSupported = false,
|
||||
ReadonlyWallet = true
|
||||
}.SetDefaultElectrumMapping(ChainName);
|
||||
services.AddBTCPayNetwork(network)
|
||||
.AddTransactionLinkProvider(PaymentTypes.CHAIN.GetPaymentMethodId(nbxplorerNetwork.CryptoCode), new DefaultTransactionLinkProvider(LiquidBlockExplorer));
|
||||
.AddTransactionLinkProvider(PaymentTypes.CHAIN.GetPaymentMethodId("USDt"), new DefaultTransactionLinkProvider(LiquidBlockExplorer));
|
||||
services.AddCurrencyData(new CurrencyData()
|
||||
{
|
||||
Code = "USDt",
|
||||
@ -45,35 +48,6 @@ public partial class AltcoinsPlugin
|
||||
selectedChains.Add("LBTC");
|
||||
}
|
||||
|
||||
private void InitETB(IServiceCollection services, SelectedChains selectedChains, NBXplorer.NBXplorerNetwork nbxplorerNetwork)
|
||||
{
|
||||
var network = new ElementsBTCPayNetwork()
|
||||
{
|
||||
CryptoCode = "ETB",
|
||||
NetworkCryptoCode = "LBTC",
|
||||
ShowSyncSummary = false,
|
||||
DefaultRateRules = new[]
|
||||
{
|
||||
|
||||
"ETB_X = ETB_BTC * BTC_X",
|
||||
"ETB_BTC = bitpay(ETB_BTC)"
|
||||
},
|
||||
Divisibility = 2,
|
||||
AssetId = new uint256("aa775044c32a7df391902b3659f46dfe004ccb2644ce2ddc7dba31e889391caf"),
|
||||
DisplayName = "Ethiopian Birr",
|
||||
NBXplorerNetwork = nbxplorerNetwork,
|
||||
CryptoImagePath = "imlegacy/etb.png",
|
||||
DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(ChainName),
|
||||
CoinType = ChainName == ChainName.Mainnet ? new KeyPath("1776'") : new KeyPath("1'"),
|
||||
SupportRBF = true,
|
||||
SupportLightning = false
|
||||
}.SetDefaultElectrumMapping(ChainName);
|
||||
|
||||
services.AddBTCPayNetwork(network)
|
||||
.AddTransactionLinkProvider(PaymentTypes.CHAIN.GetPaymentMethodId(nbxplorerNetwork.CryptoCode), new DefaultTransactionLinkProvider(LiquidBlockExplorer));
|
||||
selectedChains.Add("LBTC");
|
||||
}
|
||||
|
||||
string LiquidBlockExplorer => ChainName == ChainName.Mainnet ? "https://liquid.network/tx/{0}" : "https://liquid.network/testnet/tx/{0}";
|
||||
private void InitLCAD(IServiceCollection services, SelectedChains selectedChains, NBXplorer.NBXplorerNetwork nbxplorerNetwork)
|
||||
{
|
||||
@ -95,11 +69,14 @@ public partial class AltcoinsPlugin
|
||||
CryptoImagePath = "imlegacy/lcad.png",
|
||||
DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(ChainName),
|
||||
CoinType = ChainName == ChainName.Mainnet ? new KeyPath("1776'") : new KeyPath("1'"),
|
||||
SupportRBF = true,
|
||||
SupportLightning = false
|
||||
SupportRBF = true,
|
||||
SupportLightning = false,
|
||||
SupportPayJoin = false,
|
||||
VaultSupported = false,
|
||||
ReadonlyWallet = true
|
||||
}.SetDefaultElectrumMapping(ChainName);
|
||||
services.AddBTCPayNetwork(network)
|
||||
.AddTransactionLinkProvider(PaymentTypes.CHAIN.GetPaymentMethodId(nbxplorerNetwork.CryptoCode), new DefaultTransactionLinkProvider(LiquidBlockExplorer));
|
||||
.AddTransactionLinkProvider(PaymentTypes.CHAIN.GetPaymentMethodId("LCAD"), new DefaultTransactionLinkProvider(LiquidBlockExplorer));
|
||||
selectedChains.Add("LBTC");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user