Skip to content

Commit 7bdd35f

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

File tree

4 files changed

+154
-24
lines changed

4 files changed

+154
-24
lines changed

go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ 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
31+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250327174218-b236594958bb
3232
github.com/lightningnetwork/lnd v0.19.0-beta.rc1
3333
github.com/lightningnetwork/lnd/cert v1.2.2
3434
github.com/lightningnetwork/lnd/clock v1.1.1
@@ -237,4 +237,6 @@ replace (
237237
// taproot-assets dependency to function properly.
238238
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display
239239

240+
replace github.com/lightningnetwork/lnd => github.com/guggero/lnd v0.11.0-beta.rc4.0.20250327173849-177bbd272176
241+
240242
go 1.23.6

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4Zs
10041004
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w=
10051005
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
10061006
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
1007+
github.com/guggero/lnd v0.11.0-beta.rc4.0.20250327173849-177bbd272176 h1:F8HC5HVwRt8oRWTAHLh//2rohJ9ulOzAfykP5MlEdQQ=
1008+
github.com/guggero/lnd v0.11.0-beta.rc4.0.20250327173849-177bbd272176/go.mod h1:BP+neeFpmeAA7o5hu3zp3FwOEl26idSyPV9zBOavp6E=
10071009
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
10081010
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
10091011
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -1181,12 +1183,10 @@ github.com/lightninglabs/pool/poolrpc v1.0.1-0.20250305125211-4e860ec4e77f h1:5p
11811183
github.com/lightninglabs/pool/poolrpc v1.0.1-0.20250305125211-4e860ec4e77f/go.mod h1:lGs2hSVZ+GFpdv3btaIl9icG5/gz7BBRfvmD2iqqNl0=
11821184
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9Z6CpKxl13mS48idsu6F+cEZf0lkyiV+Dq9g=
11831185
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=
1186+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250327174218-b236594958bb h1:HYKEiVao9WYuZcsEF6CfTl//K8txubvIRFlsSymXinY=
1187+
github.com/lightninglabs/taproot-assets v0.5.2-0.20250327174218-b236594958bb/go.mod h1:sInYbAK9T3E1bZBKGN1KtOV2NEH6Qqgdu8KswYUVTLw=
11861188
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
11871189
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=
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

+145-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,108 @@ 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+
// assertClosedChannelAssetData asserts that the closed channel has the expected
2226+
// asset data.
2227+
func assertClosedChannelAssetData(t *testing.T, node *HarnessNode,
2228+
chanPoint *lnrpc.ChannelPoint) {
2229+
2230+
ctxb := context.Background()
2231+
2232+
// Make sure we can find the closed channel in the channel database.
2233+
closedChannels, err := node.ClosedChannels(
2234+
ctxb, &lnrpc.ClosedChannelsRequest{},
2235+
)
2236+
require.NoError(t, err)
2237+
2238+
require.NotEmpty(t, closedChannels.Channels)
2239+
2240+
targetChanPointStr := fmt.Sprintf("%v:%v", chanPoint.GetFundingTxidStr(),
2241+
chanPoint.GetOutputIndex())
2242+
2243+
var closedChan *lnrpc.ChannelCloseSummary
2244+
for _, ch := range closedChannels.Channels {
2245+
if ch.ChannelPoint == targetChanPointStr {
2246+
closedChan = ch
2247+
break
2248+
}
2249+
}
2250+
require.NotNil(t, closedChan)
2251+
require.NotEmpty(t, closedChan.CustomChannelData)
2252+
2253+
var closeData rfqmsg.JsonAssetChannel
2254+
err = json.Unmarshal(closedChan.CustomChannelData, &closeData)
2255+
require.NoError(t, err)
2256+
2257+
require.GreaterOrEqual(t, len(closeData.FundingAssets), 1)
2258+
}
2259+
2260+
// assertPendingForceCloseChannelAssetData asserts that the pending force close
2261+
// channel has the expected asset data.
2262+
func assertPendingForceCloseChannelAssetData(t *testing.T, node *HarnessNode,
2263+
chanPoint *lnrpc.ChannelPoint) {
2264+
2265+
ctxb := context.Background()
2266+
2267+
// Make sure we can find the closed channel in the channel database.
2268+
pendingChannels, err := node.PendingChannels(
2269+
ctxb, &lnrpc.PendingChannelsRequest{},
2270+
)
2271+
require.NoError(t, err)
2272+
2273+
require.NotEmpty(t, pendingChannels.PendingForceClosingChannels)
2274+
2275+
targetChanPointStr := fmt.Sprintf("%v:%v", chanPoint.GetFundingTxidStr(),
2276+
chanPoint.GetOutputIndex())
2277+
2278+
var pendingChan *lnrpc.PendingChannelsResponse_PendingChannel
2279+
for _, ch := range pendingChannels.PendingForceClosingChannels {
2280+
if ch.Channel.ChannelPoint == targetChanPointStr {
2281+
pendingChan = ch.Channel
2282+
break
2283+
}
2284+
}
2285+
require.NotNil(t, pendingChan)
2286+
require.NotEmpty(t, pendingChan.CustomChannelData)
2287+
2288+
var closeData rfqmsg.JsonAssetChannel
2289+
err = json.Unmarshal(pendingChan.CustomChannelData, &closeData)
2290+
require.NoError(t, err)
2291+
2292+
require.GreaterOrEqual(t, len(closeData.FundingAssets), 1)
2293+
}
2294+
2295+
// assertWaitingCloseChannelAssetData asserts that the waiting close channel has
2296+
// the expected asset data.
2297+
func assertWaitingCloseChannelAssetData(t *testing.T, node *HarnessNode,
2298+
chanPoint *lnrpc.ChannelPoint) {
2299+
2300+
ctxb := context.Background()
2301+
2302+
// Make sure we can find the closed channel in the channel database.
2303+
pendingChannels, err := node.PendingChannels(
2304+
ctxb, &lnrpc.PendingChannelsRequest{},
2305+
)
2306+
require.NoError(t, err)
2307+
2308+
require.NotEmpty(t, pendingChannels.WaitingCloseChannels)
2309+
2310+
targetChanPointStr := fmt.Sprintf("%v:%v", chanPoint.GetFundingTxidStr(),
2311+
chanPoint.GetOutputIndex())
2312+
2313+
var waitingCloseChan *lnrpc.PendingChannelsResponse_PendingChannel
2314+
for _, ch := range pendingChannels.WaitingCloseChannels {
2315+
if ch.Channel.ChannelPoint == targetChanPointStr {
2316+
waitingCloseChan = ch.Channel
2317+
break
2318+
}
2319+
}
2320+
require.NotNil(t, waitingCloseChan)
2321+
require.NotEmpty(t, waitingCloseChan.CustomChannelData)
2322+
2323+
var closeData rfqmsg.JsonAssetChannel
2324+
err = json.Unmarshal(waitingCloseChan.CustomChannelData, &closeData)
2325+
require.NoError(t, err)
2326+
2327+
require.GreaterOrEqual(t, len(closeData.FundingAssets), 1)
2328+
}

itest/litd_custom_channels_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -3276,6 +3276,8 @@ func runCustomChannelsHtlcForceClose(ctx context.Context, t *harnessTest,
32763276
_, closeTxid, err := net.CloseChannel(alice, aliceChanPoint, true)
32773277
require.NoError(t.t, err)
32783278

3279+
assertPendingForceCloseChannelAssetData(t.t, alice, aliceChanPoint)
3280+
32793281
t.Logf("Channel closed! Mining blocks, close_txid=%v", closeTxid)
32803282

32813283
// Next, we'll mine a block which should start the clock ticking on the

0 commit comments

Comments
 (0)