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