Merge pull request #8463 from ProofOfKeags/refactor/chainreg/rm-channel-constraints

Remove `DefaultChannelConstraints` from PartialChainControl and lnwallet.Config
This commit is contained in:
Olaoluwa Osuntokun
2024-02-22 14:39:35 -08:00
committed by GitHub
8 changed files with 35 additions and 63 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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

View File

@@ -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,

View File

@@ -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