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

lightningnetwork / lnd / 13211764208

08 Feb 2025 03:08AM UTC coverage: 49.288% (-9.5%) from 58.815%
13211764208

Pull #9489

github

calvinrzachman
itest: verify switchrpc server enforces send then track

We prevent the rpc server from allowing onion dispatches for
attempt IDs which have already been tracked by rpc clients.

This helps protect the client from leaking a duplicate onion
attempt. NOTE: This is not the only method for solving this
issue! The issue could be addressed via careful client side
programming which accounts for the uncertainty and async
nature of dispatching onions to a remote process via RPC.
This would require some lnd ChannelRouter changes for how
we intend to use these RPCs though.
Pull Request #9489: multi: add BuildOnion, SendOnion, and TrackOnion RPCs

474 of 990 new or added lines in 11 files covered. (47.88%)

27321 existing lines in 435 files now uncovered.

101192 of 205306 relevant lines covered (49.29%)

1.54 hits per line

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

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

3
import (
4
        "fmt"
5
)
6

7
// ShortChannelID represents the set of data which is needed to retrieve all
8
// necessary data to validate the channel existence.
9
type ShortChannelID struct {
10
        // BlockHeight is the height of the block where funding transaction
11
        // located.
12
        //
13
        // NOTE: This field is limited to 3 bytes.
14
        BlockHeight uint32
15

16
        // TxIndex is a position of funding transaction within a block.
17
        //
18
        // NOTE: This field is limited to 3 bytes.
19
        TxIndex uint32
20

21
        // TxPosition indicating transaction output which pays to the channel.
22
        TxPosition uint16
23
}
24

25
// NewShortChanIDFromInt returns a new ShortChannelID which is the decoded
26
// version of the compact channel ID encoded within the uint64. The format of
27
// the compact channel ID is as follows: 3 bytes for the block height, 3 bytes
28
// for the transaction index, and 2 bytes for the output index.
UNCOV
29
func NewShortChanIDFromInt(chanID uint64) ShortChannelID {
×
UNCOV
30
        return ShortChannelID{
×
UNCOV
31
                BlockHeight: uint32(chanID >> 40),
×
UNCOV
32
                TxIndex:     uint32(chanID>>16) & 0xFFFFFF,
×
UNCOV
33
                TxPosition:  uint16(chanID),
×
UNCOV
34
        }
×
UNCOV
35
}
×
36

37
// ToUint64 converts the ShortChannelID into a compact format encoded within a
38
// uint64 (8 bytes).
UNCOV
39
func (c ShortChannelID) ToUint64() uint64 {
×
UNCOV
40
        // TODO(roasbeef): explicit error on overflow?
×
UNCOV
41
        return ((uint64(c.BlockHeight) << 40) | (uint64(c.TxIndex) << 16) |
×
UNCOV
42
                (uint64(c.TxPosition)))
×
UNCOV
43
}
×
44

45
// String generates a human-readable representation of the channel ID.
46
func (c ShortChannelID) String() string {
×
47
        return fmt.Sprintf("%d:%d:%d", c.BlockHeight, c.TxIndex, c.TxPosition)
×
48
}
×
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