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

lightningnetwork / lnd / 13408822928

19 Feb 2025 08:59AM UTC coverage: 41.123% (-17.7%) from 58.794%
13408822928

Pull #9521

github

web-flow
Merge d2f397b3c into 0e8786348
Pull Request #9521: unit: remove GOACC, use Go 1.20 native coverage functionality

92496 of 224923 relevant lines covered (41.12%)

18825.83 hits per line

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

0.0
/lnwallet/revocation_producer.go
1
//go:build !integration
2

3
package lnwallet
4

5
import (
6
        "github.com/lightningnetwork/lnd/channeldb"
7
        "github.com/lightningnetwork/lnd/keychain"
8
        "github.com/lightningnetwork/lnd/shachain"
9
)
10

11
// nextRevocationProducer creates a new revocation producer, deriving the
12
// revocation root by applying ECDH to a new key from our revocation root
13
// family and the multisig key we use for the channel. For taproot channels a
14
// related shachain revocation root is also returned.
15
func (l *LightningWallet) nextRevocationProducer(res *ChannelReservation,
16
        keyRing keychain.KeyRing,
17
) (shachain.Producer, shachain.Producer, error) {
×
18

×
19
        // Derive the next key in the revocation root family.
×
20
        nextRevocationKeyDesc, err := keyRing.DeriveNextKey(
×
21
                keychain.KeyFamilyRevocationRoot,
×
22
        )
×
23
        if err != nil {
×
24
                return nil, nil, err
×
25
        }
×
26

27
        // If the DeriveNextKey call returns the first key with Index 0, we need
28
        // to re-derive the key as the keychain/btcwallet.go DerivePrivKey call
29
        // special-cases Index 0.
30
        if nextRevocationKeyDesc.Index == 0 {
×
31
                nextRevocationKeyDesc, err = keyRing.DeriveNextKey(
×
32
                        keychain.KeyFamilyRevocationRoot,
×
33
                )
×
34
                if err != nil {
×
35
                        return nil, nil, err
×
36
                }
×
37
        }
38

39
        res.nextRevocationKeyLoc = nextRevocationKeyDesc.KeyLocator
×
40

×
41
        // Perform an ECDH operation between the private key described in
×
42
        // nextRevocationKeyDesc and our public multisig key. The result will be
×
43
        // used to seed the revocation producer.
×
44
        revRoot, err := l.ECDH(
×
45
                nextRevocationKeyDesc, res.ourContribution.MultiSigKey.PubKey,
×
46
        )
×
47
        if err != nil {
×
48
                return nil, nil, err
×
49
        }
×
50

51
        // Once we have the root, we can then generate our shachain producer
52
        // and from that generate the per-commitment point.
53
        shaChainRoot := shachain.NewRevocationProducer(revRoot)
×
54
        taprootShaChainRoot, err := channeldb.DeriveMusig2Shachain(shaChainRoot)
×
55
        if err != nil {
×
56
                return nil, nil, err
×
57
        }
×
58

59
        return shaChainRoot, taprootShaChainRoot, nil
×
60
}
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