Skip to content

Commit

Permalink
Merge pull request #892 from lightninglabs/validate-fee
Browse files Browse the repository at this point in the history
Add itest for MinRelayFee check in tapd
  • Loading branch information
guggero authored Nov 5, 2024
2 parents 3a8f1f6 + 13fa097 commit f308629
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 7 deletions.
1 change: 0 additions & 1 deletion cmd/litcli/ln.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ var fundChannelCommand = cli.Command{
Usage: "(optional) a manual fee expressed in " +
"sat/vByte that should be used when crafting " +
"the transaction",
Value: 1,
},
cli.Uint64Flag{
Name: "push_amt",
Expand Down
41 changes: 41 additions & 0 deletions docs/release-notes/release-notes-0.13.7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Release Notes

- [Lightning Terminal](#lightning-terminal)
- [Bug Fixes](#bug-fixes)
- [Functional Changes/Additions](#functional-changesadditions)
- [Technical and Architectural Updates](#technical-and-architectural-updates)
- [Integrated Binary Updates](#integrated-binary-updates)
- [LND](#lnd)
- [Loop](#loop)
- [Pool](#pool)
- [Faraday](#faraday)
- [Taproot Assets](#taproot-assets)
- [Contributors](#contributors-alphabetical-order)

## Lightning Terminal

### Bug Fixes

### Functional Changes/Additions

* [Add itest](https://github.com/lightninglabs/lightning-terminal/pull/892) for
the MinRelayFee check added in Taproot Assets. The test ensures that
transactions with fees below the minimum relay fee are rejected.

### Technical and Architectural Updates

## Integrated Binary Updates

### LND

### Loop

### Pool

### Faraday

### Taproot Assets



# Contributors (Alphabetical Order)
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ require (
github.com/lightninglabs/lightning-node-connect v0.3.2-alpha.0.20240822142323-ee4e7ff52f83
github.com/lightninglabs/lightning-terminal/autopilotserverrpc v0.0.1
github.com/lightninglabs/lightning-terminal/litrpc v1.0.0
github.com/lightninglabs/lndclient v0.18.4-1
github.com/lightninglabs/lndclient v0.18.4-3
github.com/lightninglabs/loop v0.28.8-beta.0.20241022072406-1e8ae31ddc27
github.com/lightninglabs/loop/looprpc v1.0.0
github.com/lightninglabs/loop/swapserverrpc v1.0.10
github.com/lightninglabs/pool v0.6.5-beta.0.20241015105339-044cb451b5df
github.com/lightninglabs/pool/auctioneerrpc v1.1.2
github.com/lightninglabs/pool/poolrpc v1.0.0
github.com/lightninglabs/taproot-assets v0.4.2-0.20241031160301-588e58bfae6c
github.com/lightninglabs/taproot-assets v0.4.2-0.20241101220611-e6b78bd51722
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/fn v1.2.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,8 @@ github.com/lightninglabs/lightning-node-connect v0.3.2-alpha.0.20240822142323-ee
github.com/lightninglabs/lightning-node-connect v0.3.2-alpha.0.20240822142323-ee4e7ff52f83/go.mod h1:+SasPOt0evcJdfApb/ALTaTz4x3a2/kWy5KqFoTpiX8=
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2 h1:Er1miPZD2XZwcfE4xoS5AILqP1mj7kqnhbBSxW9BDxY=
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2/go.mod h1:antQGRDRJiuyQF6l+k6NECCSImgCpwaZapATth2Chv4=
github.com/lightninglabs/lndclient v0.18.4-1 h1:k2UnxHGNH243NRe5/dL2sKgrxc8WMHbFQRdnCtfilwc=
github.com/lightninglabs/lndclient v0.18.4-1/go.mod h1:/HLqmZGL9MtP8F1g+laq+L9VrsugBN5tsTct3C5wWCg=
github.com/lightninglabs/lndclient v0.18.4-3 h1:Xk3ZuCQE4ZlF70jaToryL2MvRcryiE0zTfUjJbmzUBY=
github.com/lightninglabs/lndclient v0.18.4-3/go.mod h1:/HLqmZGL9MtP8F1g+laq+L9VrsugBN5tsTct3C5wWCg=
github.com/lightninglabs/loop v0.28.8-beta.0.20241022072406-1e8ae31ddc27 h1:eZBvG9XvDL0zsUIqFfD7SCk+Ex8rGWEL8j5UQ/aqjco=
github.com/lightninglabs/loop v0.28.8-beta.0.20241022072406-1e8ae31ddc27/go.mod h1:4B1DqrcOc5Yv9KyclAeQJY9Ah9UMX7RpI4Uru7aEzl4=
github.com/lightninglabs/loop/looprpc v1.0.0 h1:xry4QPCZShPww660xJm1BVcNFj8etgNeN2vMpfsv3c4=
Expand All @@ -1177,8 +1177,8 @@ github.com/lightninglabs/pool/poolrpc v1.0.0 h1:vvosrgNx9WXF4mcHGqLjZOW8wNM0q+BL
github.com/lightninglabs/pool/poolrpc v1.0.0/go.mod h1:ZqpEpBFRMMBAerMmilEjh27tqauSXDwLaLR0O3jvmMA=
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9Z6CpKxl13mS48idsu6F+cEZf0lkyiV+Dq9g=
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
github.com/lightninglabs/taproot-assets v0.4.2-0.20241031160301-588e58bfae6c h1:HfU82bWD4Yk+Mf2Ax25uhcIwq0SxToTq8J8YJLReW/U=
github.com/lightninglabs/taproot-assets v0.4.2-0.20241031160301-588e58bfae6c/go.mod h1:AYq9p1FOMdwAGjEjVaT79+cDyAwcc4fj8W0YJvCU0JE=
github.com/lightninglabs/taproot-assets v0.4.2-0.20241101220611-e6b78bd51722 h1:67uNN65L8P6rcTkFAAuD+oYldQcDkSQLGK+o4Cfu/X8=
github.com/lightninglabs/taproot-assets v0.4.2-0.20241101220611-e6b78bd51722/go.mod h1:DLcxQrwsLSXLTMNr1hBY5+pJSxNJYqobPqxhflYYFp8=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61 h1:EcBM2tz+iyspYRFaDVjUe5a2bkuBWFxOWD2mzdCraUc=
Expand Down
85 changes: 85 additions & 0 deletions itest/litd_custom_channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/lightningnetwork/lnd/lntest"
"github.com/lightningnetwork/lnd/lntest/port"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -2637,3 +2638,87 @@ func testCustomChannelsOraclePricing(_ context.Context,
noOpCoOpCloseBalanceCheck,
)
}

// testCustomChannelsFee tests the whether the custom channel funding process
// fails if the proposed fee rate is lower than the minimum relay fee.
func testCustomChannelsFee(_ context.Context,
net *NetworkHarness, t *harnessTest) {

ctxb := context.Background()
lndArgs := slices.Clone(lndArgsTemplate)
litdArgs := slices.Clone(litdArgsTemplate)

zane, err := net.NewNode(
t.t, "Zane", lndArgs, false, true, litdArgs...,
)
require.NoError(t.t, err)

litdArgs = append(litdArgs, fmt.Sprintf(
"--taproot-assets.proofcourieraddr=%s://%s",
proof.UniverseRpcCourierType, zane.Cfg.LitAddr(),
))

charlie, err := net.NewNode(
t.t, "Charlie", lndArgs, false, true, litdArgs...,
)
require.NoError(t.t, err)
dave, err := net.NewNode(t.t, "Dave", lndArgs, false, true, litdArgs...)
require.NoError(t.t, err)

nodes := []*HarnessNode{charlie, dave}
connectAllNodes(t.t, net, nodes)
fundAllNodes(t.t, net, nodes)

charlieTap := newTapClient(t.t, charlie)
daveTap := newTapClient(t.t, dave)

// Mint an assets on Charlie and sync Dave to Charlie as the universe.
mintedAssets := itest.MintAssetsConfirmBatch(
t.t, t.lndHarness.Miner.Client, charlieTap,
[]*mintrpc.MintAssetRequest{
{
Asset: itestAsset,
},
},
)
cents := mintedAssets[0]
assetID := cents.AssetGenesis.AssetId

t.Logf("Minted %d lightning cents, syncing universes...", cents.Amount)
syncUniverses(t.t, charlieTap, dave)
t.Logf("Universes synced between all nodes, distributing assets...")

// Fund a channel with a fee rate of zero.
zeroFeeRate := uint32(0)

_, err = charlieTap.FundChannel(
ctxb, &tchrpc.FundChannelRequest{
AssetAmount: cents.Amount,
AssetId: assetID,
PeerPubkey: daveTap.node.PubKey[:],
FeeRateSatPerVbyte: zeroFeeRate,
PushSat: 0,
},
)

errSpecifyFeerate := "fee rate must be specified"
require.ErrorContains(t.t, err, errSpecifyFeerate)

// Fund a channel with a fee rate that is too low.
tooLowFeeRate := uint32(1)
tooLowFeeRateAmount := chainfee.SatPerVByte(tooLowFeeRate)

_, err = charlieTap.FundChannel(
ctxb, &tchrpc.FundChannelRequest{
AssetAmount: cents.Amount,
AssetId: assetID,
PeerPubkey: daveTap.node.PubKey[:],
FeeRateSatPerVbyte: tooLowFeeRate,
PushSat: 0,
},
)

errFeeRateTooLow := fmt.Sprintf("fee rate %s too low, "+
"min_relay_fee: ", tooLowFeeRateAmount.FeePerKWeight())
require.ErrorContains(t.t, err, errFeeRateTooLow)
}
4 changes: 4 additions & 0 deletions itest/litd_test_list_on_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ var allTestCases = []*testCase{
name: "test custom channels oracle pricing",
test: testCustomChannelsOraclePricing,
},
{
name: "test custom channels fee",
test: testCustomChannelsFee,
},
}

0 comments on commit f308629

Please sign in to comment.