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

lightningnetwork / lnd / 15951470896

29 Jun 2025 04:23AM UTC coverage: 67.594% (-0.01%) from 67.606%
15951470896

Pull #9751

github

web-flow
Merge 599d9b051 into 6290edf14
Pull Request #9751: multi: update Go to 1.23.10 and update some packages

135088 of 199851 relevant lines covered (67.59%)

21909.44 hits per line

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

100.0
/zpay32/hophint.go
1
package zpay32
2

3
import (
4
        "github.com/btcsuite/btcd/btcec/v2"
5
        "github.com/lightningnetwork/lnd/lnwire"
6
)
7

8
const (
9
        // DefaultAssumedFinalCLTVDelta is the default value to be used as the
10
        // final CLTV delta for a route if one is unspecified in the payment
11
        // request.
12
        // We adhere to the recommendation in BOLT 02 for terminal payments.
13
        // See also:
14
        // https://github.com/lightning/bolts/blob/master/02-peer-protocol.md
15
        DefaultAssumedFinalCLTVDelta = 18
16

17
        // feeRateParts is the total number of parts used to express fee rates.
18
        feeRateParts = 1e6
19
)
20

21
// HopHint is a routing hint that contains the minimum information of a channel
22
// required for an intermediate hop in a route to forward the payment to the
23
// next. This should be ideally used for private channels, since they are not
24
// publicly advertised to the network for routing.
25
type HopHint struct {
26
        // NodeID is the public key of the node at the start of the channel.
27
        NodeID *btcec.PublicKey
28

29
        // ChannelID is the unique identifier of the channel.
30
        ChannelID uint64
31

32
        // FeeBaseMSat is the base fee of the channel in millisatoshis.
33
        FeeBaseMSat uint32
34

35
        // FeeProportionalMillionths is the fee rate, in millionths of a
36
        // satoshi, for every satoshi sent through the channel.
37
        FeeProportionalMillionths uint32
38

39
        // CLTVExpiryDelta is the time-lock delta of the channel.
40
        CLTVExpiryDelta uint16
41
}
42

43
// Copy returns a deep copy of the hop hint.
44
func (h HopHint) Copy() HopHint {
1✔
45
        nodeID := *h.NodeID
1✔
46
        return HopHint{
1✔
47
                NodeID:                    &nodeID,
1✔
48
                ChannelID:                 h.ChannelID,
1✔
49
                FeeBaseMSat:               h.FeeBaseMSat,
1✔
50
                FeeProportionalMillionths: h.FeeProportionalMillionths,
1✔
51
                CLTVExpiryDelta:           h.CLTVExpiryDelta,
1✔
52
        }
1✔
53
}
1✔
54

55
// HopFee calculates the fee for a given amount that is forwarded over a hop.
56
// The amount has to be denoted in milli satoshi. The returned fee is also
57
// denoted in milli satoshi.
58
func (h HopHint) HopFee(amt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
11✔
59
        baseFee := lnwire.MilliSatoshi(h.FeeBaseMSat)
11✔
60
        feeRate := lnwire.MilliSatoshi(h.FeeProportionalMillionths)
11✔
61

11✔
62
        return baseFee + (amt*feeRate)/feeRateParts
11✔
63
}
11✔
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