Skip to content

Commit

Permalink
storeFinalHtlcResolutions flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsafier committed Aug 27, 2024
1 parent 1d14512 commit d593bb3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LNUnit.LND/LNUnit.LND.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>LNUnit.LND</PackageId>
<Version>1.7.2</Version>
<Version>1.7.3</Version>
<PackageDescription>LNUnit LND Typed Clients</PackageDescription>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
Expand Down
25 changes: 24 additions & 1 deletion LNUnit.Tests/Abstract/AbcLightningAbstractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public async Task SetupNetwork(string lndImage = "lightninglabs/lnd", string lnd
RemoteName = "bob"
}
], imageName: lndImage, tagName: lndTag, pullImage: false, acceptKeysend: true, mapTotmp: false,
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["alice"] : null, lndkSupport: false, nativeSql: _dbType == "postgres");
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["alice"] : null, lndkSupport: false, nativeSql: _dbType == "postgres", storeFinalHtlcResolutions: true);

Builder.AddPolarLNDNode("bob",
[
Expand Down Expand Up @@ -269,6 +269,8 @@ public async Task VirtualNodeInvoicePaymentFlowDemo()

//Setup interceptor to get virtual nodes stuff
var nodeClone = alice.Clone();
CircuitKey? htlcToCheckIfSettled = null;

var i = new LNDSimpleHtlcInterceptorHandler(nodeClone, async x =>
{
var onionBlob = x.OnionBlob.ToByteArray();
Expand All @@ -279,6 +281,7 @@ public async Task VirtualNodeInvoicePaymentFlowDemo()
//Logic for interception
$"Intercepted Payment {Convert.ToHexString(x.PaymentHash.ToByteArray())} on channel {x.IncomingCircuitKey.ChanId} for virtual node {virtualNodeKey.PubKey.ToHex()}"
.Print();
htlcToCheckIfSettled = x.IncomingCircuitKey;
return new ForwardHtlcInterceptResponse
{
Action = ResolveHoldForwardAction.Settle,
Expand All @@ -301,6 +304,26 @@ public async Task VirtualNodeInvoicePaymentFlowDemo()
Assert.That(paymentStatus.Status, Is.EqualTo(Payment.Types.PaymentStatus.Succeeded));
await Task.Delay(2000); //if we don't delay LND shows this as unsettled, it returns true early, with HTLC tracking should verify in prod setup. Otherwise this stuff is phantom

//Check HTLCs

try
{
var result = await alice.LightningClient.LookupHtlcResolutionAsync(new LookupHtlcResolutionRequest()
{
ChanId = htlcToCheckIfSettled!.ChanId,
HtlcIndex = htlcToCheckIfSettled!.HtlcId
});
result.PrintDump();
Assert.That(result.Settled, Is.True);
}
catch (RpcException e) when( e.Status.StatusCode == StatusCode.NotFound)
{
//isn't resolved yet
}




var listChannels = await alice.LightningClient.ListChannelsAsync(new ListChannelsRequest()
{
Peer = ByteString.CopyFrom(bob.LocalNodePubKeyBytes)
Expand Down
2 changes: 1 addition & 1 deletion LNUnit/LNUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<Version>1.7.2</Version>
<Version>1.7.3</Version>
<IsPackable>true</IsPackable>
<PackageId>LNUnit</PackageId>
<PackageDescription>Lightning Network Unit Testing Framework</PackageDescription>
Expand Down
6 changes: 5 additions & 1 deletion LNUnit/Setup/LNUnitBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ public static LNUnitBuilder AddPolarLNDNode(this LNUnitBuilder b, string aliasHo
string rpcUser = "bitcoin", string rpcPass = "bitcoin", string imageName = "polarlightning/lnd",
string tagName = "0.17.4-beta", bool acceptKeysend = true, bool pullImage = true, bool mapTotmp = false,
bool gcInvoiceOnStartup = false, bool gcInvoiceOnFly = false, string? postgresDSN = null,
string lndRoot = "/home/lnd/.lnd", bool lndkSupport = false, bool nativeSql = false)
string lndRoot = "/home/lnd/.lnd", bool lndkSupport = false, bool nativeSql = false, bool storeFinalHtlcResolutions = false)
{
var cmd = new List<string>
{
Expand Down Expand Up @@ -967,6 +967,10 @@ public static LNUnitBuilder AddPolarLNDNode(this LNUnitBuilder b, string aliasHo
cmd.Add("--protocol.custom-init=39");
}

if (storeFinalHtlcResolutions)
{
cmd.Add("--store-final-htlc-resolutions");
}
if (!postgresDSN.IsEmpty())
{
cmd.Add("--db.backend=postgres");
Expand Down

0 comments on commit d593bb3

Please sign in to comment.