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

lightningnetwork / lnd / 15736109134

18 Jun 2025 02:46PM UTC coverage: 58.197% (-10.1%) from 68.248%
15736109134

Pull #9752

github

web-flow
Merge d2634a68c into 31c74f20f
Pull Request #9752: routerrpc: reject payment to invoice that don't have payment secret or blinded paths

6 of 13 new or added lines in 2 files covered. (46.15%)

28331 existing lines in 455 files now uncovered.

97860 of 168153 relevant lines covered (58.2%)

1.81 hits per line

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

37.5
/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.
UNCOV
44
func (h HopHint) Copy() HopHint {
×
UNCOV
45
        nodeID := *h.NodeID
×
UNCOV
46
        return HopHint{
×
UNCOV
47
                NodeID:                    &nodeID,
×
UNCOV
48
                ChannelID:                 h.ChannelID,
×
UNCOV
49
                FeeBaseMSat:               h.FeeBaseMSat,
×
UNCOV
50
                FeeProportionalMillionths: h.FeeProportionalMillionths,
×
UNCOV
51
                CLTVExpiryDelta:           h.CLTVExpiryDelta,
×
UNCOV
52
        }
×
UNCOV
53
}
×
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 {
3✔
59
        baseFee := lnwire.MilliSatoshi(h.FeeBaseMSat)
3✔
60
        feeRate := lnwire.MilliSatoshi(h.FeeProportionalMillionths)
3✔
61

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