• 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/migration29/migration.go
1
package migration29
2

3
import (
4
        "bytes"
5

6
        "github.com/btcsuite/btcd/wire"
7
        "github.com/lightningnetwork/lnd/kvdb"
8
)
9

10
var (
11
        // outpointBucket is the bucket that stores the set of outpoints we
12
        // know about.
13
        outpointBucket = []byte("outpoint-bucket")
14

15
        // chanIDBucket is the bucket that stores the set of ChannelID's we
16
        // know about.
17
        chanIDBucket = []byte("chan-id-bucket")
18
)
19

20
// MigrateChanID populates the ChannelID index by using the set of outpoints
21
// retrieved from the outpoint bucket.
UNCOV
22
func MigrateChanID(tx kvdb.RwTx) error {
×
UNCOV
23
        log.Info("Populating ChannelID index")
×
UNCOV
24

×
UNCOV
25
        // First we'll retrieve the set of outpoints we know about.
×
UNCOV
26
        ops, err := fetchOutPoints(tx)
×
UNCOV
27
        if err != nil {
×
28
                return err
×
29
        }
×
30

UNCOV
31
        return populateChanIDIndex(tx, ops)
×
32
}
33

34
// fetchOutPoints loops through the outpointBucket and returns each stored
35
// outpoint.
UNCOV
36
func fetchOutPoints(tx kvdb.RwTx) ([]*wire.OutPoint, error) {
×
UNCOV
37
        var ops []*wire.OutPoint
×
UNCOV
38

×
UNCOV
39
        bucket := tx.ReadBucket(outpointBucket)
×
UNCOV
40

×
UNCOV
41
        err := bucket.ForEach(func(k, _ []byte) error {
×
UNCOV
42
                var op wire.OutPoint
×
UNCOV
43
                r := bytes.NewReader(k)
×
UNCOV
44
                if err := readOutpoint(r, &op); err != nil {
×
45
                        return err
×
46
                }
×
47

UNCOV
48
                ops = append(ops, &op)
×
UNCOV
49
                return nil
×
50
        })
UNCOV
51
        if err != nil {
×
52
                return nil, err
×
53
        }
×
54

UNCOV
55
        return ops, nil
×
56
}
57

58
// populateChanIDIndex uses the set of retrieved outpoints and populates the
59
// ChannelID index.
UNCOV
60
func populateChanIDIndex(tx kvdb.RwTx, ops []*wire.OutPoint) error {
×
UNCOV
61
        bucket := tx.ReadWriteBucket(chanIDBucket)
×
UNCOV
62

×
UNCOV
63
        for _, op := range ops {
×
UNCOV
64
                chanID := NewChanIDFromOutPoint(op)
×
UNCOV
65

×
UNCOV
66
                if err := bucket.Put(chanID[:], []byte{}); err != nil {
×
67
                        return err
×
68
                }
×
69
        }
70

UNCOV
71
        return nil
×
72
}
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