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

3
import (
4
        "bytes"
5
        "fmt"
6

7
        "github.com/lightningnetwork/lnd/kvdb"
8
)
9

10
// MigrateMCRouteSerialisation reads all the mission control store entries and
11
// re-serializes them using a minimal route serialisation so that only the parts
12
// of the route that are actually required for mission control are persisted.
UNCOV
13
func MigrateMCRouteSerialisation(tx kvdb.RwTx) error {
×
UNCOV
14
        log.Infof("Migrating Mission Control store to use a more minimal " +
×
UNCOV
15
                "encoding for routes")
×
UNCOV
16

×
UNCOV
17
        resultBucket := tx.ReadWriteBucket(resultsKey)
×
UNCOV
18

×
UNCOV
19
        // If the results bucket does not exist then there are no entries in
×
UNCOV
20
        // the mission control store yet and so there is nothing to migrate.
×
UNCOV
21
        if resultBucket == nil {
×
22
                return nil
×
23
        }
×
24

25
        // For each entry, read it into memory using the old encoding. Then,
26
        // extract the more minimal route, re-encode and persist the entry.
UNCOV
27
        return resultBucket.ForEach(func(k, v []byte) error {
×
UNCOV
28
                // Read the entry using the old encoding.
×
UNCOV
29
                resultOld, err := deserializeOldResult(k, v)
×
UNCOV
30
                if err != nil {
×
31
                        return err
×
32
                }
×
33

34
                // Convert to the new payment result format with the minimal
35
                // route.
UNCOV
36
                resultNew := convertPaymentResult(resultOld)
×
UNCOV
37

×
UNCOV
38
                // Serialise the new payment result using the new encoding.
×
UNCOV
39
                key, resultNewBytes, err := serializeNewResult(resultNew)
×
UNCOV
40
                if err != nil {
×
41
                        return err
×
42
                }
×
43

44
                // Make sure that the derived key is the same.
UNCOV
45
                if !bytes.Equal(key, k) {
×
46
                        return fmt.Errorf("new payment result key (%v) is "+
×
47
                                "not the same as the old key (%v)", key, k)
×
48
                }
×
49

50
                // Finally, overwrite the previous value with the new encoding.
UNCOV
51
                return resultBucket.Put(k, resultNewBytes)
×
52
        })
53
}
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