Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump clightning #4970

Merged
merged 2 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public async Task CanCreateInvoiceWithSpecificPaymentMethods()
await tester.EnsureChannelsSetup();
var user = tester.NewAccount();
user.GrantAccess(true);
user.RegisterLightningNode("BTC", LightningConnectionType.Charge);
user.RegisterLightningNode("BTC");
user.RegisterDerivationScheme("BTC");
user.RegisterDerivationScheme("LTC");

Expand Down
33 changes: 8 additions & 25 deletions BTCPayServer.Tests/GreenfieldAPITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2366,45 +2366,28 @@ public async Task CanUseLightningAPI()
Assert.NotNull(merchantInvoice.PaymentHash);
Assert.Equal(merchantInvoice.Id, merchantInvoice.PaymentHash);

// The default client is using charge, so we should not be able to query channels
var chargeClient = await user.CreateClient(Policies.CanUseInternalLightningNode);

var info = await chargeClient.GetLightningNodeInfo("BTC");
Assert.Single(info.NodeURIs);
Assert.NotEqual(0, info.BlockHeight);
Assert.NotNull(info.Alias);
Assert.NotNull(info.Color);
Assert.NotNull(info.Version);
Assert.NotNull(info.PeersCount);
Assert.NotNull(info.ActiveChannelsCount);
Assert.NotNull(info.InactiveChannelsCount);
Assert.NotNull(info.PendingChannelsCount);

var gex = await AssertAPIError("lightning-node-unavailable", () => chargeClient.ConnectToLightningNode("BTC", new ConnectToNodeRequest(NodeInfo.Parse($"{new Key().PubKey.ToHex()}@localhost:3827"))));
Assert.Contains("NotSupported", gex.Message);

await AssertAPIError("lightning-node-unavailable", () => chargeClient.GetLightningNodeChannels("BTC"));
var client = await user.CreateClient(Policies.CanUseInternalLightningNode);
// Not permission for the store!
await AssertAPIError("missing-permission", () => chargeClient.GetLightningNodeChannels(user.StoreId, "BTC"));
var invoiceData = await chargeClient.CreateLightningInvoice("BTC", new CreateLightningInvoiceRequest()
await AssertAPIError("missing-permission", () => client.GetLightningNodeChannels(user.StoreId, "BTC"));
var invoiceData = await client.CreateLightningInvoice("BTC", new CreateLightningInvoiceRequest()
{
Amount = LightMoney.Satoshis(1000),
Description = "lol",
Expiry = TimeSpan.FromSeconds(400),
PrivateRouteHints = false
});
var chargeInvoice = invoiceData;
Assert.NotNull(await chargeClient.GetLightningInvoice("BTC", invoiceData.Id));
Assert.NotNull(await client.GetLightningInvoice("BTC", invoiceData.Id));

// check list for internal node
var invoices = await chargeClient.GetLightningInvoices("BTC");
var pendingInvoices = await chargeClient.GetLightningInvoices("BTC", true);
var invoices = await client.GetLightningInvoices("BTC");
var pendingInvoices = await client.GetLightningInvoices("BTC", true);
Assert.NotEmpty(invoices);
Assert.Contains(invoices, i => i.Id == invoiceData.Id);
Assert.NotEmpty(pendingInvoices);
Assert.Contains(pendingInvoices, i => i.Id == invoiceData.Id);

var client = await user.CreateClient($"{Policies.CanUseLightningNodeInStore}:{user.StoreId}");
client = await user.CreateClient($"{Policies.CanUseLightningNodeInStore}:{user.StoreId}");
// Not permission for the server
await AssertAPIError("missing-permission", () => client.GetLightningNodeChannels("BTC"));

Expand Down Expand Up @@ -2483,7 +2466,7 @@ await Assert.ThrowsAsync<GreenfieldValidationException>(async () => await client
Assert.Contains(payments, i => i.BOLT11 == merchantInvoice.BOLT11);

// Node info
info = await client.GetLightningNodeInfo(user.StoreId, "BTC");
var info = await client.GetLightningNodeInfo(user.StoreId, "BTC");
Assert.Single(info.NodeURIs);
Assert.NotEqual(0, info.BlockHeight);

Expand Down
2 changes: 0 additions & 2 deletions BTCPayServer.Tests/SeleniumTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ public void AddLightningNode(string cryptoCode = null, LightningConnectionType?

var connectionString = connectionType switch
{
LightningConnectionType.Charge =>
$"type=charge;server={Server.MerchantCharge.Client.Uri.AbsoluteUri};allowinsecure=true",
LightningConnectionType.CLightning =>
$"type=clightning;server={((CLightningClient)Server.MerchantLightningD).Address.AbsoluteUri}",
LightningConnectionType.LndREST =>
Expand Down
11 changes: 2 additions & 9 deletions BTCPayServer.Tests/ServerTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void ActivateETH()
#endif
public void ActivateLightning()
{
ActivateLightning(LightningConnectionType.Charge);
ActivateLightning(LightningConnectionType.CLightning);
}
public void ActivateLightning(LightningConnectionType internalNode)
{
Expand All @@ -109,14 +109,7 @@ public string GetLightningConnectionString(LightningConnectionType? connectionTy
string connectionString = null;
if (connectionType is null)
return LightningSupportedPaymentMethod.InternalNode;
if (connectionType == LightningConnectionType.Charge)
{
if (isMerchant)
connectionString = $"type=charge;server={MerchantCharge.Client.Uri.AbsoluteUri};allowinsecure=true";
else
throw new NotSupportedException();
}
else if (connectionType == LightningConnectionType.CLightning)
if (connectionType == LightningConnectionType.CLightning)
{
if (isMerchant)
connectionString = "type=clightning;server=" +
Expand Down
2 changes: 1 addition & 1 deletion BTCPayServer.Tests/TestAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public string StoreId

public bool IsAdmin { get; internal set; }

public void RegisterLightningNode(string cryptoCode, LightningConnectionType connectionType, bool isMerchant = true)
public void RegisterLightningNode(string cryptoCode, LightningConnectionType? connectionType = null, bool isMerchant = true)
{
RegisterLightningNodeAsync(cryptoCode, connectionType, isMerchant).GetAwaiter().GetResult();
}
Expand Down
12 changes: 2 additions & 10 deletions BTCPayServer.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,6 @@ public async Task CanSendLightningPaymentCLightning()
await ProcessLightningPayment(LightningConnectionType.CLightning);
}

[Fact(Timeout = 60 * 2 * 1000)]
[Trait("Integration", "Integration")]
[Trait("Lightning", "Lightning")]
public async Task CanSendLightningPaymentCharge()
{
await ProcessLightningPayment(LightningConnectionType.Charge);
}

[Fact(Timeout = 60 * 2 * 1000)]
[Trait("Integration", "Integration")]
[Trait("Lightning", "Lightning")]
Expand Down Expand Up @@ -1634,7 +1626,7 @@ public async Task CanSetPaymentMethodLimitsLightning()
var user = tester.NewAccount();
var cryptoCode = "BTC";
user.GrantAccess(true);
user.RegisterLightningNode(cryptoCode, LightningConnectionType.Charge);
user.RegisterLightningNode(cryptoCode);
user.SetLNUrl(cryptoCode, false);
var vm = user.GetController<UIStoresController>().CheckoutAppearance().AssertViewModel<CheckoutAppearanceViewModel>();
var criteria = Assert.Single(vm.PaymentMethodCriteria);
Expand All @@ -1654,7 +1646,7 @@ public async Task CanSetPaymentMethodLimitsLightning()
Assert.Equal(PaymentTypes.LightningLike.ToString(), invoice.CryptoInfo[0].PaymentType);

// Activating LNUrl, we should still have only 1 payment criteria that can be set.
user.RegisterLightningNode(cryptoCode, LightningConnectionType.Charge);
user.RegisterLightningNode(cryptoCode);
user.SetLNUrl(cryptoCode, true);
vm = user.GetController<UIStoresController>().CheckoutAppearance().AssertViewModel<CheckoutAppearanceViewModel>();
criteria = Assert.Single(vm.PaymentMethodCriteria);
Expand Down
37 changes: 9 additions & 28 deletions BTCPayServer.Tests/docker-compose.altcoins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ services:
TESTS_AzureBlobStorageConnectionString: ${TESTS_AzureBlobStorageConnectionString:-none}
TEST_MERCHANTLIGHTNINGD: "type=clightning;server=unix://etc/merchant_lightningd_datadir/lightning-rpc"
TEST_CUSTOMERLIGHTNINGD: "type=clightning;server=unix://etc/customer_lightningd_datadir/lightning-rpc"
TEST_MERCHANTCHARGE: "type=charge;server=http://lightning-charged:9112/;api-token=foiewnccewuify;allowinsecure=true"
TEST_MERCHANTLND: "http://lnd:lnd@merchant_lnd:8080/"
TESTS_INCONTAINER: "true"
TESTS_SSHCONNECTION: "root@sshd:22"
Expand Down Expand Up @@ -56,7 +55,6 @@ services:
- postgres
- customer_lightningd
- merchant_lightningd
- lightning-charged
- customer_lnd
- merchant_lnd
- sshd
Expand Down Expand Up @@ -89,12 +87,17 @@ services:
- postgres
- customer_lnd
- merchant_lnd

selenium:
image: selenium/standalone-chrome:101.0
extra_hosts:
- "tests:172.23.0.18"
expose:
- "4444"
extra_hosts:
- "tests:172.18.0.18"
networks:
default:
custom:

nbxplorer:
image: nicolasdorier/nbxplorer:2.3.63
restart: unless-stopped
Expand Down Expand Up @@ -160,7 +163,7 @@ services:
- "bitcoin_datadir:/data"

customer_lightningd:
image: btcpayserver/lightning:v23.02-1-dev
image: btcpayserver/lightning:v23.05-dev
stop_signal: SIGKILL
restart: unless-stopped
environment:
Expand All @@ -186,30 +189,8 @@ services:
depends_on:
- bitcoind

lightning-charged:
image: shesek/lightning-charge:0.4.23-1-standalone
restart: unless-stopped
environment:
NETWORK: regtest
API_TOKEN: foiewnccewuify
BITCOIND_RPCCONNECT: bitcoind
LN_NET_PATH: /etc/lightning
LN_NET: /etc/lightning
volumes:
- "bitcoin_datadir:/etc/bitcoin"
- "lightning_charge_datadir:/data"
- "merchant_lightningd_datadir:/etc/lightning"
expose:
- "9112" # Charge
- "9735" # Lightning
ports:
- "54938:9112" # Charge
depends_on:
- bitcoind
- merchant_lightningd

merchant_lightningd:
image: btcpayserver/lightning:v23.02-1-dev
image: btcpayserver/lightning:v23.05-dev
stop_signal: SIGKILL
environment:
EXPOSE_TCP: "true"
Expand Down
37 changes: 9 additions & 28 deletions BTCPayServer.Tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ services:
TESTS_AzureBlobStorageConnectionString: ${TESTS_AzureBlobStorageConnectionString:-none}
TEST_MERCHANTLIGHTNINGD: "type=clightning;server=unix://etc/merchant_lightningd_datadir/lightning-rpc"
TEST_CUSTOMERLIGHTNINGD: "type=clightning;server=unix://etc/customer_lightningd_datadir/lightning-rpc"
TEST_MERCHANTCHARGE: "type=charge;server=http://lightning-charged:9112/;api-token=foiewnccewuify;allowinsecure=true"
TEST_MERCHANTLND: "http://lnd:lnd@merchant_lnd:8080/"
TESTS_INCONTAINER: "true"
TESTS_SSHCONNECTION: "root@sshd:22"
Expand Down Expand Up @@ -54,7 +53,6 @@ services:
- postgres
- customer_lightningd
- merchant_lightningd
- lightning-charged
- customer_lnd
- merchant_lnd
- sshd
Expand All @@ -79,19 +77,24 @@ services:
BITCOIN_EXTRA_ARGS: |
deprecatedrpc=signrawtransaction
connect=bitcoind:39388
rpcallowip=0.0.0.0/0
fallbackfee=0.0002
rpcallowip=0.0.0.0/0
depends_on:
- nbxplorer
- postgres
- customer_lnd
- merchant_lnd

selenium:
image: selenium/standalone-chrome:101.0
extra_hosts:
- "tests:172.18.0.18"
- "tests:172.23.0.18"
expose:
- "4444"
networks:
default:
custom:

nbxplorer:
image: nicolasdorier/nbxplorer:2.3.63
restart: unless-stopped
Expand Down Expand Up @@ -146,7 +149,7 @@ services:
- "bitcoin_datadir:/data"

customer_lightningd:
image: btcpayserver/lightning:v23.02-1-dev
image: btcpayserver/lightning:v23.05-dev
stop_signal: SIGKILL
restart: unless-stopped
environment:
Expand All @@ -172,30 +175,8 @@ services:
depends_on:
- bitcoind

lightning-charged:
image: shesek/lightning-charge:0.4.23-1-standalone
restart: unless-stopped
environment:
NETWORK: regtest
API_TOKEN: foiewnccewuify
BITCOIND_RPCCONNECT: bitcoind
LN_NET_PATH: /etc/lightning
LN_NET: /etc/lightning
volumes:
- "bitcoin_datadir:/etc/bitcoin"
- "lightning_charge_datadir:/data"
- "merchant_lightningd_datadir:/etc/lightning"
expose:
- "9112" # Charge
- "9735" # Lightning
ports:
- "54938:9112" # Charge
depends_on:
- bitcoind
- merchant_lightningd

merchant_lightningd:
image: btcpayserver/lightning:v23.02-1-dev
image: btcpayserver/lightning:v23.05-dev
stop_signal: SIGKILL
environment:
EXPOSE_TCP: "true"
Expand Down
2 changes: 1 addition & 1 deletion BTCPayServer/BTCPayServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<ItemGroup>
<PackageReference Include="BIP78.Sender" Version="0.2.2" />
<PackageReference Include="BTCPayServer.Hwi" Version="2.0.2" />
<PackageReference Include="BTCPayServer.Lightning.All" Version="1.4.23" />
<PackageReference Include="BTCPayServer.Lightning.All" Version="1.4.24" />
<PackageReference Include="CsvHelper" Version="15.0.5" />
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Fido2" Version="2.0.2" />
Expand Down