Skip to content

Commit e111765

Browse files
committed
multi: add minrelayfee check to tapchannel funding
This commit adds `MinRelayFee` to the `WalletAnchor` and uses it during tapchannel funding to check whether the feerate meets the minimum relay fee.
1 parent 05ad64b commit e111765

File tree

8 files changed

+38
-6
lines changed

8 files changed

+38
-6
lines changed

docs/examples/basic-price-oracle/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ require (
9292
github.com/kkdai/bstream v1.0.0 // indirect
9393
github.com/lib/pq v1.10.9 // indirect
9494
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
95-
github.com/lightninglabs/lndclient v0.18.4-1 // indirect
95+
github.com/lightninglabs/lndclient v0.18.4-3 // indirect
9696
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd // indirect
9797
github.com/lightninglabs/neutrino/cache v1.1.2 // indirect
9898
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb // indirect

docs/examples/basic-price-oracle/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQ
418418
github.com/lightninglabs/lightning-node-connect v0.2.5-alpha h1:ZRVChwczFXK0CEbxOCWwUA6TIZvrkE0APd1T3WjFAwg=
419419
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2 h1:Er1miPZD2XZwcfE4xoS5AILqP1mj7kqnhbBSxW9BDxY=
420420
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2/go.mod h1:antQGRDRJiuyQF6l+k6NECCSImgCpwaZapATth2Chv4=
421-
github.com/lightninglabs/lndclient v0.18.4-1 h1:k2UnxHGNH243NRe5/dL2sKgrxc8WMHbFQRdnCtfilwc=
422-
github.com/lightninglabs/lndclient v0.18.4-1/go.mod h1:/HLqmZGL9MtP8F1g+laq+L9VrsugBN5tsTct3C5wWCg=
421+
github.com/lightninglabs/lndclient v0.18.4-3 h1:Xk3ZuCQE4ZlF70jaToryL2MvRcryiE0zTfUjJbmzUBY=
422+
github.com/lightninglabs/lndclient v0.18.4-3/go.mod h1:/HLqmZGL9MtP8F1g+laq+L9VrsugBN5tsTct3C5wWCg=
423423
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd h1:D8aRocHpoCv43hL8egXEMYyPmyOiefFHZ66338KQB2s=
424424
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd/go.mod h1:x3OmY2wsA18+Kc3TSV2QpSUewOCiscw2mKpXgZv2kZk=
425425
github.com/lightninglabs/neutrino/cache v1.1.2 h1:C9DY/DAPaPxbFC+xNNEI/z1SJY9GS3shmlu5hIQ798g=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/lib/pq v1.10.9
2727
github.com/lightninglabs/aperture v0.3.2-beta.0.20241015115230-d59b5514c19a
2828
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2
29-
github.com/lightninglabs/lndclient v0.18.4-1
29+
github.com/lightninglabs/lndclient v0.18.4-3
3030
github.com/lightninglabs/neutrino/cache v1.1.2
3131
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61
3232
github.com/lightningnetwork/lnd/cert v1.2.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ github.com/lightninglabs/lightning-node-connect v0.2.5-alpha h1:ZRVChwczFXK0CEbx
486486
github.com/lightninglabs/lightning-node-connect v0.2.5-alpha/go.mod h1:A9Pof9fETkH+F67BnOmrBDThPKstqp73wlImWOZvTXQ=
487487
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2 h1:Er1miPZD2XZwcfE4xoS5AILqP1mj7kqnhbBSxW9BDxY=
488488
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2/go.mod h1:antQGRDRJiuyQF6l+k6NECCSImgCpwaZapATth2Chv4=
489-
github.com/lightninglabs/lndclient v0.18.4-1 h1:k2UnxHGNH243NRe5/dL2sKgrxc8WMHbFQRdnCtfilwc=
490-
github.com/lightninglabs/lndclient v0.18.4-1/go.mod h1:/HLqmZGL9MtP8F1g+laq+L9VrsugBN5tsTct3C5wWCg=
489+
github.com/lightninglabs/lndclient v0.18.4-3 h1:Xk3ZuCQE4ZlF70jaToryL2MvRcryiE0zTfUjJbmzUBY=
490+
github.com/lightninglabs/lndclient v0.18.4-3/go.mod h1:/HLqmZGL9MtP8F1g+laq+L9VrsugBN5tsTct3C5wWCg=
491491
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd h1:D8aRocHpoCv43hL8egXEMYyPmyOiefFHZ66338KQB2s=
492492
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd/go.mod h1:x3OmY2wsA18+Kc3TSV2QpSUewOCiscw2mKpXgZv2kZk=
493493
github.com/lightninglabs/neutrino/cache v1.1.2 h1:C9DY/DAPaPxbFC+xNNEI/z1SJY9GS3shmlu5hIQ798g=

tapchannel/aux_funding_controller.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,18 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
13541354
fundReq.PeerPub.SerializeCompressed())
13551355
}
13561356

1357+
// Before we proceed, we'll make sure the fee rate we're using is above
1358+
// the min relay fee.
1359+
minRelayFee, err := f.cfg.ChainWallet.MinRelayFee(fundReq.ctx)
1360+
if err != nil {
1361+
return fmt.Errorf("unable to establish min_relay_fee: %w",
1362+
err)
1363+
}
1364+
if fundReq.FeeRate.FeePerKWeight() < minRelayFee {
1365+
return fmt.Errorf("fee rate %v too low, min_relay_fee: %v",
1366+
fundReq.FeeRate.FeePerKWeight(), minRelayFee)
1367+
}
1368+
13571369
// To start, we'll make a new pending asset funding desc. This'll be
13581370
// our scratch pad during the asset funding process.
13591371
tempPID, err := newPendingChanID()

tapgarden/interface.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ type WalletAnchor interface {
372372
// relevant to the wallet are sent over.
373373
SubscribeTransactions(context.Context) (<-chan lndclient.Transaction,
374374
<-chan error, error)
375+
376+
// MinRelayFee returns the current minimum relay fee based on
377+
// our chain backend in sat/kw.
378+
MinRelayFee(ctx context.Context) (chainfee.SatPerKWeight, error)
375379
}
376380

377381
// KeyRing is a mirror of the keychain.KeyRing interface, with the addition of

tapgarden/mock.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ func (m *MockWalletAnchor) ListTransactions(ctx context.Context, _, _ int32,
302302
return m.Transactions, nil
303303
}
304304

305+
// MinRelayFee estimates the minimum fee rate required for a
306+
// transaction.
307+
func (m *MockWalletAnchor) MinRelayFee(
308+
ctx context.Context) (chainfee.SatPerKWeight, error) {
309+
310+
return chainfee.SatPerKWeight(10), nil
311+
}
312+
305313
type MockChainBridge struct {
306314
FeeEstimateSignal chan struct{}
307315
PublishReq chan *wire.MsgTx

wallet_anchor.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ func (l *LndRpcWalletAnchor) ListChannels(
218218
return l.lnd.Client.ListChannels(ctx, true, false)
219219
}
220220

221+
// MinRelayFee estimates the minimum fee rate required for a
222+
// transaction.
223+
func (l *LndRpcWalletAnchor) MinRelayFee(
224+
ctx context.Context) (chainfee.SatPerKWeight, error) {
225+
226+
return l.lnd.WalletKit.MinRelayFee(ctx)
227+
}
228+
221229
// A compile time assertion to ensure LndRpcWalletAnchor meets the
222230
// tapgarden.WalletAnchor interface.
223231
var _ tapgarden.WalletAnchor = (*LndRpcWalletAnchor)(nil)

0 commit comments

Comments
 (0)