Skip to content

Commit 7c8b3f4

Browse files
committed
multi: bump to latest lnd/tapd, assert close chan data
1 parent 5de55a4 commit 7c8b3f4

File tree

4 files changed

+192
-25
lines changed

4 files changed

+192
-25
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ require (
2828
github.com/lightninglabs/pool v0.6.5-beta.0.20250305125211-4e860ec4e77f
2929
github.com/lightninglabs/pool/auctioneerrpc v1.1.3-0.20250305125211-4e860ec4e77f
3030
github.com/lightninglabs/pool/poolrpc v1.0.1-0.20250305125211-4e860ec4e77f
31-
github.com/lightninglabs/taproot-assets v0.5.2-0.20250326140136-a724d385e7ae
32-
github.com/lightningnetwork/lnd v0.19.0-beta.rc1
31+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250401150538-a9ea76a9ed3c
32+
github.com/lightningnetwork/lnd v0.19.0-beta.rc1.0.20250327183348-eb822a5e117f
3333
github.com/lightningnetwork/lnd/cert v1.2.2
3434
github.com/lightningnetwork/lnd/clock v1.1.1
3535
github.com/lightningnetwork/lnd/fn v1.2.3

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1181,12 +1181,12 @@ github.com/lightninglabs/pool/poolrpc v1.0.1-0.20250305125211-4e860ec4e77f h1:5p
11811181
github.com/lightninglabs/pool/poolrpc v1.0.1-0.20250305125211-4e860ec4e77f/go.mod h1:lGs2hSVZ+GFpdv3btaIl9icG5/gz7BBRfvmD2iqqNl0=
11821182
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9Z6CpKxl13mS48idsu6F+cEZf0lkyiV+Dq9g=
11831183
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
1184-
github.com/lightninglabs/taproot-assets v0.5.2-0.20250326140136-a724d385e7ae h1:t2GDmnV/ab+dsaTDjCDTGbCVSMCE13pxc6zu4zQFsJs=
1185-
github.com/lightninglabs/taproot-assets v0.5.2-0.20250326140136-a724d385e7ae/go.mod h1:hLK/spdccubmDZjufTqGJrj9mn0hQpOxaJBQ767Idxw=
1184+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250401150538-a9ea76a9ed3c h1:Rebx5DVZx3u327vKRrueFjZNlei1RzdGzFmOZmenkiQ=
1185+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250401150538-a9ea76a9ed3c/go.mod h1:e3SjXbbi4xKhOzq54c672Z/j9UTRq5DLJGx/URgVTJo=
11861186
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
11871187
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
1188-
github.com/lightningnetwork/lnd v0.19.0-beta.rc1 h1:FJvsdw4PZ41ykrHi7vNGit9IIohE+IlKpVwL5/1+L+0=
1189-
github.com/lightningnetwork/lnd v0.19.0-beta.rc1/go.mod h1:BP+neeFpmeAA7o5hu3zp3FwOEl26idSyPV9zBOavp6E=
1188+
github.com/lightningnetwork/lnd v0.19.0-beta.rc1.0.20250327183348-eb822a5e117f h1:+Bejv2Ij/ryUjLacBd5au0acMH0AYs0lhb7ki5rx9ms=
1189+
github.com/lightningnetwork/lnd v0.19.0-beta.rc1.0.20250327183348-eb822a5e117f/go.mod h1:BP+neeFpmeAA7o5hu3zp3FwOEl26idSyPV9zBOavp6E=
11901190
github.com/lightningnetwork/lnd/cert v1.2.2 h1:71YK6hogeJtxSxw2teq3eGeuy4rHGKcFf0d0Uy4qBjI=
11911191
github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bqGVxViXhX6Cd7HXM6U=
11921192
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=

itest/assets_test.go

+180-19
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,9 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
473473
pendingChan.Channel.CustomChannelData, &pendingJSON,
474474
)
475475
require.NoError(t, err)
476-
require.Len(t, pendingJSON.Assets, 1)
476+
require.Len(t, pendingJSON.FundingAssets, 1)
477477

478-
require.NotZero(t, pendingJSON.Assets[0].Capacity)
478+
require.NotZero(t, pendingJSON.Capacity)
479479

480480
// Check the decimal display of the channel funding blob. If no explicit
481481
// value was set, we assume and expect the value of 0.
@@ -488,7 +488,7 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
488488

489489
require.Equal(
490490
t, expectedDecimalDisplay,
491-
pendingJSON.Assets[0].AssetInfo.DecimalDisplay,
491+
pendingJSON.FundingAssets[0].DecimalDisplay,
492492
)
493493

494494
// Check the balance of the pending channel.
@@ -501,21 +501,36 @@ func assertPendingChannels(t *testing.T, node *HarnessNode,
501501
require.EqualValues(t, remoteSum, pendingRemoteBalance)
502502
}
503503

504+
// haveFundingAsset returns true if the given channel has the asset with the
505+
// given asset ID as a funding asset.
506+
func haveFundingAsset(assetChannel *rfqmsg.JsonAssetChannel,
507+
assetID []byte) bool {
508+
509+
assetIDStr := hex.EncodeToString(assetID)
510+
for _, fundingAsset := range assetChannel.FundingAssets {
511+
if fundingAsset.AssetGenesis.AssetID == assetIDStr {
512+
return true
513+
}
514+
}
515+
516+
return false
517+
}
518+
504519
func assertAssetChan(t *testing.T, src, dst *HarnessNode, fundingAmount uint64,
505520
mintedAsset *taprpc.Asset) {
506521

507-
assetID := mintedAsset.AssetGenesis.AssetId
508-
assetIDStr := hex.EncodeToString(assetID)
509522
err := wait.NoError(func() error {
510523
a, err := getChannelCustomData(src, dst)
511524
if err != nil {
512525
return err
513526
}
514527

515-
if a.AssetInfo.AssetGenesis.AssetID != assetIDStr {
516-
return fmt.Errorf("expected asset ID %s, got %s",
517-
assetIDStr, a.AssetInfo.AssetGenesis.AssetID)
528+
assetID := mintedAsset.AssetGenesis.AssetId
529+
if !haveFundingAsset(a, assetID) {
530+
return fmt.Errorf("expected asset ID %x, to "+
531+
"be in channel", assetID)
518532
}
533+
519534
if a.Capacity != fundingAmount {
520535
return fmt.Errorf("expected capacity %d, got %d",
521536
fundingAmount, a.Capacity)
@@ -530,10 +545,10 @@ func assertAssetChan(t *testing.T, src, dst *HarnessNode, fundingAmount uint64,
530545
)
531546
}
532547

533-
if a.AssetInfo.DecimalDisplay != expectedDecimalDisplay {
548+
if a.FundingAssets[0].DecimalDisplay != expectedDecimalDisplay {
534549
return fmt.Errorf("expected decimal display %d, got %d",
535550
expectedDecimalDisplay,
536-
a.AssetInfo.DecimalDisplay)
551+
a.FundingAssets[0].DecimalDisplay)
537552
}
538553

539554
return nil
@@ -580,7 +595,7 @@ func assertChannelKnown(t *testing.T, node *HarnessNode,
580595
require.NoError(t, err)
581596
}
582597

583-
func getChannelCustomData(src, dst *HarnessNode) (*rfqmsg.JsonAssetChanInfo,
598+
func getChannelCustomData(src, dst *HarnessNode) (*rfqmsg.JsonAssetChannel,
584599
error) {
585600

586601
ctxb := context.Background()
@@ -614,12 +629,12 @@ func getChannelCustomData(src, dst *HarnessNode) (*rfqmsg.JsonAssetChanInfo,
614629
err)
615630
}
616631

617-
if len(assetData.Assets) != 1 {
632+
if len(assetData.FundingAssets) != 1 {
618633
return nil, fmt.Errorf("expected 1 asset, got %d",
619-
len(assetData.Assets))
634+
len(assetData.FundingAssets))
620635
}
621636

622-
return &assetData.Assets[0], nil
637+
return &assetData, nil
623638
}
624639

625640
func getAssetChannelBalance(t *testing.T, node *HarnessNode, assetID []byte,
@@ -706,10 +721,10 @@ func assertChannelAssetBalance(t *testing.T, node *HarnessNode,
706721
err := json.Unmarshal(targetChan.CustomChannelData, &assetBalance)
707722
require.NoError(t, err)
708723

709-
require.Len(t, assetBalance.Assets, 1)
724+
require.Len(t, assetBalance.FundingAssets, 1)
710725

711-
require.InDelta(t, local, assetBalance.Assets[0].LocalBalance, 1)
712-
require.InDelta(t, remote, assetBalance.Assets[0].RemoteBalance, 1)
726+
require.InDelta(t, local, assetBalance.LocalBalance, 1)
727+
require.InDelta(t, remote, assetBalance.RemoteBalance, 1)
713728
}
714729

715730
// addRoutingFee adds the default routing fee (1 part per million fee rate plus
@@ -1385,6 +1400,9 @@ func closeAssetChannelAndAssert(t *harnessTest, net *NetworkHarness,
13851400
)
13861401
require.NoError(t.t, err)
13871402

1403+
assertWaitingCloseChannelAssetData(t.t, local, chanPoint)
1404+
assertWaitingCloseChannelAssetData(t.t, remote, chanPoint)
1405+
13881406
mineBlocks(t, net, 1, 1)
13891407

13901408
closeUpdate, err := t.lndHarness.WaitForChannelClose(closeStream)
@@ -1405,6 +1423,9 @@ func closeAssetChannelAndAssert(t *harnessTest, net *NetworkHarness,
14051423
t.t, local, remote, closeTx, closeUpdate, assetID, groupKey,
14061424
universeTap,
14071425
)
1426+
1427+
assertClosedChannelAssetData(t.t, local, chanPoint)
1428+
assertClosedChannelAssetData(t.t, remote, chanPoint)
14081429
}
14091430

14101431
// assertDefaultCoOpCloseBalance returns a default implementation of the co-op
@@ -2128,8 +2149,8 @@ func newCloseExpiryInfo(t *testing.T, node *HarnessNode) forceCloseExpiryInfo {
21282149
csvDelay: mainChan.CsvDelay,
21292150
currentHeight: nodeInfo.BlockHeight,
21302151
cltvDelays: cltvs,
2131-
localAssetBalance: assetData.Assets[0].LocalBalance,
2132-
remoteAssetBalance: assetData.Assets[0].RemoteBalance,
2152+
localAssetBalance: assetData.LocalBalance,
2153+
remoteAssetBalance: assetData.RemoteBalance,
21332154
t: t,
21342155
node: node,
21352156
}
@@ -2200,3 +2221,143 @@ func assertInvoiceState(t *testing.T, hn *HarnessNode, payAddr []byte,
22002221
}, defaultTimeout)
22012222
require.NoError(t, err, "timeout waiting for invoice settled state")
22022223
}
2224+
2225+
type pendingChan = lnrpc.PendingChannelsResponse_PendingChannel
2226+
2227+
// assertWaitingCloseChannelAssetData asserts that the waiting close channel has
2228+
// the expected asset data.
2229+
func assertPendingChannelAssetData(t *testing.T, node *HarnessNode,
2230+
chanPoint *lnrpc.ChannelPoint, find func(string,
2231+
*lnrpc.PendingChannelsResponse) (*pendingChan, error)) {
2232+
2233+
ctxb := context.Background()
2234+
2235+
err := wait.NoError(func() error {
2236+
// Make sure we can find the closed channel in the channel
2237+
// database.
2238+
pendingChannels, err := node.PendingChannels(
2239+
ctxb, &lnrpc.PendingChannelsRequest{},
2240+
)
2241+
if err != nil {
2242+
return err
2243+
}
2244+
2245+
targetChanPointStr := fmt.Sprintf("%v:%v",
2246+
chanPoint.GetFundingTxidStr(),
2247+
chanPoint.GetOutputIndex())
2248+
2249+
targetChan, err := find(targetChanPointStr, pendingChannels)
2250+
if err != nil {
2251+
return err
2252+
}
2253+
2254+
if len(targetChan.CustomChannelData) == 0 {
2255+
return fmt.Errorf("pending channel %s has no "+
2256+
"custom channel data", targetChanPointStr)
2257+
}
2258+
2259+
var closeData rfqmsg.JsonAssetChannel
2260+
err = json.Unmarshal(targetChan.CustomChannelData, &closeData)
2261+
if err != nil {
2262+
return fmt.Errorf("error unmarshalling custom channel "+
2263+
"data: %v", err)
2264+
}
2265+
2266+
if len(closeData.FundingAssets) != 1 {
2267+
return fmt.Errorf("expected 1 funding asset, got %d",
2268+
len(closeData.FundingAssets))
2269+
}
2270+
2271+
return nil
2272+
}, defaultTimeout)
2273+
require.NoError(t, err, "timeout waiting for pending channel")
2274+
}
2275+
2276+
// assertPendingForceCloseChannelAssetData asserts that the pending force close
2277+
// channel has the expected asset data.
2278+
func assertPendingForceCloseChannelAssetData(t *testing.T, node *HarnessNode,
2279+
chanPoint *lnrpc.ChannelPoint) {
2280+
2281+
assertPendingChannelAssetData(
2282+
t, node, chanPoint, func(chanPoint string,
2283+
resp *lnrpc.PendingChannelsResponse) (*pendingChan,
2284+
error) {
2285+
2286+
if len(resp.PendingForceClosingChannels) == 0 {
2287+
return nil, fmt.Errorf("no pending force close " +
2288+
"channels found")
2289+
}
2290+
2291+
for _, ch := range resp.PendingForceClosingChannels {
2292+
if ch.Channel.ChannelPoint == chanPoint {
2293+
return ch.Channel, nil
2294+
}
2295+
}
2296+
2297+
return nil, fmt.Errorf("pending channel %s not found",
2298+
chanPoint)
2299+
},
2300+
)
2301+
}
2302+
2303+
// assertWaitingCloseChannelAssetData asserts that the waiting close channel has
2304+
// the expected asset data.
2305+
func assertWaitingCloseChannelAssetData(t *testing.T, node *HarnessNode,
2306+
chanPoint *lnrpc.ChannelPoint) {
2307+
2308+
assertPendingChannelAssetData(
2309+
t, node, chanPoint, func(chanPoint string,
2310+
resp *lnrpc.PendingChannelsResponse) (*pendingChan,
2311+
error) {
2312+
2313+
if len(resp.WaitingCloseChannels) == 0 {
2314+
return nil, fmt.Errorf("no waiting close " +
2315+
"channels found")
2316+
}
2317+
2318+
for _, ch := range resp.WaitingCloseChannels {
2319+
if ch.Channel.ChannelPoint == chanPoint {
2320+
return ch.Channel, nil
2321+
}
2322+
}
2323+
2324+
return nil, fmt.Errorf("pending channel %s not found",
2325+
chanPoint)
2326+
},
2327+
)
2328+
}
2329+
2330+
// assertClosedChannelAssetData asserts that the closed channel has the expected
2331+
// asset data.
2332+
func assertClosedChannelAssetData(t *testing.T, node *HarnessNode,
2333+
chanPoint *lnrpc.ChannelPoint) {
2334+
2335+
ctxb := context.Background()
2336+
2337+
// Make sure we can find the closed channel in the channel database.
2338+
closedChannels, err := node.ClosedChannels(
2339+
ctxb, &lnrpc.ClosedChannelsRequest{},
2340+
)
2341+
require.NoError(t, err)
2342+
2343+
require.NotEmpty(t, closedChannels.Channels)
2344+
2345+
targetChanPointStr := fmt.Sprintf("%v:%v",
2346+
chanPoint.GetFundingTxidStr(), chanPoint.GetOutputIndex())
2347+
2348+
var closedChan *lnrpc.ChannelCloseSummary
2349+
for _, ch := range closedChannels.Channels {
2350+
if ch.ChannelPoint == targetChanPointStr {
2351+
closedChan = ch
2352+
break
2353+
}
2354+
}
2355+
require.NotNil(t, closedChan)
2356+
require.NotEmpty(t, closedChan.CustomChannelData)
2357+
2358+
var closeData rfqmsg.JsonAssetChannel
2359+
err = json.Unmarshal(closedChan.CustomChannelData, &closeData)
2360+
require.NoError(t, err)
2361+
2362+
require.GreaterOrEqual(t, len(closeData.FundingAssets), 1)
2363+
}

itest/litd_custom_channels_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -3278,6 +3278,9 @@ func runCustomChannelsHtlcForceClose(ctx context.Context, t *harnessTest,
32783278

32793279
t.Logf("Channel closed! Mining blocks, close_txid=%v", closeTxid)
32803280

3281+
// The channel should first be in "waiting close" until it confirms.
3282+
assertWaitingCloseChannelAssetData(t.t, alice, aliceChanPoint)
3283+
32813284
// Next, we'll mine a block which should start the clock ticking on the
32823285
// relative timeout for the Alice, and Bob.
32833286
//
@@ -3297,6 +3300,9 @@ func runCustomChannelsHtlcForceClose(ctx context.Context, t *harnessTest,
32973300

32983301
t.Logf("Settling Bob's hodl invoice")
32993302

3303+
// It should then go to "pending force closed".
3304+
assertPendingForceCloseChannelAssetData(t.t, alice, aliceChanPoint)
3305+
33003306
// At this point, the commitment transaction has been mined, and we have
33013307
// 4 total HTLCs on Alice's commitment transaction:
33023308
//

0 commit comments

Comments
 (0)