• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 11170835610

03 Oct 2024 10:41PM UTC coverage: 49.188% (-9.6%) from 58.738%
11170835610

push

github

web-flow
Merge pull request #9154 from ziggie1984/master

multi: bump btcd version.

3 of 6 new or added lines in 6 files covered. (50.0%)

26110 existing lines in 428 files now uncovered.

97359 of 197934 relevant lines covered (49.19%)

1.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/channeldb/migration/lnwire21/msat.go
1
package lnwire
2

3
import (
4
        "fmt"
5

6
        "github.com/btcsuite/btcd/btcutil"
7
)
8

9
const (
10
        // mSatScale is a value that's used to scale satoshis to milli-satoshis, and
11
        // the other way around.
12
        mSatScale uint64 = 1000
13

14
        // MaxMilliSatoshi is the maximum number of msats that can be expressed
15
        // in this data type.
16
        MaxMilliSatoshi = ^MilliSatoshi(0)
17
)
18

19
// MilliSatoshi are the native unit of the Lightning Network. A milli-satoshi
20
// is simply 1/1000th of a satoshi. There are 1000 milli-satoshis in a single
21
// satoshi. Within the network, all HTLC payments are denominated in
22
// milli-satoshis. As milli-satoshis aren't deliverable on the native
23
// blockchain, before settling to broadcasting, the values are rounded down to
24
// the nearest satoshi.
25
type MilliSatoshi uint64
26

27
// NewMSatFromSatoshis creates a new MilliSatoshi instance from a target amount
28
// of satoshis.
UNCOV
29
func NewMSatFromSatoshis(sat btcutil.Amount) MilliSatoshi {
×
UNCOV
30
        return MilliSatoshi(uint64(sat) * mSatScale)
×
UNCOV
31
}
×
32

33
// ToBTC converts the target MilliSatoshi amount to its corresponding value
34
// when expressed in BTC.
35
func (m MilliSatoshi) ToBTC() float64 {
×
36
        sat := m.ToSatoshis()
×
37
        return sat.ToBTC()
×
38
}
×
39

40
// ToSatoshis converts the target MilliSatoshi amount to satoshis. Simply, this
41
// sheds a factor of 1000 from the mSAT amount in order to convert it to SAT.
UNCOV
42
func (m MilliSatoshi) ToSatoshis() btcutil.Amount {
×
UNCOV
43
        return btcutil.Amount(uint64(m) / mSatScale)
×
UNCOV
44
}
×
45

46
// String returns the string representation of the mSAT amount.
47
func (m MilliSatoshi) String() string {
×
48
        return fmt.Sprintf("%v mSAT", uint64(m))
×
49
}
×
50

51
// TODO(roasbeef): extend with arithmetic operations?
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc