Files
lnd/lnwallet/confscale_prod.go
T
Olaoluwa Osuntokun 09c813a61c lnwallet: define helper func to coop close conf scaling
We have two versions: for itests, we just use one conf, but in prod,
we'll scale the number of confirmations.
2026-01-15 16:22:26 -08:00

26 lines
859 B
Go

//go:build !integration
// +build !integration
package lnwallet
import "github.com/btcsuite/btcd/btcutil"
// CloseConfsForCapacity returns the number of confirmations to wait before
// signaling a channel close, scaled by channel capacity. This is used for both
// cooperative and force closes. We enforce a minimum of 3 confirmations to
// provide better reorg protection, even for small channels.
func CloseConfsForCapacity(capacity btcutil.Amount) uint32 {
// For cooperative closes, we don't have a push amount to consider,
// so we pass 0 for the pushAmt parameter.
scaledConfs := uint32(ScaleNumConfs(capacity, 0))
// Enforce a minimum of 3 confirmations for reorg safety.
// This protects against shallow reorgs which are more common.
const minCloseConfs = 3
if scaledConfs < minCloseConfs {
return minCloseConfs
}
return scaledConfs
}