mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
lnwallet+funding+lnd: trim unused parameters, from lnwallet.Config
chainreg: remove unused GenDefaultBtcConstraints lnwallet+funding+lnd: remove DefaultDustLimit from lnwallet.Config
This commit is contained in:
parent
c6ecb10865
commit
fb8de14798
@ -200,19 +200,6 @@ type ChainControl struct {
|
||||
Wallet *lnwallet.LightningWallet
|
||||
}
|
||||
|
||||
// GenDefaultBtcConstraints generates the default set of channel constraints
|
||||
// that are to be used when funding a Bitcoin channel.
|
||||
func GenDefaultBtcConstraints() channeldb.ChannelConstraints {
|
||||
// We use the dust limit for the maximally sized witness program with
|
||||
// a 40-byte data push.
|
||||
dustLimit := lnwallet.DustLimitForSize(input.UnknownWitnessSize)
|
||||
|
||||
return channeldb.ChannelConstraints{
|
||||
DustLimit: dustLimit,
|
||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||
}
|
||||
}
|
||||
|
||||
// NewPartialChainControl creates a new partial chain control that contains all
|
||||
// the parts that can be purely constructed from the passed in global
|
||||
// configuration and doesn't need any wallet instance yet.
|
||||
|
@ -686,15 +686,14 @@ func (d *DefaultWalletImpl) BuildChainControl(
|
||||
// Create, and start the lnwallet, which handles the core payment
|
||||
// channel logic, and exposes control via proxy state machines.
|
||||
lnWalletConfig := lnwallet.Config{
|
||||
Database: partialChainControl.Cfg.ChanStateDB,
|
||||
Notifier: partialChainControl.ChainNotifier,
|
||||
WalletController: walletController,
|
||||
Signer: walletController,
|
||||
FeeEstimator: partialChainControl.FeeEstimator,
|
||||
SecretKeyRing: keyRing,
|
||||
ChainIO: walletController,
|
||||
DefaultConstraints: chainreg.GenDefaultBtcConstraints(),
|
||||
NetParams: *walletConfig.NetParams,
|
||||
Database: partialChainControl.Cfg.ChanStateDB,
|
||||
Notifier: partialChainControl.ChainNotifier,
|
||||
WalletController: walletController,
|
||||
Signer: walletController,
|
||||
FeeEstimator: partialChainControl.FeeEstimator,
|
||||
SecretKeyRing: keyRing,
|
||||
ChainIO: walletController,
|
||||
NetParams: *walletConfig.NetParams,
|
||||
}
|
||||
|
||||
// The broadcast is already always active for neutrino nodes, so we
|
||||
@ -801,15 +800,14 @@ func (d *RPCSignerWalletImpl) BuildChainControl(
|
||||
// Create, and start the lnwallet, which handles the core payment
|
||||
// channel logic, and exposes control via proxy state machines.
|
||||
lnWalletConfig := lnwallet.Config{
|
||||
Database: partialChainControl.Cfg.ChanStateDB,
|
||||
Notifier: partialChainControl.ChainNotifier,
|
||||
WalletController: rpcKeyRing,
|
||||
Signer: rpcKeyRing,
|
||||
FeeEstimator: partialChainControl.FeeEstimator,
|
||||
SecretKeyRing: rpcKeyRing,
|
||||
ChainIO: walletController,
|
||||
DefaultConstraints: chainreg.GenDefaultBtcConstraints(),
|
||||
NetParams: *walletConfig.NetParams,
|
||||
Database: partialChainControl.Cfg.ChanStateDB,
|
||||
Notifier: partialChainControl.ChainNotifier,
|
||||
WalletController: rpcKeyRing,
|
||||
Signer: rpcKeyRing,
|
||||
FeeEstimator: partialChainControl.FeeEstimator,
|
||||
SecretKeyRing: rpcKeyRing,
|
||||
ChainIO: walletController,
|
||||
NetParams: *walletConfig.NetParams,
|
||||
}
|
||||
|
||||
// We've created the wallet configuration now, so we can finish
|
||||
|
@ -360,15 +360,14 @@ func createTestWallet(cdb *channeldb.ChannelStateDB, netParams *chaincfg.Params,
|
||||
estimator chainfee.Estimator) (*lnwallet.LightningWallet, error) {
|
||||
|
||||
wallet, err := lnwallet.NewLightningWallet(lnwallet.Config{
|
||||
Database: cdb,
|
||||
Notifier: notifier,
|
||||
SecretKeyRing: keyRing,
|
||||
WalletController: wc,
|
||||
Signer: signer,
|
||||
ChainIO: bio,
|
||||
FeeEstimator: estimator,
|
||||
NetParams: *netParams,
|
||||
DefaultConstraints: chainreg.GenDefaultBtcConstraints(),
|
||||
Database: cdb,
|
||||
Notifier: notifier,
|
||||
SecretKeyRing: keyRing,
|
||||
WalletController: wc,
|
||||
Signer: signer,
|
||||
ChainIO: bio,
|
||||
FeeEstimator: estimator,
|
||||
NetParams: *netParams,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -49,10 +49,6 @@ type Config struct {
|
||||
// used to lookup the existence of outputs within the UTXO set.
|
||||
ChainIO BlockChainIO
|
||||
|
||||
// DefaultConstraints is the set of default constraints that will be
|
||||
// used for any incoming or outgoing channel reservation requests.
|
||||
DefaultConstraints channeldb.ChannelConstraints
|
||||
|
||||
// NetParams is the set of parameters that tells the wallet which chain
|
||||
// it will be operating on.
|
||||
NetParams chaincfg.Params
|
||||
|
@ -80,3 +80,8 @@ func DustLimitForSize(scriptSize int) btcutil.Amount {
|
||||
|
||||
return dustlimit
|
||||
}
|
||||
|
||||
// DustLimitUnknownWitness returns the dust limit for an UnknownWitnessSize.
|
||||
func DustLimitUnknownWitness() btcutil.Amount {
|
||||
return DustLimitForSize(input.UnknownWitnessSize)
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
||||
}
|
||||
|
||||
// Used to cut down on verbosity.
|
||||
defaultDust := wallet.Cfg.DefaultConstraints.DustLimit
|
||||
defaultDust := DustLimitUnknownWitness()
|
||||
|
||||
// If we're the responder to a single-funder reservation, then we have
|
||||
// no initial balance in the channel unless the remote party is pushing
|
||||
|
@ -356,14 +356,7 @@ func createTestWallet(tempTestDir string, miningNode *rpctest.Harness,
|
||||
Signer: signer,
|
||||
ChainIO: bio,
|
||||
FeeEstimator: chainfee.NewStaticEstimator(2500, 0),
|
||||
DefaultConstraints: channeldb.ChannelConstraints{
|
||||
DustLimit: 500,
|
||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(btcutil.SatoshiPerBitcoin) * 100,
|
||||
ChanReserve: 100,
|
||||
MinHTLC: 400,
|
||||
MaxAcceptedHtlcs: 900,
|
||||
},
|
||||
NetParams: *netParams,
|
||||
NetParams: *netParams,
|
||||
}
|
||||
|
||||
wallet, err := lnwallet.NewLightningWallet(cfg)
|
||||
@ -458,7 +451,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
||||
require.NoError(t, err, "unable to initialize funding reservation")
|
||||
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
||||
channelConstraints := &channeldb.ChannelConstraints{
|
||||
DustLimit: alice.Cfg.DefaultConstraints.DustLimit,
|
||||
DustLimit: lnwallet.DustLimitUnknownWitness(),
|
||||
ChanReserve: fundingAmount / 100,
|
||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmount),
|
||||
MinHTLC: 1,
|
||||
@ -863,7 +856,7 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
||||
require.NoError(t, err, "unable to init channel reservation")
|
||||
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
||||
channelConstraints := &channeldb.ChannelConstraints{
|
||||
DustLimit: alice.Cfg.DefaultConstraints.DustLimit,
|
||||
DustLimit: lnwallet.DustLimitUnknownWitness(),
|
||||
ChanReserve: fundingAmt / 100,
|
||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmt),
|
||||
MinHTLC: 1,
|
||||
|
@ -1363,7 +1363,8 @@ func (l *LightningWallet) initOurContribution(reservation *ChannelReservation,
|
||||
)
|
||||
|
||||
reservation.partialState.RevocationProducer = producer
|
||||
reservation.ourContribution.ChannelConstraints = l.Cfg.DefaultConstraints
|
||||
reservation.ourContribution.ChannelConstraints.DustLimit =
|
||||
DustLimitUnknownWitness()
|
||||
|
||||
// If taproot channels are active, then we'll generate our verification
|
||||
// nonce here. We'll use this nonce to verify the signature for our
|
||||
|
Loading…
Reference in New Issue
Block a user