mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
Testing invoice payment with Lnd
This commit is contained in:
parent
8fc1b0c856
commit
f97173e9e7
2 changed files with 18 additions and 6 deletions
|
@ -9,6 +9,7 @@ using NBitcoin.RPC;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace BTCPayServer.Tests.UnitTests
|
namespace BTCPayServer.Tests.UnitTests
|
||||||
{
|
{
|
||||||
|
@ -59,9 +60,19 @@ namespace BTCPayServer.Tests.UnitTests
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task SetupWalletForPayment()
|
public async Task CreateLndInvoiceAndPay()
|
||||||
{
|
{
|
||||||
|
var merchantInvoice = await InvoiceClient.CreateInvoice(10000, "Hello world", TimeSpan.FromSeconds(3600));
|
||||||
|
|
||||||
await EnsureLightningChannelAsync();
|
await EnsureLightningChannelAsync();
|
||||||
|
var payResponse = await CustomerLnd.SendPaymentSyncAsync(new LnrpcSendRequest
|
||||||
|
{
|
||||||
|
Payment_request = merchantInvoice.BOLT11
|
||||||
|
});
|
||||||
|
|
||||||
|
var invoice = await InvoiceClient.GetInvoice(merchantInvoice.Id);
|
||||||
|
|
||||||
|
Assert.True(invoice.PaidAt.HasValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,10 @@ namespace BTCPayServer.Payments.Lightning.Lnd
|
||||||
NodeId = resp.Identity_pubkey
|
NodeId = resp.Identity_pubkey
|
||||||
};
|
};
|
||||||
|
|
||||||
// Lnd doesn't return this data as Clightning so we add it manually from data we have
|
// Lnd doesn't return this data as Clightning, find alternative ways to supply
|
||||||
var uri = new Uri(_Decorator.BaseUrl);
|
// it always should be merchant_lnd:9735 because of docker
|
||||||
nodeInfo.Address = uri.Host;
|
nodeInfo.Address = null;
|
||||||
nodeInfo.P2PPort = uri.Port;
|
nodeInfo.P2PPort = 9735;
|
||||||
|
|
||||||
return nodeInfo;
|
return nodeInfo;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ namespace BTCPayServer.Payments.Lightning.Lnd
|
||||||
return ConvertLndInvoice(resp);
|
return ConvertLndInvoice(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: These two methods where you wait on invoice are still work in progress
|
||||||
public Task<ILightningListenInvoiceSession> Listen(CancellationToken cancellation = default(CancellationToken))
|
public Task<ILightningListenInvoiceSession> Listen(CancellationToken cancellation = default(CancellationToken))
|
||||||
{
|
{
|
||||||
return Task.FromResult<ILightningListenInvoiceSession>(this);
|
return Task.FromResult<ILightningListenInvoiceSession>(this);
|
||||||
|
@ -80,8 +81,8 @@ namespace BTCPayServer.Payments.Lightning.Lnd
|
||||||
{
|
{
|
||||||
var resp = await _Decorator.SubscribeInvoicesAsync(cancellation);
|
var resp = await _Decorator.SubscribeInvoicesAsync(cancellation);
|
||||||
return ConvertLndInvoice(resp);
|
return ConvertLndInvoice(resp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Eof work in progress
|
||||||
|
|
||||||
|
|
||||||
// utility static methods... maybe move to separate class
|
// utility static methods... maybe move to separate class
|
||||||
|
|
Loading…
Add table
Reference in a new issue