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

lightningnetwork / lnd / 13536249039

26 Feb 2025 03:42AM UTC coverage: 57.462% (-1.4%) from 58.835%
13536249039

Pull #8453

github

Roasbeef
peer: update chooseDeliveryScript to gen script if needed

In this commit, we update `chooseDeliveryScript` to generate a new
script if needed. This allows us to fold in a few other lines that
always followed this function into this expanded function.

The tests have been updated accordingly.
Pull Request #8453: [4/4] - multi: integrate new rbf coop close FSM into the existing peer flow

275 of 1318 new or added lines in 22 files covered. (20.86%)

19521 existing lines in 257 files now uncovered.

103858 of 180741 relevant lines covered (57.46%)

24750.23 hits per line

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

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

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