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

lightningnetwork / lnd / 11292787765

11 Oct 2024 12:58PM UTC coverage: 49.179% (-9.5%) from 58.716%
11292787765

push

github

web-flow
Merge pull request #9168 from feelancer21/fix-lncli-wallet-proto

lnrpc: fix lncli documentation tags in walletkit.proto

97369 of 197987 relevant lines covered (49.18%)

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.
29
func NewMSatFromSatoshis(sat btcutil.Amount) MilliSatoshi {
×
30
        return MilliSatoshi(uint64(sat) * mSatScale)
×
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.
42
func (m MilliSatoshi) ToSatoshis() btcutil.Amount {
×
43
        return btcutil.Amount(uint64(m) / mSatScale)
×
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