@@ -27,6 +27,7 @@ import (
27
27
"github.com/lightningnetwork/lnd/lntest"
28
28
"github.com/lightningnetwork/lnd/lntest/port"
29
29
"github.com/lightningnetwork/lnd/lntest/wait"
30
+ "github.com/lightningnetwork/lnd/lnwallet/chainfee"
30
31
"github.com/lightningnetwork/lnd/lnwire"
31
32
"github.com/stretchr/testify/require"
32
33
)
@@ -2637,3 +2638,87 @@ func testCustomChannelsOraclePricing(_ context.Context,
2637
2638
noOpCoOpCloseBalanceCheck ,
2638
2639
)
2639
2640
}
2641
+
2642
+ // testCustomChannelsFee tests the whether the custom channel funding process
2643
+ // fails if the proposed fee rate is lower than the minimum relay fee.
2644
+ func testCustomChannelsFee (_ context.Context ,
2645
+ net * NetworkHarness , t * harnessTest ) {
2646
+
2647
+ ctxb := context .Background ()
2648
+ lndArgs := slices .Clone (lndArgsTemplate )
2649
+ litdArgs := slices .Clone (litdArgsTemplate )
2650
+
2651
+ zane , err := net .NewNode (
2652
+ t .t , "Zane" , lndArgs , false , true , litdArgs ... ,
2653
+ )
2654
+ require .NoError (t .t , err )
2655
+
2656
+ litdArgs = append (litdArgs , fmt .Sprintf (
2657
+ "--taproot-assets.proofcourieraddr=%s://%s" ,
2658
+ proof .UniverseRpcCourierType , zane .Cfg .LitAddr (),
2659
+ ))
2660
+
2661
+ charlie , err := net .NewNode (
2662
+ t .t , "Charlie" , lndArgs , false , true , litdArgs ... ,
2663
+ )
2664
+ require .NoError (t .t , err )
2665
+ dave , err := net .NewNode (t .t , "Dave" , lndArgs , false , true , litdArgs ... )
2666
+ require .NoError (t .t , err )
2667
+
2668
+ nodes := []* HarnessNode {charlie , dave }
2669
+ connectAllNodes (t .t , net , nodes )
2670
+ fundAllNodes (t .t , net , nodes )
2671
+
2672
+ charlieTap := newTapClient (t .t , charlie )
2673
+ daveTap := newTapClient (t .t , dave )
2674
+
2675
+ // Mint an assets on Charlie and sync Dave to Charlie as the universe.
2676
+ mintedAssets := itest .MintAssetsConfirmBatch (
2677
+ t .t , t .lndHarness .Miner .Client , charlieTap ,
2678
+ []* mintrpc.MintAssetRequest {
2679
+ {
2680
+ Asset : itestAsset ,
2681
+ },
2682
+ },
2683
+ )
2684
+ cents := mintedAssets [0 ]
2685
+ assetID := cents .AssetGenesis .AssetId
2686
+
2687
+ t .Logf ("Minted %d lightning cents, syncing universes..." , cents .Amount )
2688
+ syncUniverses (t .t , charlieTap , dave )
2689
+ t .Logf ("Universes synced between all nodes, distributing assets..." )
2690
+
2691
+ // Fund a channel with a fee rate of zero.
2692
+ zeroFeeRate := uint32 (0 )
2693
+
2694
+ _ , err = charlieTap .FundChannel (
2695
+ ctxb , & tchrpc.FundChannelRequest {
2696
+ AssetAmount : cents .Amount ,
2697
+ AssetId : assetID ,
2698
+ PeerPubkey : daveTap .node .PubKey [:],
2699
+ FeeRateSatPerVbyte : zeroFeeRate ,
2700
+ PushSat : 0 ,
2701
+ },
2702
+ )
2703
+
2704
+ errSpecifyFeerate := "fee rate must be specified"
2705
+ require .ErrorContains (t .t , err , errSpecifyFeerate )
2706
+
2707
+ // Fund a channel with a fee rate that is too low.
2708
+ tooLowFeeRate := uint32 (1 )
2709
+ tooLowFeeRateAmount := chainfee .SatPerVByte (tooLowFeeRate )
2710
+
2711
+ _ , err = charlieTap .FundChannel (
2712
+ ctxb , & tchrpc.FundChannelRequest {
2713
+ AssetAmount : cents .Amount ,
2714
+ AssetId : assetID ,
2715
+ PeerPubkey : daveTap .node .PubKey [:],
2716
+ FeeRateSatPerVbyte : tooLowFeeRate ,
2717
+ PushSat : 0 ,
2718
+ },
2719
+ )
2720
+
2721
+ errFeeRateTooLow := fmt .Sprintf ("fee rate %s too low, " +
2722
+ "min_relay_fee: " , tooLowFeeRateAmount .FeePerKWeight ())
2723
+ require .ErrorContains (t .t , err , errFeeRateTooLow )
2724
+ }
0 commit comments