github.com/decred/dcrlnd@v0.7.6/lnwallet/chainfee/rates.go (about)

     1  package chainfee
     2  
     3  import (
     4  	"github.com/decred/dcrd/dcrutil/v4"
     5  )
     6  
     7  const (
     8  	// FeePerKBFloor is the lowest fee rate in atom/kB that we should use
     9  	// for determining transaction fees. Originally, this was used due to
    10  	// the conversion from sats/kB => sats/KW causing a possible rounding
    11  	// error, but in Decred we use this to track the widely deployed
    12  	// minimum relay fee.
    13  	FeePerKBFloor AtomPerKByte = 1e4
    14  )
    15  
    16  // AtomPerKByte represents a fee rate in atom/kB.
    17  type AtomPerKByte dcrutil.Amount
    18  
    19  // FeeForSize calculates the fee resulting from this fee rate and the given
    20  // size in bytes.
    21  func (s AtomPerKByte) FeeForSize(bytes int64) dcrutil.Amount {
    22  	return dcrutil.Amount(s) * dcrutil.Amount(bytes) / 1000
    23  }
    24  
    25  // String returns a pretty string representation for the rate in DCR/kB.
    26  func (s AtomPerKByte) String() string {
    27  	return dcrutil.Amount(s).String() + "/kB"
    28  }