mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-21 06:12:38 +02: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
|
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
|
// NewPartialChainControl creates a new partial chain control that contains all
|
||||||
// the parts that can be purely constructed from the passed in global
|
// the parts that can be purely constructed from the passed in global
|
||||||
// configuration and doesn't need any wallet instance yet.
|
// 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
|
// Create, and start the lnwallet, which handles the core payment
|
||||||
// channel logic, and exposes control via proxy state machines.
|
// channel logic, and exposes control via proxy state machines.
|
||||||
lnWalletConfig := lnwallet.Config{
|
lnWalletConfig := lnwallet.Config{
|
||||||
Database: partialChainControl.Cfg.ChanStateDB,
|
Database: partialChainControl.Cfg.ChanStateDB,
|
||||||
Notifier: partialChainControl.ChainNotifier,
|
Notifier: partialChainControl.ChainNotifier,
|
||||||
WalletController: walletController,
|
WalletController: walletController,
|
||||||
Signer: walletController,
|
Signer: walletController,
|
||||||
FeeEstimator: partialChainControl.FeeEstimator,
|
FeeEstimator: partialChainControl.FeeEstimator,
|
||||||
SecretKeyRing: keyRing,
|
SecretKeyRing: keyRing,
|
||||||
ChainIO: walletController,
|
ChainIO: walletController,
|
||||||
DefaultConstraints: chainreg.GenDefaultBtcConstraints(),
|
NetParams: *walletConfig.NetParams,
|
||||||
NetParams: *walletConfig.NetParams,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The broadcast is already always active for neutrino nodes, so we
|
// 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
|
// Create, and start the lnwallet, which handles the core payment
|
||||||
// channel logic, and exposes control via proxy state machines.
|
// channel logic, and exposes control via proxy state machines.
|
||||||
lnWalletConfig := lnwallet.Config{
|
lnWalletConfig := lnwallet.Config{
|
||||||
Database: partialChainControl.Cfg.ChanStateDB,
|
Database: partialChainControl.Cfg.ChanStateDB,
|
||||||
Notifier: partialChainControl.ChainNotifier,
|
Notifier: partialChainControl.ChainNotifier,
|
||||||
WalletController: rpcKeyRing,
|
WalletController: rpcKeyRing,
|
||||||
Signer: rpcKeyRing,
|
Signer: rpcKeyRing,
|
||||||
FeeEstimator: partialChainControl.FeeEstimator,
|
FeeEstimator: partialChainControl.FeeEstimator,
|
||||||
SecretKeyRing: rpcKeyRing,
|
SecretKeyRing: rpcKeyRing,
|
||||||
ChainIO: walletController,
|
ChainIO: walletController,
|
||||||
DefaultConstraints: chainreg.GenDefaultBtcConstraints(),
|
NetParams: *walletConfig.NetParams,
|
||||||
NetParams: *walletConfig.NetParams,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've created the wallet configuration now, so we can finish
|
// 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) {
|
estimator chainfee.Estimator) (*lnwallet.LightningWallet, error) {
|
||||||
|
|
||||||
wallet, err := lnwallet.NewLightningWallet(lnwallet.Config{
|
wallet, err := lnwallet.NewLightningWallet(lnwallet.Config{
|
||||||
Database: cdb,
|
Database: cdb,
|
||||||
Notifier: notifier,
|
Notifier: notifier,
|
||||||
SecretKeyRing: keyRing,
|
SecretKeyRing: keyRing,
|
||||||
WalletController: wc,
|
WalletController: wc,
|
||||||
Signer: signer,
|
Signer: signer,
|
||||||
ChainIO: bio,
|
ChainIO: bio,
|
||||||
FeeEstimator: estimator,
|
FeeEstimator: estimator,
|
||||||
NetParams: *netParams,
|
NetParams: *netParams,
|
||||||
DefaultConstraints: chainreg.GenDefaultBtcConstraints(),
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -49,10 +49,6 @@ type Config struct {
|
|||||||
// used to lookup the existence of outputs within the UTXO set.
|
// used to lookup the existence of outputs within the UTXO set.
|
||||||
ChainIO BlockChainIO
|
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
|
// NetParams is the set of parameters that tells the wallet which chain
|
||||||
// it will be operating on.
|
// it will be operating on.
|
||||||
NetParams chaincfg.Params
|
NetParams chaincfg.Params
|
||||||
|
@ -80,3 +80,8 @@ func DustLimitForSize(scriptSize int) btcutil.Amount {
|
|||||||
|
|
||||||
return dustlimit
|
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.
|
// 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
|
// 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
|
// 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,
|
Signer: signer,
|
||||||
ChainIO: bio,
|
ChainIO: bio,
|
||||||
FeeEstimator: chainfee.NewStaticEstimator(2500, 0),
|
FeeEstimator: chainfee.NewStaticEstimator(2500, 0),
|
||||||
DefaultConstraints: channeldb.ChannelConstraints{
|
NetParams: *netParams,
|
||||||
DustLimit: 500,
|
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(btcutil.SatoshiPerBitcoin) * 100,
|
|
||||||
ChanReserve: 100,
|
|
||||||
MinHTLC: 400,
|
|
||||||
MaxAcceptedHtlcs: 900,
|
|
||||||
},
|
|
||||||
NetParams: *netParams,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet, err := lnwallet.NewLightningWallet(cfg)
|
wallet, err := lnwallet.NewLightningWallet(cfg)
|
||||||
@ -458,7 +451,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
|||||||
require.NoError(t, err, "unable to initialize funding reservation")
|
require.NoError(t, err, "unable to initialize funding reservation")
|
||||||
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
||||||
channelConstraints := &channeldb.ChannelConstraints{
|
channelConstraints := &channeldb.ChannelConstraints{
|
||||||
DustLimit: alice.Cfg.DefaultConstraints.DustLimit,
|
DustLimit: lnwallet.DustLimitUnknownWitness(),
|
||||||
ChanReserve: fundingAmount / 100,
|
ChanReserve: fundingAmount / 100,
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmount),
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmount),
|
||||||
MinHTLC: 1,
|
MinHTLC: 1,
|
||||||
@ -863,7 +856,7 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
|||||||
require.NoError(t, err, "unable to init channel reservation")
|
require.NoError(t, err, "unable to init channel reservation")
|
||||||
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
||||||
channelConstraints := &channeldb.ChannelConstraints{
|
channelConstraints := &channeldb.ChannelConstraints{
|
||||||
DustLimit: alice.Cfg.DefaultConstraints.DustLimit,
|
DustLimit: lnwallet.DustLimitUnknownWitness(),
|
||||||
ChanReserve: fundingAmt / 100,
|
ChanReserve: fundingAmt / 100,
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmt),
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmt),
|
||||||
MinHTLC: 1,
|
MinHTLC: 1,
|
||||||
|
@ -1363,7 +1363,8 @@ func (l *LightningWallet) initOurContribution(reservation *ChannelReservation,
|
|||||||
)
|
)
|
||||||
|
|
||||||
reservation.partialState.RevocationProducer = producer
|
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
|
// If taproot channels are active, then we'll generate our verification
|
||||||
// nonce here. We'll use this nonce to verify the signature for our
|
// nonce here. We'll use this nonce to verify the signature for our
|
||||||
|
Loading…
x
Reference in New Issue
Block a user